public static function getJSONRecordsData(TS_User &$current_user, array $filter_ar = array()) { // set static variables self::$current_user = $current_user; self::$filter_ar = $filter_ar; // get filtered record id's, and full records when applicable $records_id_ar = TS_DB_HRM_Employees::getFilteredIDs(array('is_in_dienst' => 1)); if (!$records_id_ar) { return json_encode(array('data' => array())); } $records_ar = TS_DB_HRM_Employees::getFullRecords($records_id_ar); if (!$records_ar) { return json_encode(array('data' => array())); } // check for user rights $user_may_edit_leaves = $current_user->hasAccess('Personeel Vrij Planning', 'edit_employee_leaves'); // build return data array $data_ar = array(); foreach ($records_ar as $record) { // init variables $record_id = $record['id']; $record_name = $record['voornaam'] . ' ' . $record['achternaam']; $optional_links_ar = array(); // edit record link if ($user_may_edit_leaves) { $optional_links_ar['edit'] = HTML::A(TS_Module_Icons::get('edit_item'), '', 'icon_link'); $optional_links_ar['edit']->title = 'Bewerk verloven bij : ' . $record_name; $optional_links_ar['edit']->href = TS_Module_HRM_PresencePlanning_Links::getHref('edit_employee', array('employee_id' => $record_id)); } // build cells $column_data_ar = array(); $column_data_ar[] = (int) $record_id; $column_data_ar[] = (string) $record_name; //$column_data_ar[] = (string)implode('', $optional_links_ar); $data_ar[] = $column_data_ar; } // return data in JSON format return json_encode(array('data' => $data_ar), JSON_HEX_QUOT | JSON_HEX_TAG); }
public static function get(TS_User &$current_user, $selected_page, TS_Module_HRM_Employee &$employee = null) { // check for provided objects self::$employee =& $employee; if (!self::$employee) { self::$employee = new TS_Module_HRM_Employee(); } // set current page and get all existing pages array self::$selected_page = $selected_page; self::$module_pages_ar = self::getPageNamesList(); // build 'employees_overview' link if ($current_user->hasAccess('Main Menu', 'Personeel Vrij Planning')) { //self::addTab('employees_overview', 'overview'); } // build 'edit_employee' link if (self::$employee->id && self::$employee->isValidID() && self::$employee->hasEditAccess($current_user) && $current_user->hasAccess('Personeel Vrij Planning', 'edit_employee_leaves')) { self::addTab('edit_employee', 'edit_item', true); } // build 'planning_overview' link if ($current_user->hasAccess('Main Menu', 'Personeel Vrij Planning')) { self::addTab('planning_overview', 'overview'); } // build tabs list $tabs_li_ar = array(); foreach (self::$tabs_links_ar as $page_link) { $tabs_li_ar[] = HTML::Li($page_link, '', in_array('selected_tab', $page_link->class) ? 'selected_tab' : ''); } // add non-existing page if provided, and add selected page to page title if (!array_key_exists(self::$selected_page, self::$module_pages_ar)) { self::$current_page_subtitle_ar[] = self::$selected_page; $tabs_li_ar[] = HTML::Li(HTML::A(self::$selected_page, '', 'selected_tab'), '', 'selected_tab'); } // build and return list if (!$tabs_li_ar) { return ''; } return self::getLocalStyleScript() . self::getJquery() . HTML::Div(HTML::Ul(implode('', $tabs_li_ar)), 'tabs_container', 'clearfix'); }
public static function getJSONRecordsData(TS_User &$current_user, array $filter_ar = array()) { // set static variables self::$current_user = $current_user; self::setFilter($filter_ar); // get filtered record id's, and full records when applicable $filter_ar['is_in_dienst'] = 1; $records_id_ar = TS_DB_HRM_Employees::getFilteredIDs($filter_ar); if (!$records_id_ar) { return json_encode(array('data' => array())); } $records_ar = TS_DB_HRM_Employees::getFullRecords($records_id_ar); if (!$records_ar) { return json_encode(array('data' => array())); } // check for user rights $user_may_edit_employee_presence = $current_user->hasAccess('Personeel Vrij Planning', 'edit_employee_leaves'); // get presence values for selected period $presence_values_id_ar = TS_DB_HRM_PresencePlanning_EmployeePresenceValues::getFilteredIDs(self::$filter_ar); if ($presence_values_id_ar) { $presence_values_ar = TS_DB_HRM_PresencePlanning_EmployeePresenceValues::getFullRecords($presence_values_id_ar); } else { $presence_values_ar = array(); } // Process found leaves in dates table, to group by employee $employees_presence_values_ar = array(); foreach ($presence_values_ar as $tmp_presence_value) { $tmp_employee_id = $tmp_presence_value['employee_id']; $tmp_presence_value_date = $tmp_presence_value['presence_value_date']; $employees_presence_values_ar[$tmp_employee_id][$tmp_presence_value_date] = array('num_worked_hours' => $tmp_presence_value['num_worked_hours'], 'presence_value' => $tmp_presence_value['presence_value']); } //dd::show($employees_presence_values_ar); // build return data array $data_ar = array(); foreach ($records_ar as $record) { // init variables $record_id = $record['id']; $record_name = $record['voornaam'] . ' ' . $record['achternaam']; $optional_links_ar = array(); // build cells $column_data_ar = array(); $column_data_ar[] = (int) $record_id; $column_data_ar[] = (string) $record_name; $column_data_ar[] = (string) $record['function_group_description']; // start loop for workdays in selected month/year foreach (self::getWorkdays() as $workday_int) { $workday_date = date('Y-m-d', $workday_int); // determine current value for this employee and date $current_value = ''; if (!empty($employees_presence_values_ar[$record_id][$workday_date])) { if (!empty($employees_presence_values_ar[$record_id][$workday_date]['presence_value'])) { $current_value = $employees_presence_values_ar[$record_id][$workday_date]['presence_value']; } elseif (isset($employees_presence_values_ar[$record_id][$workday_date]['num_worked_hours'])) { $current_value = $employees_presence_values_ar[$record_id][$workday_date]['num_worked_hours']; } } // get presence cell value, and build cell if ($user_may_edit_employee_presence) { $tmp_cell_value = TS_Module_HRM_PresencePlanning_Tables_InlineEditing_PlanningEditing::getPresenceInput($record_id, $workday_date, $current_value); } else { $tmp_cell_value = $current_value; } $tmp_employee_day_span = HTML::Span($tmp_cell_value, '', 'small_rounded_container'); $tmp_employee_day_span->addStyle('background-color', TS_Module_HRM_PresencePlanning_Constants::getPresenceOptionColor($current_value)); $column_data_ar[] = (string) $tmp_employee_day_span; } $data_ar[] = $column_data_ar; } // return data in JSON format return json_encode(array('data' => $data_ar), JSON_HEX_QUOT | JSON_HEX_TAG); }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/classes2/autoloadclasses.php'; restore_error_handler(); error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); $tristar = TS_TriStar::get(); $current_user = new TS_User(); if (!$current_user->hasAccess('Admin', 'test_scripts')) { die('Sorry, je hebt geen toegang tot deze pagina.'); } ?> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>[Test] Personeel Vrij Planning</title> <link rel="stylesheet" type="text/css" href="<?php echo TS_Module_HRM_PresencePlanning_Constants::MODULE_ROOT_PATH . 'css/mainstyles.css'; ?> "> </head><body style="font: 12px Verdana, Geneva, sans-serif;"><pre> <?php $filter_ar = array('month' => 9, 'year' => 2015); $result = TS_Module_HRM_PresencePlanning_Tables_PlanningTable::getJSONRecordsData($current_user, $filter_ar); dd::show($result); ?> </pre></body></html>
<?php // Load classes chdir($_SERVER['DOCUMENT_ROOT'] . '/'); include_once $_SERVER['DOCUMENT_ROOT'] . '/classes2/autoloadclasses.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/classes/Form.class.php'; // retrieve current user $current_user = new TS_User(); if ($current_user->id == 72) { error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); } // get selected page define('CURRENT_PAGE_NAME', !empty($_GET['page']) ? strtolower($_GET['page']) : 'planning_overview'); // check this page's access rights for current user $user_has_page_access = $current_user->hasAccess('Main Menu', 'Personeel Vrij Planning'); if (!$user_has_page_access) { die('Sorry, u heeft geen toegang tot deze pagina.'); } // check for extra parameters, and initialize objects where applicable $employee = new TS_Module_HRM_Employee(!empty($_REQUEST['employee_id']) ? $_REQUEST['employee_id'] : 0); define('LEAVE_ID', !empty($_REQUEST['leave_id']) ? $_REQUEST['leave_id'] : 0); // Set records filter $filter_ar = array_diff_key($_GET, array_flip(array('page', 'nocache'))); // perform any selected action if (!empty($filter_ar['action'])) { $unset_filter_ar = array('action'); $action_success_ar = $action_errors_ar = array(); switch (strtolower($filter_ar['action'])) { case 'add_leave':