function getScheduleArray($filter_data) { global $current_user, $current_user_prefs; //Get all schedule data by general filter criteria. Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__, 10); if (!isset($filter_data['start_date']) or $filter_data['start_date'] == '') { return FALSE; } if (!isset($filter_data['end_date']) or $filter_data['end_date'] == '') { return FALSE; } $filter_data['start_date'] = TTDate::getBeginDayEpoch($filter_data['start_date']); $filter_data['end_date'] = TTDate::getEndDayEpoch($filter_data['end_date']); $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($current_user->getCompany(), FALSE); $dlf = new DepartmentListFactory(); $department_options = $dlf->getByCompanyIdArray($current_user->getCompany(), FALSE); $slf = new ScheduleListFactory(); $slf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data); Debug::text('Found Scheduled Rows: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($slf->getRecordCount() > 0) { foreach ($slf as $s_obj) { Debug::text('Schedule ID: ' . $s_obj->getId() . ' User ID: ' . $s_obj->getColumn('user_id') . ' Start Time: ' . $s_obj->getStartTime(), __FILE__, __LINE__, __METHOD__, 10); if (is_object($s_obj->getAbsencePolicyObject())) { $absence_policy_name = (string) $s_obj->getAbsencePolicyObject()->getName(); } else { $absence_policy_name = 'N/A'; } $iso_date_stamp = TTDate::getISODateStamp($s_obj->getStartTime()); $schedule_shifts[$iso_date_stamp][$s_obj->getColumn('user_id') . $s_obj->getStartTime()] = array('id' => (int) $s_obj->getID(), 'user_id' => (int) $s_obj->getColumn('user_id'), 'user_created_by' => (int) $s_obj->getColumn('user_created_by'), 'user_full_name' => Misc::getFullName($s_obj->getColumn('first_name'), NULL, $s_obj->getColumn('last_name'), FALSE, FALSE), 'first_name' => $s_obj->getColumn('first_name'), 'last_name' => $s_obj->getColumn('last_name'), 'status_id' => (int) $s_obj->getStatus(), 'date_stamp' => TTDate::getAPIDate('DATE', TTDate::parseDateTime($s_obj->getColumn('date_stamp'))), 'start_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'start_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'total_time' => $s_obj->getTotalTime(), 'schedule_policy_id' => (int) $s_obj->getSchedulePolicyID(), 'absence_policy_id' => (int) $s_obj->getAbsencePolicyID(), 'absence_policy' => $absence_policy_name, 'branch_id' => (int) $s_obj->getBranch(), 'branch' => Option::getByKey($s_obj->getBranch(), $branch_options, NULL), 'department_id' => (int) $s_obj->getDepartment(), 'department' => Option::getByKey($s_obj->getDepartment(), $department_options, NULL)); $schedule_shifts_index[$iso_date_stamp][$s_obj->getColumn('user_id')][] = $s_obj->getColumn('user_id') . $s_obj->getStartTime(); unset($absence_policy_name); } //Debug::Arr($schedule_shifts, 'Committed Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10); //Debug::Arr($schedule_shifts_index, 'Committed Schedule Shifts Index: ', __FILE__, __LINE__, __METHOD__, 10); } else { $schedule_shifts = array(); } unset($slf); //Get holidays //FIXME: What if there are two holiday policies, one that defaults to working, and another that defaults to not working, and they are assigned //to two different groups of employees? For that matter what if the holiday policy isn't assigned to a specific user at all. $holiday_data = array(); $hlf = new HolidayListFactory(); $hlf->getByCompanyIdAndStartDateAndEndDate($current_user->getCompany(), $filter_data['start_date'], $filter_data['end_date']); Debug::text('Found Holiday Rows: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); foreach ($hlf as $h_obj) { if (is_object($h_obj->getHolidayPolicyObject()) and is_object($h_obj->getHolidayPolicyObject()->getAbsencePolicyObject())) { $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => (int) $h_obj->getHolidayPolicyObject()->getDefaultScheduleStatus(), 'absence_policy_id' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyID(), 'absence_policy' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyObject()->getName()); } else { $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => 10); //Working } } unset($hlf); $recurring_schedule_shifts = array(); $recurring_schedule_shifts_index = array(); $rstlf = new RecurringScheduleTemplateListFactory(); $rstlf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data); Debug::text('Found Recurring Schedule Template Rows: ' . $rstlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($rstlf->getRecordCount() > 0) { foreach ($rstlf as $rst_obj) { //Debug::text('Recurring Schedule Template ID: '. $rst_obj->getID() , __FILE__, __LINE__, __METHOD__, 10); $rst_obj->getShifts($filter_data['start_date'], $filter_data['end_date'], $holiday_data, $branch_options, $department_options, &$schedule_shifts, &$schedule_shifts_index); } } else { Debug::text('DID NOT find Recurring Schedule for this time period: ', __FILE__, __LINE__, __METHOD__, 10); } //Debug::Arr($schedule_shifts, 'Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10); unset($schedule_shifts_index, $recurring_schedule_shifts_index); if (isset($schedule_shifts)) { return $schedule_shifts; } return FALSE; }
$time_stamp = $date_stamp; } */ $ulf = new UserListFactory(); $ulf->getByIdAndCompanyId($user_id, $current_company->getId()); if ($ulf->getRecordCount() > 0) { $user_obj = $ulf->getCurrent(); $pc_data = array('user_id' => $user_obj->getId(), 'user_full_name' => $user_obj->getFullName(), 'date_stamp' => $date_stamp, 'time_stamp' => $time_stamp, 'status_id' => $status_id, 'branch_id' => $user_obj->getDefaultBranch(), 'department_id' => $user_obj->getDefaultDepartment(), 'quantity' => 0, 'bad_quantity' => 0); } unset($time_stamp, $plf); } } $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($current_company->getId()); $dlf = new DepartmentListFactory(); $department_options = $dlf->getByCompanyIdArray($current_company->getId()); if ($current_company->getProductEdition() == 20) { $jlf = new JobListFactory(); $jlf->getByCompanyIdAndUserIdAndStatus($current_company->getId(), $pc_data['user_id'], array(10, 20, 30, 40)); $pc_data['job_options'] = $jlf->getArrayByListFactory($jlf, TRUE, TRUE); $pc_data['job_manual_id_options'] = $jlf->getManualIDArrayByListFactory($jlf, TRUE); $jilf = new JobItemListFactory(); $jilf->getByCompanyId($current_company->getId()); $pc_data['job_item_options'] = $jilf->getArrayByListFactory($jilf, TRUE, TRUE); $pc_data['job_item_manual_id_options'] = $jilf->getManualIdArrayByListFactory($jilf, TRUE); } //Select box options; $pc_data['status_options'] = $pf->getOptions('status'); $pc_data['type_options'] = $pf->getOptions('type'); $pc_data['branch_options'] = $branch_options; $pc_data['department_options'] = $department_options;
Debug::Text('Highest Employee Number is not an integer.', __FILE__, __LINE__, __METHOD__, 10); $user_data['next_available_employee_number'] = NULL; } } else { $user_data['next_available_employee_number'] = 1; } if (!isset($user_data['hire_date']) or $user_data['hire_date'] == '') { $user_data['hire_date'] = time(); } } //var_dump($user_data); //Select box options; $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($company_id); $dlf = new DepartmentListFactory(); $department_options = $dlf->getByCompanyIdArray($company_id); $culf = new CurrencyListFactory(); $culf->getByCompanyId($company_id); $currency_options = $culf->getArrayByListFactory($culf, FALSE, TRUE); $hotf = new HierarchyObjectTypeFactory(); $hierarchy_object_type_options = $hotf->getOptions('object_type'); $hclf = new HierarchyControlListFactory(); $hclf->getObjectTypeAppendedListByCompanyID($company_id); $hierarchy_control_options = $hclf->getArrayByListFactory($hclf, TRUE, TRUE); //Select box options; $user_data['branch_options'] = $branch_options; $user_data['department_options'] = $department_options; $user_data['currency_options'] = $currency_options; $user_data['sex_options'] = $uf->getOptions('sex'); $user_data['status_options'] = $uf->getOptions('status'); $clf = new CompanyListFactory();