![]() $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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |