Example Description
In this example we display a list of existing staff members and their payroll calculations in a repeater. Calculations are filtered according to date, and are based on the defined service rates and the number of participants for each session.
Security Note
The code in this example exposes sensitive business and client information. Make sure that only authorized admins can access this data. See below for best security practices for this example.
How We Built It
Page Elements
2 input elements to set start & end date filters
2 input elements to set the service rates for classes and appointments
Submit button
Text element to display error messages
Repeater to display attendance and payment information for each staff member
Code
For best security practices, verify that the visitor is a logged-in member with an Admin role both on the frontend and backend. The code for this functionality is currently commented out in the example site. You can remove the comments to activate the code.
Backend Code
booking-functions.js: Includes functions to return the staff session data based on the date filters.
calculator.jsw: Includes functions to calculate and return the staff session data based on rate filters.
Note that the queryBookings() function returns by default only the booking data of the logged-in member. In order to query all booking data, we added the option {“suppressAuth”: true}.
Page Code
Initialize the filters and set default values.
Set the repeater onItemReady() event to show the relevant booking data.
Use the backend getStaffData() function to return the staff data.
Display the returned bookings data in the repeater.
Display error messages if needed.
Security best practices
Verify that the visitor is a site member with an Admin role on the frontend and backend. The code is provided in a comment.
Build the example as a dashboard page. Dashboard pages can be accessed only by site administrators.
If the page is not a dashboard page then restrict page access to admin members only.
Restrict backend function access to admins only.
Related Examples
Did this help?
|
Thanks for your feedback!
Block Off Time for Staff Members
Block off chunks of time in bookings staff calendars.
Advanced
Send SMS on Booking Confirmation
Send a confirmation SMS when customers book a service.
Advanced