Step 4: Add the reports to the dashboard
Admin dashboard:
To track employee working hours
This dashboard will help the admin keep track of employee work hours. Apart from the two buttons on the page, there are two reports, which are embedded using an HTML snippet.
- The list report will dynamically display records based on the logged-in user (for example: if Employee A is logged in, they can only view their own times).
- The Kanban report will list all the users who've checked in on that day, and it can only be viewed by the admins of the application.
Now let's embed these two reports on the dashboard. To do that, we need to drag and drop the HTML snippet onto the page builder and write the script below:
In the code above, we're embedding the user report using an iframe, so that the user report (iframe) is automatically refreshed after a user clicks on Check In or Check Out. We've also hidden the secondary header present on the user report by setting up zc_SecHeader=false to prevent users from manually adding or modifying the record from the report. The logged-in user filter can be directly applied on the report, or by using the parameter "Email=" + zoho.loginuserid" in the URL.
The admin report is added using a DIV tag, and is displayed only to the account's super admin using the if condition. if(zoho.loginuserid == zoho.adminuserid)
If required, we can add other non-admin emails using the criteria below to make the admin report available for those particular users:
The admin will also have the option to check out users, in case they forget at the end of their shift.
Admin report
The Kanban report is created using the status field, which is a dropdown field, and you can add the code in On Update of the Status Field.For example, when the admin drags the record from the Check in time column to the Check out time column, the user will be automatically checked out.
You need to choose Edited for Run when a record is while creating the workflow.
Below is the script you need to write in On Update of the Status Field, so that when the record is dragged and dropped to the Check out time column on the Kanban report, the check-out time will be captured.
- if(input.Status == "Checked Out" && input.Check_out_time == null)
- {
- input.Check_out_time = zoho.currenttime;
- mil_sec = (input.Check_out_time - input.Check_in_time);
- actual_minutes = mil_sec / (1000 * 60);
- //1000 -> mill sec to sec, 60 -> sec to min
- mins = actual_minutes.toLong() % 60;
- // % 60 -> Exclude Hours
- hours = (actual_minutes / 60).toLong();
- // 60 -> min to hour, % 24 (optional) -> Exclude Days
- time_string = hours + " : " + mins;
- input.Total_time = time_string;
- }
We've also added a filter to the admin report, that will allow the admin to view all the employees who checked in and out for the day. And, if required, you can edit it by week or month, depending on your requirements.
Note: We will soon roll out the hoursBetween function, which can be used to find the difference between the check in and check out times. This function will return the difference of hours between the given start and end date-time values.
We hope this tip was useful for you! If you have any questions, feel free to ask in the comments below, and we'll be happy to address them for you!