/** * 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 getUserObject() { if (is_object($this->user_obj)) { return $this->user_obj; } else { $ulf = new UserListFactory(); $this->user_obj = $ulf->getById($this->getUser())->getCurrent(); return $this->user_obj; } }
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; }
case 'login': if ($permission->Check('company', 'view') and $permission->Check('company', 'login_other_user')) { Debug::Text('Login as different user: '******'Login', TTi18n::getText('Switch User') . ': ' . TTi18n::getText('SourceIP') . ': ' . $authentication->getIPAddress() . ' ' . TTi18n::getText('SessionID') . ': ' . $authentication->getSessionID() . ' ' . TTi18n::getText('UserID') . ': ' . $id, $current_user->getId(), 'authentication'); Redirect::Page(URLBuilder::getURL(NULL, '../index.php')); } break; case 'submit': //Debug::setVerbosity( 11 ); Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); unset($id); //Do this so it doesn't reload the data from the DB. //Additional permission checks. if ($permission->Check('company', 'view')) { $ulf->getById($user_data['id']); } else { $ulf->getByIdAndCompanyId($user_data['id'], $current_company->getId()); } if ($ulf->getRecordCount() > 0) { $user = $ulf->getCurrent(); $is_owner = $permission->isOwner($user->getCreatedBy(), $user->getID()); $is_child = $permission->isChild($user->getId(), $permission_children_ids); if ($permission->Check('user', 'edit') or $permission->Check('user', 'edit_child') and $is_child === TRUE or $permission->Check('user', 'edit_own') and $is_owner === TRUE) { // Security measure. if (!empty($user_data['id'])) { if ($permission->Check('company', 'view')) { $uf = $ulf->getById($user_data['id'])->getCurrent(); } else { $uf = $ulf->getByIdAndCompanyId($user_data['id'], $current_company->getId())->getCurrent(); }
/* 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 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 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; }
$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 $object_name_options = $mlf->getOptions('object_name');
$t4sum->setEmployeeCPP($rows[$last_row]['employee_cpp']); $t4sum->setEmployeeEI($rows[$last_row]['employee_ei']); $t4sum->setEmployerCPP($rows[$last_row]['employer_cpp']); $t4sum->setEmployerEI($rows[$last_row]['employer_ei']); $t4sum->setEmployeeRPP($rows[$last_row]['rpp']); $t4sum->setPensionAdjustment($rows[$last_row]['pension_adjustment']); $total_deductions = Misc::MoneyFormat($rows[$last_row]['employee_cpp'] + $rows[$last_row]['employer_cpp'] + $rows[$last_row]['employee_ei'] + $rows[$last_row]['employer_ei'] + $rows[$last_row]['income_tax'], FALSE); $t4sum->setTotalDeductions($total_deductions); $t4->addT4Summary($t4sum); $i = 0; foreach ($rows as $row) { if ($i == $last_row) { continue; } $ulf = new UserListFactory(); $user_obj = $ulf->getById($row['user_id'])->getCurrent(); $t4ee = new T4Employee(); $t4ee->setSin($row['sin']); $t4ee->setFirstName($user_obj->getFirstName()); $t4ee->setMiddleName($user_obj->getMiddleName()); $t4ee->setLastName($user_obj->getLastName()); $t4ee->setAddress1($user_obj->getAddress1()); $t4ee->setAddress2($user_obj->getAddress2()); $t4ee->setCity($user_obj->getCity()); $t4ee->setProvince($user_obj->getProvince()); $t4ee->setPostalCode($user_obj->getPostalCode()); //$t4ee->setEmployementCode( ); //Get User Tax / Deductions by Pay Stub Account. $udlf = new UserDeductionListFactory(); if (isset($setup_data['employee_cpp_psea_id'])) { $udlf->getByUserIdAndPayStubEntryAccountID($user_obj->getId(), $setup_data['employee_cpp_psea_id']);
function postSave() { //Handle dirty work here. Debug::Text('ID we just saved: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10); if ($this->getEnableReCalculate() == TRUE) { //Set User Termination date to Last Day. $ulf = new UserListFactory(); $ulf->getById($this->getUser()); if ($ulf->getRecordCount() > 0) { Debug::Text('Setting User Termination Date', __FILE__, __LINE__, __METHOD__, 10); $user_obj = $ulf->getCurrent(); $user_obj->setTerminationDate($this->getLastDate()); if ($user_obj->isValid()) { $user_obj->Save(); UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Employee Record'), 30, TTi18n::gettext('Setting employee termination date to:') . ' ' . TTDate::getDate('DATE', $this->getLastDate()), NULL); } } $this->ReCalculate(); } return TRUE; }
if (isset($object_type_id) and isset($object_id)) { BreadCrumb::setCrumb($title); $mlf = new MessageListFactory(); $mlf->getByObjectTypeAndObjectAndId($object_type_id, $object_id, $id); $ack_message_id = NULL; $require_ack = FALSE; $i = 0; foreach ($mlf as $message) { //Get user info $ulf = new UserListFactory(); if ($message->getRequireAck() == TRUE and $message->isAck() == FALSE and $ack_message_id == NULL and $message->getCreatedBy() != $current_user->getId()) { $require_ack = TRUE; $ack_message_id = $message->getId(); } if ($message->getAckBy() != '') { $ack_by_full_name = $ulf->getById($message->getAckBy())->getCurrent()->getFullName(); } else { $ack_by_full_name = NULL; } $messages[] = array('id' => $message->getId(), 'parent_id' => $message->getParent(), 'object_type' => $message->getObjectType(), 'object_id' => $message->getObject(), 'priority' => $message->getPriority(), 'status' => $message->getStatus(), 'require_ack' => $message->getRequireAck(), 'ack_date' => $message->getAckDate(), 'ack_by' => $message->getAckBy(), 'ack_by_full_name' => $ack_by_full_name, 'is_ack' => $message->isAck(), '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(); if ($message_obj->getStatus() == 10) { $message_obj->setStatus(20); $message_obj->Save(); } } if ($i == 0) { $parent_id = $message->getId();
function getByUserIdAndStatusAndType($user_id, $status, $type, $order = NULL) { if ($user_id == '') { return FALSE; } if ($status == '') { return FALSE; } if ($type == '') { return FALSE; } $status_key = Option::getByValue($status, $this->getOptions('status')); if ($status_key !== FALSE) { $status = $status_key; } $type_key = Option::getByValue($type, $this->getOptions('type')); if ($type_key !== FALSE) { $type = $type_key; } $ulf = new UserListFactory(); $ulf->getById($user_id); if ($ulf->getRecordCount() != 1) { return FALSE; } $sugf = new StationUserGroupFactory(); $sbf = new StationBranchFactory(); $sdf = new StationDepartmentFactory(); $siuf = new StationIncludeUserFactory(); $seuf = new StationExcludeUserFactory(); $uf = new UserFactory(); $ph = array('user_id_a' => $user_id, 'company_id' => $ulf->getCurrent()->getCompany(), 'status' => $status, 'type' => $type); $query = ' select a.* from ' . $this->getTable() . ' as a LEFT JOIN ' . $uf->getTable() . ' as z ON z.id = ? where a.company_id = ? AND a.status_id = ? AND a.type_id = ? AND ( ( ( a.user_group_selection_type_id = 10 OR ( a.user_group_selection_type_id = 20 AND z.group_id in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE a.id = b.station_id ) ) OR ( a.user_group_selection_type_id = 30 AND z.group_id not in ( select b.group_id from ' . $sugf->getTable() . ' as b WHERE a.id = b.station_id ) ) ) AND ( a.branch_selection_type_id = 10 OR ( a.branch_selection_type_id = 20 AND z.default_branch_id in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE a.id = c.station_id ) ) OR ( a.branch_selection_type_id = 30 AND z.default_branch_id not in ( select c.branch_id from ' . $sbf->getTable() . ' as c WHERE a.id = c.station_id ) ) ) AND ( a.department_selection_type_id = 10 OR ( a.department_selection_type_id = 20 AND z.default_department_id in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE a.id = d.station_id ) ) OR ( a.department_selection_type_id = 30 AND z.default_department_id not in ( select d.department_id from ' . $sdf->getTable() . ' as d WHERE a.id = d.station_id ) ) ) AND z.id not in ( select f.user_id from ' . $seuf->getTable() . ' as f WHERE a.id = f.station_id ) ) OR z.id in ( select e.user_id from ' . $siuf->getTable() . ' as e WHERE a.id = e.station_id ) ) AND ( a.deleted = 0 AND z.deleted = 0 ) ORDER BY lower(a.source) = \'any\' desc, lower(station_id) = \'any\' desc '; //Try to order the SQL query to hit wildcard stations first. //$query .= $this->getSortSQL( $order, $strict ); //Debug::text('Query: '. $query, __FILE__, __LINE__, __METHOD__, 10); //Debug::arr($ph, 'PH: ', __FILE__, __LINE__, __METHOD__, 10); $this->rs = $this->db->Execute($query, $ph); return $this; }
$balf->getCompanyAccountByCompanyId($current_company->getId()); $country = $current_company->getCountry(); } else { $permission->Redirect(FALSE); } if (!isset($action)) { BreadCrumb::setCrumb($title); foreach ($balf as $bank_account) { //Debug::Arr($department,'Department', __FILE__, __LINE__, __METHOD__,10); $bank_data = array('id' => $bank_account->getId(), 'country' => strtolower($country), 'institution' => $bank_account->getInstitution(), 'transit' => $bank_account->getTransit(), 'account' => $bank_account->getAccount(), 'created_date' => $bank_account->getCreatedDate(), 'created_by' => $bank_account->getCreatedBy(), 'updated_date' => $bank_account->getUpdatedDate(), 'updated_by' => $bank_account->getUpdatedBy(), 'deleted_date' => $bank_account->getDeletedDate(), 'deleted_by' => $bank_account->getDeletedBy()); } } if (isset($user_id) and $company_id == '') { //$user_id = $current_user->getId(); $ulf = new UserListFactory(); $full_name = $ulf->getById($user_id)->getCurrent()->getFullName(); } elseif ($company_id != '') { $clf = new CompanyListFactory(); $full_name = $clf->getById($company_id)->getCurrent()->getName(); } $bank_data['full_name'] = $full_name; $bank_data['country'] = strtolower($country); $bank_data['user_id'] = $user_id; $bank_data['company_id'] = $company_id; //var_dump($bank_data); $smarty->assign_by_ref('bank_data', $bank_data); $smarty->assign_by_ref('data_saved', $data_saved); break; } $smarty->assign_by_ref('baf', $baf); //$smarty->assign_by_ref('current_time', TTDate::getDate('TIME') );
function getData() { $psenlf = new PayStubEntryNameListFactory(); $pslf = new PayStubListFactory(); //$pslf->getByIdAndUserId($id, $current_user->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); $pslf->getById($this->pay_stub_id); $pager = new Pager($pslf); foreach ($pslf as $pay_stub_obj) { //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { $description_subscript = NULL; $pay_stub_entry_name_obj = $psenlf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } $this->pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getDescription(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); $prev_type = $pay_stub_entry_name_obj->getType(); } //'entries' => $pay_stub_entries, $this->pay_stub = array('id' => $pay_stub_obj->getId(), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'advance' => $pay_stub_obj->getAdvance(), 'status' => $pay_stub_obj->getStatus(), 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy()); //Get Pay Period information $pplf = new PayPeriodListFactory(); $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(); } $this->pay_period = array('start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date)); //Get User information $ulf = new UserListFactory(); $this->user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $this->company_obj = $clf->getById($this->user_obj->getCompany())->getCurrent(); } }
function getEmailExceptionAddresses($u_obj = NULL, $ep_obj = NULL) { Debug::text(' Attempting to Email Notification...', __FILE__, __LINE__, __METHOD__, 10); //Make sure type is not pre-mature. if ($this->getType() > 5) { if (!is_object($ep_obj)) { $ep_obj = $this->getExceptionPolicyObject(); } //Make sure exception policy email notifications are enabled. if ($ep_obj->getEmailNotification() > 0) { if (!is_object($u_obj)) { $u_obj = $this->getUserDateObject()->getUserObject(); } $up_obj = $this->getUserDateObject()->getUserObject()->getUserPreferenceObject(); //Make sure user email notifications are enabled. if (($ep_obj->getEmailNotification() == 10 or $ep_obj->getEmailNotification() == 100) and $up_obj->getEnableEmailNotificationException() == TRUE) { Debug::Text(' Emailing exception to user!', __FILE__, __LINE__, __METHOD__, 10); if ($u_obj->getWorkEmail() != '') { $retarr[] = $u_obj->getWorkEmail(); } if ($up_obj->getEnableEmailNotificationHome() == TRUE and $u_obj->getHomeEmail() != '') { $retarr[] = $u_obj->getHomeEmail(); } } else { Debug::Text(' Skipping email to user.', __FILE__, __LINE__, __METHOD__, 10); } //Make sure supervisor email notifcations are enabled if ($ep_obj->getEmailNotification() == 20 or $ep_obj->getEmailNotification() == 100) { //Find supervisor $hlf = new HierarchyListFactory(); $parent_user_id = $hlf->getHierarchyParentByCompanyIdAndUserIdAndObjectTypeID($u_obj->getCompany(), $u_obj->getId(), 80); if ($parent_user_id != FALSE) { $ulf = new UserListFactory(); $ulf->getById($parent_user_id); if ($ulf->getRecordCount() > 0) { $parent_user_obj = $ulf->getCurrent(); if (is_object($parent_user_obj->getUserPreferenceObject()) and $parent_user_obj->getUserPreferenceObject()->getEnableEmailNotificationException() == TRUE) { Debug::Text(' Emailing exception to supervisor!', __FILE__, __LINE__, __METHOD__, 10); if ($parent_user_obj->getWorkEmail() != '') { $retarr[] = $parent_user_obj->getWorkEmail(); } if ($up_obj->getEnableEmailNotificationHome() == TRUE and $parent_user_obj->getHomeEmail() != '') { $retarr[] = $parent_user_obj->getHomeEmail(); } } else { Debug::Text(' Skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10); } } } else { Debug::Text(' No Hierarchy Parent Found, skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10); } } if (isset($retarr) and is_array($retarr)) { return $retarr; } else { Debug::text(' No user objects to email too...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::text(' Exception Policy Email Exceptions are disabled, skipping email...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::text(' Pre-Mature exception, or not in production mode, skipping email...', __FILE__, __LINE__, __METHOD__, 10); } return FALSE; }
function setUser($ids) { Debug::text('Setting User IDs : ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($ids) and count($ids) > 0) { //Remove any of the selected employees from other permission control objects first. //So there we can switch employees from one group to another in a single action. $pulf = new PermissionUserListFactory(); //$pculf->getByCompanyIdAndUserId( $this->getCompany(), $ids ); $pulf->getByCompanyIdAndUserIdAndNotPermissionControlId($this->getCompany(), $ids, (int) $this->getId()); if ($pulf->getRecordCount() > 0) { Debug::text('Found User IDs assigned to another Permission Group, unassigning them!', __FILE__, __LINE__, __METHOD__, 10); foreach ($pulf as $pu_obj) { $pu_obj->Delete(); } } unset($pulf, $pu_obj); $tmp_ids = array(); $pf = new PermissionFactory(); if (!$this->isNew()) { //If needed, delete mappings first. $pulf = new PermissionUserListFactory(); $pulf->getByPermissionControlId($this->getId()); $tmp_ids = array(); foreach ($pulf as $obj) { $id = $obj->getUser(); Debug::text('Permission Control ID: ' . $obj->getPermissionControl() . ' 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); $this->tmp_previous_user_ids[] = $id; $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)) { //Remove users from any other permission control object //first, otherwise there is a gab where an employee has //no permissions, this is especially bad for administrators //who are currently logged in. $puf = new PermissionUserFactory(); $puf->setPermissionControl($this->getId()); $puf->setUser($id); $obj = $ulf->getById($id)->getCurrent(); if ($this->Validator->isTrue('user', $puf->Validator->isValid(), TTi18n::gettext('Selected employee is invalid, or already assigned to another permission group') . ' (' . $obj->getFullName() . ')')) { $puf->save(); } } } return TRUE; } Debug::text('No User IDs to set.', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
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; }
switch ($action) { default: if (isset($id)) { $hlf = new HierarchyListFactory(); $tmp_id = $id; $i = 0; do { Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10); $parents = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id); $level = $hlf->getFastTreeObject()->getLevel($tmp_id) - 1; if (is_array($parents) and count($parents) > 0) { $parent_users = array(); foreach ($parents as $user_id) { //Get user information $ulf = new UserListFactory(); $ulf->getById($user_id); $user = $ulf->getCurrent(); unset($ulf); $parent_users[] = array('name' => $user->getFullName()); unset($user); } $parent_groups[] = array('users' => $parent_users, 'level' => $level); unset($parent_users); } if (isset($parents[0])) { $tmp_id = $parents[0]; } $i++; } while (is_array($parents) and count($parents) > 0 and $i < 100); } $smarty->assign_by_ref('parent_groups', $parent_groups);
$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); $filter_data['status_options'] = Misc::prependArray($all_array_option, $ulf->getOptions('status')); $filter_data['pay_period_options'] = Misc::prependArray($all_array_option, $pay_period_options); $filter_data['punch_status_options'] = Misc::prependArray($all_array_option, $punch_status_options); $filter_data['punch_type_options'] = Misc::prependArray($all_array_option, $punch_type_options);
function getPayStub($pslf = NULL, $hide_employer_rows = TRUE) { if (!is_object($pslf) and $this->getId() != '') { $pslf = new PayStubListFactory(); $pslf->getById($this->getId()); } if (get_class($pslf) !== 'PayStubListFactory') { return FALSE; } $border = 0; if ($pslf->getRecordCount() > 0) { $pdf = new TTPDF('P', 'mm', 'Letter'); $pdf->setMargins(0, 0); //$pdf->SetAutoPageBreak(TRUE, 30); $pdf->SetAutoPageBreak(FALSE); $pdf->SetFont('freeserif', '', 10); //$pdf->SetFont('FreeSans','',10); $i = 0; foreach ($pslf as $pay_stub_obj) { $psealf = new PayStubEntryAccountListFactory(); Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10); //Get Pay Period information $pplf = new PayPeriodListFactory(); $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent(); //Use Pay Stub dates, not Pay Period dates. $pp_start_date = $pay_stub_obj->getStartDate(); $pp_end_date = $pay_stub_obj->getEndDate(); $pp_transaction_date = $pay_stub_obj->getTransactionDate(); //Get pay period numbers $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent(); //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(); //Change locale to users own locale. TTi18n::setCountry($user_obj->getCountry()); TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage()); TTi18n::setLocale(); // // Pay Stub Header // $pdf->AddPage(); $adjust_x = 20; $adjust_y = 10; //Logo $pdf->Image($company_obj->getLogoFileName(), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), 50, 12, '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE); //Company name/address $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C'); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C'); $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C'); //Pay Period info $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R'); $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y)); $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R'); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y)); $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', 0); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y)); $pdf->setLineWidth(0.25); //Get pay stub entries. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($pay_stub_obj->getId()); Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $prev_type = NULL; $description_subscript_counter = 1; foreach ($pself as $pay_stub_entry) { Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10); $description_subscript = NULL; $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent(); //Use this to put the total for each type at the end of the array. if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) { $type = $pay_stub_entry_name_obj->getType(); } //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10); if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) { $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription()); $description_subscript = $description_subscript_counter; $description_subscript_counter++; } //If type if 40 (a total) and the amount is 0, skip it. //This if the employee has no deductions at all, it won't be displayed //on the pay stub. if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) { $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy()); } $prev_type = $pay_stub_entry_name_obj->getType(); } //There should always be pay stub entries for a pay stub. if (!isset($pay_stub_entries)) { continue; } //Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10); //$pay_period_number = $pay_period_schedule_obj->getCurrentPayPeriodNumber( $pay_period_obj->getTransactionDate(), $pay_period_obj->getEndDate() ); $block_adjust_y = 30; // //Earnings // if (isset($pay_stub_entries[10])) { //Earnings Header $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, TTi18n::gettext('Earnings'), $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::gettext('Rate'), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[10] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 10) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(88, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(17, 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(110, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(131, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(90, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(17, 5, '', $border, 0, 'R'); $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // // Deductions // if (isset($pay_stub_entries[20])) { $max_deductions = count($pay_stub_entries[20]); //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Deductions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[20] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 20) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } if (isset($pay_stub_entries[40][0])) { $block_adjust_y = $block_adjust_y + 5; //Net Pay entry $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entries[40][0]['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['ytd_amount']), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; } // //Employer Contributions // //echo "Employee Ded: <br>\n"; if (isset($pay_stub_entries[30]) and $hide_employer_rows != TRUE) { $max_deductions = count($pay_stub_entries[30]); //echo "Max Employee Ded: ". $max_deductions ."<br>\n"; //Deductions Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R'); $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); $x = 0; $max_block_adjust_y = 0; foreach ($pay_stub_entries[30] as $pay_stub_entry) { //Start with the right side. if ($x < floor($max_deductions / 2)) { $tmp_adjust_x = 90; } else { if ($tmp_block_adjust_y != 0) { $block_adjust_y = $tmp_block_adjust_y; $tmp_block_adjust_y = 0; } $tmp_adjust_x = 0; } if ($pay_stub_entry['type'] == 30) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } if ($max_deductions > 2) { $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } else { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); } $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } else { $block_adjust_y = $max_block_adjust_y + 0; //Total $pdf->SetFont('', 'B', 10); $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; if ($block_adjust_y > $max_block_adjust_y) { $max_block_adjust_y = $block_adjust_y; } $x++; } //Draw line to separate the two columns if ($max_deductions > 2) { $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y)); } unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y); } // //Accruals PS accounts // if (isset($pay_stub_entries[50])) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(130, 5, TTi18n::gettext('Accruals'), $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::gettext('Balance'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 10); foreach ($pay_stub_entries[50] as $pay_stub_entry) { if ($pay_stub_entry['type'] == 50) { if ($pay_stub_entry['description_subscript'] != '') { $subscript = '[' . $pay_stub_entry['description_subscript'] . ']'; } else { $subscript = NULL; } $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L'); $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R'); $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R'); } $block_adjust_y = $block_adjust_y + 5; } } // //Accrual Policy Balances // $ablf = new AccrualBalanceListFactory(); $ablf->getByUserIdAndCompanyIdAndEnablePayStubBalanceDisplay($user_obj->getId(), $user_obj->getCompany(), TRUE); if ($ablf->getRecordCount() > 0) { //Accrual Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $accrual_time_header_start_x = $pdf->getX(); $accrual_time_header_start_y = $pdf->getY(); $pdf->Cell(70, 5, TTi18n::gettext('Accrual Time Balances as of ') . TTDate::getDate('DATE', time()), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::gettext('Balance (hrs)'), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = 5; $pdf->SetFont('', '', 10); foreach ($ablf as $ab_obj) { $balance = $ab_obj->getBalance(); if (!is_numeric($balance)) { $balance = 0; } $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(70, 5, $ab_obj->getColumn('name'), $border, 0, 'L'); $pdf->Cell(25, 5, TTi18n::formatNumber(TTDate::getHours($balance)), $border, 0, 'R'); $block_adjust_y = $block_adjust_y + 5; $box_height = $box_height + 5; unset($balance); } $pdf->Rect($accrual_time_header_start_x, $accrual_time_header_start_y, 95, $box_height); unset($accrual_time_header_start_x, $accrual_time_header_start_y, $box_height); } // //Descriptions // if (isset($pay_stub_entry_descriptions) and count($pay_stub_entry_descriptions) > 0) { //Description Header $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', 'B', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('Notes'), $border, 0, 'L'); $block_adjust_y = $block_adjust_y + 5; $pdf->SetFont('', '', 8); $x = 0; foreach ($pay_stub_entry_descriptions as $pay_stub_entry_description) { if ($x % 2 == 0) { $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } else { $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y)); } //$pdf->Cell(173,5, '['.$pay_stub_entry_description['subscript'].'] '.$pay_stub_entry_description['description'], $border, 0, 'L'); $pdf->Cell(85, 5, '[' . $pay_stub_entry_description['subscript'] . '] ' . $pay_stub_entry_description['description'], $border, 0, 'L'); if ($x % 2 != 0) { $block_adjust_y = $block_adjust_y + 5; } $x++; } } unset($x, $pay_stub_entry_descriptions, $pay_stub_entry_description); // // Pay Stub Footer // $block_adjust_y = 215; //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y, $adjust_y)); //Non Negotiable $pdf->SetFont('', 'B', 14); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 3, $adjust_y)); $pdf->Cell(175, 5, TTi18n::gettext('NON NEGOTIABLE'), $border, 0, 'C', 0); //Employee Address $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 9, $adjust_y)); $pdf->Cell(60, 5, TTi18n::gettext('CONFIDENTIAL'), $border, 0, 'C', 0); $pdf->SetFont('', '', 10); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 14, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C', 0); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 19, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress1(), $border, 0, 'C', 0); $address2_adjust_y = 0; if ($user_obj->getAddress2() != '') { $address2_adjust_y = 5; $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getAddress2(), $border, 0, 'C', 0); } $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24 + $address2_adjust_y, $adjust_y)); $pdf->Cell(60, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 1, 'C', 0); //Pay Period - Balance - ID $net_pay_amount = 0; if (isset($pay_stub_entries[40][0])) { $net_pay_amount = $pay_stub_entries[40][0]['amount']; } if (isset($pay_stub_entries[65]) and count($pay_stub_entries[65]) > 0) { $net_pay_label = TTi18n::gettext('Balance'); } else { $net_pay_label = TTi18n::gettext('Net Pay'); } /* if ( $pay_period_schedule_obj->getType() != 5 AND $pay_period_number > 0 AND $pay_period_schedule_obj->getAnnualPayPeriods() > 0 ) { $pdf->setXY( Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y+10, $adjust_y) ); $pdf->Cell(50, 5, TTi18n::gettext('Pay Period').' '. $pay_period_number .' '. TTi18n::gettext('of') .' '. $pay_period_schedule_obj->getAnnualPayPeriods(), $border, 1, 'L', 0); } */ $pdf->SetFont('', 'B', 12); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 17, $adjust_y)); $pdf->Cell(50, 5, $net_pay_label . ': ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $net_pay_amount . ' ' . $pay_stub_obj->getCurrencyObject()->getISOCode(), $border, 1, 'L', 0); if ($pay_stub_obj->getTainted() == TRUE) { $tainted_flag = 'T'; } else { $tainted_flag = ''; } $pdf->SetFont('', '', 8); $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 30, $adjust_y)); $pdf->Cell(50, 5, TTi18n::gettext('Identification #:') . ' ' . str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT) . $tainted_flag, $border, 1, 'L', 0); unset($net_pay_amount, $tainted_flag); //Line $pdf->setLineWidth(1); $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 35, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y + 35, $adjust_y)); $pdf->SetFont('', '', 6); $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 38, $adjust_y)); $pdf->Cell(175, 1, TTi18n::gettext('Pay Stub Generated by') . ' ' . APPLICATION_NAME, $border, 0, 'C', 0); unset($pay_period_schedule_obj, $pay_stub_entries, $pay_period_number); $i++; } $output = $pdf->Output('', 'S'); } TTi18n::setMasterLocale(); if (isset($output)) { return $output; } return FALSE; }
$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); //Get Parents $default_schedule_parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id); Debug::Arr($default_schedule_parent_level_user_ids, 'Default Schedule Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10); //Get Children $default_schedule_child_level_user_ids = $hlf->getChildLevelIdArrayByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id); Debug::Arr($default_schedule_child_level_user_ids, 'Default Schedule Child Level Ids', __FILE__, __LINE__, __METHOD__, 10); if (!($default_schedule_current_level_user_ids === FALSE and $default_schedule_parent_level_user_ids === FALSE and $default_schedule_child_level_user_ids === FALSE)) { $dsculf = new DefaultScheduleControlUserListFactory(); $dsculf->getByUserIdListAndStatusAndNotAuthorized($default_schedule_current_level_user_ids, 30, $default_schedule_parent_level_user_ids, $default_schedule_current_level_user_ids, NULL, NULL, NULL, array('a.created_date' => 'asc')); $dsculf->getByUserIdListAndStatusAndNotAuthorized($default_schedule_child_level_user_ids, 30, $default_schedule_parent_level_user_ids, $default_schedule_current_level_user_ids, NULL, NULL, NULL, array('a.created_date' => 'asc')); foreach ($dsculf as $default_schedule_control_user) { //Grab authorizations for this object. Debug::Text('Default Schedule Control User ID: ' . $default_schedule_control_user->getId(), __FILE__, __LINE__, __METHOD__, 10); $default_schedule_control_user_data = $ulf->getById($default_schedule_control_user->getUser())->getCurrent(); $default_schedule_controls[] = array('id' => $default_schedule_control_user->getId(), 'user_id' => $default_schedule_control_user->getUser(), 'user_full_name' => $default_schedule_control_user_data->getFullName(), 'name' => $default_schedule_control_user->getDefaultScheduleControlObject()->getName(), 'description' => $default_schedule_control_user->getDefaultScheduleControlObject()->getDescription()); } if (isset($default_schedule_controls)) { $pending_amendments['Recurring Schedules'] = $default_schedule_controls; } } unset($default_schedule_user_id, $default_schedule_controls); } if ($permission->Check('schedule_amendment', 'authorize', $user->getId(), $user->getCompany())) { //Get Hierarchy Control ID $schedule_amendment_hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($user->getCompany(), 20)->getCurrent()->getHierarchyControl(); Debug::Text('Schedule Amendment Hierarchy ID: ' . $schedule_amendment_hierarchy_id, __FILE__, __LINE__, __METHOD__, 10); //Get all levels below us. $schedule_amendment_levels = $hlf->getLevelsByHierarchyControlIdAndUserId($schedule_amendment_hierarchy_id, $user->getId()); Debug::Arr($schedule_amendment_levels, 'Schedule Amendment Levels', __FILE__, __LINE__, __METHOD__, 10);
$mlf->getByUserIdAndFolder($current_user->getId(), $filter_folder_id, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); $object_name_options = $mlf->getOptions('object_name'); $pager = new Pager($mlf); $require_ack = FALSE; foreach ($mlf as $message) { //Get user info $ulf = new UserListFactory(); if ($message->isAck() == FALSE) { $require_ack = TRUE; } if ($message->getRequireAck() == TRUE) { $show_ack_column = TRUE; } $sent_to_full_name = NULL; if ($message->getColumn('sent_to_user_id') != FALSE) { $ulf->getById($message->getColumn('sent_to_user_id')); if ($ulf->getRecordCount() > 0) { $sent_to_full_name = $ulf->getCurrent()->getFullName(); } } $created_by_full_name = NULL; if ($message->getCreatedBy() != FALSE) { $ulf->getById($message->getCreatedBy()); if ($ulf->getRecordCount() > 0) { $created_by_full_name = $ulf->getCurrent()->getFullName(); } } $messages[] = array('id' => $message->getId(), 'parent_id' => $message->getParent(), 'object_type_id' => $message->getObjectType(), 'object_type' => $object_name_options[$message->getObjectType()], 'object_id' => $message->getObject(), 'priority' => $message->getPriority(), 'status_id' => $message->getStatus(), 'require_ack' => $message->getRequireAck(), 'ack_date' => $message->getAckDate(), 'subject' => $message->getSubject(), 'body' => $message->getBody(), 'sent_to_user_id' => $message->getColumn('sent_to_user_id'), 'sent_to_full_name' => $sent_to_full_name, 'created_date' => $message->getCreatedDate(), 'created_by' => $message->getCreatedBy(), 'created_by_full_name' => $created_by_full_name, 'updated_date' => $message->getUpdatedDate(), 'updated_by' => $message->getUpdatedBy(), 'deleted_date' => $message->getDeletedDate(), 'deleted_by' => $message->getDeletedBy()); } //var_dump($messages); $smarty->assign_by_ref('messages', $messages);
$station_type_options = $slf->getOptions('type'); if ($current_company->getProductEdition() == 20) { $jlf = new JobListFactory(); $job_options = $jlf->getByCompanyIdArray($current_company->getId()); $jilf = new JobItemListFactory(); $job_item_options = $jilf->getByCompanyIdArray($current_company->getId()); } else { $job_options = array(); $job_item_options = array(); } $punch_type_options = $plf->getOptions('type'); $plf->getLastPunchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data); if ($plf->getRecordCount() > 0) { foreach ($plf as $p_obj) { //Get user info $ulf->getById($p_obj->getColumn('user_id')); if ($ulf->getRecordCount() > 0) { $user_obj = $ulf->getCurrent(); /* {if $permission->Check('punch','view') OR ( $permission->Check('punch','view_child') AND $user.is_child === TRUE ) OR ( $permission->Check('punch','view_own') AND $user.is_owner === TRUE ) } {assign var="user_id" value=$user.id} [ <a href="{urlbuilder script="../timesheet/ViewUserTimeSheet.php" values="filter_data[user_id]=$user_id" merge="FALSE"}">{t}View{/t}</a> ] {/if} */ $view_link = $rows[] = array('id' => $user_obj->GetId(), 'first_name' => $user_obj->getFirstName(), 'last_name' => $user_obj->getLastName(), 'employee_number' => $user_obj->getEmployeeNumber(), 'title' => Option::getByKey($user_obj->getTitle(), $title_options), 'province' => $user_obj->getProvince(), 'country' => $user_obj->getCountry(), '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), 'is_owner' => $permission->isOwner($user_obj->getCreatedBy(), $user_obj->getId()), 'is_child' => $permission->isChild($user_obj->getId(), $permission_children_ids), 'punch_id' => $p_obj->getId(), 'time_stamp' => $p_obj->getTimeStamp(), 'actual_time_stamp' => $p_obj->getActualTimeStamp(), 'status_id' => $p_obj->getStatus(), 'status' => Option::getByKey($p_obj->getStatus(), $p_obj->getOptions('status')), 'type_id' => $p_obj->getType(), 'type' => Option::getByKey($p_obj->getType(), $p_obj->getOptions('type')), '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), 'job_id' => $p_obj->getColumn('job_id'), 'job' => Option::getByKey($p_obj->getColumn('job_id'), $job_options), 'job_item_id' => $p_obj->getColumn('job_id'), 'job_item' => Option::getByKey($p_obj->getColumn('job_item_id'), $job_item_options), 'note' => $p_obj->getColumn('note'), 'station_type' => Option::getByKey($p_obj->getColumn('station_type_id'), $station_type_options), 'station_station_id' => $p_obj->getColumn('station_station_id'), 'station_source' => $p_obj->getColumn('station_source'), 'station_description' => Misc::TruncateString($p_obj->getColumn('station_description'), 30)); } } } //print_r($rows); if (isset($rows)) { foreach ($rows as $row) {
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; }
$title_options = $utlf->getByCompanyIdArray($current_company->getId()); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($current_company->getId()); $currency_options = $crlf->getArrayByListFactory($crlf, FALSE, TRUE); //Get Base Currency $crlf->getByCompanyIdAndBase($current_company->getId(), TRUE); if ($crlf->getRecordCount() > 0) { $base_currency_obj = $crlf->getCurrent(); } $currency_convert_to_base = FALSE; if (in_array('-1', $filter_data['currency_ids']) or count($filter_data['currency_ids']) > 1) { Debug::Text('More then one currency selected, converting to base!', __FILE__, __LINE__, __METHOD__, 10); $currency_convert_to_base = TRUE; } foreach ($pslf as $ps_obj) { $user_obj = $ulf->getById($ps_obj->getUser())->getCurrent(); $replace_arr = array($branch_code_map[(int) $user_obj->getDefaultBranch()], $department_code_map[(int) $user_obj->getDefaultDepartment()], $user_obj->getEmployeeNumber()); $je_records = NULL; //Get all PS Entries for this pay stub. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($ps_obj->getId()); if ($pself->getRecordCount() > 0) { Debug::Text('Found Pay Stub Entries for PS ID:' . $ps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); foreach ($pself as $pse_obj) { Debug::Text('Pay Stub Entry ID:' . $pse_obj->getId() . ' PSE Account ID: ' . $pse_obj->getPayStubEntryNameId() . ' Currency Rate: ' . $ps_obj->getCurrencyRate() . ' Amount: ' . $pse_obj->getAmount(), __FILE__, __LINE__, __METHOD__, 10); if (isset($psea_arr[$pse_obj->getPayStubEntryNameId()])) { if (isset($psea_arr[$pse_obj->getPayStubEntryNameId()]['debit_account']) and $psea_arr[$pse_obj->getPayStubEntryNameId()]['debit_account'] != '') { $debit_accounts = explode(',', $psea_arr[$pse_obj->getPayStubEntryNameId()]['debit_account']); foreach ($debit_accounts as $debit_account) { $debit_account = replaceGLAccountVariables($debit_account, $replace_arr); Debug::Text('Debit Entry: Account: ' . $debit_account . ' Amount: ' . $pse_obj->getAmount(), __FILE__, __LINE__, __METHOD__, 10);
function Validate() { if ($this->getUser() == $this->getParent()) { $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('User is the same as parent')); } //Make sure both user and parent belong to the same company $ulf = new UserListFactory(); $ulf->getById($this->getUser()); $user = $ulf->getIterator()->current(); unset($ulf); $ulf = new UserListFactory(); $ulf->getById($this->getParent()); $parent = $ulf->getIterator()->current(); unset($ulf); if ($this->getUser() == 0 and $this->getParent() == 0) { $parent_company_id = 0; $user_company_id = 0; } elseif ($this->getUser() == 0) { $parent_company_id = $parent->getCompany(); $user_company_id = $parent->getCompany(); } elseif ($this->getParent() == 0) { $parent_company_id = $user->getCompany(); $user_company_id = $user->getCompany(); } else { $parent_company_id = $parent->getCompany(); $user_company_id = $user->getCompany(); } if ($user_company_id > 0 and $parent_company_id > 0) { Debug::Text(' User Company: ' . $user_company_id . ' Parent Company: ' . $parent_company_id, __FILE__, __LINE__, __METHOD__, 10); if ($user_company_id != $parent_company_id) { $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('User or parent has incorrect company')); } $this->getFastTreeObject()->setTree($this->getHierarchyControl()); $children_arr = $this->getFastTreeObject()->getAllChildren($this->getUser(), 'RECURSE'); if (is_array($children_arr)) { $children_ids = array_keys($children_arr); if (isset($children_ids) and is_array($children_ids) and in_array($this->getParent(), $children_ids) == TRUE) { Debug::Text(' Objects cant be re-parented to their own children...', __FILE__, __LINE__, __METHOD__, 10); $this->Validator->isTrue('parent', FALSE, TTi18n::gettext('Unable to change parent to a child of itself')); } } /* //Make sure we're not re-parenting to a child. $uhlf = new UserHierarchyListFactory(); $hierarchy = $uhlf->getByCompanyIdArray( $parent_company_id ); Debug::Text(' User ID: '. $this->getUser() .' Parent ID: '. $this->getParent(), __FILE__, __LINE__, __METHOD__,10); if ( is_array( $hierarchy ) ) { if ( in_array( $this->getParent(), array_keys( $hierarchy[$this->getUser()] ) ) ) { Debug::Text(' Trying to re-parent to a child! ', __FILE__, __LINE__, __METHOD__,10); $this->Validator->isTrue( 'parent', FALSE, TTi18n::gettext('Unable to change parent to a child of itself') ); } else { Debug::Text(' NOT Trying to re-parent to a child! ', __FILE__, __LINE__, __METHOD__,10); } } else { Debug::Text(' NOT Trying to re-parent to a child! 22', __FILE__, __LINE__, __METHOD__,10); } */ } return TRUE; }
static function releaseAllAccruals($user_id, $effective_date = NULL) { Debug::Text('Release 100% of all accruals!', __FILE__, __LINE__, __METHOD__, 10); if ($user_id == '') { return FALSE; } if ($effective_date == '') { $effective_date = TTDate::getTime(); } Debug::Text('Effective Date: ' . TTDate::getDate('DATE+TIME', $effective_date), __FILE__, __LINE__, __METHOD__, 10); $ulf = new UserListFactory(); $ulf->getById($user_id); if ($ulf->getRecordCount() > 0) { $user_obj = $ulf->getCurrent(); } else { return FALSE; } //Get all PSE acccount accruals $psealf = new PayStubEntryAccountListFactory(); $psealf->getByCompanyIdAndStatusIdAndTypeId($user_obj->getCompany(), 10, 50); if ($psealf->getRecordCount() > 0) { $ulf->StartTransaction(); foreach ($psealf as $psea_obj) { //Get PSE account that affects this accrual. $psealf_tmp = new PayStubEntryAccountListFactory(); $psealf_tmp->getByCompanyIdAndAccrualId($user_obj->getCompany(), $psea_obj->getId()); if ($psealf_tmp->getRecordCount() > 0) { $release_account_id = $psealf_tmp->getCurrent()->getId(); $psaf = new PayStubAmendmentFactory(); $psaf->setStatus(50); //Active $psaf->setType(20); //Percent $psaf->setUser($user_obj->getId()); $psaf->setPayStubEntryNameId($release_account_id); $psaf->setPercentAmount(100); $psaf->setPercentAmountEntryNameId($psea_obj->getId()); $psaf->setEffectiveDate($effective_date); $psaf->setDescription('Release Accrual Balance'); if ($psaf->isValid()) { Debug::Text('Release Accrual Is Valid!!: ', __FILE__, __LINE__, __METHOD__, 10); $psaf->Save(); } } else { Debug::Text('No Release Account for this Accrual!!', __FILE__, __LINE__, __METHOD__, 10); } } //$ulf->FailTransaction(); $ulf->CommitTransaction(); } else { Debug::Text('No Accruals to release...', __FILE__, __LINE__, __METHOD__, 10); } return FALSE; }
function createPayStubAmendments($epoch = NULL) { //Get all recurring pay stub amendments and generate single pay stub amendments if appropriate. if ($epoch == '') { $epoch = TTDate::getTime(); } $ulf = new UserListFactory(); Debug::text('Recurring PS Amendment ID: ' . $this->getId() . ' Frequency: ' . $this->getFrequency(), __FILE__, __LINE__, __METHOD__, 10); $this->StartTransaction(); $tmp_user_ids = $this->getUser(); if ($tmp_user_ids[0] == -1) { $ulf->getByCompanyIdAndStatus($this->getCompany(), 10); foreach ($ulf as $user_obj) { $user_ids[] = $user_obj->getId(); } unset($user_obj); } else { $user_ids = $this->getUser(); } unset($tmp_user_ids); Debug::text('Total User IDs: ' . count($user_ids), __FILE__, __LINE__, __METHOD__, 10); if (is_array($user_ids) and count($user_ids) > 0) { //Make the PS amendment duplicate check start/end date separate //Make the PS amendment effective date separate. switch ($this->getFrequency()) { case 10: //Get all open pay periods $pplf = new PayPeriodListFactory(); //FIXME: Get all non-closed pay periods AFTER the start date. $pplf->getByUserIdListAndNotStatusAndStartDateAndEndDate($user_ids, 20, $this->getStartDate(), $this->getEndDate()); //All non-closed pay periods Debug::text('Found Open Pay Periods: ' . $pplf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); foreach ($pplf as $pay_period_obj) { Debug::text('Working on Pay Period: ' . $pay_period_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); //If near the end of a pay period, or a pay period is already ended, add PS amendment if //it does not already exist. if ($epoch >= $pay_period_obj->getEndDate() and $this->checkTimeFrame($epoch)) { Debug::text('After end of pay period.', __FILE__, __LINE__, __METHOD__, 10); $psalf = new PayStubAmendmentListFactory(); //Loop through each user of this Pay Period Schedule adding PS amendments if they don't already exist. $pay_period_schedule_users = $pay_period_obj->getPayPeriodScheduleObject()->getUser(); Debug::text(' Pay Period Schedule Users: ' . count($pay_period_schedule_users), __FILE__, __LINE__, __METHOD__, 10); foreach ($pay_period_schedule_users as $user_id) { //Make sure schedule user is in the PS amendment user list and user is active. Debug::text(' Pay Period Schedule User: '******' Recurring PS Amendment Selected Users: ', __FILE__, __LINE__, __METHOD__,10); if ($ulf->getById($user_id)->getCurrent()->getStatus() == 10 and in_array($user_id, $user_ids)) { //Check to see if the amendment was added already. if ($psalf->getByUserIdAndRecurringPayStubAmendmentIdAndStartDateAndEndDate($user_id, $this->getId(), $pay_period_obj->getStartDate(), $pay_period_obj->getEndDate())->getRecordCount() == 0) { //No amendment, good to insert one Debug::text('Inserting Recurring PS Amendment for User: '******'Recurring PS Amendment already inserted for User: '******'Skipping User because they are INACTIVE or are not on the Recurring PS Amendment User List - ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); //continue; } } } else { Debug::text('Not in TimeFrame, not inserting amendments: Epoch: ' . $epoch . ' Pay Period End Date: ' . $pay_period_obj->getEndDate(), __FILE__, __LINE__, __METHOD__, 10); } } break; case 30: //Weekly //Weekly case 40: //Monthly //Monthly case 70: //Annually switch ($this->getFrequency()) { case 30: $trigger_date = TTDate::getDateOfNextDayOfWeek(TTDate::getBeginWeekEpoch($epoch), $this->getStartDate()); $start_date = TTDate::getBeginWeekEpoch($epoch); $end_date = TTDate::getEndWeekEpoch($epoch); break; case 40: $trigger_date = TTDate::getDateOfNextDayOfMonth(TTDate::getBeginMonthEpoch($epoch), $this->getStartDate()); //$monthly_date = TTDate::getDateOfNextDayOfMonth( TTDate::getBeginMonthEpoch($epoch), $this->getStartDate() ); $start_date = TTDate::getBeginMonthEpoch($epoch); $end_date = TTDate::getEndMonthEpoch($epoch); break; case 70: $trigger_date = TTDate::getDateOfNextYear($this->getStartDate()); $start_date = TTDate::getBeginYearEpoch($epoch); $end_date = TTDate::getEndYearEpoch($epoch); break; } Debug::text('Trigger Date: ' . TTDate::getDate('DATE', $trigger_date), __FILE__, __LINE__, __METHOD__, 10); if ($epoch >= $trigger_date and $this->checkTimeFrame($epoch)) { Debug::text('After end of pay period.', __FILE__, __LINE__, __METHOD__, 10); foreach ($user_ids as $user_id) { //Make sure schedule user is in the PS amendment user list and user is active. if ($ulf->getById($user_id)->getCurrent()->getStatus() != 10 and !in_array($user_id, $user_ids)) { Debug::text('Skipping User because they are INACTIVE or are not on the Recurring PS Amendment User List - ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); continue; } $psalf = new PayStubAmendmentListFactory(); if ($psalf->getByUserIdAndRecurringPayStubAmendmentIdAndStartDateAndEndDate($user_id, $this->getId(), $start_date, $end_date)->getRecordCount() == 0) { //No amendment, good to insert one Debug::text('Inserting Recurring PS Amendment for User: '******'Recurring PS Amendment already inserted for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); } } } break; } } //$this->FailTransaction(); $this->CommitTransaction(); return TRUE; }
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; }
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; }