function isUniqueUser($id) { $ppslf = new PayPeriodScheduleListFactory(); $ph = array('id' => $id); $query = 'select a.id from ' . $this->getTable() . ' as a, ' . $ppslf->getTable() . ' as b where a.pay_period_schedule_id = b.id AND a.user_id = ? AND b.deleted=0'; $user_id = $this->db->GetOne($query, $ph); Debug::Arr($user_id, 'Unique User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10); if ($user_id === FALSE) { return TRUE; } return FALSE; }
function getPayPeriodMaximumShiftTime($user_id, $maximum_shift_time = NULL) { if (!is_numeric($maximum_shift_time)) { //Get pay period start/maximum shift time $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($user_id); if ($ppslf->getRecordCount() == 1) { $pps_obj = $ppslf->getCurrent(); $maximum_shift_time = $pps_obj->getMaximumShiftTime(); //Debug::Text(' aPay Period Schedule Maximum Shift Time: '. $maximum_shift_time, __FILE__, __LINE__, __METHOD__,10); } else { //Debug::Text(' bPay Period Schedule Not Found! Using 4hrs as default', __FILE__, __LINE__, __METHOD__,10); $maximum_shift_time = 3600 * 16; } } Debug::Text(' cPay Period Schedule Maximum Shift Time: ' . $maximum_shift_time, __FILE__, __LINE__, __METHOD__, 10); return $maximum_shift_time; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //New Pay Period Schedule format, update any current schedules. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getAll(); Debug::text('Found Pay Period Schedules: ' . $ppslf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 9); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { if ($pps_obj->getType() == 10 or $pps_obj->getType() == 20) { $pps_obj->setStartDayOfWeek(TTDate::getDayOfWeek(TTDate::strtotime($pps_obj->getColumn('anchor_date')))); $pps_obj->setTransactionDate(floor((TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')) - TTDate::strtotime($pps_obj->getColumn('primary_date'))) / 86400) + 1); } elseif ($pps_obj->getType() == 30) { $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date'))) + 1); if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) { $pps_obj->setPrimaryTransactionDayOfMonth(-1); } else { $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')))); } $pps_obj->setSecondaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_date')))); if ($pps_obj->getColumn('secondary_transaction_date_ldom') == 1) { $pps_obj->setSecondaryTransactionDayOfMonth(-1); } else { $pps_obj->setSecondaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('secondary_transaction_date')))); } } elseif ($pps_obj->getType() == 50) { $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date')))); if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) { $pps_obj->setPrimaryTransactionDayOfMonth(-1); } else { $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')))); } } if ($pps_obj->getColumn('transaction_date_bd') == 1 or $pps_obj->getColumn('secondary_transaction_date_bd') == 1) { $pps_obj->setTransactionDateBusinessDay(TRUE); } if ($pps_obj->isValid()) { $pps_obj->Save(); } } } return TRUE; }
function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Get all pay period schedules. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getAll(); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $user_ids = $pps_obj->getUser(); if (is_array($user_ids)) { $time_zone_arr = array(); foreach ($user_ids as $user_id) { $uplf = new UserPreferenceListFactory(); $uplf->getByUserId($user_id); if ($uplf->getRecordCount() > 0) { if (isset($time_zone_arr[$uplf->getCurrent()->getTimeZone()])) { $time_zone_arr[$uplf->getCurrent()->getTimeZone()]++; } else { $time_zone_arr[$uplf->getCurrent()->getTimeZone()] = 1; } } } arsort($time_zone_arr); //Grab the first time zone, as it is most common foreach ($time_zone_arr as $time_zone => $count) { break; } if ($time_zone != '') { //Set pay period timezone to the timezone of the majority of the users are in. $pps_obj->setTimeZone($time_zone); if ($pps_obj->isValid()) { $pps_obj->Save(); } } } } } Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); return TRUE; }
function createPayPeriods($start_date = NULL) { if ($start_date == '') { $start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginYearEpoch(time()) - 86400 * (7 * 6)); } $max_pay_periods = 192; //Make a lot of pay periods as we need to test 6 years worth of accruals for different milestones. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getById($this->pay_period_schedule_id); if ($ppslf->getRecordCount() > 0) { $pps_obj = $ppslf->getCurrent(); for ($i = 0; $i < $max_pay_periods; $i++) { if ($i == 0) { //$end_date = TTDate::getBeginYearEpoch( strtotime('01-Jan-07') ); $end_date = $start_date; } else { $end_date = $end_date + 86400 * 14; } Debug::Text('I: ' . $i . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10); $pps_obj->createNextPayPeriod($end_date, 86400 * 3600); } } return TRUE; }
function getROE($rlf = NULL, $show_background = TRUE) { if (!is_object($rlf) and $this->getId() != '') { $rlf = new ROEListFactory(); $rlf->getById($this->getId()); } if (get_class($rlf) !== 'ROEListFactory') { return FALSE; } $border = 0; if ($rlf->getRecordCount() > 0) { $ppsf = new PayPeriodScheduleListFactory(); $pay_period_type_options = $ppsf->getOptions('type'); $pdf = new TTPDF(); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(FALSE); foreach ($rlf as $r_obj) { $pdf->SetFont('freesans', '', 12); //Get User information $ulf = new UserListFactory(); $user_obj = $ulf->getById($r_obj->getUser())->getCurrent(); $ulf = new UserListFactory(); $created_user_obj = $ulf->getById($r_obj->getCreatedBy())->getCurrent(); //Get company information $clf = new CompanyListFactory(); $company_obj = $clf->getById($user_obj->getCompany())->getCurrent(); $pdf->AddPage(); if ($show_background == TRUE) { $pdf->Image(Environment::getImagesPath() . 'roe-template.jpg', 0, 0, 210, 300); } //Serial $pdf->setXY(10, 17); $pdf->Cell(55, 10, $r_obj->getSerial(), $border, 0, 'L'); //Employer Info $pdf->setXY(10, 30); $pdf->Cell(120, 10, $company_obj->getName(), $border, 0, 'L'); $pdf->setXY(10, 40); $pdf->Cell(120, 10, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'L'); $pdf->setXY(10, 50); $pdf->Cell(90, 10, $company_obj->getCity() . ', ' . $company_obj->getProvince(), $border, 0, 'L'); $postal_code_a = substr($company_obj->getPostalCode(), 0, 3); $postal_code_b = substr($company_obj->getPostalCode(), 3, 6); $pdf->setXY(110, 50); $pdf->Cell(10, 10, $postal_code_a, $border, 0, 'L'); $pdf->setXY(122, 50); $pdf->Cell(10, 10, $postal_code_b, $border, 0, 'L'); //Business Number $pdf->setXY(138, 28); $pdf->Cell(120, 10, $company_obj->getBusinessNumber(), $border, 0, 'L'); //Pay Period Type $pdf->setXY(138, 40); $pdf->Cell(50, 10, $pay_period_type_options[$r_obj->getPayPeriodType()], $border, 0, 'L'); //SIN $pdf->setXY(138, 50); $pdf->Cell(50, 10, $user_obj->getSIN(), $border, 0, 'L'); //Employee info $pdf->SetFontSize(10); $pdf->setXY(10, 75); $pdf->Cell(90, 5, $user_obj->getFullName(), $border, 0, 'L'); $pdf->setXY(10, 80); $pdf->Cell(90, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L'); $pdf->setXY(10, 85); $pdf->Cell(90, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L'); $pdf->SetFontSize(12); //Employee Title if (is_object($user_obj->getTitleObject())) { $title = $user_obj->getTitleObject()->getName(); } else { $title = NULL; } $pdf->setXY(10, 100); $pdf->Cell(90, 10, $title, $border, 0, 'L'); //First Day Worked $pdf->SetFontSize(10); $first_date = getdate($r_obj->getFirstDate()); $pdf->setXY(175, 64); $pdf->Cell(8, 10, $first_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 64); $pdf->Cell(8, 10, $first_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 64); $pdf->Cell(10, 10, $first_date['year'], $border, 0, 'C'); //Last day paid $last_date = getdate($r_obj->getLastDate()); $pdf->setXY(175, 75); $pdf->Cell(8, 10, $last_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 75); $pdf->Cell(8, 10, $last_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 75); $pdf->Cell(10, 10, $last_date['year'], $border, 0, 'C'); //Pay Period End Date $pay_period_end_date = getdate($r_obj->getPayPeriodEndDate()); $pdf->setXY(175, 86); $pdf->Cell(8, 10, $pay_period_end_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 86); $pdf->Cell(8, 10, $pay_period_end_date['mon'], $border, 0, 'C'); $pdf->setXY(196, 86); $pdf->Cell(10, 10, $pay_period_end_date['year'], $border, 0, 'C'); //Insurable Hours $pdf->SetFontSize(10); $pdf->setXY(75, 113); $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableHours()), $border, 0, 'R'); $pdf->setXY(101, 113); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableHours(), FALSE)), $border, 0, 'L'); //Enter Code $pdf->setXY(185, 113); $pdf->Cell(10, 10, $r_obj->getCode(), $border, 0, 'C'); //Further Information Contact Name $pdf->setXY(130, 126); $pdf->Cell(75, 5, $created_user_obj->getFullName(), $border, 0, 'R'); $pdf->setXY(130, 132); $pdf->Cell(75, 10, $created_user_obj->getWorkPhone(), $border, 0, 'R'); //Insurable Earnings $pdf->setXY(75, 131); $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableEarnings()), $border, 0, 'R'); $pdf->setXY(101, 131); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableEarnings(), FALSE)), $border, 0, 'L'); //Check to see if a pay period didn't have earnings. if ($r_obj->isPayPeriodWithNoEarnings() == TRUE) { $pay_period_earnings = $r_obj->getInsurableEarningsByPayPeriod(); if (is_array($pay_period_earnings)) { //Add additional entries for testing alignment purposes. /* for( $y=0; $y < 14; $y++ ) { $pay_period_earnings[] = array('amount' => rand(1,10) ); } */ $top_left_x = $x = Misc::AdjustXY(30, 0); $top_left_y = $y = Misc::AdjustXY(157, 0); $col = 1; $i = 1; foreach ($pay_period_earnings as $pay_period_earning) { Debug::Text('I: ' . $i . ' X: ' . $x . ' Y: ' . $y . ' Col: ' . $col . ' Amount: ' . (double) $pay_period_earning['amount'], __FILE__, __LINE__, __METHOD__, 10); $pdf->setXY($x, $y); $pdf->Cell(6, 6, Misc::MoneyFormat((double) $pay_period_earning['amount'], FALSE), $border, 0, 'R'); if ($i > 0 and $i % 3 == 0) { $x = $top_left_x; $y += 7; } else { $x += 35; } $i++; } } } //Box 17A, Vacation pay in last pay period. $vacation_pay = $r_obj->getLastPayPeriodVacationEarnings(); if ($vacation_pay > 0) { $pdf->setXY(132, 155); $pdf->Cell(10, 10, Misc::getBeforeDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'R'); $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'L'); } //Comments $pdf->setXY(115, 212); $pdf->MultiCell(85, 5, $r_obj->getComments(), $border, 'L'); //English $pdf->setXY(8.5, 256.5); $pdf->Cell(10, 10, 'X', $border, 0, 'L'); //ROE creator phone number $pdf->setXY(75, 258); $pdf->Cell(25, 10, $created_user_obj->getWorkPhone(), $border, 0, 'L'); //ROE create name. $pdf->SetFontSize(12); $pdf->setXY(87, 273); $pdf->Cell(75, 10, $created_user_obj->getFullName(), $border, 0, 'C'); //Create Date $created_date = getdate($r_obj->getCreatedDate()); $pdf->SetFontSize(10); $pdf->setXY(175, 273); $pdf->Cell(8, 10, $created_date['mday'], $border, 0, 'C'); $pdf->setXY(185, 273); $pdf->Cell(8, 10, $created_date['mon'], $border, 0, 'C'); $pdf->setXY(195, 273); $pdf->Cell(10, 10, $created_date['year'], $border, 0, 'C'); } $output = $pdf->Output('', 'S'); } if (isset($output)) { return $output; } return FALSE; }
} else { $ppsf->setUser(array()); } if ($ppsf->isValid()) { $ppsf->Save(TRUE); //$ppsf->FailTransaction(); $ppsf->CommitTransaction(); Redirect::Page(URLBuilder::getURL(NULL, 'PayPeriodScheduleList.php')); break; } } $ppsf->FailTransaction(); default: if (isset($id)) { BreadCrumb::setCrumb($title); $ppslf = new PayPeriodScheduleListFactory(); $ppslf->GetByIdAndCompanyId($id, $current_company->getId()); foreach ($ppslf as $pay_period_schedule) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); $pay_period_schedule_data = array('id' => $pay_period_schedule->getId(), 'company_id' => $pay_period_schedule->getCompany(), 'name' => $pay_period_schedule->getName(), 'description' => $pay_period_schedule->getDescription(), 'type' => $pay_period_schedule->getType(), 'start_week_day_id' => $pay_period_schedule->getStartWeekDay(), 'start_day_of_week' => $pay_period_schedule->getStartDayOfWeek(), 'transaction_date' => $pay_period_schedule->getTransactionDate(), 'primary_day_of_month' => $pay_period_schedule->getPrimaryDayOfMonth(), 'secondary_day_of_month' => $pay_period_schedule->getSecondaryDayOfMonth(), 'primary_transaction_day_of_month' => $pay_period_schedule->getPrimaryTransactionDayOfMonth(), 'secondary_transaction_day_of_month' => $pay_period_schedule->getSecondaryTransactionDayOfMonth(), 'transaction_date_bd' => $pay_period_schedule->getTransactionDateBusinessDay(), 'anchor_date' => $pay_period_schedule->getAnchorDate(), 'annual_pay_periods' => $pay_period_schedule->getAnnualPayPeriods(), 'day_start_time' => $pay_period_schedule->getDayStartTime(), 'time_zone' => $pay_period_schedule->getTimeZone(), 'new_day_trigger_time' => $pay_period_schedule->getNewDayTriggerTime(), 'maximum_shift_time' => $pay_period_schedule->getMaximumShiftTime(), 'shift_assigned_day_id' => $pay_period_schedule->getShiftAssignedDay(), 'timesheet_verify_before_end_date' => (int) $pay_period_schedule->getTimeSheetVerifyBeforeEndDate(), 'timesheet_verify_before_transaction_date' => (int) $pay_period_schedule->getTimeSheetVerifyBeforeTransactionDate(), 'timesheet_verify_notice_before_transaction_date' => $pay_period_schedule->getTimeSheetVerifyNoticeBeforeTransactionDate(), 'timesheet_verify_notice_email' => $pay_period_schedule->getTimeSheetVerifyNoticeEmail(), 'user_ids' => $pay_period_schedule->getUser(), 'deleted' => $pay_period_schedule->getDeleted(), 'created_date' => $pay_period_schedule->getCreatedDate(), 'created_by' => $pay_period_schedule->getCreatedBy(), 'updated_date' => $pay_period_schedule->getUpdatedDate(), 'updated_by' => $pay_period_schedule->getUpdatedBy(), 'deleted_date' => $pay_period_schedule->getDeletedDate(), 'deleted_by' => $pay_period_schedule->getDeletedBy()); } } elseif ($action != 'submit') { $pay_period_schedule_data = array('anchor_date' => TTDate::getBeginMonthEpoch(time()), 'day_start_time' => 0, 'new_day_trigger_time' => 3600 * 4, 'maximum_shift_time' => 3600 * 16, 'time_zone' => $current_user_prefs->getTimeZone(), 'type' => 20, 'timesheet_verify_before_end_date' => 0, 'timesheet_verify_before_transaction_date' => 0, 'annual_pay_periods' => 0); } //Select box options; $pay_period_schedule_data['type_options'] = $ppsf->getOptions('type'); $pay_period_schedule_data['startweekday_options'] = $ppsf->getOptions('startweekday'); $pay_period_schedule_data['shift_assigned_day_options'] = $ppsf->getOptions('shift_assigned_day'); $pay_period_schedule_data['time_zone_options'] = $ppsf->getTimeZoneOptions(); $pay_period_schedule_data['transaction_date_bd_options'] = $ppsf->getOptions('transaction_date_business_day'); $pay_period_schedule_data['day_of_week_options'] = TTDate::getDayOfWeekArray();
function setPayPeriodSchedule($id) { $id = trim($id); $ppslf = new PayPeriodScheduleListFactory(); if ($id == 0 or $this->Validator->isResultSetWithRows('pay_period_schedule_id', $ppslf->getByID($id), TTi18n::gettext('Pay Period schedule is invalid'))) { $this->data['pay_period_schedule_id'] = $id; return TRUE; } return FALSE; }
function createPayPeriods() { $max_pay_periods = 29; $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getById($this->pay_period_schedule_id); if ($ppslf->getRecordCount() > 0) { $pps_obj = $ppslf->getCurrent(); for ($i = 0; $i < $max_pay_periods; $i++) { if ($i == 0) { //$end_date = TTDate::getBeginYearEpoch( strtotime('01-Jan-07') ); $end_date = TTDate::getBeginYearEpoch(time()); } else { $end_date = $end_date + 86400 * 14; } Debug::Text('I: ' . $i . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10); $pps_obj->createNextPayPeriod($end_date, 86400 * 3600); } } return TRUE; }
* $Revision: 2116 $ * $Id: AddPayPeriod.php 2116 2008-09-05 18:49:48Z ipso $ * $Date: 2008-09-05 11:49:48 -0700 (Fri, 05 Sep 2008) $ */ /* * Adds pay periods X hrs in advance, so schedules/shifts have something to attach to. * This file should/can be run as often as it needs to (once an hour) * */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; //If offset is only 24hrs then adding user_date rows can happen before the pay period //was added. Add pay periods 48hrs in advance now? $offset = 86400 * 2; //48hrs $ppslf = new PayPeriodScheduleListFactory(); $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { //Get all pay period schedules. $ppslf->getByCompanyId($c_obj->getId()); foreach ($ppslf as $pay_period_schedule) { $end_date = NULL; $pay_period_schedule->createNextPayPeriod($end_date, $offset); unset($ppf); unset($pay_period_schedule); } } }
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; }
function getPayPeriodScheduleObject() { if (is_object($this->pay_period_schedule_obj)) { return $this->pay_period_schedule_obj; } else { if ($this->getUser() > 0) { $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($this->getUser()); if ($ppslf->getRecordCount() == 1) { $this->pay_period_schedule_obj = $ppslf->getCurrent(); return $this->pay_period_schedule_obj; } } return FALSE; } }
$wage_data['wage_group_options'] = $wglf->getArrayByListFactory($wglf->getByCompanyId($current_company->getId()), TRUE); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($current_company->getId()); $currency_options = $crlf->getArrayByListFactory($crlf, FALSE, TRUE); $ulf = new UserListFactory(); $ulf->getByIdAndCompanyId($user_id, $current_company->getId()); $user_data = $ulf->getCurrent(); if (is_object($user_data->getCurrencyObject())) { $wage_data['currency_symbol'] = $user_data->getCurrencyObject()->getSymbol(); $wage_data['iso_code'] = $user_data->getCurrencyObject()->getISOCode(); } //Get pay period boundary dates for this user. //Include user hire date in the list. $pay_period_boundary_dates[TTDate::getDate('DATE', $user_data->getHireDate())] = TTi18n::gettext('(Hire Date)') . ' ' . TTDate::getDate('DATE', $user_data->getHireDate()); $pay_period_boundary_dates = Misc::prependArray(array(-1 => TTi18n::gettext('(Choose Date)')), $pay_period_boundary_dates); $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($user_id); if ($ppslf->getRecordCount() > 0) { $pay_period_schedule_id = $ppslf->getCurrent()->getId(); $pay_period_schedule_name = $ppslf->getCurrent()->getName(); Debug::Text('Pay Period Schedule ID: ' . $pay_period_schedule_id, __FILE__, __LINE__, __METHOD__, 10); $pplf = new PayPeriodListFactory(); $pplf->getByPayPeriodScheduleId($pay_period_schedule_id, 10, NULL, NULL, array('transaction_date' => 'desc')); $pay_period_dates = NULL; foreach ($pplf as $pay_period_obj) { //$pay_period_boundary_dates[TTDate::getDate('DATE', $pay_period_obj->getEndDate() )] = '('. $pay_period_schedule_name .') '.TTDate::getDate('DATE', $pay_period_obj->getEndDate() ); if (!isset($pay_period_boundary_dates[TTDate::getDate('DATE', $pay_period_obj->getStartDate())])) { $pay_period_boundary_dates[TTDate::getDate('DATE', $pay_period_obj->getStartDate())] = '(' . $pay_period_schedule_name . ') ' . TTDate::getDate('DATE', $pay_period_obj->getStartDate()); } } } else {
function postSave() { $this->removeCache($this->getId()); if ($this->getDeleted() == FALSE and $this->getPermissionControl() !== FALSE) { Debug::text('Permission Group is set...', __FILE__, __LINE__, __METHOD__, 10); $pclf = new PermissionControlListFactory(); $pclf->getByCompanyIdAndUserID($this->getCompany(), $this->getId()); if ($pclf->getRecordCount() > 0) { Debug::text('Already assigned to a Permission Group...', __FILE__, __LINE__, __METHOD__, 10); $pc_obj = $pclf->getCurrent(); if ($pc_obj->getId() == $this->getPermissionControl()) { $add_permission_control = FALSE; } else { Debug::text('Permission Group has changed...', __FILE__, __LINE__, __METHOD__, 10); //Remove user from current schedule. $pulf = new PermissionUserListFactory(); $pulf->getByPermissionControlIdAndUserID($pc_obj->getId(), $this->getId()); Debug::text('Record Count: ' . $pulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($pulf->getRecordCount() > 0) { foreach ($pulf as $pu_obj) { Debug::text('Deleteing from Permission Group: ' . $pu_obj->getPermissionControl(), __FILE__, __LINE__, __METHOD__, 10); $pu_obj->Delete(); } } $add_permission_control = TRUE; } } else { Debug::text('NOT Already assigned to a Permission Group...', __FILE__, __LINE__, __METHOD__, 10); $add_permission_control = TRUE; } if ($this->getPermissionControl() !== FALSE and $add_permission_control == TRUE) { Debug::text('Adding user to Permission Group...', __FILE__, __LINE__, __METHOD__, 10); //Add to new permission group $puf = new PermissionUserFactory(); $puf->setPermissionControl($this->getPermissionControl()); $puf->setUser($this->getID()); if ($puf->isValid()) { $puf->Save(); //Clear permission class for this employee. $pf = new PermissionFactory(); $pf->clearCache($this->getID(), $this->getCompany()); } } unset($add_permission_control); } if ($this->getDeleted() == FALSE and $this->getPayPeriodSchedule() !== FALSE) { Debug::text('Pay Period Schedule is set...', __FILE__, __LINE__, __METHOD__, 10); $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($this->getId()); if ($ppslf->getRecordCount() > 0) { $pps_obj = $ppslf->getCurrent(); if ($this->getPayPeriodSchedule() == $pps_obj->getId()) { Debug::text('Already assigned to this Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10); $add_pay_period_schedule = FALSE; } else { Debug::text('Changing Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10); //Remove user from current schedule. $ppsulf = new PayPeriodScheduleUserListFactory(); $ppsulf->getByPayPeriodScheduleIdAndUserID($pps_obj->getId(), $this->getId()); Debug::text('Record Count: ' . $ppsulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($ppsulf->getRecordCount() > 0) { foreach ($ppsulf as $ppsu_obj) { Debug::text('Deleteing from Pay Period Schedule: ' . $ppsu_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10); $ppsu_obj->Delete(); } } $add_pay_period_schedule = TRUE; } } else { Debug::text('Not assigned to ANY Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10); $add_pay_period_schedule = TRUE; } if ($this->getPayPeriodSchedule() !== FALSE and $add_pay_period_schedule == TRUE) { //Add to new pay period schedule $ppsuf = new PayPeriodScheduleUserFactory(); $ppsuf->setPayPeriodSchedule($this->getPayPeriodSchedule()); $ppsuf->setUser($this->getID()); if ($ppsuf->isValid()) { $ppsuf->Save(); } } unset($add_pay_period_schedule); } if ($this->getDeleted() == FALSE and $this->getPolicyGroup() !== FALSE) { Debug::text('Policy Group is set...', __FILE__, __LINE__, __METHOD__, 10); $pglf = new PolicyGroupListFactory(); $pglf->getByUserIds($this->getId()); if ($pglf->getRecordCount() > 0) { $pg_obj = $pglf->getCurrent(); if ($this->getPolicyGroup() == $pg_obj->getId()) { Debug::text('Already assigned to this Policy Group...', __FILE__, __LINE__, __METHOD__, 10); $add_policy_group = FALSE; } else { Debug::text('Changing Policy Group...', __FILE__, __LINE__, __METHOD__, 10); //Remove user from current schedule. $pgulf = new PolicyGroupUserListFactory(); $pgulf->getByPolicyGroupIdAndUserId($pg_obj->getId(), $this->getId()); Debug::text('Record Count: ' . $pgulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($pgulf->getRecordCount() > 0) { foreach ($pgulf as $pgu_obj) { Debug::text('Deleteing from Policy Group: ' . $pgu_obj->getPolicyGroup(), __FILE__, __LINE__, __METHOD__, 10); $pgu_obj->Delete(); } } $add_policy_group = TRUE; } } else { Debug::text('Not assigned to ANY Policy Group...', __FILE__, __LINE__, __METHOD__, 10); $add_policy_group = TRUE; } if ($this->getPolicyGroup() !== FALSE and $add_policy_group == TRUE) { //Add to new policy group $pguf = new PolicyGroupUserFactory(); $pguf->setPolicyGroup($this->getPolicyGroup()); $pguf->setUser($this->getID()); if ($pguf->isValid()) { $pguf->Save(); } } unset($add_policy_group); } if ($this->getDeleted() == FALSE and $this->getHierarchyControl() !== FALSE) { Debug::text('Hierarchies are set...', __FILE__, __LINE__, __METHOD__, 10); $hierarchy_control_data = array_unique(array_values((array) $this->getHierarchyControl())); //Debug::Arr($hierarchy_control_data, 'Setting hierarchy control data...', __FILE__, __LINE__, __METHOD__, 10); if (is_array($hierarchy_control_data)) { $hclf = new HierarchyControlListFactory(); $hclf->getObjectTypeAppendedListByCompanyIDAndUserID($this->getCompany(), $this->getID()); $existing_hierarchy_control_data = array_unique(array_values((array) $hclf->getArrayByListFactory($hclf, FALSE, TRUE, FALSE))); //Debug::Arr($existing_hierarchy_control_data, 'Existing hierarchy control data...', __FILE__, __LINE__, __METHOD__, 10); $hierarchy_control_delete_diff = array_diff($existing_hierarchy_control_data, $hierarchy_control_data); //Debug::Arr($hierarchy_control_delete_diff, 'Hierarchy control delete diff: ', __FILE__, __LINE__, __METHOD__, 10); //Remove user from existing hierarchy control if (is_array($hierarchy_control_delete_diff)) { foreach ($hierarchy_control_delete_diff as $hierarchy_control_id) { if ($hierarchy_control_id != 0) { $hulf = new HierarchyUserListFactory(); $hulf->getByHierarchyControlAndUserID($hierarchy_control_id, $this->getID()); if ($hulf->getRecordCount() > 0) { Debug::text('Deleting user from hierarchy control ID: ' . $hierarchy_control_id, __FILE__, __LINE__, __METHOD__, 10); $hulf->getCurrent()->Delete(); } } } } unset($hierarchy_control_delete_diff, $hulf, $hclf, $hierarchy_control_id); $hierarchy_control_add_diff = array_diff($hierarchy_control_data, $existing_hierarchy_control_data); //Debug::Arr($hierarchy_control_add_diff, 'Hierarchy control add diff: ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($hierarchy_control_add_diff)) { foreach ($hierarchy_control_add_diff as $hierarchy_control_id) { Debug::text('Hierarchy data changed...', __FILE__, __LINE__, __METHOD__, 10); if ($hierarchy_control_id != 0) { $huf = new HierarchyUserFactory(); $huf->setHierarchyControl($hierarchy_control_id); $huf->setUser($this->getId()); if ($huf->isValid()) { Debug::text('Adding user to hierarchy control ID: ' . $hierarchy_control_id, __FILE__, __LINE__, __METHOD__, 10); $huf->Save(); } } } } unset($hierarchy_control_add, $huf, $hierarchy_control_id); } } if (isset($this->is_new) and $this->is_new == TRUE) { $udlf = new UserDefaultListFactory(); $udlf->getByCompanyId($this->getCompany()); if ($udlf->getRecordCount() > 0) { Debug::Text('Using User Defaults', __FILE__, __LINE__, __METHOD__, 10); $udf_obj = $udlf->getCurrent(); Debug::text('Inserting Default Deductions...', __FILE__, __LINE__, __METHOD__, 10); $company_deduction_ids = $udf_obj->getCompanyDeduction(); if (is_array($company_deduction_ids) and count($company_deduction_ids) > 0) { foreach ($company_deduction_ids as $company_deduction_id) { $udf = new UserDeductionFactory(); $udf->setUser($this->getId()); $udf->setCompanyDeduction($company_deduction_id); if ($udf->isValid()) { $udf->Save(); } } } unset($company_deduction_ids, $company_deduction_id, $udf); Debug::text('Inserting Default Prefs...', __FILE__, __LINE__, __METHOD__, 10); $upf = new UserPreferenceFactory(); $upf->setUser($this->getId()); $upf->setLanguage($udf_obj->getLanguage()); $upf->setDateFormat($udf_obj->getDateFormat()); $upf->setTimeFormat($udf_obj->getTimeFormat()); $upf->setTimeUnitFormat($udf_obj->getTimeUnitFormat()); $upf->setTimeZone($udf_obj->getTimeZone()); $upf->setItemsPerPage($udf_obj->getItemsPerPage()); $upf->setStartWeekDay($udf_obj->getStartWeekDay()); $upf->setEnableEmailNotificationException($udf_obj->getEnableEmailNotificationException()); $upf->setEnableEmailNotificationMessage($udf_obj->getEnableEmailNotificationMessage()); $upf->setEnableEmailNotificationHome($udf_obj->getEnableEmailNotificationHome()); if ($upf->isValid()) { $upf->Save(); } } } if ($this->getDeleted() == TRUE) { //Remove them from the authorization hierarchy, policy group, and pay period schedule. //Delete any accruals for them as well. //Pay Period Schedule $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($this->getId()); if ($ppslf->getRecordCount() > 0) { $pps_obj = $ppslf->getCurrent(); //Remove user from current schedule. $ppsulf = new PayPeriodScheduleUserListFactory(); $ppsulf->getByPayPeriodScheduleIdAndUserID($pps_obj->getId(), $this->getId()); Debug::text('Record Count: ' . $ppsulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($ppsulf->getRecordCount() > 0) { foreach ($ppsulf as $ppsu_obj) { Debug::text('Deleteing from Pay Period Schedule: ' . $ppsu_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10); $ppsu_obj->Delete(); } } } //Policy Group $pglf = new PolicyGroupListFactory(); $pglf->getByUserIds($this->getId()); if ($pglf->getRecordCount() > 0) { $pg_obj = $pglf->getCurrent(); $pgulf = new PolicyGroupUserListFactory(); $pgulf->getByPolicyGroupIdAndUserId($pg_obj->getId(), $this->getId()); Debug::text('Record Count: ' . $pgulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($pgulf->getRecordCount() > 0) { foreach ($pgulf as $pgu_obj) { Debug::text('Deleteing from Policy Group: ' . $pgu_obj->getPolicyGroup(), __FILE__, __LINE__, __METHOD__, 10); $pgu_obj->Delete(); } } } //Hierarchy $hclf = new HierarchyControlListFactory(); $hclf->getByCompanyId($this->getCompany()); if ($hclf->getRecordCount() > 0) { foreach ($hclf as $hc_obj) { $hf = new HierarchyListFactory(); $hf->setUser($this->getID()); $hf->setHierarchyControl($hc_obj->getId()); $hf->Delete(); } $hf->removeCache(NULL, $hf->getTable(TRUE)); //On delete we have to delete the entire group. unset($hf); } //Accrual balances $alf = new AccrualListFactory(); $alf->getByUserIdAndCompanyId($this->getId(), $this->getCompany()); if ($alf->getRecordCount() > 0) { foreach ($alf as $a_obj) { $a_obj->setDeleted(TRUE); if ($a_obj->isValid()) { $a_obj->Save(); } } } } return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through all pay period schedules and update the annual pay period column $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getAll(); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $pps_obj->setAnnualPayPeriods($pps_obj->calcAnnualPayPeriods()); if ($pps_obj->isValid()) { $pps_obj->Save(); } } } //Go through all employee wages and update HourlyRate to the accurate annual hourly rate. //**Handle this in 1034A postInstall() instead, as it needs to handle incorrect effective_dates properly. /* $uwlf = new UserWageListFactory(); $uwlf->getAll(); if ( $uwlf->getRecordCount() > 0 ) { foreach( $uwlf as $uw_obj ) { $uw_obj->setHourlyRate( $uw_obj->calcHourlyRate( time(), TRUE ) ); if ( $uw_obj->isValid() ) { $uw_obj->Save(); } } } */ //Upgrade to new hierarchy format. $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { /* if ( !($c_obj->getId() == 1052) ) { //$c_obj->getId() == 1009 OR $c_obj->getId() == 1087 OR continue; } */ $company_id = $c_obj->getId(); Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); $hclf = new HierarchyControlListFactory(); $hclf->StartTransaction(); $hclf->getByCompanyId($company_id); if ($hclf->getRecordCount() > 0) { foreach ($hclf as $hc_obj) { $paths_to_root = array(); $hierarchy_id = $hc_obj->getId(); $hlf = new HierarchyListFactory(); $hierarchy_users = $hlf->getByCompanyIdAndHierarchyControlId($company_id, $hierarchy_id); if (is_array($hierarchy_users) and count($hierarchy_users) > 0) { $hotlf = new HierarchyObjectTypeListFactory(); $hotlf->getByHierarchyControlId($hierarchy_id); if ($hotlf->getRecordCount() > 0) { foreach ($hotlf as $hot_obj) { $object_types[$hierarchy_id][] = $hot_obj->getObjectType(); } } foreach ($hierarchy_users as $hierarchy_user_arr) { Debug::Text(' Checking User ID: ' . $hierarchy_user_arr['id'], __FILE__, __LINE__, __METHOD__, 10); $id = $hierarchy_user_arr['id']; $tmp_id = $id; $i = 0; do { Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10); $hlf_b = new HierarchyListFactory(); $parents = $hlf_b->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id); sort($parents); $level = $hlf_b->getFastTreeObject()->getLevel($tmp_id) - 1; if (is_array($parents) and count($parents) > 0) { $parent_users = array(); foreach ($parents as $user_id) { $parent_users[] = $user_id; unset($user); } $parent_groups[$level] = $parent_users; unset($parent_users); } if (isset($parents[0])) { $tmp_id = $parents[0]; } $i++; } while (is_array($parents) and count($parents) > 0 and $i < 100); if (isset($parent_groups)) { $serialized_path = serialize($parent_groups); $paths_to_root[$serialized_path][] = $id; unset($serialized_path); } unset($parent_groups, $parents); } } Debug::Arr($paths_to_root, ' Paths To Root: ', __FILE__, __LINE__, __METHOD__, 10); //Decode path_to_root array if (isset($paths_to_root) and count($paths_to_root) > 0) { foreach ($paths_to_root as $serialized_path => $children) { $path_arr = unserialize($serialized_path); $decoded_paths[] = array('hierarchy_control_id' => $hierarchy_id, 'path' => $path_arr, 'children' => $children); } unset($path_arr, $children); Debug::Arr($decoded_paths, ' Decoded Paths: ', __FILE__, __LINE__, __METHOD__, 10); if (isset($decoded_paths) and is_array($decoded_paths)) { foreach ($decoded_paths as $decoded_path) { Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10); //Create new hierarchy_control $hcf = new HierarchyControlFactory(); $hcf->setCompany($company_id); $hcf->setObjectType($object_types[$decoded_path['hierarchy_control_id']]); //Generate meaningful name $name = FALSE; if (isset($decoded_path['path']) and is_array($decoded_path['path'])) { ksort($decoded_path['path']); //Sort by level. foreach ($decoded_path['path'] as $level => $superior_ids) { foreach ($superior_ids as $superior_id) { $ulf = new UserListFactory(); $ulf->getById($superior_id); if ($ulf->getRecordCount() > 0) { $name[] = $level . '. ' . $ulf->getCurrent()->getFullName(); } } } unset($level, $superior_ids, $superior_id); } if (isset($name)) { $name = $hc_obj->getName() . ' ' . implode(', ', $name) . ' (#' . rand(1000, 9999) . ')'; } else { $name = $hc_obj->getName() . ' (#' . rand(1000, 9999) . ')'; } $hcf->setName(substr($name, 0, 249)); $hcf->setDescription(TTi18n::getText('Automatically created by TimeTrex')); if ($hcf->isValid()) { $hc_id = $hcf->Save(FALSE); Debug::Text('Hierarchy Control ID: ' . $hc_id, __FILE__, __LINE__, __METHOD__, 10); $hcf->setUser($decoded_path['children']); if (isset($decoded_path['path']) and is_array($decoded_path['path'])) { foreach ($decoded_path['path'] as $level => $superior_ids) { foreach ($superior_ids as $superior_id) { $hlf = new HierarchyLevelFactory(); $hlf->setHierarchyControl($hc_id); $hlf->setLevel($level); $hlf->setUser($superior_id); if ($hlf->isValid()) { $hlf->Save(); Debug::Text('Saving Level Row ID... User ID: ' . $superior_id, __FILE__, __LINE__, __METHOD__, 10); } } } unset($level, $superior_ids, $superior_id); } } } } unset($decoded_paths); } //Delete existing hierarchy control. $hc_obj->setDeleted(TRUE); if ($hc_obj->isValid() == TRUE) { $hc_obj->Save(); } } } //$hclf->FailTransaction(); $hclf->CommitTransaction(); } } } //Go through each permission group, and enable break policies for anyone who can see meal policies $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); if ($c_obj->getStatus() != 30) { $pclf = new PermissionControlListFactory(); $pclf->getByCompanyId($c_obj->getId()); if ($pclf->getRecordCount() > 0) { foreach ($pclf as $pc_obj) { Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $plf = new PermissionListFactory(); $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'meal_policy', 'enabled'); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with meal policy enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('break_policy' => array('enabled' => TRUE, 'view' => TRUE, 'add' => TRUE, 'edit' => TRUE, 'delete' => TRUE))); } else { Debug::text('Permission group does NOT have meal policy enabled...', __FILE__, __LINE__, __METHOD__, 9); } } } } } } //Add MiscDaily cronjob to database. $cjf = new CronJobFactory(); $cjf->setName('MiscDaily'); $cjf->setMinute(55); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand('MiscDaily.php'); $cjf->Save(); //Add MiscWeekly cronjob to database. $cjf = new CronJobFactory(); $cjf->setName('MiscWeekly'); $cjf->setMinute(55); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('0'); //Sunday morning. $cjf->setCommand('MiscWeekly.php'); $cjf->Save(); return TRUE; }
break; case 'delete' or 'undelete': if (strtolower($action) == 'delete') { $delete = TRUE; } else { $delete = FALSE; } $ppslf = new PayPeriodScheduleListFactory(); foreach ($ids as $id) { $ppslf->GetByIdAndCompanyId($id, $current_company->getId()); foreach ($ppslf as $pay_period_schedule) { $pay_period_schedule->setDeleted($delete); $pay_period_schedule->Save(); } } Redirect::Page(URLBuilder::getURL(NULL, 'PayPeriodScheduleList.php')); break; default: $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order)); $pager = new Pager($ppslf); foreach ($ppslf as $pay_period_schedule) { $pay_period_schedules[] = array('id' => $pay_period_schedule->getId(), 'company_id' => $pay_period_schedule->getCompany(), 'name' => $pay_period_schedule->getName(), 'description' => $pay_period_schedule->getDescription(), 'type' => Option::getByKey($pay_period_schedule->getType(), $pay_period_schedule->getOptions('type')), 'deleted' => $pay_period_schedule->getDeleted()); } $smarty->assign_by_ref('pay_period_schedules', $pay_period_schedules); $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('payperiod/PayPeriodScheduleList.tpl');
static function smartReCalculate($user_id, $user_date_ids, $enable_exception = TRUE, $enable_premature_exceptions = FALSE, $enable_future_exceptions = TRUE) { if ($user_id == '') { return FALSE; } //Debug::Arr($user_date_ids, 'aUser Date IDs: ', __FILE__, __LINE__, __METHOD__, 10); if (!is_array($user_date_ids) and is_int($user_date_ids)) { $user_date_ids = array($user_date_ids); } if (!is_array($user_date_ids)) { return FALSE; } $user_date_ids = array_unique($user_date_ids); //Debug::Arr($user_date_ids, 'bUser Date IDs: ', __FILE__, __LINE__, __METHOD__, 10); $start_week_day_id = 0; $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByUserId($user_id); if ($ppslf->getRecordCount() == 1) { $pps_obj = $ppslf->getCurrent(); $start_week_day_id = $pps_obj->getStartWeekDay(); } Debug::text('Start Week Day ID: ' . $start_week_day_id, __FILE__, __LINE__, __METHOD__, 10); //Get date stamps for all user_date_ids. $udlf = new UserDateListFactory(); $udlf->getByIds($user_date_ids, NULL, array('date_stamp' => 'asc')); //Order by date asc if ($udlf->getRecordCount() > 0) { //Order them, and get the one or more sets of date ranges that need to be recalculated. //Need to consider re-calculating multiple weeks at once. $i = 0; foreach ($udlf as $ud_obj) { $start_week_epoch = TTDate::getBeginWeekEpoch($ud_obj->getDateStamp(), $start_week_day_id); $end_week_epoch = TTDate::getEndWeekEpoch($ud_obj->getDateStamp(), $start_week_day_id); Debug::text('Current Date: ' . TTDate::getDate('DATE', $ud_obj->getDateStamp()) . ' Start Week: ' . TTDate::getDate('DATE', $start_week_epoch) . ' End Week: ' . TTDate::getDate('DATE', $end_week_epoch), __FILE__, __LINE__, __METHOD__, 10); if ($i == 0) { $range_arr[$start_week_epoch] = array('start_date' => $ud_obj->getDateStamp(), 'end_date' => $end_week_epoch); } else { //Loop through each range extending it if needed. foreach ($range_arr as $tmp_start_week_epoch => $tmp_range) { if ($ud_obj->getDateStamp() >= $tmp_range['start_date'] and $ud_obj->getDateStamp() <= $tmp_range['end_date']) { //Date falls within already existing range continue; } elseif ($ud_obj->getDateStamp() < $tmp_range['start_date'] and $ud_obj->getDateStamp() >= $tmp_start_week_epoch) { //Date falls within the same week, but before the current start date. $range_arr[$tmp_start_week_epoch]['start_date'] = $ud_obj->getDateStamp(); Debug::text('Pushing Start Date back...', __FILE__, __LINE__, __METHOD__, 10); } else { //Outside current range. Check to make sure it isn't within another range. if (isset($range_arr[$start_week_epoch])) { //Within another existing week, check to see if we need to extend it. if ($ud_obj->getDateStamp() < $range_arr[$start_week_epoch]['start_date']) { Debug::text('bPushing Start Date back...', __FILE__, __LINE__, __METHOD__, 10); $range_arr[$start_week_epoch]['start_date'] = $ud_obj->getDateStamp(); } } else { //Not within another existing week Debug::text('Adding new range...', __FILE__, __LINE__, __METHOD__, 10); $range_arr[$start_week_epoch] = array('start_date' => $ud_obj->getDateStamp(), 'end_date' => $end_week_epoch); } } } unset($tmp_range, $tmp_start_week_epoch); } $i++; } unset($start_week_epoch, $end_week_epoch, $udlf, $ud_obj); if (is_array($range_arr)) { ksort($range_arr); //Sort range by start week, so recalculating goes in date order. //Debug::Arr($range_arr, 'Range Array: ', __FILE__, __LINE__, __METHOD__, 10); foreach ($range_arr as $week_range) { $udlf = new UserDateListFactory(); $udlf->getByUserIdAndStartDateAndEndDate($user_id, $week_range['start_date'], $week_range['end_date']); if ($udlf->getRecordCount() > 0) { Debug::text('Found days to re-calculate: ' . $udlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $udlf->StartTransaction(); $z = 1; $z_max = $udlf->getRecordCount(); foreach ($udlf as $ud_obj) { //We only need to re-calculate exceptions on the exact days specified by user_date_ids. //This was the case before we Over Weekly Time/Over Scheduled Weekly Time exceptions, //Now we have to enable calculating exceptions for the entire week. /* if ( in_array( $ud_obj->getId(), $user_date_ids ) ) { //Calculate exceptions Debug::text('Re-calculating day with exceptions: '. $ud_obj->getId() , __FILE__, __LINE__, __METHOD__, 10); UserDateTotalFactory::reCalculateDay( $ud_obj->getId(), $enable_exception, $enable_premature_exceptions, $enable_future_exceptions ); } else { //Don't calculate exceptions. UserDateTotalFactory::reCalculateDay( $ud_obj->getId() ); } */ Debug::text('Re-calculating day with exceptions: ' . $ud_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); if ($z == $z_max) { //Enable recalculating holidays at the end of each week. UserDateTotalFactory::reCalculateDay($ud_obj->getId(), $enable_exception, $enable_premature_exceptions, $enable_future_exceptions, TRUE); } else { UserDateTotalFactory::reCalculateDay($ud_obj->getId(), $enable_exception, $enable_premature_exceptions, $enable_future_exceptions); } $z++; } $udlf->CommitTransaction(); } } return TRUE; } } Debug::text('Returning FALSE!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
Redirect::Page(URLBuilder::getURL(array('id' => $data['pay_period_schedule_id']), 'PayPeriodList.php')); break; } $ppf->FailTransaction(); default: if (isset($id)) { BreadCrumb::setCrumb($title); $pplf = new PayPeriodListFactory(); $pplf->getByIdAndCompanyId($id, $current_company->getId()); foreach ($pplf as $pp_obj) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); $data = array('id' => $pp_obj->getId(), 'company_id' => $pp_obj->getCompany(), 'pay_period_schedule_id' => $pp_obj->getPayPeriodSchedule(), 'pay_period_schedule_type_id' => $pp_obj->getPayPeriodScheduleObject()->getType(), 'start_date' => $pp_obj->getStartDate(), 'end_date' => $pp_obj->getEndDate(), 'transaction_date' => $pp_obj->getTransactionDate(), 'advance_end_date' => $pp_obj->getAdvanceEndDate(), 'advance_transaction_date' => $pp_obj->getAdvanceTransactionDate(), 'deleted' => $pp_obj->getDeleted(), 'created_date' => $pp_obj->getCreatedDate(), 'created_by' => $pp_obj->getCreatedBy(), 'updated_date' => $pp_obj->getUpdatedDate(), 'updated_by' => $pp_obj->getUpdatedBy(), 'deleted_date' => $pp_obj->getDeletedDate(), 'deleted_by' => $pp_obj->getDeletedBy()); } } else { if (isset($pay_period_schedule_id) and $pay_period_schedule_id != '') { $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByIdAndCompanyId($pay_period_schedule_id, $current_company->getId()); if ($ppslf->getRecordCount() > 0) { $data['pay_period_schedule_type_id'] = $ppslf->getCurrent()->getType(); } $data['pay_period_schedule_id'] = $pay_period_schedule_id; //Get end date of previous pay period, and default the start date of the new pay period to that. $pplf = new PayPeriodListFactory(); $pplf->getByPayPeriodScheduleId($pay_period_schedule_id, 1, NULL, NULL, array('start_date' => 'desc')); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { $data['start_date'] = $pp_obj->getEndDate() + 1; $data['end_date'] = $pp_obj->getEndDate() + 86400; } } }
* Adds a user_date row for every ACTIVE user, every day * This fixes a limitation when employees are switched from one pay period * schedule to another, then they click on a day without a user_date row. * TimeTrex doesn't know which pay period the day belongs too. * * * Run this twice a day. AFTER AddPayPeriod if possible. */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php'; $clf = new CompanyListFactory(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() != 30) { $ppslf = new PayPeriodScheduleListFactory(); $ulf = new UserListFactory(); $ulf->getByCompanyId($c_obj->getId()); if ($ulf->getRecordCount() > 0) { $i = 0; foreach ($ulf as $u_obj) { if ($u_obj->getStatus() != 10) { continue; } Debug::text($i . '. User: ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 10); //Find the pay period schedule for each user and change the timezone to that of the pay period schedule. $ppslf->getByCompanyIdAndUserId($c_obj->getId(), $u_obj->getId()); if ($ppslf->getRecordCount() > 0) { $pps_obj = $ppslf->getCurrent(); $pps_obj->setPayPeriodTimeZone(); //Insert user date row for TOMORROW.
function createPayPeriodSchedule($type, $start_dow, $transaction_dow, $primary_dom, $secondary_dom, $primary_transaction_dom, $secondary_transaction_dom, $transaction_bd, $day_start_time = '00:00') { $ppsf = new PayPeriodScheduleFactory(); $ppsf->setCompany($this->company_id); Debug::text('zzzCompany ID: ' . $this->company_id, __FILE__, __LINE__, __METHOD__, 10); $ppsf->setName('test_' . rand(1000, 99999)); $ppsf->setDescription('test'); /* 20 => 'Bi-Weekly', 30 => 'Semi-Monthly', 40 => 'Monthly + Advance' */ $ppsf->setType($type); $day_start_time = TTDate::parseTimeUnit($day_start_time); Debug::text('parsed Day Start Time: ' . $day_start_time, __FILE__, __LINE__, __METHOD__, 10); $ppsf->setDayStartTime($day_start_time); if ($type == 10 or $type == 20) { $ppsf->setStartDayOfWeek($start_dow); $ppsf->setTransactionDate($transaction_dow); } elseif ($type == 30) { $ppsf->setPrimaryDayOfMonth($primary_dom); $ppsf->setSecondaryDayOfMonth($secondary_dom); $ppsf->setPrimaryTransactionDayOfMonth($primary_transaction_dom); $ppsf->setSecondaryTransactionDayOfMonth($secondary_transaction_dom); } elseif ($type == 50) { $ppsf->setPrimaryDayOfMonth($primary_dom); $ppsf->setPrimaryTransactionDayOfMonth($primary_transaction_dom); } $ppsf->setTransactionDateBusinessDay((bool) $transaction_bd); $ppsf->setTimeZone('PST8PDT'); $ppsf->setEnableInitialPayPeriods(FALSE); if ($ppsf->isValid()) { $pp_schedule_id = $ppsf->Save(); $ppslf = new PayPeriodScheduleListFactory(); $ret_obj = $ppslf->getById($pp_schedule_id)->getCurrent(); return $ret_obj; } return FALSE; }
if (isset($pay_period_obj) and is_object($pay_period_obj)) { Debug::text('Pay Period Object Found!', __FILE__, __LINE__, __METHOD__, 10); $is_assigned_pay_period_schedule = TRUE; //Don't use assign_by_ref for these as that seems to trigger a fatal error in PHP v5.0.4 $smarty->assign('pay_period_id', $pay_period_obj->getId()); $smarty->assign('pay_period_start_date', $pay_period_obj->getStartDate()); $smarty->assign('pay_period_end_date', $pay_period_obj->getEndDate()); $smarty->assign('pay_period_verify_window_start_date', $pay_period_obj->getTimeSheetVerifyWindowStartDate()); $smarty->assign('pay_period_verify_window_end_date', $pay_period_obj->getTimeSheetVerifyWindowEndDate()); $smarty->assign('pay_period_transaction_date', $pay_period_obj->getTransactionDate()); $smarty->assign('pay_period_is_locked', $pay_period_obj->getIsLocked()); $smarty->assign('pay_period_status_id', $pay_period_obj->getStatus()); } else { Debug::text('Pay Period Object NOT Found!', __FILE__, __LINE__, __METHOD__, 10); //Check to see if employee is even assigned to pay period schedule. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyIdAndUserId($current_company->getId(), $user_id); if ($ppslf->getRecordCount() > 0) { Debug::text('Pay Period Schedule Found!', __FILE__, __LINE__, __METHOD__, 10); $is_assigned_pay_period_schedule = TRUE; } } $smarty->assign_by_ref('is_assigned_pay_period_schedule', $is_assigned_pay_period_schedule); $action_options = array('0' => TTi18n::gettext('-- Select Action --'), 'recalculate employee' => TTi18n::gettext('Recalculate Employee'), 'recalculate company' => TTi18n::gettext('Recalculate Company')); if ($permission->Check('pay_period_schedule', 'enabled') and ($permission->Check('pay_period_schedule', 'edit') or $permission->Check('pay_period_schedule', 'edit_own'))) { $action_options['recalculate pay stub'] = TTi18n::gettext('Recalculate Pay Stub'); } if (isset($pay_period_obj) and is_object($pay_period_obj) and $pay_period_obj->getStatus() == 30) { //Add a spacer so its less likely for someone to accidently hit "Recalc Pay Stub" //instead of calculate adjustment. $action_options['-1'] = '---';
function getByCompanyIdArray($company_id, $include_blank = TRUE) { $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyId($company_id); if ($include_blank == TRUE) { $list[0] = '--'; } foreach ($ppslf as $pps_obj) { $list[$pps_obj->getID()] = $pps_obj->getName(); } if (isset($list)) { return $list; } return FALSE; }
//Get default branch list $blf = new BranchListFactory(); $branch_options = $blf->getByCompanyIdArray($current_company->getId()); $dlf = new DepartmentListFactory(); $department_options = $dlf->getByCompanyIdArray($current_company->getId()); $pclf = new PermissionControlListFactory(); $pclf->getByCompanyId($current_company->getId()); $permission_control_options = $pclf->getArrayByListFactory($pclf, TRUE); $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_options = $ppslf->getByCompanyIDArray($current_company->getId()); $pglf = new PolicyGroupListFactory(); $policy_group_options = $pglf->getByCompanyIDArray($current_company->getId()); $pclf = new PermissionControlListFactory(); $pclf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $permission_control_user_map = $pclf->getUserToPermissionControlMapArrayByListFactory($pclf); $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $pay_period_schedule_user_map = $ppslf->getUserToPayPeriodScheduleMapArrayByListFactory($ppslf); $pglf = new PolicyGroupListFactory(); $pglf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']); $policy_group_user_map = $pglf->getUserToPolicyGroupMapArrayByListFactory($pglf); $crlf = new CurrencyListFactory(); $crlf->getByCompanyId($current_company->getId()); $currency_options = $crlf->getArrayByListFactory($crlf, FALSE, TRUE); $upf = new UserPreferenceFactory(); $language_options = TTi18n::getLanguageArray(); $date_format_options = $upf->getOptions('date_format'); $time_format_options = $upf->getOptions('time_format'); $time_unit_format_options = $upf->getOptions('time_unit_format'); $timesheet_view_options = $upf->getOptions('timesheet_view'); $start_week_day_options = $upf->getOptions('start_week_day');
//Select box options; $user_data['branch_options'] = $branch_options; $user_data['department_options'] = $department_options; $user_data['currency_options'] = $currency_options; $cf = new CompanyFactory(); $user_data['country_options'] = $cf->getOptions('country'); $user_data['province_options'] = $cf->getOptions('province', $user_data['country']); $utlf = new UserTitleListFactory(); $user_titles = $utlf->getByCompanyIdArray($current_company->getId()); $user_data['title_options'] = $user_titles; //Get Permission Groups $pclf = new PermissionControlListFactory(); $pclf->getByCompanyId($current_company->getId()); $user_data['permission_control_options'] = $pclf->getArrayByListFactory($pclf, FALSE); //Get pay period schedules $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedules = $ppslf->getByCompanyIDArray($current_company->getId()); $user_data['pay_period_schedule_options'] = $pay_period_schedules; $pglf = new PolicyGroupListFactory(); $policy_groups = $pglf->getByCompanyIDArray($current_company->getId()); $user_data['policy_group_options'] = $policy_groups; $user_data['company'] = $current_company->getName(); $user_data['language_options'] = TTi18n::getLanguageArray(); $user_data['date_format_options'] = $upf->getOptions('date_format'); $user_data['other_date_format_options'] = $upf->getOptions('other_date_format'); $user_data['time_format_options'] = $upf->getOptions('time_format'); $user_data['time_unit_format_options'] = $upf->getOptions('time_unit_format'); $user_data['timesheet_view_options'] = $upf->getOptions('timesheet_view'); $user_data['start_week_day_options'] = $upf->getOptions('start_week_day'); $timezone_options = Misc::prependArray(array(-1 => '---'), $upf->getOptions('time_zone')); $user_data['time_zone_options'] = $timezone_options;
unset($pay_stub_entries); 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(); 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;
function getPayPeriodScheduleObject() { if (is_object($this->pay_period_schedule_obj)) { return $this->pay_period_schedule_obj; } else { $ppslf = new PayPeriodScheduleListFactory(); $this->pay_period_schedule_obj = $ppslf->getById($this->getPayPeriodObject()->getPayPeriodSchedule())->getCurrent(); return $this->pay_period_schedule_obj; } }
function postSave() { if ($this->getEnableInitialPayPeriods() == TRUE and $this->getCreateInitialPayPeriods() == TRUE) { $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedule_obj = $ppslf->getById($this->getId())->getCurrent(); $pay_period_schedule_obj->createNextPayPeriod($pay_period_schedule_obj->getAnchorDate()); Debug::text('New Pay Period Schdule, creating pay periods start from (' . $pay_period_schedule_obj->getAnchorDate() . '): ' . TTDate::getDate('DATE+TIME', $pay_period_schedule_obj->getAnchorDate()), __FILE__, __LINE__, __METHOD__, 10); //Create pay periods up until now, at most 104. for ($i = 0; $i <= 104; $i++) { if ($pay_period_schedule_obj->createNextPayPeriod() == FALSE) { Debug::text('createNextPayPeriod returned false, stopping loop.', __FILE__, __LINE__, __METHOD__, 10); break; } } } $this->CommitTransaction(); return TRUE; }
$user_data['department_options'] = $department_options; $user_data['currency_options'] = $currency_options; $user_data['sex_options'] = $uf->getOptions('sex'); $user_data['status_options'] = $uf->getOptions('status'); $clf = new CompanyListFactory(); $user_data['country_options'] = $clf->getOptions('country'); $user_data['province_options'] = $clf->getOptions('province', $user_data['country']); $utlf = new UserTitleListFactory(); $user_titles = $utlf->getByCompanyIdArray($company_id); $user_data['title_options'] = $user_titles; //Get Permission Groups $pclf = new PermissionControlListFactory(); $pclf->getByCompanyId($company_id); $user_data['permission_control_options'] = $pclf->getArrayByListFactory($pclf, FALSE); //Get pay period schedules $ppslf = new PayPeriodScheduleListFactory(); $pay_period_schedules = $ppslf->getByCompanyIDArray($company_id); $user_data['pay_period_schedule_options'] = $pay_period_schedules; $pglf = new PolicyGroupListFactory(); $policy_groups = $pglf->getByCompanyIDArray($company_id); $user_data['policy_group_options'] = $policy_groups; $uglf = new UserGroupListFactory(); $user_data['group_options'] = $uglf->getArrayByNodes(FastTree::FormatArray($uglf->getByCompanyIdArray($company_id), 'TEXT', TRUE)); //Get other field names $oflf = new OtherFieldListFactory(); $user_data['other_field_names'] = $oflf->getByCompanyIdAndTypeIdArray($company_id, 10); $user_data['hierarchy_object_type_options'] = $hierarchy_object_type_options; $user_data['hierarchy_control_options'] = $hierarchy_control_options; //Company list. if ($permission->Check('company', 'view')) { $user_data['company_options'] = CompanyListFactory::getAllArray();
//Get the last time cron ran this script. $cjlf = new CronJobListFactory(); $cjlf->getByName('calcExceptions'); if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cj_obj) { $tmp_start_date = $cj_obj->getLastRunDate(); if ($tmp_start_date < $start_date) { $start_date = $tmp_start_date; Debug::text(' CRON Job hasnt run in more then 48hrs, reducing Start Date to: ' . TTDate::getDate('DATE+TIME', $start_date), __FILE__, __LINE__, __METHOD__, 5); } } } unset($cjlf, $cj_obj, $tmp_start_date); //Get maximum shift time for each pay period schedule, so we know how far back //we have to recalculate days at the minimum. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getByCompanyId($c_obj->getId()); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $tmp_start_date = TTDate::getMiddleDayEpoch($execution_time) - $pps_obj->getMaximumShiftTime(); if ($tmp_start_date < $start_date) { $start_date = $tmp_start_date; Debug::text(' Maximum Shift Time is greater then 48hrs, reducing Start Date to: ' . TTDate::getDate('DATE+TIME', $start_date), __FILE__, __LINE__, __METHOD__, 5); } } } unset($ppslf, $pps_obj, $tmp_start_date); //Get earliest pre_mature exception in a NON-closed pay period. $elf = new ExceptionListFactory(); $elf->getByCompanyIDAndTypeAndPayPeriodStatus($c_obj->getId(), 5, array(10, 12, 15, 30), 1, NULL, NULL, array('b.date_stamp' => 'asc')); //Limit 1
$pplf = new PayPeriodListFactory(); $pplf->StartTransaction(); foreach ($ids as $pay_period_id) { $pplf->GetByIdAndCompanyId($pay_period_id, $current_company->getId()); foreach ($pplf as $pay_period) { $pay_period->setDeleted($delete); $pay_period->Save(); } } //$pplf->FailTransaction(); $pplf->CommitTransaction(); Redirect::Page(URLBuilder::getURL(array('id' => $id), 'PayPeriodList.php')); break; default: $pplf = new PayPeriodListFactory(); $ppslf = new PayPeriodScheduleListFactory(); //$pplf->GetByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); //$pplf->GetByPayPeriodScheduleId($id, $current_user_prefs->getItemsPerPage(), $page, NULL, array($sort_column => $sort_order) ); $pplf->getByPayPeriodScheduleId($id, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array); $pager = new Pager($pplf); if ($pplf->getRecordCount() >= 1) { if (is_numeric($projected_pay_periods)) { $max_projected_pay_periods = $projected_pay_periods; } else { $max_projected_pay_periods = 1; } } else { $max_projected_pay_periods = 24; } Debug::Text('Projected Pay Periods: ' . $max_projected_pay_periods, __FILE__, __LINE__, __METHOD__, 10); //Now project in to the future X pay periods...