12/4/2023 0 Comments Php datagridIt supports client-side paging, sorting and filtering on server-side. The data can be loaded from JavaScript array or be loadedįrom the server (in JSON or XML format). We will need this value later to sum the total hours once they have been grouped by employee.Free jqGrid is a JavaScript plugin that displays table-based data in a lot of different configurations. The first line uses an SQL statement with a generated column named hours which is used to compute the time difference between time_from and time_to. $dg -> set_group_properties ( 'employee_id', false, true, true, false ) -> set_group_summary ( 'hours', 'sum' ) $dg -> set_col_edittype ( "employee_id", "select", "Select id, last_name from account" ) -> set_col_title ( 'employee_id', 'Employee' ) $dg -> set_col_property ( 'hours', array ( 'editable' => false, 'hidedlg' => true ) ) hide aggregate field hours from the edit form Time_from, time_to, ROUND(TIMESTAMPDIFF(MINUTE, time_from, time_to)/60, 2) as hours, $dg = new C_DataGrid ( "SELECT id, employee_id, date, That’s it for the employee timesheet dashboard. The fields must be the TIME type in MySQL. We made the activity field a dropdown by setting the type to select in set_col_edittype() so it could be used as a look up for Activity table.įinally, note the use of the set_col_time() function used to enable our time-picker, followed by the formatter function so that the time is set to the right value during edit. We hid certain fields from our grid id, and employee_id with set_col_hidden(). In a real-world application, you would replace it with a user id which was authenticated through a login. Here we used set_query_filter() and hard coded the employee id for demo purposes only. The first line has a simple SQL Select statement that uses the database table timesheet as the datasource that will populate the datagrid in the dashboard. Let’s break our code down for a quick review. $dg -> enable_edit ( 'FORM' ) -> enable_autowidth ( true ) $dg -> set_col_time ( "time_to" ) -> set_col_property ( "time_to" , $dg -> set_col_time ( "time_from" ) -> set_col_property ( "time_from" ,Īrray ( "formatter" => "date", "formatoptions" => array ( "srcformat" => "h:i A", "newformat" => "h:i A" ) ) ) $dg -> set_col_edittype ( "activity_id", "select", "Select id, code from activity" ) -> set_col_title ( 'activity_id', 'Activity' ) $dg -> set_col_hidden ( 'id, employee_id', false ) $dg -> set_query_filter ( "employee_id = '1'" ) $dg = new C_DataGrid ( "SELECT * FROM timesheet", "id", "timesheet" ) Most employees will only have permission to access their own time entries, but managers/supervisors have access to all aspects of the timesheet database including the cost center and projects. Typically, a timesheet system has four basic elements - cost center, project, activity, and lastly, the timesheet for time entry. The primary component is obviously the Timesheet, but the system requires other entities to work together with it for companies, firms and agencies to effectively collect, manage, track and share records about Projects, Employees, Timesheets, Activities and Cost Centers. phpGrid The Components of the Employee Timesheet SystemĪn employee timesheet system has several components.The Employee Timesheet application requires the standard commercial phpGrid license as it needs several key features such as the latest time-only picker and group summary. It could be extended to track any additional information you would want to record. This project is another great example of combining roles with an online database to make a really functional app. An employee can have either an employee or a supervisory role. A supervisor can manage his employees, projects, activities, and cost centers. With the Employee Timesheet application, employees can log in to add their hours for the day and view past time-sheets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |