function setUser($id) { $id = trim($id); $ulf = new UserListFactory(); if ($id != 0 and $this->Validator->isResultSetWithRows('user', $ulf->getByID($id), TTi18n::gettext('Selected Employee is invalid')) and $this->Validator->isTrue('user', $this->isUniqueUser($id), TTi18n::gettext('Selected Employee is already assigned to another Permission Group'))) { $this->data['user_id'] = $id; return TRUE; } return FALSE; }
function setUser($id) { $id = trim($id); $ulf = new UserListFactory(); if ($id == 0 or $this->Validator->isResultSetWithRows('user', $ulf->getByID($id), TTi18n::gettext('Invalid User'))) { $this->data['user_id'] = $id; return TRUE; } return FALSE; }
function setIncludeUser($id) { $id = trim($id); $ulf = new UserListFactory(); if ($this->Validator->isResultSetWithRows('include_user', $ulf->getByID($id), TTi18n::gettext('Selected User is invalid'))) { $this->data['user_id'] = $id; return TRUE; } return FALSE; }
/** * Smarty plugin * @package Smarty * @subpackage plugins */ function smarty_function_EmbeddedAuthorizationList($params, &$smarty) { global $current_company, $current_user; $object_type_id = $params['object_type_id']; $object_id = $params['object_id']; $ulf = new UserListFactory(); $hlf = new HierarchyListFactory(); $hotlf = new HierarchyObjectTypeListFactory(); $alf = new AuthorizationListFactory(); $alf->setObjectType($object_type_id); //$authorizing_obj = $alf->getObjectHandler()->getById( $object_id )->getCurrent(); $tmp_authorizing_obj = $alf->getObjectHandler()->getById($object_id); if (is_object($tmp_authorizing_obj)) { $authorizing_obj = $tmp_authorizing_obj->getCurrent(); } else { return FALSE; } //var_dump($authorizing_obj); unset($alf); $user_id = $authorizing_obj->getUserObject()->getId(); $alf = new AuthorizationListFactory(); $alf->getByObjectTypeAndObjectId($object_type_id, $object_id); foreach ($alf as $authorization_obj) { $authorization_data[] = array('id' => $authorization_obj->getId(), 'created_by_full_name' => $ulf->getById($authorization_obj->getCreatedBy())->getCurrent()->getFullName(), 'authorized' => $authorization_obj->getAuthorized(), 'created_date' => $authorization_obj->getCreatedDate(), 'created_by' => $authorization_obj->getCreatedBy(), 'updated_date' => $authorization_obj->getUpdatedDate(), 'updated_by' => $authorization_obj->getUpdatedBy(), 'deleted_date' => $authorization_obj->getDeletedDate(), 'deleted_by' => $authorization_obj->getDeletedBy()); $user_id = $authorization_obj->getCreatedBy(); } if ($authorizing_obj->getStatus() == 30) { //If the object is still pending authorization, display who its waiting on... $hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($current_company->getId(), $object_type_id)->getCurrent()->getHierarchyControl(); Debug::Text('Hierarchy ID: ' . $hierarchy_id, __FILE__, __LINE__, __METHOD__, 10); //Get Parents $parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $user_id); Debug::Arr($parent_level_user_ids, 'Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10); if ($parent_level_user_ids !== FALSE and count($parent_level_user_ids) > 0) { Debug::Text('Adding Pending Line: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($parent_level_user_ids as $parent_user_id) { $created_by_full_name[] = $ulf->getById($parent_user_id)->getCurrent()->getFullName(); } $authorization_data[] = array('id' => NULL, 'created_by_full_name' => implode('<br>', $created_by_full_name), 'authorized' => NULL, 'created_date' => NULL, 'created_by' => NULL); } } $smarty->assign_by_ref('authorization_data', $authorization_data); $smarty->display('authorization/EmbeddedAuthorizationList.tpl'); }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $clf = new CompanyListFactory(); $clf->StartTransaction(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() == 10) { $ulf = new UserListFactory(); $ulf->getHighestEmployeeNumberByCompanyId($c_obj->getId()); if ($ulf->getRecordCount() > 0) { $next_available_employee_number = $ulf->getCurrent()->getEmployeeNumber() + 1; } else { $next_available_employee_number = 1; } $ulf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('hire_date' => 'asc')); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $u_obj) { if ($u_obj->getEmployeeNumber() == '') { Debug::text('Setting Employee Number to: ' . $next_available_employee_number . ' for ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9); $u_obj->setEmployeeNumber($next_available_employee_number); if ($u_obj->isValid()) { $u_obj->Save(); $next_available_employee_number++; } } else { Debug::text('NOT Setting Employee Number for ' . $u_obj->getUserName() . ' already set to: ' . $u_obj->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 9); } } } } } } //$clf->FailTransaction(); $clf->CommitTransaction(); return TRUE; }
Debug::Text('Found Default Report!', __FILE__, __LINE__, __METHOD__, 10); $ugd_obj = $ugdlf->getCurrent(); $filter_data = $ugd_obj->getData(); $generic_data['id'] = $ugd_obj->getId(); } else { Debug::Text('Default Settings!', __FILE__, __LINE__, __METHOD__, 10); //Default selections $filter_data['user_status_ids'] = array(-1); $filter_data['branch_ids'] = array(-1); $filter_data['department_ids'] = array(-1); $filter_data['user_title_ids'] = array(-1); $filter_data['group_ids'] = array(-1); } } $filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'user_title_ids', 'pay_period_ids', 'column_ids'), NULL); $ulf = new UserListFactory(); $all_array_option = array('-1' => TTi18n::gettext('-- All --')); //Get include employee list. $ulf->getByCompanyId($current_company->getId()); $user_options = $ulf->getArrayByListFactory($ulf, FALSE, TRUE); $filter_data['src_include_user_options'] = Misc::arrayDiffByKey((array) $filter_data['include_user_ids'], $user_options); $filter_data['selected_include_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['include_user_ids'], $user_options); //Get exclude employee list $exclude_user_options = Misc::prependArray($all_array_option, $ulf->getArrayByListFactory($ulf, FALSE, TRUE)); $filter_data['src_exclude_user_options'] = Misc::arrayDiffByKey((array) $filter_data['exclude_user_ids'], $user_options); $filter_data['selected_exclude_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['exclude_user_ids'], $user_options); //Get employee status list. $user_status_options = Misc::prependArray($all_array_option, $ulf->getOptions('status')); $filter_data['src_user_status_options'] = Misc::arrayDiffByKey((array) $filter_data['user_status_ids'], $user_status_options); $filter_data['selected_user_status_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_status_ids'], $user_status_options); //Get Employee Groups
$utlf = new UserTaxListFactory(); //$uwlf->GetByUserIdAndCompanyId($current_user->getId(), $current_company->getId() ); $utlf->GetByUserId($user_id); foreach ($utlf as $tax) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); //$user_id = $tax->getUser(); $tax_data = array('id' => $tax->getId(), 'user_id' => $tax->getUser(), 'country' => $user_obj->getCountry(), 'federal_claim' => $tax->getFederalClaim(), 'provincial_claim' => $tax->getProvincialClaim(), 'federal_additional_deduction' => $tax->getFederalAdditionalDeduction(), 'wcb_rate' => $tax->getWCBRate(), 'vacation_rate' => $tax->getVacationRate(), 'release_vacation' => $tax->getReleaseVacation(), 'ei_exempt' => $tax->getEIExempt(), 'cpp_exempt' => $tax->getCPPExempt(), 'federal_tax_exempt' => $tax->getFederalTaxExempt(), 'provincial_tax_exempt' => $tax->getProvincialTaxExempt(), 'federal_filing_status_id' => $tax->getFederalFilingStatus(), 'state_filing_status_id' => $tax->getStateFilingStatus(), 'federal_allowance' => $tax->getFederalAllowance(), 'state_allowance' => $tax->getStateAllowance(), 'state_additional_deduction' => $tax->getStateAdditionalDeduction(), 'state_ui_rate' => $tax->getStateUIRate(), 'state_ui_wage_base' => $tax->getStateUIWageBase(), 'social_security_exempt' => $tax->getSocialSecurityExempt(), 'ui_exempt' => $tax->getUIExempt(), 'medicare_exempt' => $tax->getMedicareExempt(), 'created_date' => $tax->getCreatedDate(), 'created_by' => $tax->getCreatedBy(), 'updated_date' => $tax->getUpdatedDate(), 'updated_by' => $tax->getUpdatedBy(), 'deleted_date' => $tax->getDeletedDate(), 'deleted_by' => $tax->getDeletedBy()); } if (!isset($tax_data)) { $tax_data = array('country' => $user_obj->getCountry(), 'wcb_rate' => 0, 'vacation_rate' => 0, 'federal_claim' => 0, 'provincial_claim' => 0, 'federal_additional_deduction' => 0, 'federal_allowance' => 0, 'state_allowance' => 0, 'state_additional_deduction' => 0, 'state_ui_rate' => 0, 'state_ui_wage_base' => 0); } } else { if ($tax_data['user_id'] != '') { $user_id = $tax_data['user_id']; } } $tax_data['user_options'] = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE); $tax_data['federal_filing_status_options'] = $utf->getOptions('federal_filing_status'); $tax_data['state_filing_status_options'] = $utf->getOptions('state_filing_status'); //var_dump($tax_data); $smarty->assign_by_ref('tax_data', $tax_data); $smarty->assign_by_ref('user_id', $user_id); $ulf = new UserListFactory(); $ulf->getByIdAndCompanyId($user_id, $current_company->getId()); $user_data = $ulf->getCurrent(); $smarty->assign_by_ref('full_name', $user_data->getFullName()); $smarty->assign_by_ref('data_saved', $data_saved); break; } $smarty->assign_by_ref('utf', $utf); $smarty->display('users/EditUserTax.tpl');
function setUser($ids) { if (is_array($ids)) { if (!$this->isNew()) { //If needed, delete mappings first. $ppsulf = new PayPeriodScheduleUserListFactory(); $ppsulf->getByPayPeriodScheduleId($this->getId()); $user_ids = array(); foreach ($ppsulf as $pay_period_schedule) { $user_id = $pay_period_schedule->getUser(); Debug::text('Schedule ID: ' . $pay_period_schedule->getPayPeriodSchedule() . ' User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($user_id, $ids)) { Debug::text('Deleting User: '******'s that need to be updated. Debug::text('NOT Deleting User: '******'' and isset($user_ids) and !in_array($id, $user_ids)) { $ppsuf = new PayPeriodScheduleUserFactory(); $ppsuf->setPayPeriodSchedule($this->getId()); $ppsuf->setUser($id); $user_obj = $ulf->getById($id)->getCurrent(); if ($this->Validator->isTrue('user', $ppsuf->Validator->isValid(), TTi18n::gettext('Selected Employee is already assigned to another Pay Period') . ' (' . $user_obj->getFullName() . ')')) { $ppsuf->save(); } } } return TRUE; } return FALSE; }
function setOfflinePunch($data) { Debug::Text('Setting Offline Punches... Rows: ' . count($data), __FILE__, __LINE__, __METHOD__, 10); // //WHen in Offline mode, default Type/Status to "AUTO"... //That way once I get the punches, I can determine what they should be on my end. // if (!is_array($data) or count($data) == 0) { return FALSE; } ksort($data); //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10); /* //Original $data[] = array( 'user_id' => 1, 'time_stamp' => '12:00 PM', 'date_stamp' => '03-Dec-05', 'branch_id' => 1, 'department_id' => NULL, 'status_id' => 20, 'type_id' => 20, 'punch_control_id' => 0, 'station_id' => '7D00000023352A81' ); */ /* unset($data); $data[] = array( 'user_id' => 1001, 'time_stamp' => '08:00 AM', 'date_stamp' => '05-Dec-05', 'branch_id' => 5, 'department_id' => 3, 'status_id' => 0, 'type_id' => 0, 'punch_control_id' => 0, 'station_id' => '7D00000023352A81' ); $data[] = array( 'user_id' => 1001, 'time_stamp' => '12:00 PM', 'date_stamp' => '05-Dec-05', 'branch_id' => 0, 'department_id' => 3, 'status_id' => 20, 'type_id' => 0, 'punch_control_id' => 0, 'station_id' => '7D00000023352A81' ); */ /* $data[] = array( 'user_id' => 1001, 'time_stamp' => '1:00 PM', 'date_stamp' => '05-Dec-05', 'branch_id' => 6, 'department_id' => 0, 'status_id' => 0, 'type_id' => 20, 'punch_control_id' => 0, 'station_id' => '7D00000023352A81' ); */ /* $data[] = array( 'user_id' => 1001, 'time_stamp' => '5:00 PM', 'date_stamp' => '05-Dec-05', 'branch_id' => 0, 'department_id' => 0, 'status_id' => 0, 'type_id' => 0, 'punch_control_id' => 0, 'station_id' => '7D00000023352A81' ); */ //Debug::Arr($data, 'offlinePunchDataArr', __FILE__, __LINE__, __METHOD__,10); //One punch per row foreach ($data as $row_key => $punch_row) { Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10); Debug::Text('--------------------------========================---------------------------', __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Row Key: ' . $row_key . ' Date: ' . $punch_row['date_stamp'] . ' Time: ' . $punch_row['time_stamp'] . ' Station ID: ' . $punch_row['station_id'], __FILE__, __LINE__, __METHOD__, 10); if (isset($punch_row['station_id'])) { $slf = new StationListFactory(); $slf->getByStationId($punch_row['station_id']); if ($slf->getRecordCount() > 0) { Debug::Text('Found Station Data...', __FILE__, __LINE__, __METHOD__, 10); $current_station = $slf->getCurrent(); } else { Debug::Text('DID NOT Find Station Data...', __FILE__, __LINE__, __METHOD__, 10); continue; } unset($slf); } if (isset($punch_row['user_id']) and $punch_row['user_id'] != '') { $ulf = new UserListFactory(); $ulf->getById($punch_row['user_id']); if ($ulf->getRecordCount() > 0) { $current_user = $ulf->getCurrent(); Debug::Text('Valid User ID: ' . $punch_row['user_id'] . ' User Name: ' . $current_user->getFullName(), __FILE__, __LINE__, __METHOD__, 10); //Need to handle timezone somehow. The station should send us the system's timezone //so we can calculate based on that. //Or just use the employees date preference. $current_user->getUserPreferenceObject()->setDateTimePreferences(); } else { Debug::Text('aInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10); continue; } } else { Debug::Text('bInValid User ID: ' . $punch_row['user_id'], __FILE__, __LINE__, __METHOD__, 10); continue; } //Check to make sure the station is allowed. if (is_object($current_station) and is_object($current_user) and $current_station->checkAllowed($current_user->getId(), $current_station->getStation(), $current_station->getType()) == FALSE) { Debug::text('Station NOT allowed: Station ID: ' . $current_station->getId() . ' User: '******'date_stamp'] . ' ' . $punch_row['time_stamp']); //Make sure time stamp converts properly, otherwise skip this punch. if (!is_int($punch_full_time_stamp)) { Debug::Text('Failed TimeStamp: ' . $punch_full_time_stamp, __FILE__, __LINE__, __METHOD__, 10); continue; } Debug::Text('Punch Date/Time: ' . $punch_full_time_stamp . ' Offset that was already applied: ' . $punch_row['offset'], __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = FALSE; $pf = new PunchFactory(); $pf->StartTransaction(); $slf = new ScheduleListFactory(); //Auto Punch if (isset($punch_row['status_id']) and $punch_row['status_id'] == 0 or isset($punch_row['type_id']) and $punch_row['type_id'] == 0 or isset($punch_row['branch_id']) and $punch_row['branch_id'] == 0 or isset($punch_row['department_id']) and $punch_row['department_id'] == 0 or isset($punch_row['job_id']) and $punch_row['job_id'] == 0 or isset($punch_row['job_item_id']) and $punch_row['job_item_id'] == 0) { $plf = new PunchListFactory(); $plf->getPreviousPunchByUserIDAndEpoch($punch_row['user_id'], $punch_full_time_stamp); if ($plf->getRecordCount() > 0) { Debug::Text(' Found Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10); $prev_punch_obj = $plf->getCurrent(); $branch_id = $prev_punch_obj->getPunchControlObject()->getBranch(); $department_id = $prev_punch_obj->getPunchControlObject()->getDepartment(); $job_id = $prev_punch_obj->getPunchControlObject()->getJob(); $job_item_id = $prev_punch_obj->getPunchControlObject()->getJobItem(); $quantity = $prev_punch_obj->getPunchControlObject()->getQuantity(); $bad_quantity = $prev_punch_obj->getPunchControlObject()->getBadQuantity(); if ($branch_id == '' or empty($branch_id) or $department_id == '' or empty($department_id)) { Debug::Text(' Branch or department are null. ', __FILE__, __LINE__, __METHOD__, 10); $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp); if (is_object($s_obj)) { Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10); if ($branch_id == '' or empty($branch_id)) { Debug::Text(' overrriding branch: ' . $s_obj->getBranch(), __FILE__, __LINE__, __METHOD__, 10); $branch_id = $s_obj->getBranch(); } if ($department_id == '' or empty($department_id)) { Debug::Text(' overrriding department: ' . $s_obj->getDepartment(), __FILE__, __LINE__, __METHOD__, 10); $department_id = $s_obj->getDepartment(); } } } $type_id = $prev_punch_obj->getNextType(); $status_id = $prev_punch_obj->getNextStatus(); $next_type = $prev_punch_obj->getNextType(); //Check for break policy window. if ($next_type != 30 and ($prev_punch_obj->getStatus() != 30 and $prev_punch_obj->getType() != 30)) { $prev_punch_obj->setUser($current_user->getId()); $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp)); if ($prev_punch_obj->inBreakPolicyWindow($punch_full_time_stamp, $prev_punch_obj->getTimeStamp()) == TRUE) { Debug::Text(' Setting Type to Break: ', __FILE__, __LINE__, __METHOD__, 10); $next_type = 30; } } //Check for meal policy window. if ($next_type != 20 and ($prev_punch_obj->getStatus() != 20 and $prev_punch_obj->getType() != 20)) { $prev_punch_obj->setUser($current_user->getId()); $prev_punch_obj->setScheduleID($prev_punch_obj->findScheduleID($punch_full_time_stamp)); if ($prev_punch_obj->inMealPolicyWindow($punch_full_time_stamp, $prev_punch_obj->getTimeStamp()) == TRUE) { Debug::Text(' Setting Type to Lunch: ', __FILE__, __LINE__, __METHOD__, 10); $next_type = 20; } } } else { Debug::Text(' DID NOT Find Previous Punch within Continuous Time from now: ', __FILE__, __LINE__, __METHOD__, 10); $branch_id = NULL; $department_id = NULL; $job_id = NULL; $job_item_id = NULL; $s_obj = $slf->getScheduleObjectByUserIdAndEpoch($punch_row['user_id'], $punch_full_time_stamp); if (is_object($s_obj)) { Debug::Text(' Found Schedule!: ', __FILE__, __LINE__, __METHOD__, 10); $branch_id = $s_obj->getBranch(); $department_id = $s_obj->getDepartment(); } else { $branch_id = $current_user->getDefaultBranch(); $department_id = $current_user->getDefaultDepartment(); //Check station for default/forced settings. if (is_object($current_station)) { if ($current_station->getDefaultBranch() !== FALSE and $current_station->getDefaultBranch() != 0) { $branch_id = $current_station->getDefaultBranch(); } if ($current_station->getDefaultDepartment() !== FALSE and $current_station->getDefaultDepartment() != 0) { $department_id = $current_station->getDefaultDepartment(); } if ($current_station->getDefaultJob() !== FALSE and $current_station->getDefaultJob() != 0) { $job_id = $current_station->getDefaultJob(); } if ($current_station->getDefaultJobItem() !== FALSE and $current_station->getDefaultJobItem() != 0) { $job_item_id = $current_station->getDefaultJobItem(); } } } $status_id = 10; //In $type_id = 10; //Normal } if (isset($punch_row['status_id']) and $punch_row['status_id'] != 0) { Debug::Text(' Status ID is NOT AUTO: ' . $punch_row['status_id'], __FILE__, __LINE__, __METHOD__, 10); $status_id = $punch_row['status_id']; } if (isset($punch_row['type_id']) and $punch_row['type_id'] != 0) { Debug::Text(' Type ID is NOT AUTO: ' . $punch_row['type_id'], __FILE__, __LINE__, __METHOD__, 10); $type_id = $punch_row['type_id']; } if (isset($punch_row['branch_id']) and $punch_row['branch_id'] != 0) { Debug::Text(' Branch ID is NOT AUTO: ' . $punch_row['branch_id'], __FILE__, __LINE__, __METHOD__, 10); $branch_id = $punch_row['branch_id']; } if (isset($punch_row['department_id']) and $punch_row['department_id'] != 0) { Debug::Text(' Department ID is NOT AUTO: ' . $punch_row['department_id'], __FILE__, __LINE__, __METHOD__, 10); $department_id = $punch_row['department_id']; } if (isset($punch_row['job_id']) and $punch_row['job_id'] != 0) { Debug::Text(' Job ID is NOT AUTO: ' . $punch_row['job_id'], __FILE__, __LINE__, __METHOD__, 10); $job_id = $punch_row['job_id']; } if (isset($punch_row['job_item_id']) and $punch_row['job_item_id'] != 0) { Debug::Text(' Job Item ID is NOT AUTO: ' . $punch_row['job_item_id'], __FILE__, __LINE__, __METHOD__, 10); $job_item_id = $punch_row['job_item_id']; } if (isset($punch_row['quantity'])) { Debug::Text(' Quantity is NOT AUTO: ' . $punch_row['quantity'], __FILE__, __LINE__, __METHOD__, 10); $quantity = $punch_row['quantity']; } if (isset($punch_row['bad_quantity'])) { Debug::Text(' Bad Quantity is NOT AUTO: ' . $punch_row['bad_quantity'], __FILE__, __LINE__, __METHOD__, 10); $bad_quantity = $punch_row['bad_quantity']; } } else { $status_id = $punch_row['status_id']; $type_id = $punch_row['type_id']; $branch_id = $punch_row['branch_id']; $department_id = $punch_row['department_id']; $job_id = $punch_row['job_id']; $job_item_id = $punch_row['job_item_id']; $quantity = $punch_row['quantity']; $bad_quantity = $punch_row['bad_quantity']; } //Set User before setTimeStamp so rounding can be done properly. $pf->setUser($punch_row['user_id']); if (isset($punch_row['transfer']) and $punch_row['transfer'] == 1) { Debug::Text(' Enabling Transfer!: ', __FILE__, __LINE__, __METHOD__, 10); $type_id = 10; $status_id = 10; $pf->setTransfer(TRUE); } $pf->setType($type_id); $pf->setStatus($status_id); $pf->setTimeStamp($punch_full_time_stamp, TRUE); //Make sure we round here. if (isset($status_id) and $status_id == 20 and isset($punch_row['punch_control_id']) and $punch_row['punch_control_id'] != '' and $punch_row['punch_control_id'] != 0) { $pf->setPunchControlID($punch_row['punch_control_id']); } else { $pf->setPunchControlID($pf->findPunchControlID()); } $pf->setStation($current_station->getId()); if ($pf->isNew()) { $pf->setActualTimeStamp($punch_full_time_stamp); $pf->setOriginalTimeStamp($pf->getTimeStamp()); } if ($pf->isValid() == TRUE) { if ($pf->Save(FALSE) == TRUE) { $pcf = new PunchControlFactory(); $pcf->setId($pf->getPunchControlID()); $pcf->setPunchObject($pf); if (isset($branch_id) and $branch_id != '') { $pcf->setBranch($branch_id); } if (isset($department_id) and $department_id != '') { $pcf->setDepartment($department_id); } if (isset($job_id) and $job_id != '') { $pcf->setJob($job_id); } if (isset($job_item_id) and $job_item_id != '') { $pcf->setJobItem($job_item_id); } if (isset($quantity) and $quantity != '') { $pcf->setQuantity($quantity); } if (isset($bad_quantity) and $bad_quantity != '') { $pcf->setBadQuantity($bad_quantity); } if (isset($punch_row['note']) and $punch_row['note'] != '') { $pcf->setNote($punch_row['note']); } if (isset($punch_row['other_id1']) and $punch_row['other_id1'] != '') { $pcf->setOtherID1($punch_row['other_id1']); } if (isset($punch_row['other_id2']) and $punch_row['other_id2'] != '') { $pcf->setOtherID2($punch_row['other_id2']); } if (isset($punch_row['other_id3']) and $punch_row['other_id3'] != '') { $pcf->setOtherID3($punch_row['other_id3']); } if (isset($punch_row['other_id4']) and $punch_row['other_id4'] != '') { $pcf->setOtherID4($punch_row['other_id4']); } if (isset($punch_row['other_id5']) and $punch_row['other_id5'] != '') { $pcf->setOtherID5($punch_row['other_id5']); } $pcf->setEnableStrictJobValidation(TRUE); $pcf->setEnableCalcUserDateID(TRUE); $pcf->setEnableCalcTotalTime(TRUE); $pcf->setEnableCalcSystemTotalTime(TRUE); $pcf->setEnableCalcUserDateTotal(TRUE); $pcf->setEnableCalcException(TRUE); $pcf->setEnablePreMatureException(TRUE); //Enable pre-mature exceptions at this point. if ($pcf->isValid() == TRUE) { Debug::Text(' Punch Control is valid, saving...: ', __FILE__, __LINE__, __METHOD__, 10); if ($pcf->Save(TRUE, TRUE) == TRUE) { //Force isNew() lookup. Debug::text('Saved Punch!', __FILE__, __LINE__, __METHOD__, 10); } else { Debug::text('PCF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = TRUE; } } else { Debug::text('PCF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = TRUE; } } else { Debug::text('PF Save failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = TRUE; } } else { Debug::text('PF Validate failed... Failing Transaction!', __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = TRUE; } if ($fail_transaction == FALSE) { $pf->CommitTransaction(); } else { $pf->FailTransaction(); } unset($punch_full_time_stamp, $current_station, $current_user); //End Foreach } return TRUE; }
function setUser($ids) { Debug::text('Setting User IDs : ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($ids)) { if (!$this->isNew()) { //If needed, delete mappings first. $udlf = new UserDeductionListFactory(); $udlf->getByCompanyIdAndCompanyDeductionId($this->getCompany(), $this->getId()); $tmp_ids = array(); foreach ($udlf as $obj) { $id = $obj->getUser(); Debug::text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($id, $ids)) { Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $obj->Delete(); } else { //Save ID's that need to be updated. Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10); $tmp_ids[] = $id; } } unset($id, $obj); } //Insert new mappings. //$psealf = new PayStubEntryAccountListFactory(); $ulf = new UserListFactory(); foreach ($ids as $id) { if ($id != FALSE and isset($ids) and !in_array($id, $tmp_ids)) { $udf = new UserDeductionFactory(); $udf->setUser($id); $udf->setCompanyDeduction($this->getId()); $obj = $ulf->getById($id)->getCurrent(); if ($this->Validator->isTrue('user', $udf->Validator->isValid(), TTi18n::gettext('Employee is invalid') . ' (' . $obj->getFullName() . ')')) { $udf->save(); } } } return TRUE; } Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
if ($action != 'submit' and !is_array($data)) { Debug::Text(' ID was NOT passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $user_id = NULL; $user_date_id = NULL; $user_full_name = NULL; $user_default_branch = NULL; $user_default_department = NULL; $pay_period_is_locked = FALSE; $time_stamp = $start_date_stamp = $end_date_stamp = TTDate::getBeginDayEpoch(TTDate::getTime()) + 3600 * 12; //Noon $data = array('start_date_stamp' => $start_date_stamp, 'end_date_stamp' => $end_date_stamp, 'start_time' => strtotime('08:00 AM'), 'parsed_start_time' => strtotime('08:00 AM'), 'end_time' => strtotime('05:00 PM'), 'parsed_end_time' => strtotime('05:00 PM'), 'total_time' => 3600 * 9, 'branch_id' => $user_default_branch, 'department_id' => $user_default_department, 'dow' => array(1 => TRUE, 2 => TRUE, 3 => TRUE, 4 => TRUE, 5 => TRUE)); } //var_dump($data); $ulf = TTnew('UserListFactory'); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); $src_user_options = UserListFactory::getArrayByListFactory($ulf, FALSE, FALSE); $user_options = Misc::arrayDiffByKey((array) $filter_user_id, $src_user_options); $filter_user_options = Misc::arrayIntersectByKey((array) $filter_user_id, $src_user_options); $prepend_array_option = array(0 => '--', -1 => TTi18n::gettext('-- Default --')); $splf = TTnew('SchedulePolicyListFactory'); $schedule_policy_options = $splf->getByCompanyIdArray($current_company->getId()); $aplf = TTnew('AbsencePolicyListFactory'); $absence_policy_options = $aplf->getByCompanyIdArray($current_company->getId()); $blf = TTnew('BranchListFactory'); $blf->getByCompanyId($current_company->getId()); $branch_options = Misc::prependArray($prepend_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE)); $dlf = TTnew('DepartmentListFactory'); $dlf->getByCompanyId($current_company->getId()); $department_options = Misc::prependArray($prepend_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE)); if ($current_company->getProductEdition() >= 20) { $jlf = TTnew('JobListFactory');
} unset($include_psea_id, $tmp_psea_options); } $smarty->assign_by_ref('filter_include_options', $filter_include_options); $data['exclude_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50, 80), FALSE); if (isset($data['exclude_pay_stub_entry_account_ids']) and is_array($data['exclude_pay_stub_entry_account_ids'])) { $tmp_psea_options = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50, 80), FALSE); foreach ($data['exclude_pay_stub_entry_account_ids'] as $exclude_psea_id) { $filter_exclude_options[$exclude_psea_id] = $tmp_psea_options[$exclude_psea_id]; } unset($exclude_psea_id, $tmp_psea_options); } $smarty->assign_by_ref('filter_exclude_options', $filter_exclude_options); //var_dump($data); //Employee Selection Options $data['user_options'] = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE, TRUE); if (isset($data['user_ids']) and is_array($data['user_ids'])) { $tmp_user_options = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE, TRUE); foreach ($data['user_ids'] as $user_id) { if (isset($tmp_user_options[$user_id])) { $filter_user_options[$user_id] = $tmp_user_options[$user_id]; } } unset($user_id, $tmp_user_options); } $smarty->assign_by_ref('filter_user_options', $filter_user_options); $smarty->assign_by_ref('data', $data); break; } $smarty->assign_by_ref('cdf', $cdf); $smarty->display('company/EditCompanyDeduction.tpl');
$utlf = new UserTitleListFactory(); $utlf->getByCompanyId($current_company->getId()); $title_options = $utlf->getArrayByListFactory($utlf, FALSE, TRUE); $blf = new BranchListFactory(); $blf->getByCompanyId($current_company->getId()); $branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE); $dlf = new DepartmentListFactory(); $dlf->getByCompanyId($current_company->getId()); $department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE); $uglf = new UserGroupListFactory(); $group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE)); $rstclf = new RecurringScheduleTemplateControlListFactory(); $template_options = $rstclf->getByCompanyIdArray($current_company->getId(), FALSE, TRUE); foreach ($rsclf as $rsc_obj) { $user_id = $rsc_obj->getColumn('user_id'); $ulf = new UserListFactory(); $ulf->getByID($user_id); if ($ulf->getRecordCount() == 1) { $u_obj = $ulf->getCurrent(); } else { //Skip this row. Debug::Text('Skipping Row: User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); continue; } $rows[] = array('id' => $rsc_obj->getId(), 'user_id' => $user_id, 'name' => $rsc_obj->getColumn('name'), 'description' => $rsc_obj->getColumn('description'), 'start_week' => $rsc_obj->getStartWeek(), 'start_date' => $rsc_obj->getStartDate(), 'end_date' => $rsc_obj->getEndDate(), 'first_name' => $u_obj->getFirstName(), 'middle_name' => $u_obj->getMiddleName(), 'last_name' => $u_obj->getLastName(), 'user_full_name' => $u_obj->getFullName(TRUE), 'is_owner' => $permission->isOwner($u_obj->getCreatedBy(), $u_obj->getId()), 'is_child' => $permission->isChild($u_obj->getId(), $permission_children_ids), 'deleted' => $rsc_obj->getDeleted()); } $all_array_option = array('-1' => TTi18n::gettext('-- Any --')); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); $filter_data['user_options'] = Misc::prependArray($all_array_option, UserListFactory::getArrayByListFactory($ulf, FALSE, TRUE)); //Select box options; $filter_data['template_options'] = Misc::prependArray($all_array_option, $template_options);
if ($ulf->getRecordCount() > 0) { $user_obj = $ulf->getCurrent(); if (is_object($user_obj)) { $is_owner = $permission->isOwner($user_obj->getCreatedBy(), $user_obj->getID()); $is_child = $permission->isChild($user_obj->getId(), $permission_children_ids); if ($permission->Check('user_tax_deduction', 'view') or $permission->Check('user_tax_deduction', 'view_own') and $is_owner === TRUE or $permission->Check('user_tax_deduction', 'view_child') and $is_child === TRUE) { foreach ($udlf as $ud_obj) { $cd_obj = $ud_obj->getCompanyDeductionObject(); $rows[] = array('id' => $ud_obj->getId(), 'status_id' => $cd_obj->getStatus(), 'user_id' => $ud_obj->getUser(), 'name' => $cd_obj->getName(), 'type_id' => $cd_obj->getType(), 'type' => Option::getByKey($cd_obj->getType(), $cd_obj->getOptions('type')), 'calculation' => Option::getByKey($cd_obj->getCalculation(), $cd_obj->getOptions('calculation')), 'is_owner' => $is_owner, 'is_child' => $is_child, 'deleted' => $ud_obj->getDeleted()); } } } } $smarty->assign_by_ref('rows', $rows); $smarty->assign_by_ref('user_id', $user_id); $ulf = new UserListFactory(); $filter_data = NULL; extract(UserGenericDataFactory::getSearchFormData($saved_search_id, NULL)); if ($permission->Check('user_tax_deduction', 'view') == FALSE) { if ($permission->Check('user_tax_deduction', 'view_child')) { $filter_data['permission_children_ids'] = $permission_children_ids; } if ($permission->Check('user_tax_deduction', 'view_own')) { $filter_data['permission_children_ids'][] = $current_user->getId(); } } $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); $user_options = UserListFactory::getArrayByListFactory($ulf, FALSE, TRUE); $smarty->assign_by_ref('user_options', $user_options); $smarty->assign_by_ref('sort_column', $sort_column); $smarty->assign_by_ref('sort_order', $sort_order);
function getReportByStartDateAndEndDateAndUserIdList($start_date, $end_date, $user_ids, $order = NULL) { if ($user_ids == '') { return FALSE; } if ($start_date == '') { return FALSE; } if ($end_date == '') { return FALSE; } //$order = array( 'b.pay_period_id' => 'asc', 'b.user_id' => 'asc' ); $order = array('z.last_name' => 'asc'); /* if ( $order == NULL ) { $order = array( 'b.pay_period_id' => 'asc', 'b.user_id' => 'asc' ); $strict = FALSE; } else { $strict = TRUE; } */ $ulf = new UserListFactory(); $udf = new UserDateFactory(); $uwf = new UserWageFactory(); $otpf = new OverTimePolicyFactory(); $apf = new AbsencePolicyFactory(); $ppf = new PremiumPolicyFactory(); $ph = array('start_date' => $this->db->BindDate($start_date), 'end_date' => $this->db->BindDate($end_date)); //Make it so employees with 0 hours still show up!! Very important! //Order dock hours first, so it can be deducted from regular time. $query = ' select z.id, tmp.* from ' . $ulf->getTable() . ' as z LEFT JOIN ( select b.user_id, b.date_stamp as date_stamp, a.status_id as status_id, a.type_id as type_id, a.over_time_policy_id as over_time_policy_id, n.id as over_time_policy_wage_id, n.effective_date as over_time_policy_wage_effective_date, a.absence_policy_id as absence_policy_id, p.id as absence_policy_wage_id, p.effective_date as absence_policy_wage_effective_date, a.premium_policy_id as premium_policy_id, r.id as premium_policy_wage_id, r.effective_date as premium_policy_wage_effective_date, z.id as user_wage_id, z.effective_date as user_wage_effective_date, sum(total_Time) as total_time, sum(actual_total_Time) as actual_total_time from ' . $this->getTable() . ' as a LEFT JOIN ' . $udf->getTable() . ' as b ON a.user_date_id = b.id LEFT JOIN ' . $otpf->getTable() . ' as m ON a.over_time_policy_id = m.id LEFT JOIN ' . $uwf->getTable() . ' as n ON n.id = (select n.id from ' . $uwf->getTable() . ' as n where n.user_id = b.user_id and n.wage_group_id = m.wage_group_id and n.effective_date <= b.date_stamp and n.deleted = 0 order by n.effective_date desc limit 1) LEFT JOIN ' . $apf->getTable() . ' as o ON a.absence_policy_id = o.id LEFT JOIN ' . $uwf->getTable() . ' as p ON p.id = (select p.id from ' . $uwf->getTable() . ' as p where p.user_id = b.user_id and p.wage_group_id = o.wage_group_id and p.effective_date <= b.date_stamp and p.deleted = 0 order by p.effective_date desc limit 1) LEFT JOIN ' . $ppf->getTable() . ' as q ON a.premium_policy_id = q.id LEFT JOIN ' . $uwf->getTable() . ' as r ON r.id = (select r.id from ' . $uwf->getTable() . ' as r where r.user_id = b.user_id and r.wage_group_id = q.wage_group_id and r.effective_date <= b.date_stamp and r.deleted = 0 order by r.effective_date desc limit 1) LEFT JOIN ' . $uwf->getTable() . ' as z ON z.id = (select z.id from ' . $uwf->getTable() . ' as z where z.user_id = b.user_id and z.effective_date <= b.date_stamp and z.deleted = 0 order by z.effective_date desc limit 1) where b.date_stamp >= ? AND b.date_stamp <= ? AND b.user_id in (' . $this->getListSQL($user_ids, $ph) . ') AND a.status_id in (10,30) AND ( a.deleted = 0 AND b.deleted = 0) group by b.user_id, b.date_stamp, user_wage_id, user_wage_effective_date, over_time_policy_wage_id, over_time_policy_wage_effective_date, absence_policy_wage_id, absence_policy_wage_effective_date, premium_policy_wage_id, premium_policy_wage_effective_date, a.status_id, a.type_id, a.over_time_policy_id, a.absence_policy_id, a.premium_policy_id ) as tmp ON z.id = tmp.user_id WHERE z.id in (' . $this->getListSQL($user_ids, $ph) . ') AND z.deleted = 0 '; $query .= $this->getSortSQL($order, FALSE); $this->ExecuteSQL($query, $ph); return $this; }
* "Powered by TimeTrex" logo. If the display of the logo is not reasonably * feasible for technical reasons, the Appropriate Legal Notices must display * the words "Powered by TimeTrex". ********************************************************************************/ /* * $Revision: 1396 $ * $Id: AuthorizationNotify.php 1396 2007-11-07 16:49:35Z ipso $ * $Date: 2007-11-07 08:49:35 -0800 (Wed, 07 Nov 2007) $ */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; $permission = new Permission(); $hlf = new HierarchyListFactory(); $hotlf = new HierarchyObjectTypeListFactory(); //Get all users $ulf = new UserListFactory(); $ulf->getByStatus(10, NULL, array('company_id' => 'asc')); foreach ($ulf as $user) { //Check authorize permissions for eact object type. if ($permission->Check('default_schedule', 'authorize', $user->getId(), $user->getCompany())) { //Get Hierarchy Control ID $default_schedule_hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($user->getCompany(), 10)->getCurrent()->getHierarchyControl(); Debug::Text('Default Schedule Hierarchy ID: ' . $default_schedule_hierarchy_id, __FILE__, __LINE__, __METHOD__, 10); //Get all levels below us. $default_schedule_levels = $hlf->getLevelsByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $user->getId()); Debug::Arr($default_schedule_levels, 'Default Schedule Levels', __FILE__, __LINE__, __METHOD__, 10); $default_schedule_user_id = $user->getId(); $default_schedule_node_data = $hlf->getByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id); //Get current level IDs $default_schedule_current_level_user_ids = $hlf->getCurrentLevelIdArrayByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id); Debug::Arr($default_schedule_current_level_user_ids, 'Default Schedule Current Level Ids', __FILE__, __LINE__, __METHOD__, 10);
$mf->setSubject($message_data['subject']); $mf->setBody($message_data['body']); if ($mf->isValid()) { $mf->Save(); Redirect::Page(URLBuilder::getURL(array('template' => $template, 'close' => 1, 'object_type_id' => $object_type_id, 'object_id' => $object_id), 'EmbeddedMessageList.php')); break; } } default: if (isset($object_type_id) and isset($object_id)) { $mlf = new MessageListFactory(); $mlf->getByObjectTypeAndObject($object_type_id, $object_id); $i = 0; foreach ($mlf as $message) { //Get user info $ulf = new UserListFactory(); $messages[] = array('id' => $message->getId(), 'parent_id' => $message->getParent(), 'object_type' => $message->getObjectType(), 'object_id' => $message->getObject(), 'priority' => $message->getPriority(), 'status' => $message->getStatus(), 'subject' => $message->getSubject(), 'body' => $message->getBody(), 'created_date' => $message->getCreatedDate(), 'created_by' => $message->getCreatedBy(), 'created_by_full_name' => $ulf->getById($message->getCreatedBy())->getCurrent()->getFullName(), 'updated_date' => $message->getUpdatedDate(), 'updated_by' => $message->getUpdatedBy(), 'deleted_date' => $message->getDeletedDate(), 'deleted_by' => $message->getDeletedBy()); //Mark own messages as read. if ($message->getCreatedBy() != $current_user->getId()) { $mlf_b = new MessageListFactory(); $message_obj = $mlf_b->getById($message->getId())->getCurrent(); $message_obj->setStatus(20); $message_obj->Save(); } if ($i == 0) { $parent_id = $message->getId(); $default_subject = TTi18n::gettext('Re:') . ' ' . $message->getSubject(); } $i++; } //Get object data
function postSave() { $this->removeCache($this->getId()); $this->remoteSave(); if ($this->getDeleted() == FALSE) { //Add base currency for this new company. if ($this->getEnableAddCurrency() == TRUE) { $clf = new CurrencyListFactory(); $clf->getByCompanyId($this->getId()); if ($clf->getRecordCount() == 0) { Debug::text('Adding Default Currency', __FILE__, __LINE__, __METHOD__, 9); $cf = new CurrencyFactory(); $country_to_currency_map_arr = $cf->getOptions('country_currency'); if (isset($country_to_currency_map_arr[$this->getCountry()])) { $base_currency = $country_to_currency_map_arr[$this->getCountry()]; Debug::text('Found Base Currency For Country: ' . $this->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9); } else { Debug::text('DID NOT Find Base Currency For Country: ' . $this->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9); $base_currency = 'USD'; } $cf->setCompany($this->getId()); $cf->setStatus(10); $cf->setName($base_currency); $cf->setISOCode($base_currency); $cf->setConversionRate('1.000000000'); $cf->setAutoUpdate(FALSE); $cf->setBase(TRUE); $cf->setDefault(TRUE); if ($cf->isValid()) { $cf->Save(); } } } if ($this->getEnableAddPermissionGroupPreset() == TRUE) { Debug::text('Adding Preset Permission Groups', __FILE__, __LINE__, __METHOD__, 9); $pf = new PermissionFactory(); $pf->StartTransaction(); if ($this->getProductEdition() == 20) { $preset_flags = array('job' => 1, 'invoice' => 1, 'document' => 1); } else { $preset_flags = array(); } $preset_options = $pf->getOptions('preset'); foreach ($preset_options as $preset_id => $preset_name) { $pcf = new PermissionControlFactory(); $pcf->setCompany($this->getId()); $pcf->setName($preset_name); $pcf->setDescription(''); if ($pcf->isValid()) { $pcf_id = $pcf->Save(FALSE); $pf->applyPreset($pcf_id, $preset_id, $preset_flags); } } //$pf->FailTransaction(); $pf->CommitTransaction(); } if ($this->getEnableAddStation() == TRUE) { Debug::text('Adding Default Station', __FILE__, __LINE__, __METHOD__, 9); //Enable punching in from all stations $sf = new StationFactory(); $sf->setCompany($this->getId()); $sf->setStatus(20); $sf->setType(10); $sf->setSource('ANY'); $sf->setStation('ANY'); $sf->setDescription('All stations'); $sf->setGroupSelectionType(10); $sf->setBranchSelectionType(10); $sf->setDepartmentSelectionType(10); if ($sf->isValid()) { $sf->Save(); } } if ($this->getEnableAddPayStubEntryAccountPreset() == TRUE) { Debug::text('Adding Pay Stub Entry Account Presets', __FILE__, __LINE__, __METHOD__, 9); PayStubEntryAccountFactory::addPresets($this->getId()); } if ($this->getEnableAddCompanyDeductionPreset() == TRUE) { Debug::text('Adding Company Deduction Presets', __FILE__, __LINE__, __METHOD__, 9); CompanyDeductionFactory::addPresets($this->getId()); } if ($this->getEnableAddRecurringHolidayPreset() == TRUE) { Debug::text('Adding Recurring Holiday Presets', __FILE__, __LINE__, __METHOD__, 9); RecurringHolidayFactory::addPresets($this->getId(), $this->getCountry()); } } if ($this->getDeleted() == TRUE) { $ulf = new UserListFactory(); $ulf->getByCompanyId($this->getID()); if ($ulf->getRecordCount() > 0) { $ulf->StartTransaction(); foreach ($ulf as $u_obj) { Debug::text('Deleting User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 9); $u_obj->setDeleted(TRUE); if ($u_obj->isValid()) { $u_obj->Save(); } } $ulf->CommitTransaction(); } } return TRUE; }
$plf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); $pager = new Pager($plf); $punch_status_options = $plf->getOptions('status'); $punch_type_options = $plf->getOptions('type'); $utlf = new UserTitleListFactory(); $utlf->getByCompanyId($current_company->getId()); $title_options = $utlf->getArrayByListFactory($utlf, FALSE, TRUE); $blf = new BranchListFactory(); $blf->getByCompanyId($current_company->getId()); $branch_options = $blf->getArrayByListFactory($blf, FALSE, TRUE); $dlf = new DepartmentListFactory(); $dlf->getByCompanyId($current_company->getId()); $department_options = $dlf->getArrayByListFactory($dlf, FALSE, TRUE); $uglf = new UserGroupListFactory(); $group_options = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE)); $ulf = new UserListFactory(); $user_options = $ulf->getByCompanyIdArray($current_company->getID(), FALSE); foreach ($plf as $p_obj) { //Debug::Text('Status ID: '. $r_obj->getStatus() .' Status: '. $status_options[$r_obj->getStatus()], __FILE__, __LINE__, __METHOD__,10); $user_obj = $ulf->getById($p_obj->getColumn('user_id'))->getCurrent(); $rows[] = array('id' => $p_obj->getColumn('punch_id'), 'punch_control_id' => $p_obj->getPunchControlId(), 'user_id' => $p_obj->getColumn('user_id'), 'first_name' => $user_obj->getFirstName(), 'last_name' => $user_obj->getLastName(), 'title' => Option::getByKey($user_obj->getTitle(), $title_options), 'group' => Option::getByKey($user_obj->getGroup(), $group_options), 'default_branch' => Option::getByKey($user_obj->getDefaultBranch(), $branch_options), 'default_department' => Option::getByKey($user_obj->getDefaultDepartment(), $department_options), 'branch_id' => $p_obj->getColumn('branch_id'), 'branch' => Option::getByKey($p_obj->getColumn('branch_id'), $branch_options), 'department_id' => $p_obj->getColumn('department_id'), 'department' => Option::getByKey($p_obj->getColumn('department_id'), $department_options), 'status_id' => Option::getByKey($p_obj->getStatus(), $punch_status_options), 'type_id' => Option::getByKey($p_obj->getType(), $punch_type_options), 'date_stamp' => TTDate::getDate('DATE', TTDate::strtotime($p_obj->getColumn('date_stamp'))), 'job_id' => $p_obj->getColumn('job_id'), 'job_name' => $p_obj->getColumn('job_name'), 'job_group_id' => $p_obj->getColumn('job_group_id'), 'job_item_id' => $p_obj->getColumn('job_item_id'), 'time_stamp' => TTDate::getDate('DATE+TIME', $p_obj->getTimeStamp()), 'is_owner' => $permission->isOwner($p_obj->getCreatedBy(), $current_user->getId()), 'is_child' => $permission->isChild($p_obj->getColumn('user_id'), $permission_children_ids)); } $smarty->assign_by_ref('rows', $rows); $all_array_option = array('-1' => TTi18n::gettext('-- Any --')); $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); $filter_data['user_options'] = Misc::prependArray($all_array_option, UserListFactory::getArrayByListFactory($ulf, FALSE, TRUE)); //Select box options; $filter_data['branch_options'] = Misc::prependArray($all_array_option, $branch_options); $filter_data['department_options'] = Misc::prependArray($all_array_option, $department_options); $filter_data['title_options'] = Misc::prependArray($all_array_option, $title_options); $filter_data['group_options'] = Misc::prependArray($all_array_option, $group_options);
function getByHierarchyControlId($tree_id) { if ($tree_id == '') { return FALSE; } $this->getFastTreeObject()->setTree($tree_id); $children = $this->getFastTreeObject()->getAllChildren(NULL, 'RECURSE'); $ulf = new UserListFactory(); $hslf = new HierarchyShareListFactory(); $hslf->getByHierarchyControlId($tree_id); $shared_user_ids = array(); foreach ($hslf as $hierarchy_share) { $shared_user_ids[] = $hierarchy_share->getUser(); } if ($children !== FALSE) { foreach ($children as $object_id => $level) { if ($object_id !== 0) { $user_obj = $ulf->getById($object_id)->getCurrent(); unset($shared); if (in_array($object_id, $shared_user_ids) === TRUE) { $shared = TRUE; } else { $shared = FALSE; } $nodes[] = array('id' => $object_id, 'name' => $user_obj->getFullName(), 'level' => $level, 'shared' => $shared); } } if (isset($nodes)) { return $nodes; } } return FALSE; }
/* if ( $permission->Check('company','view') ) { //View all default_schedules //$dsclf->GetByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array ); $ulf->GetAll( $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array ); } else { //$dsclf->GetByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); //$dsclf->GetByUserId($current_user->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array ); $ulf->GetByCompanyID($current_company->getID(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array ); } */ $roelf->getByUserId($user_id, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); $pager = new Pager($roelf); $roe_code_options = $roelf->getOptions('code'); foreach ($roelf as $roe) { //$company_name = $clf->getById( $user->getCompany() )->getCurrent()->getName(); $roes[] = array('id' => $roe->getId(), 'user_id' => $roe->getUser(), 'pay_period_type_id' => $roe->getPayPeriodType(), 'code_id' => $roe->getCode(), 'code' => $roe_code_options[$roe->getCode()], 'first_date' => $roe->getFirstDate(), 'last_date' => $roe->getLastDate(), 'pay_period_end_date' => $roe->getPayPeriodEndDate(), 'recall_date' => $roe->getRecallDate(), 'insurable_hours' => $roe->getInsurableHours(), 'insurable_earnings' => $roe->getInsurableEarnings(), 'vacation_pay' => $roe->getVacationPay(), 'serial' => $roe->getSerial(), 'comments' => $roe->getComments(), 'created_date' => $roe->getCreatedDate(), 'created_by' => $roe->getCreatedBy(), 'updated_date' => $roe->getUpdatedDate(), 'updated_by' => $roe->getUpdatedBy(), 'deleted_date' => $roe->getDeletedDate(), 'deleted_by' => $roe->getDeletedBy()); } $smarty->assign_by_ref('roes', $roes); $smarty->assign_by_ref('user_id', $user_id); if (isset($user_id)) { $ulf = new UserListFactory(); $user_obj = $ulf->getById($user_id)->getCurrent(); $smarty->assign_by_ref('user_full_name', $user_obj->getFullName()); } $smarty->assign_by_ref('sort_column', $sort_column); $smarty->assign_by_ref('sort_order', $sort_order); $smarty->assign_by_ref('paging_data', $pager->getPageVariables()); break; } $smarty->display('roe/ROEList.tpl');
function setUser($id) { $id = trim($id); $ulf = new UserListFactory(); $hllf = new HierarchyLevelListFactory(); if ($id != 0 and $this->Validator->isResultSetWithRows('user', $ulf->getByID($id), TTi18n::gettext('Selected Employee is invalid')) and $this->Validator->isNotResultSetWithRows('user', $hllf->getByHierarchyControlIdAndUserId($this->getHierarchyControl(), $id), TTi18n::gettext('Selected employee is assigned as both a superior and subordinate')) and $this->Validator->isTrue('user', $this->isUniqueUser($id), TTi18n::gettext('Selected Employee is already assigned to another hierarchy'))) { $this->data['user_id'] = $id; return TRUE; } return FALSE; }
$pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); if ($pay_stub_obj->getAdvance() == TRUE) { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getAdvanceEndDate(); $pp_transaction_date = $pay_period_obj->getAdvanceTransactionDate(); } else { $pp_start_date = $pay_period_obj->getStartDate(); $pp_end_date = $pay_period_obj->getEndDate(); $pp_transaction_date = $pay_period_obj->getTransactionDate(); } //Get pay period numbers $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent(); $pay_period_data = array('advance' => $pay_stub_obj->getAdvance(), 'start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date), 'annual_pay_periods' => $pay_period_schedule_obj->getAnnualPayPeriods()); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); //} //Figure out how much white space we need to fill the entire page. $max_rows = 29; //With borders you gotta drop this down to 28. $total_rows = floor($pself->getRecordCount() + $description_subscript_counter); if ($pay_stub_obj->getAdvance() === FALSE) { //$total_rows -= 1; $total_rows += 1; } if ($description_subscript_counter > 1) { $total_rows += 2;
$filter_data['job_group_ids'] = array(-1); $filter_data['include_job_ids'] = array(); $filter_data['exclude_job_ids'] = array(); $filter_data['job_item_ids'] = array(-1); $filter_data['group_ids'] = array(-1); //$filter_data['user_ids'] = array_keys( UserListFactory::getByCompanyIdArray( $current_company->getId(), FALSE, FALSE ) ); if (!isset($filter_data['column_ids'])) { $filter_data['column_ids'] = array(); } $filter_data['column_ids'] = array_merge($filter_data['column_ids'], array('-1000-first_name', '-1001-last_name', '-1160-branch', '-1170-department', '-1120-type', '-1130-status', '-1100-time_stamp', '-1174-station_description')); $filter_data['primary_sort'] = '-1001-last_name'; $filter_data['secondary_sort'] = '-1100-time_stamp'; } } $filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'punch_branch_ids', 'punch_department_ids', 'user_title_ids', 'pay_period_ids', 'include_job_ids', 'exclude_job_ids', 'job_branch_ids', 'job_department_ids', 'job_group_ids', 'client_ids', 'job_item_ids', 'job_item_group_ids', 'column_ids'), NULL); $ulf = new UserListFactory(); $all_array_option = array('-1' => TTi18n::gettext('-- All --')); //Get include employee list. $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), array('permission_children_ids' => $permission_children_ids)); $user_options = $ulf->getArrayByListFactory($ulf, FALSE, TRUE); $filter_data['src_include_user_options'] = Misc::arrayDiffByKey((array) $filter_data['include_user_ids'], $user_options); $filter_data['selected_include_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['include_user_ids'], $user_options); //Get exclude employee list $exclude_user_options = Misc::prependArray($all_array_option, $ulf->getArrayByListFactory($ulf, FALSE, TRUE)); $filter_data['src_exclude_user_options'] = Misc::arrayDiffByKey((array) $filter_data['exclude_user_ids'], $user_options); $filter_data['selected_exclude_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['exclude_user_ids'], $user_options); //Get employee status list. $user_status_options = Misc::prependArray($all_array_option, $ulf->getOptions('status')); $filter_data['src_user_status_options'] = Misc::arrayDiffByKey((array) $filter_data['user_status_ids'], $user_status_options); $filter_data['selected_user_status_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_status_ids'], $user_status_options); //Get Employee Groups
break; } } $pgf->FailTransaction(); default: if (isset($id)) { BreadCrumb::setCrumb($title); $pglf = new PolicyGroupListFactory(); $pglf->getByIdAndCompanyID($id, $current_company->getID()); foreach ($pglf as $pg_obj) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); $data = array('id' => $pg_obj->getId(), 'name' => $pg_obj->getName(), 'meal_policy_ids' => $pg_obj->getMealPolicy(), 'break_policy_ids' => $pg_obj->getBreakPolicy(), 'holiday_policy_ids' => $pg_obj->getHolidayPolicy(), 'exception_policy_control_id' => $pg_obj->getExceptionPolicyControlID(), 'user_ids' => $pg_obj->getUser(), 'over_time_policy_ids' => $pg_obj->getOverTimePolicy(), 'premium_policy_ids' => $pg_obj->getPremiumPolicy(), 'round_interval_policy_ids' => $pg_obj->getRoundIntervalPolicy(), 'accrual_policy_ids' => $pg_obj->getAccrualPolicy(), 'created_date' => $pg_obj->getCreatedDate(), 'created_by' => $pg_obj->getCreatedBy(), 'updated_date' => $pg_obj->getUpdatedDate(), 'updated_by' => $pg_obj->getUpdatedBy(), 'deleted_date' => $pg_obj->getDeletedDate(), 'deleted_by' => $pg_obj->getDeletedBy()); } } $none_array_option = array('0' => TTi18n::gettext('-- None --')); $ulf = new UserListFactory(); $user_options = $ulf->getByCompanyIDArray($current_company->getId(), FALSE, TRUE); $otplf = new OverTimePolicyListFactory(); $over_time_policy_options = Misc::prependArray($none_array_option, $otplf->getByCompanyIDArray($current_company->getId(), FALSE)); $pplf = new PremiumPolicyListFactory(); $premium_policy_options = Misc::prependArray($none_array_option, $pplf->getByCompanyIDArray($current_company->getId(), FALSE)); $riplf = new RoundIntervalPolicyListFactory(); $round_interval_policy_options = Misc::prependArray($none_array_option, $riplf->getByCompanyIDArray($current_company->getId(), FALSE)); $mplf = new MealPolicyListFactory(); $meal_options = Misc::prependArray($none_array_option, $mplf->getByCompanyIdArray($current_company->getId(), FALSE)); $bplf = new BreakPolicyListFactory(); $break_options = Misc::prependArray($none_array_option, $bplf->getByCompanyIdArray($current_company->getId(), FALSE)); $epclf = new ExceptionPolicyControlListFactory(); $exception_options = Misc::prependArray($none_array_option, $epclf->getByCompanyIdArray($current_company->getId(), FALSE)); $hplf = new HolidayPolicyListFactory(); $holiday_policy_options = Misc::prependArray($none_array_option, $hplf->getByCompanyIdArray($current_company->getId(), FALSE));
function generateData() { global $current_company, $current_user; TTDate::setTimeZone('PST8PDT'); $current_epoch = time(); $cf = new CompanyFactory(); $cf->StartTransaction(); $company_id = $this->createCompany(); $clf = new CompanyListFactory(); $clf->getById($company_id); $current_company = $clf->getCurrent(); if ($company_id !== FALSE) { Debug::Text('Company Created Successfully!', __FILE__, __LINE__, __METHOD__, 10); $this->createPermissionGroups($company_id); //Create currency $currency_ids[] = $this->createCurrency($company_id, 10); //USD $currency_ids[] = $this->createCurrency($company_id, 20); //CAD //Create branch $branch_ids[] = $this->createBranch($company_id, 10); //NY $branch_ids[] = $this->createBranch($company_id, 20); //WA //Create departments $department_ids[] = $this->createDepartment($company_id, 10); $department_ids[] = $this->createDepartment($company_id, 20); //Create stations $station_id = $this->createStation($company_id); //Create pay stub accounts. $this->createPayStubAccount($company_id); //Link pay stub accounts. $this->createPayStubAccountLink($company_id); //Company Deductions $this->createCompanyDeduction($company_id); //Wage Groups $wage_group_ids[] = $this->createUserWageGroups($company_id); //User Groups $user_group_ids[] = $this->createUserGroup($company_id, 10, 0); $user_group_ids[] = $this->createUserGroup($company_id, 20, $user_group_ids[0]); $user_group_ids[] = $this->createUserGroup($company_id, 30, $user_group_ids[0]); $user_group_ids[] = $this->createUserGroup($company_id, 40, 0); $user_group_ids[] = $this->createUserGroup($company_id, 50, $user_group_ids[3]); //Users $user_ids[] = $this->createUser($company_id, 10, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 11, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 12, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 13, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[0]); $user_ids[] = $this->createUser($company_id, 14, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 15, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 16, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 17, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[1]); $user_ids[] = $this->createUser($company_id, 18, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 19, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 20, 0, $branch_ids[0], $department_ids[1], $currency_ids[0], $user_group_ids[2]); $user_ids[] = $this->createUser($company_id, 21, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 22, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 23, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 24, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[3]); $user_ids[] = $this->createUser($company_id, 25, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 26, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 27, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 28, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 29, 0, $branch_ids[1], $department_ids[1], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 30, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]); $user_ids[] = $this->createUser($company_id, 40, 0, $branch_ids[1], $department_ids[0], $currency_ids[0], $user_group_ids[4]); $current_user_id = $user_ids[] = $this->createUser($company_id, 100, 0, $branch_ids[0], $department_ids[0], $currency_ids[0], $user_group_ids[1]); //Create random users. for ($i = 0; $i <= $this->getMaxRandomUsers(); $i++) { $tmp_user_id = $this->createUser($company_id, 999, 0, $branch_ids[$i % 2], $department_ids[$i % 2], $currency_ids[0], $user_group_ids[$i % 5]); if ($tmp_user_id != FALSE) { $user_ids[] = $tmp_user_id; } } Debug::Arr($user_ids, 'All User IDs:', __FILE__, __LINE__, __METHOD__, 10); $ulf = new UserListFactory(); $ulf->getById($current_user_id); $current_user = $ulf->getCurrent(); unset($current_user_id); //Create policies $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 10); //In $policy_ids['round'][] = $this->createRoundingPolicy($company_id, 20); //Out $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 10); //Bank Time $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 20); //Vacaction $policy_ids['accrual'][] = $this->createAccrualPolicy($company_id, 30); //Sick $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 10); $policy_ids['overtime'][] = $this->createOverTimePolicy($company_id, 20, $policy_ids['accrual'][0]); $policy_ids['premium'][] = $this->createPremiumPolicy($company_id, 10); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 10, $policy_ids['accrual'][1]); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 20, $policy_ids['accrual'][0]); $policy_ids['absence'][] = $this->createAbsencePolicy($company_id, 30, $policy_ids['accrual'][2]); $policy_ids['meal_1'] = $this->createMealPolicy($company_id); $policy_ids['schedule_1'] = $this->createSchedulePolicy($company_id, $policy_ids['meal_1']); $policy_ids['exception_1'] = $this->createExceptionPolicy($company_id); $hierarchy_user_ids = $user_ids; $root_user_id = array_pop($hierarchy_user_ids); unset($hierarchy_user_ids[0], $hierarchy_user_ids[1]); //Create authorization hierarchy $hierarchy_control_id = $this->createAuthorizationHierarchyControl($company_id, $hierarchy_user_ids); if ($root_user_id == FALSE) { Debug::Text('Administrator wasn\'t created! Duplicate username perhaps? Are we appending a random number?', __FILE__, __LINE__, __METHOD__, 10); } //Admin user at the top $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $root_user_id, 1); $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[0], 2); $this->createAuthorizationHierarchyLevel($company_id, $hierarchy_control_id, $user_ids[1], 3); unset($hierarchy_user_ids, $root_user_id); //Pay Period Schedule $this->createPayPeriodSchedule($company_id, $user_ids); //Create Policy Group $this->createPolicyGroup($company_id, $policy_ids['meal_1'], $policy_ids['exception_1'], NULL, $policy_ids['overtime'], $policy_ids['premium'], $policy_ids['round'], $user_ids); if (getTTProductEdition() == TT_PRODUCT_PROFESSIONAL) { //Task Groups $task_group_ids[] = $this->createTaskGroup($company_id, 10, 0); $task_group_ids[] = $this->createTaskGroup($company_id, 20, $task_group_ids[0]); $task_group_ids[] = $this->createTaskGroup($company_id, 30, $task_group_ids[0]); $task_group_ids[] = $this->createTaskGroup($company_id, 40, 0); $task_group_ids[] = $this->createTaskGroup($company_id, 50, $task_group_ids[3]); $task_group_ids[] = $this->createTaskGroup($company_id, 60, $task_group_ids[3]); //Job Tasks $default_task_id = $this->createTask($company_id, 10, $task_group_ids[2]); $task_ids[] = $this->createTask($company_id, 20, $task_group_ids[1]); $task_ids[] = $this->createTask($company_id, 30, $task_group_ids[1]); $task_ids[] = $this->createTask($company_id, 40, $task_group_ids[2]); $task_ids[] = $this->createTask($company_id, 50, $task_group_ids[4]); $task_ids[] = $this->createTask($company_id, 60, $task_group_ids[4]); $task_ids[] = $this->createTask($company_id, 70, $task_group_ids[5]); //Job Groups $job_group_ids[] = $this->createJobGroup($company_id, 10, 0); $job_group_ids[] = $this->createJobGroup($company_id, 20, $job_group_ids[0]); $job_group_ids[] = $this->createJobGroup($company_id, 30, $job_group_ids[0]); $job_group_ids[] = $this->createJobGroup($company_id, 40, 0); $job_group_ids[] = $this->createJobGroup($company_id, 50, $job_group_ids[3]); $job_group_ids[] = $this->createJobGroup($company_id, 60, $job_group_ids[3]); //Jobs $job_ids[] = $this->createJob($company_id, 10, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 11, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 12, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 13, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 14, $default_task_id, $job_group_ids[1], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 15, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 16, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 17, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 18, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 19, $default_task_id, $job_group_ids[2], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 20, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 21, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 22, $default_task_id, $job_group_ids[4], $branch_ids[0], $department_ids[0]); $job_ids[] = $this->createJob($company_id, 23, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 24, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); $job_ids[] = $this->createJob($company_id, 25, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]); } else { $task_ids[] = 0; $job_ids[] = 0; } //Create Accrual balances foreach ($user_ids as $user_id) { foreach ($policy_ids['accrual'] as $accrual_policy_id) { $this->createAccrualBalance($user_id, $accrual_policy_id); } unset($accrual_policy_id); } //Create recurring schedule templates $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 10, $policy_ids['schedule_1']); //Morning shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 20, $policy_ids['schedule_1']); //Afternoon shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 30, $policy_ids['schedule_1']); //Evening shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 40); //Split Shift $recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 50, $policy_ids['schedule_1']); //Full rotation $recurring_schedule_start_date = TTDate::getBeginWeekEpoch($current_epoch + 86400 * 7.5); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[0], $recurring_schedule_start_date, '', array($user_ids[0], $user_ids[1], $user_ids[2], $user_ids[3], $user_ids[4])); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[1], $recurring_schedule_start_date, '', array($user_ids[5], $user_ids[6], $user_ids[7], $user_ids[8], $user_ids[9])); $this->createRecurringSchedule($company_id, $recurring_schedule_ids[2], $recurring_schedule_start_date, '', array($user_ids[10], $user_ids[11], $user_ids[12], $user_ids[13], $user_ids[14])); //Create schedule for each employee. foreach ($user_ids as $user_id) { //Create schedule starting 6 weeks ago, up to the end of the week. $schedule_options_arr = array('status_id' => 10, 'start_time' => '08:00AM', 'end_time' => '05:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']); //$schedule_date = ($current_epoch-(86400*42)); $schedule_date = $current_epoch - 86400 * 14; $schedule_end_date = TTDate::getEndWeekEpoch($current_epoch); //$schedule_date = ($current_epoch-(86400*14)); //$schedule_end_date = ($current_epoch+(86400*28)); while ($schedule_date <= $schedule_end_date) { //Random departments/branches $schedule_options_arr['branch_id'] = $branch_ids[rand(0, count($branch_ids) - 1)]; $schedule_options_arr['department_id'] = $department_ids[rand(0, count($department_ids) - 1)]; //Skip weekends. if (date('w', $schedule_date) != 0 and date('w', $schedule_date) != 6) { $this->createSchedule($user_id, $schedule_date, $schedule_options_arr); } $schedule_date += 86400; } //break; unset($schedule_options_arr, $schedule_date, $schedule_end_date, $user_id); } //Punch users in/out randomly. foreach ($user_ids as $user_id) { //Pick random jobs/tasks that are used for the entire date range. //So one employee isn't punching into 15 jobs. $user_random_job_ids = array_rand($job_ids, 2); $user_random_task_ids = array_rand($job_ids, 3); //Create punches starting 6 weeks ago, up to the end of the week. //$start_date = $punch_date = ($current_epoch-(86400*42)); $start_date = $punch_date = $current_epoch - 86400 * 14; $end_date = TTDate::getEndWeekEpoch($current_epoch); //$start_date = $punch_date = ($current_epoch-(86400*14)); //$end_date = ($current_epoch+(86400*28)); $i = 0; while ($punch_date <= $end_date) { $date_stamp = TTDate::getDate('DATE', $punch_date); //$punch_full_time_stamp = strtotime($pc_data['date_stamp'].' '.$pc_data['time_stamp']); $exception_cutoff_date = $current_epoch - 86400 * 14; if (date('w', $punch_date) != 0 and date('w', $punch_date) != 6) { if ($punch_date >= $exception_cutoff_date and $i % 4 == 0) { $first_punch_in = rand(7, 8) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'AM'; $last_punch_out = strtotime($date_stamp . ' ' . rand(4, 5) . ':' . str_pad(rand(0, 30), 2, '0', STR_PAD_LEFT) . 'PM'); if ($punch_date >= $exception_cutoff_date and rand(0, 20) == 0) { //Create request $this->createRequest(20, $user_id, $date_stamp); } if ($punch_date >= $exception_cutoff_date and rand(0, 16) == 0) { //Create request $this->createRequest(20, $user_id, $date_stamp); } } else { $first_punch_in = '08:00AM'; if ($punch_date >= $exception_cutoff_date and $i % 10 == 0) { //Don't punch out to generate exception. $last_punch_out = NULL; //Forgot to punch out request $this->createRequest(30, $user_id, $date_stamp); } else { $last_punch_out = strtotime($date_stamp . ' 5:00PM'); } } //Weekdays $this->createPunchPair($user_id, strtotime($date_stamp . ' ' . $first_punch_in), strtotime($date_stamp . ' 11:00AM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); $this->createPunchPair($user_id, strtotime($date_stamp . ' 11:00AM'), strtotime($date_stamp . ' 1:00PM'), array('in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); //Calc total time on last punch pair only. $this->createPunchPair($user_id, strtotime($date_stamp . ' 2:00PM'), $last_punch_out, array('in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); } elseif ($punch_date > $exception_cutoff_date and date('w', $punch_date) == 6 and $i % 10 == 0) { //Sat. $this->createPunchPair($user_id, strtotime($date_stamp . ' 10:00AM'), strtotime($date_stamp . ' 2:30PM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $branch_ids[rand(0, count($branch_ids) - 1)], 'department_id' => $department_ids[rand(0, count($department_ids) - 1)], 'job_id' => $job_ids[array_rand($user_random_job_ids)], 'job_item_id' => $task_ids[array_rand($user_random_task_ids)]), TRUE); } //Recalculate entire day. Performance optimization. //UserDateTotalFactory::reCalculateRange( $user_id, $start_date, $end_date ); $punch_date += 86400; $i++; } unset($punch_options_arr, $punch_date, $user_id); } //Generate pay stubs for each pay period $pplf = new PayPeriodListFactory(); $pplf->getByCompanyId($company_id); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { foreach ($user_ids as $user_id) { $cps = new CalculatePayStub(); $cps->setUser($user_id); $cps->setPayPeriod($pp_obj->getId()); $cps->calculate(); } } } unset($pplf, $pp_obj, $user_id); } //$cf->FailTransaction(); $cf->CommitTransaction(); return FALSE; }
function postSave() { if ($this->getEnableTimeSheetVerificationCheck()) { //Check to see if schedule is verified, if so unverify it on modified punch. //Make sure exceptions are calculated *after* this so TimeSheet Not Verified exceptions can be triggered again. if (is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()->getPayPeriodScheduleObject()) and $this->getUserDateObject()->getPayPeriodObject()->getPayPeriodScheduleObject()->getTimeSheetVerifyType() != 10) { //Find out if timesheet is verified or not. $pptsvlf = TTnew('PayPeriodTimeSheetVerifyListFactory'); $pptsvlf->getByPayPeriodIdAndUserId($this->getUserDateObject()->getPayPeriod(), $this->getUserDateObject()->getUser()); if ($pptsvlf->getRecordCount() > 0) { //Pay period is verified, delete all records and make log entry. //These can be added during the maintenance jobs, so the audit records are recorded as user_id=0, check those first. Debug::text('Pay Period is verified, deleting verification records: ' . $pptsvlf->getRecordCount() . ' User ID: ' . $this->getUserDateObject()->getUser() . ' Pay Period ID: ' . $this->getUserDateObject()->getPayPeriod(), __FILE__, __LINE__, __METHOD__, 10); foreach ($pptsvlf as $pptsv_obj) { TTLog::addEntry($pptsv_obj->getId(), 500, TTi18n::getText('Schedule Modified After Verification') . ': ' . UserListFactory::getFullNameById($this->getUserDateObject()->getUser()) . ' ' . TTi18n::getText('Schedule') . ': ' . TTDate::getDate('DATE', $this->getStartTime()), NULL, $pptsvlf->getTable()); $pptsv_obj->setDeleted(TRUE); if ($pptsv_obj->isValid()) { $pptsv_obj->Save(); } } } } } if ($this->getEnableReCalculateDay() == TRUE) { //Calculate total time. Mainly for docked. //Calculate entire week as Over Schedule (Weekly) OT policy needs to be reapplied if the schedule changes. if (is_object($this->getUserDateObject()) and $this->getUserDateObject()->getUser() > 0) { //When shifts are assigned to different days, we need to calculate both days the schedule touches, as the shift could be assigned to either of them. UserDateTotalFactory::smartReCalculate($this->getUserDateObject()->getUser(), array($this->getUserDateID(), $this->getOldUserDateID(), UserDateFactory::findOrInsertUserDate($this->getUserDateObject()->getUser(), $this->getStartTime()), UserDateFactory::findOrInsertUserDate($this->getUserDateObject()->getUser(), $this->getEndTime())), TRUE, FALSE); } } return TRUE; }
$epoch = $date_stamp; } else { $epoch = TTDate::getTime(); } //Get previous punch, and default timestamp to that. $plf = new PunchListFactory(); $plf->getPreviousPunchByUserIDAndEpoch( $user_id, $epoch ); if ( $plf->getRecordCount() > 0 ) { Debug::Text(' Found Previous punch: ', __FILE__, __LINE__, __METHOD__,10); $prev_punch_obj = $plf->getCurrent(); $time_stamp = $prev_punch_obj->getTimeStamp()+3600; } else { $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));
$cf->FailTransaction(); default: if (isset($id)) { BreadCrumb::setCrumb($title); $clf = new CompanyListFactory(); if ($permission->Check('company', 'edit')) { $clf->GetByID($id); } else { $id = $current_company->getId(); $clf->GetByID($id); } foreach ($clf as $company) { //Debug::Arr($company,'Company', __FILE__, __LINE__, __METHOD__,10); $company_data = array('id' => $company->getId(), 'parent' => $company->getParent(), 'status' => $company->getStatus(), 'product_edition' => $company->getProductEdition(), 'name' => $company->getName(), 'short_name' => $company->getShortName(), 'business_number' => $company->getBusinessNumber(), 'originator_id' => $company->getOriginatorID(), 'data_center_id' => $company->getDataCenterID(), 'address1' => $company->getAddress1(), 'address2' => $company->getAddress2(), 'city' => $company->getCity(), 'province' => $company->getProvince(), 'country' => $company->getCountry(), 'postal_code' => $company->getPostalCode(), 'work_phone' => $company->getWorkPhone(), 'fax_phone' => $company->getFaxPhone(), 'admin_contact' => $company->getAdminContact(), 'billing_contact' => $company->getBillingContact(), 'support_contact' => $company->getSupportContact(), 'logo_file_name' => $company->getLogoFileName(NULL, FALSE), 'enable_second_last_name' => $company->getEnableSecondLastName(), 'created_date' => $company->getCreatedDate(), 'created_by' => $company->getCreatedBy(), 'updated_date' => $company->getUpdatedDate(), 'updated_by' => $company->getUpdatedBy(), 'deleted_date' => $company->getDeletedDate(), 'deleted_by' => $company->getDeletedBy()); } } //Select box options; $company_data['status_options'] = $cf->getOptions('status'); $company_data['country_options'] = $cf->getOptions('country'); //Company list. $company_data['company_list_options'] = CompanyListFactory::getAllArray(); $company_data['product_edition_options'] = $cf->getOptions('product_edition'); if (!isset($id) and isset($company_data['id'])) { $id = $company_data['id']; } $company_data['user_list_options'] = UserListFactory::getByCompanyIdArray($id); $smarty->assign_by_ref('company_data', $company_data); break; } $smarty->assign_by_ref('cf', $cf); $smarty->display('company/EditCompany.tpl');
function setUser($ids) { Debug::text('Setting User IDs : ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($ids) and count($ids) > 0) { if (!$this->isNew()) { //If needed, delete mappings first. $rsulf = new RecurringScheduleUserListFactory(); $rsulf->getByRecurringScheduleControlId($this->getId()); $tmp_ids = array(); foreach ($rsulf as $obj) { $id = $obj->getUser(); Debug::text('Recurring Schedule ID: ' . $obj->getRecurringScheduleControl() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($id, $ids)) { Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $obj->Delete(); } else { //Save ID's that need to be updated. Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10); $tmp_ids[] = $id; } } unset($id, $obj); } //Insert new mappings. $ulf = new UserListFactory(); foreach ($ids as $id) { if (isset($ids) and !in_array($id, $tmp_ids)) { $ulf->getById($id); if ($ulf->getRecordCount() > 0) { $obj = $ulf->getCurrent(); $rsuf = new RecurringScheduleUserFactory(); $rsuf->setRecurringScheduleControl($this->getId()); $rsuf->setUser($id); if ($this->Validator->isTrue('user', $rsuf->Validator->isValid(), TTi18n::gettext('Selected Employee is invalid') . ' (' . $obj->getFullName() . ')')) { $rsuf->save(); } } } } return TRUE; } Debug::text('No User IDs to set.', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }