/** * Get default recurring_schedule_control data for creating new recurring_schedule_controles. * @return array */ function getRecurringScheduleControlDefaultData() { $company_obj = $this->getCurrentCompanyObject(); Debug::Text('Getting recurring_schedule_control default data...', __FILE__, __LINE__, __METHOD__, 10); $data = array('company_id' => $company_obj->getId(), 'start_week' => 1, 'start_date' => TTDate::getAPIDate('DATE', TTDate::getBeginWeekEpoch(TTDate::getTime())), 'end_date' => NULL); return $this->returnHandler($data); }
/** * Get default recurring_schedule_template data for creating new recurring_schedule_templates. * @return array */ function getRecurringScheduleTemplateDefaultData() { $company_obj = $this->getCurrentCompanyObject(); Debug::Text('Getting recurring_schedule_template default data...', __FILE__, __LINE__, __METHOD__, 10); $data = array('id' => -1, 'week' => 1, 'mon' => TRUE, 'tue' => TRUE, 'wed' => TRUE, 'thu' => TRUE, 'fri' => TRUE, 'start_time' => TTDate::getAPIDate('TIME', strtotime('08:00')), 'end_time' => TTDate::getAPIDate('TIME', strtotime('17:00')), 'total_time' => 9 * 3600, 'branch_id' => -1, 'department_id' => -1, 'schedule_policy_id' => 0, 'open_shift_multiplier' => 1); return $this->returnHandler($data); }
/** * Get default branch data for creating new branches. * @return array */ function getUserWageDefaultData($user_id = NULL) { $company_obj = $this->getCurrentCompanyObject(); Debug::Text('Getting wage default data...', __FILE__, __LINE__, __METHOD__, 10); //If user_id is passed, check for other wage entries, if none, default to the employees hire date. if ($user_id > 0) { //Check for existing wage entries. $uwlf = TTnew('UserWageListFactory'); $uwlf->getLastWageByUserId($user_id); if ($uwlf->getRecordCount() == 1) { Debug::Text('Previous wage entry already exists...', __FILE__, __LINE__, __METHOD__, 10); $effective_date = time(); } else { Debug::Text('Trying to use hire date...', __FILE__, __LINE__, __METHOD__, 10); $ulf = TTnew('UserListFactory'); $ulf->getByIdAndCompanyId($user_id, $this->getCurrentCompanyObject()->getId()); if ($ulf->getRecordCount() > 0) { $effective_date = $ulf->getCurrent()->getHireDate(); } } } else { Debug::Text('No user specified...', __FILE__, __LINE__, __METHOD__, 10); $effective_date = time(); } $data = array('company_id' => $company_obj->getId(), 'type_id' => 10, 'wage' => '0.00', 'hourly_rate' => '0.00', 'effective_date' => TTDate::getAPIDate('DATE', $effective_date), 'labor_burden_percent' => 0, 'weekly_time' => 3600 * 40); return $this->returnHandler($data); }
/** * Get default holiday data for creating new holidayes. * @return array */ function getHolidayDefaultData() { $company_obj = $this->getCurrentCompanyObject(); Debug::Text('Getting holiday default data...', __FILE__, __LINE__, __METHOD__, 10); $data = array('company_id' => $company_obj->getId(), 'date_stamp' => TTDate::getAPIDate('DATE', TTDate::getTime())); return $this->returnHandler($data); }
/** * Get default data for creating pay period schedules. * @return array */ function getPayPeriodScheduleDefaultData() { $company_id = $this->getCurrentCompanyObject()->getId(); Debug::Text('Getting user default data...', __FILE__, __LINE__, __METHOD__, 10); $data = array('company_id' => $this->getCurrentCompanyObject()->getId(), 'anchor_date' => TTDate::getAPIDate('DATE', TTDate::getBeginMonthEpoch(time())), 'shift_assigned_day_id' => 10, 'day_start_time' => 0, 'new_day_trigger_time' => 3600 * 4, 'maximum_shift_time' => 3600 * 16, 'time_zone' => $this->getCurrentUserPreferenceObject()->getTimeZone(), 'type_id' => 20, 'start_week_day_id' => 0, 'start_day_of_week' => 0, 'timesheet_verify_type_id' => 10, 'timesheet_verify_before_end_date' => 0, 'timesheet_verify_before_transaction_date' => 0); Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10); return $this->returnHandler($data); }
/** * Get default roe data for creating new roe. * @return array */ function getROEDefaultData($user_id = NULL) { $company_obj = $this->getCurrentCompanyObject(); if ($user_id > 0) { //Debug::Text('Current User Id: '.$user_id, __FILE__, __LINE__, __METHOD__,10); $rf = new ROEFactory(); $first_date = $rf->calculateFirstDate($user_id); $last_date = $rf->calculateLastDate($user_id); $pay_period = $rf->calculatePayPeriodType($user_id, $last_date); Debug::Text('Getting roe default data...', __FILE__, __LINE__, __METHOD__, 10); $data = array('company_id' => $company_obj->getId(), 'user_id' => $user_id, 'pay_period_type_id' => $pay_period['pay_period_type_id'], 'first_date' => TTDate::getAPIDate('DATE', $first_date), 'last_date' => TTDate::getAPIDate('DATE', $last_date), 'pay_period_end_date' => TTDate::getAPIDate('DATE', $pay_period['pay_period_end_date'])); } else { $data = array('company_id' => $company_obj->getId()); } return $this->returnHandler($data); }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'accrual_policy': case 'first_name': case 'last_name': case 'title': case 'user_group': case 'default_branch': case 'default_department': $data[$variable] = $this->getColumn($variable); break; case 'accrual_policy_type': $data[$variable] = Option::getByKey($this->getColumn('accrual_policy_type_id'), $this->getOptions($variable)); break; case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'time_stamp': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; case 'date_stamp': //This is a combination of the time_stamp and user_date.date_stamp columns. $data[$variable] = TTDate::getAPIDate('DATE', strtotime($this->getColumn($variable))); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getUser(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } //Debug::Arr($data, 'Data Object: ', __FILE__, __LINE__, __METHOD__, 10); return $data; }
/** * Get default user data for creating new users. * @return array */ function getUserDefaultData($tmp_company_id = NULL) { //Allow getting default data from other companies, so it makes it easier to create the first employee of a company. if ($tmp_company_id != '' and $tmp_company_id > 0 and $this->getPermissionObject()->Check('company', 'enabled') and $this->getPermissionObject()->Check('company', 'view')) { $company_id = $tmp_company_id; } else { $company_id = $this->getCurrentCompanyObject()->getId(); } Debug::Text('Getting user default data for Company ID: ' . $company_id . ' TMP Company ID: ' . $tmp_company_id, __FILE__, __LINE__, __METHOD__, 10); //Get New Hire Defaults. $udlf = TTnew('UserDefaultListFactory'); $udlf->getByCompanyId($company_id); if ($udlf->getRecordCount() > 0) { Debug::Text('Using User Defaults, as they exist...', __FILE__, __LINE__, __METHOD__, 10); $udf_obj = $udlf->getCurrent(); $data = array('company_id' => $company_id, 'status_id' => 10, 'title_id' => $udf_obj->getTitle(), 'employee_number' => UserFactory::getNextAvailableEmployeeNumber($company_id), 'city' => $udf_obj->getCity(), 'country' => $udf_obj->getCountry(), 'province' => $udf_obj->getProvince(), 'work_phone' => $udf_obj->getWorkPhone(), 'work_phone_ext' => $udf_obj->getWorkPhoneExt(), 'work_email' => $udf_obj->getWorkEmail(), 'hire_date' => TTDate::getAPIDate('DATE', $udf_obj->getHireDate()), 'sex_id' => 5, 'default_branch_id' => $udf_obj->getDefaultBranch(), 'default_department_id' => $udf_obj->getDefaultDepartment(), 'permission_control_id' => $udf_obj->getPermissionControl(), 'pay_period_schedule_id' => $udf_obj->getPayPeriodSchedule(), 'policy_group_id' => $udf_obj->getPolicyGroup(), 'currency_id' => $udf_obj->getCurrency()); } if (!isset($data['company_id'])) { $data['company_id'] = $company_id; } if (!isset($data['country'])) { $data['country'] = 'US'; } $ulf = TTnew('UserListFactory'); $ulf->getHighestEmployeeNumberByCompanyId($company_id); if ($ulf->getRecordCount() > 0) { Debug::Text('Highest Employee Number: ' . $ulf->getCurrent()->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 10); if (is_numeric($ulf->getCurrent()->getEmployeeNumber()) == TRUE) { $data['next_available_employee_number'] = $ulf->getCurrent()->getEmployeeNumber() + 1; } else { Debug::Text('Highest Employee Number is not an integer.', __FILE__, __LINE__, __METHOD__, 10); $data['next_available_employee_number'] = NULL; } } else { $data['next_available_employee_number'] = 1; } if (!isset($data['hire_date']) or $data['hire_date'] == '') { $data['hire_date'] = TTDate::getAPIDate('DATE', time()); } return $this->returnHandler($data); }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { // //When using the Recurring Schedule view, it returns the user list for every single row and runs out of memory at about 1000 rows. //Need to make the 'user' column explicitly defined instead perhaps? // $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': $data[$variable] = $this->getColumn($variable) == '' ? TTi18n::getText('OPEN') : $this->getColumn($variable); break; case 'title': case 'user_group': case 'default_branch': case 'default_department': case 'recurring_schedule_template_control': case 'recurring_schedule_template_control_description': case 'user_id': $data[$variable] = $this->getColumn($variable); break; case 'start_date': case 'end_date': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->{$function}())); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } //Handle expanded and non-expanded mode. In non-expanded mode we need to get all the users //so we can check is_owner/is_child permissions on them. if ($this->getColumn('user_id') !== FALSE) { $user_ids = $this->getColumn('user_id'); } else { $user_ids = $this->getUser(); } $this->getPermissionColumns($data, $user_ids, $this->getCreatedBy(), $permission_children_ids, $include_columns); //$this->getPermissionColumns( $data, $this->getColumn('user_id'), $this->getCreatedBy(), $permission_children_ids, $include_columns ); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $uf = TTnew('UserFactory'); $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'hire_date': $data[$variable] = TTDate::getAPIDate('DATE', $this->getHireDate()); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $uf = new UserFactory(); $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'user_id': case 'first_name': case 'last_name': case 'user_status_id': case 'group_id': case 'group': case 'title_id': case 'title': case 'default_branch_id': case 'default_branch': case 'default_department_id': case 'default_department': case 'schedule_policy_id': case 'schedule_policy': case 'pay_period_id': case 'branch': case 'department': $data[$variable] = $this->getColumn($variable); break; case 'status': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'user_status': $data[$variable] = Option::getByKey((int) $this->getColumn('user_status_id'), $uf->getOptions('status')); break; case 'date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::parseDateTime($this->getColumn('date_stamp'))); break; case 'start_date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getStartTime()); //Include both date+time break; case 'end_date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getEndTime()); //Include both date+time break; case 'start_time': case 'end_time': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('TIME', $this->{$function}()); //Just include time, so Mass Edit sees similar times without dates } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns(&$data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': case 'title': case 'user_group': case 'default_branch': case 'default_department': case 'user_id': $data[$variable] = $this->getColumn($variable); break; case 'message': //Message is attached in the message factory, so we can't return it here. break; case 'status': case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('date_stamp'))); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getColumn('user_id'), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $uf = TTnew('UserFactory'); $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': case 'user_status_id': case 'group_id': case 'user_group': case 'title_id': case 'title': case 'default_branch_id': case 'default_branch': case 'default_department_id': case 'default_department': case 'pay_stub_entry_name': $data[$variable] = $this->getColumn($variable); break; case 'user_status': $data[$variable] = Option::getByKey((int) $this->getColumn('user_status_id'), $uf->getOptions('status')); break; case 'status': case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'effective_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getID(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { /* $include_columns = array( 'id' => TRUE, 'company_id' => TRUE, ... ) */ $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'full_name': $data[$variable] = $this->getFullName(TRUE); case 'status': case 'sex': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'company': case 'title': case 'user_group': case 'ethnic_group': case 'currency': case 'currency_rate': case 'default_branch': case 'default_department': case 'default_job': case 'default_job_item': case 'permission_control': case 'pay_period_schedule': case 'policy_group': case 'password_updated_date': $data[$variable] = $this->getColumn($variable); break; //The below fields may be set if APISearch ListFactory is used to obtain the data originally, //but if it isn't, use the explicit function to get the data instead. //The below fields may be set if APISearch ListFactory is used to obtain the data originally, //but if it isn't, use the explicit function to get the data instead. case 'permission_control_id': //These functions are slow to obtain (especially in a large loop), so make sure the column is requested explicitly before we include it. //Flex currently doesn't specify these fields in the Edit view though, so this breaks Flex. //if ( isset($include_columns[$variable]) AND $include_columns[$variable] == TRUE ) { $data[$variable] = $this->getColumn($variable); if ($data[$variable] == FALSE) { $data[$variable] = $this->getPermissionControl(); } //} break; case 'pay_period_schedule_id': //These functions are slow to obtain (especially in a large loop), so make sure the column is requested explicitly before we include it. //Flex currently doesn't specify these fields in the Edit view though, so this breaks Flex. //if ( isset($include_columns[$variable]) AND $include_columns[$variable] == TRUE ) { $data[$variable] = $this->getColumn($variable); if ($data[$variable] == FALSE) { $data[$variable] = $this->getPayPeriodSchedule(); } //} break; case 'policy_group_id': //These functions are slow to obtain (especially in a large loop), so make sure the column is requested explicitly before we include it. //Flex currently doesn't specify these fields in the Edit view though, so this breaks Flex. //if ( isset($include_columns[$variable]) AND $include_columns[$variable] == TRUE ) { $data[$variable] = $this->getColumn($variable); if ($data[$variable] == FALSE) { $data[$variable] = $this->getPolicyGroup(); } //} break; case 'hierarchy_control': //These functions are slow to obtain (especially in a large loop), so make sure the column is requested explicitly before we include it. //Flex currently doesn't specify these fields in the Edit view though, so this breaks Flex. //if ( isset($include_columns[$variable]) AND $include_columns[$variable] == TRUE ) { $data[$variable] = $this->getHierarchyControl(); //} break; case 'hierarchy_control_display': //These functions are slow to obtain (especially in a large loop), so make sure the column is requested explicitly before we include it. //if ( isset($include_columns[$variable]) AND $include_columns[$variable] == TRUE ) { $data[$variable] = $this->getHierarchyControlDisplay(); //} break; case 'hierarchy_level_display': $data[$variable] = $this->getHierarchyLevelDisplay(); break; case 'password': //Don't return password break; //case 'sin': //This is handled in the API class instead. // $data[$variable] = $this->getSecureSIN(); // break; //case 'sin': //This is handled in the API class instead. // $data[$variable] = $this->getSecureSIN(); // break; case 'last_login_date': case 'hire_date': case 'birth_date': case 'termination_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; case 'birth_date_age': $data[$variable] = (int) floor((time() - $this->getBirthDate()) / 60 / 60 / 24 / 30 / 12); break; case 'hire_date_age': if ($this->getTerminationDate() != '') { $end_epoch = $this->getTerminationDate(); } else { $end_epoch = time(); } $data[$variable] = (int) floor(($end_epoch - $this->getHireDate()) / 60 / 60 / 24 / 30 / 12); unset($end_epoch); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } unset($function); } $this->getPermissionColumns($data, $this->getID(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { $ppsf = TTnew('PayPeriodScheduleFactory'); foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'status': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'type': //Make sure type_id is set first. $data[$variable] = Option::getByKey($this->getColumn('type_id'), $ppsf->getOptions($variable)); break; case 'type_id': case 'pay_period_schedule': $data[$variable] = $this->getColumn($variable); break; case 'start_date': case 'end_date': case 'transaction_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->{$function}()); } break; case 'total_punches': case 'pending_requests': case 'ps_amendments': case 'pay_stubs': //These functions are slow to obtain, so make sure the column is requested explicitly before we include it. if (isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $data[$variable] = $this->{$function}(); } break; case 'exceptions_critical': case 'exceptions_high': case 'exceptions_medium': case 'exceptions_low': //These functions are slow to obtain, so make sure the column is requested explicitly before we include it. if (isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { if (!isset($exceptions_arr)) { $exceptions_arr = $this->getExceptions(); } $data[$variable] = $exceptions_arr[$variable]; } break; case 'verified_timesheets': case 'pending_timesheets': case 'total_timesheets': //These functions are slow to obtain, so make sure the column is requested explicitly before we include it. if (isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { if (!isset($timesheet_arr)) { $timesheet_arr = $this->getTimeSheets(); } $data[$variable] = $timesheet_arr[$variable]; } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'type': case 'term': case 'severity': case 'status': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'user': $data[$variable] = Misc::getFullName($this->getColumn('user_first_name'), NULL, $this->getColumn('user_last_name'), FALSE, FALSE); break; case 'reviewer_user': $data[$variable] = Misc::getFullName($this->getColumn('reviewer_user_first_name'), NULL, $this->getColumn('reviewer_user_last_name'), FALSE, FALSE); break; case 'start_date': $data['start_date'] = TTDate::getAPIDate('DATE', $this->getStartDate()); break; case 'end_date': $data['end_date'] = TTDate::getAPIDate('DATE', $this->getEndDate()); break; case 'due_date': $data['due_date'] = TTDate::getAPIDate('DATE', $this->getDueDate()); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getUser(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'wage_group': case 'first_name': case 'last_name': case 'title': case 'user_group': case 'currency': case 'default_branch': case 'default_department': $data[$variable] = $this->getColumn($variable); break; case 'currency_symbol': $data[$variable] = TTi18n::getCurrencySymbol($this->getColumn('iso_code')); break; case 'effective_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getID(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'status': case 'type': case 'calculation': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'start_date': case 'end_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); $epf = TTnew('ExceptionPolicyFactory'); $exception_policy_type_options = $epf->getOptions('type'); $exception_policy_severity_options = $epf->getOptions('severity'); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'pay_period_id': case 'pay_period_schedule_id': case 'pay_period_start_date': case 'pay_period_end_date': case 'pay_period_transaction_date': case 'user_id': case 'first_name': case 'last_name': case 'country': case 'province': case 'user_status_id': case 'group_id': case 'group': case 'title_id': case 'title': case 'default_branch_id': case 'default_branch': case 'default_department_id': case 'default_department': case 'branch_id': case 'branch': case 'department_id': case 'department': case 'severity_id': case 'exception_policy_type_id': case 'policy_group': case 'permission_group': case 'pay_period_schedule': $data[$variable] = $this->getColumn($variable); break; case 'severity': $data[$variable] = Option::getByKey($this->getColumn('severity_id'), $exception_policy_severity_options); break; case 'exception_policy_type': $data[$variable] = Option::getByKey($this->getColumn('exception_policy_type_id'), $exception_policy_type_options); break; case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('date_stamp'))); break; case 'pay_period_start_date': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('pay_period_start_date'))); break; case 'pay_period_end_date': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('pay_period_end_date'))); break; case 'pay_period': case 'pay_period_transaction_date': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('pay_period_transaction_date'))); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { /* $include_columns = array( 'id' => TRUE, 'company_id' => TRUE, ... ) */ $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'status': case 'sex': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'title': case 'group': case 'currency': case 'default_branch': case 'default_department': case 'permission_control_id': case 'permission_control': case 'pay_period_schedule_id': case 'pay_period_schedule': case 'policy_group_id': case 'policy_group': $data[$variable] = $this->getColumn($variable); case 'password': //Don't return password break; case 'hire_date': case 'birth_date': case 'termination_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns(&$data, $this->getID(), $this->getCreatedBy(), $permission_children_ids); $this->getCreatedAndUpdatedColumns(&$data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'qualification': case 'group': case 'first_name': case 'last_name': case 'title': case 'user_group': case 'default_branch': case 'default_department': $data[$variable] = $this->getColumn($variable); break; case 'proficiency': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'first_used_date': $data['first_used_date'] = TTDate::getAPIDate('DATE', $this->getFirstUsedDate()); break; case 'last_used_date': $data['last_used_date'] = TTDate::getAPIDate('DATE', $this->getLastUsedDate()); break; case 'expiry_date': $data['expiry_date'] = TTDate::getAPIDate('DATE', $this->getExpiryDate()); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getUser(), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'type': case 'pay_type': case 'branch_selection_type': case 'department_selection_type': case 'job_group_selection_type': case 'job_selection_type': case 'job_item_group_selection_type': case 'job_item_selection_type': $function = 'get' . str_replace('_', '', $variable); if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'start_date': case 'end_date': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}()); } break; case 'start_time': case 'end_time': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('TIME', $this->{$function}()); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns(&$data, $include_columns); } return $data; }
/** * Get all necessary dates for building the schedule in a single call, this is mainly as a performance optimization. * @param array $data filter data * @return array */ function getScheduleDates($base_date, $type, $strict = TRUE) { $epoch = TTDate::parseDateTime($base_date); if ($epoch == '') { $epoch = TTDate::getTime(); } if ($type == '') { $type = 'week'; } switch (strtolower($type)) { case 'day': if ($strict == TRUE) { $start_date = TTDate::getBeginDayEpoch($epoch); $end_date = TTDate::getEndDayEpoch($epoch); } else { $start_date = TTDate::getBeginDayEpoch($epoch); $end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 86400); } break; case 'week': if ($strict == TRUE) { $start_date = TTDate::getBeginWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay()); $end_date = TTDate::getEndWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay()); } else { $start_date = TTDate::getBeginDayEpoch($epoch); $end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 7 * 86400); } break; case 'month': if ($strict == TRUE) { $start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay()); $end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay()); } else { $start_date = TTDate::getBeginDayEpoch($epoch); $end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 30 * 86400); } break; case 'year': if ($strict == TRUE) { $start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay()); $end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch(TTDate::getEndMonthEpoch($epoch) + 86400 * 2), $this->getCurrentUserPreferenceObject()->getStartWeekDay()); } else { $start_date = TTDate::getBeginDayEpoch($epoch); $end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 62 * 86400); } break; } $retarr = array('base_date' => $epoch, 'start_date' => $start_date, 'end_date' => $end_date, 'base_display_date' => TTDate::getAPIDate('DATE', $epoch), 'start_display_date' => TTDate::getAPIDate('DATE', $start_date), 'end_display_date' => TTDate::getAPIDate('DATE', $end_date)); Debug::Arr($retarr, 'Schedule Dates: Base Date: ' . $base_date . ' Type: ' . $type . ' Strict: ' . (int) $strict, __FILE__, __LINE__, __METHOD__, 10); return $retarr; }
function getCreatedAndUpdatedColumns(&$data, $include_columns = NULL) { //Update array in-place. if ($include_columns == NULL or isset($include_columns['created_by_id']) and $include_columns['created_by_id'] == TRUE) { $data['created_by_id'] = $this->getCreatedBy(); } if ($include_columns == NULL or isset($include_columns['created_by']) and $include_columns['created_by'] == TRUE) { $data['created_by'] = Misc::getFullName($this->getColumn('created_by_first_name'), $this->getColumn('created_by_middle_name'), $this->getColumn('created_by_last_name')); } if ($include_columns == NULL or isset($include_columns['created_date']) and $include_columns['created_date'] == TRUE) { $data['created_date'] = TTDate::getAPIDate('DATE+TIME', $this->getCreatedDate()); } if ($include_columns == NULL or isset($include_columns['updated_by_id']) and $include_columns['updated_by_id'] == TRUE) { $data['updated_by_id'] = $this->getUpdatedBy(); } if ($include_columns == NULL or isset($include_columns['updated_by']) and $include_columns['updated_by'] == TRUE) { $data['updated_by'] = Misc::getFullName($this->getColumn('updated_by_first_name'), $this->getColumn('updated_by_middle_name'), $this->getColumn('updated_by_last_name')); } if ($include_columns == NULL or isset($include_columns['updated_date']) and $include_columns['updated_date'] == TRUE) { $data['updated_date'] = TTDate::getAPIDate('DATE+TIME', $this->getUpdatedDate()); } return TRUE; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'status': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'start_time': case 'end_time': //$data[$variable] = ( defined('TIMETREX_API') ) ? TTDate::getAPIDate( 'TIME', TTDate::strtotime( $this->$function() ) ) : $this->$function(); $data[$variable] = defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', TTDate::strtotime($this->{$function}())) : $this->{$function}(); //Need to include the raw_start_time,raw_end_time columns that are in EPOCH format so getShiftsByStartDateAndEndDate() can convert them as needed. $data['raw_' . $variable] = $this->{$function}(); break; case 'sun': case 'mon': case 'tue': case 'wed': case 'thu': case 'fri': case 'sat': //For backwards compatibility, put all days inside the "days" array, AS WELL as in their own column for the API to use. if (method_exists($this, $function)) { $data['days'][$variable] = $this->{$function}(); } default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $uf = TTnew('UserFactory'); $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'user_id': case 'first_name': case 'last_name': case 'user_status_id': case 'group_id': case 'group': case 'title_id': case 'title': case 'default_branch_id': case 'default_branch': case 'default_department_id': case 'default_department': case 'pay_period_id': case 'branch': case 'department': case 'over_time_policy': case 'absence_policy': case 'absence_policy_type_id': case 'premium_policy': case 'meal_policy': case 'break_policy': case 'job': case 'job_item': $data[$variable] = $this->getColumn($variable); break; case 'status': case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'user_status': $data[$variable] = Option::getByKey((int) $this->getColumn('user_status_id'), $uf->getOptions('status')); break; case 'date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', TTDate::strtotime($this->getColumn('date_stamp'))); break; case 'start_time_stamp': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->{$function}()); //Include both date+time break; case 'end_time_stamp': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->{$function}()); //Include both date+time break; case 'name': $data[$variable] = $this->getName(); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getColumn('user_id'), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE) { $uf = TTnew('UserFactory'); $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': if ($this->getColumn('user_id') > 0) { $data[$variable] = $this->getColumn($variable); } else { $data[$variable] = TTi18n::getText('OPEN'); } break; case 'user_id': //Make sure getUser() returns the proper user_id, otherwise mass edit will always assign shifts to OPEN employee. //We have to make sure the 'user_id' function map is FALSE as well, so we don't get a SQL error when getting the empty record set. $data[$variable] = $this->tmp_data['user_id'] = $this->getColumn($variable); break; case 'user_status_id': case 'group_id': case 'group': case 'title_id': case 'title': case 'default_branch_id': case 'default_branch': case 'default_department_id': case 'default_department': case 'schedule_policy_id': case 'schedule_policy': case 'pay_period_id': case 'branch': case 'department': case 'job': case 'job_item': $data[$variable] = $this->getColumn($variable); break; case 'status': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'user_status': $data[$variable] = Option::getByKey((int) $this->getColumn('user_status_id'), $uf->getOptions('status')); break; case 'date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', strtotime($this->getColumn('date_stamp'))); break; case 'start_date_stamp': $data[$variable] = TTDate::getAPIDate('DATE', $this->getStartTime()); //Include both date+time break; case 'start_date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getStartTime()); //Include both date+time break; case 'end_date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getEndTime()); //Include both date+time break; case 'start_time_stamp': $data[$variable] = $this->getStartTime(); //Include start date/time in epoch format for sorting... break; case 'end_time_stamp': $data[$variable] = $this->getEndTime(); //Include end date/time in epoch format for sorting... break; case 'start_time': case 'end_time': if (method_exists($this, $function)) { $data[$variable] = TTDate::getAPIDate('TIME', $this->{$function}()); //Just include time, so Mass Edit sees similar times without dates } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getPermissionColumns($data, $this->getColumn('user_id'), $this->getCreatedBy(), $permission_children_ids, $include_columns); $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); $data = array(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': $data[$variable] = $this->getColumn($variable); break; case 'date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->getDate()); break; case 'object': $data[$variable] = Option::getByKey($this->getTableName(), $this->getOptions('table_name')); break; case 'action': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'details': if (isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $data[$variable] = $this->getDetails(); } break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } //$this->getCreatedAndUpdatedColumns( $data, $include_columns ); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'first_name': case 'last_name': $data[$variable] = $this->getColumn($variable); break; case 'code': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'pay_period_type': $ppsf = TTnew('PayPeriodScheduleFactory'); $data[$variable] = Option::getByKey($this->getPayPeriodType(), $ppsf->getOptions('type')); break; case 'first_date': $data[$variable] = TTDate::getAPIDate('DATE', $this->getFirstDate()); break; case 'last_date': $data[$variable] = TTDate::getAPIDate('DATE', $this->getLastDate()); break; case 'pay_period_end_date': $data[$variable] = TTDate::getAPIDate('DATE', $this->getPayPeriodEndDate()); break; case 'recall_date': $data[$variable] = TTDate::getAPIDate('DATE', $this->getRecallDate()); break; case 'insurable_earnings': $data[$variable] = $this->getInsurableEarnings(); break; case 'vacation_pay': $data[$variable] = $this->getVacationPay(); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }
function getObjectAsArray($include_columns = NULL) { $variable_function_map = $this->getVariableToFunctionMap(); if (is_array($variable_function_map)) { foreach ($variable_function_map as $variable => $function_stub) { if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) { $function = 'get' . $function_stub; switch ($variable) { case 'status': case 'type': $function = 'get' . $variable; if (method_exists($this, $function)) { $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable)); } break; case 'last_punch_time_stamp': case 'last_poll_date': case 'last_push_date': case 'last_partial_push_date': $data[$variable] = TTDate::getAPIDate('DATE+TIME', $this->{$function}()); break; case 'group': $data[$variable] = $this->getGroup(); break; case 'branch': $data[$variable] = $this->getBranch(); break; case 'department': $data[$variable] = $this->getDepartment(); break; case 'include_user': $data[$variable] = $this->getIncludeUser(); break; case 'exclude_user': $data[$variable] = $this->getExcludeUser(); break; default: if (method_exists($this, $function)) { $data[$variable] = $this->{$function}(); } break; } } } $this->getCreatedAndUpdatedColumns($data, $include_columns); } return $data; }