本文整理汇总了PHP中TTDate::getHours方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getHours方法的具体用法?PHP TTDate::getHours怎么用?PHP TTDate::getHours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getHours方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPayStub
//.........这里部分代码省略.........
}
$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++;
}
示例2: bcsub
} else {
$tmp_rows[$pay_period_id][$user_id][$date_stamp][$column] = (int) $udt_obj->getColumn('total_time');
}
if (isset($tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time'])) {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time'] += $udt_obj->getColumn('actual_total_time');
} else {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time'] = $udt_obj->getColumn('actual_total_time');
}
$actual_time_diff = bcsub($udt_obj->getColumn('actual_total_time'), $udt_obj->getColumn('total_time'));
if (isset($tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time_diff'])) {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time_diff'] += $actual_time_diff;
} else {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time_diff'] = $actual_time_diff;
}
if (isset($user_wage[$user_id])) {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time_diff_wage'] = Misc::MoneyFormat(bcmul(TTDate::getHours($actual_time_diff), $user_wage[$user_id]), FALSE);
} else {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['actual_time_diff_wage'] = Misc::MoneyFormat(0, FALSE);
}
unset($actual_time_diff);
} elseif ($column != NULL) {
if ($udt_obj->getColumn('total_time') > 0) {
//Total up all absence time.
if ($status_id == 30 and $type_id == 10) {
if (isset($tmp_rows[$pay_period_id][$user_id][$date_stamp]['absence_time'])) {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['absence_time'] += $udt_obj->getColumn('total_time');
} else {
$tmp_rows[$pay_period_id][$user_id][$date_stamp]['absence_time'] = $udt_obj->getColumn('total_time');
}
}
if ($status_id == 10 and $type_id == 30) {
示例3: getAnnualHourlyRate
function getAnnualHourlyRate($annual_wage, $epoch = FALSE, $accurate_calculation = FALSE)
{
if ($epoch == FALSE) {
$epoch = TTDate::getTime();
}
if ($annual_wage == '') {
return FALSE;
}
if ($accurate_calculation == TRUE) {
Debug::text('EPOCH: ' . $epoch, __FILE__, __LINE__, __METHOD__, 10);
$annual_week_days = TTDate::getAnnualWeekDays($epoch);
Debug::text('Annual Week Days: ' . $annual_week_days, __FILE__, __LINE__, __METHOD__, 10);
//Calculate weeks from adjusted annual weekdays
//We could use just 52 weeks in a year, but that isn't as accurate.
$annual_work_weeks = bcdiv($annual_week_days, 5);
Debug::text('Adjusted annual work weeks : ' . $annual_work_weeks, __FILE__, __LINE__, __METHOD__, 10);
} else {
$annual_work_weeks = 52;
}
$average_weekly_hours = TTDate::getHours($this->getWeeklyTime());
//Debug::text('Average Weekly Hours: '. $average_weekly_hours , __FILE__, __LINE__, __METHOD__,10);
if ($average_weekly_hours == 0) {
//No default schedule, can't pay them.
$hourly_wage = 0;
} else {
//Divide by average hours/day from default schedule?
$hours_per_year = bcmul($annual_work_weeks, $average_weekly_hours);
if ($hours_per_year > 0) {
$hourly_wage = bcdiv($annual_wage, $hours_per_year);
}
unset($hours_per_year);
}
//Debug::text('User Wage: '. $this->getWage() , __FILE__, __LINE__, __METHOD__,10);
//Debug::text('Annual Hourly Rate: '. $hourly_wage , __FILE__, __LINE__, __METHOD__,10);
return $hourly_wage;
}
示例4: reCalculate
function reCalculate()
{
//Re-generate final pay stub
//get current pay period based off their last day of work
$pplf = TTnew('PayPeriodListFactory');
$pay_period_id = $pplf->getByUserIdAndEndDate($this->getUser(), $this->getLastDate())->getCurrent()->getId();
Debug::Text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
if (is_numeric($pay_period_id) == FALSE) {
UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub'), 10, TTi18n::gettext('Pay Period is invalid!'), NULL);
return FALSE;
}
if ($this->getEnableGeneratePayStub() == TRUE) {
//Find out if a pay stub is already generated for the pay period we are currently in.
//If it is, delete it so we can start from fresh
$pslf = TTnew('PayStubListFactory');
$pslf->getByUserIdAndPayPeriodId($this->getUser(), $pay_period_id);
foreach ($pslf as $pay_stub) {
Debug::Text('Found Pay Stub ID: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10);
//Do not delete PAID pay stubs!
if ($pay_stub->getStatus() == 10) {
Debug::Text('Last Pay Stub Exists: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setDeleted(TRUE);
$pay_stub->Save();
}
}
//FIXME: Make sure user isn't already in-active! Otherwise pay stub won't generate.
//Check if pay stub is already generated as well, if it is, and marked paid, then
//we can't re-generate it, we need to skip this step.
Debug::Text('Calculating Pay Stub...', __FILE__, __LINE__, __METHOD__, 10);
$cps = new CalculatePayStub();
$cps->setUser($this->getUser());
$cps->setPayPeriod($pay_period_id);
$cps->calculate();
Debug::Text('Done Calculating Pay Stub', __FILE__, __LINE__, __METHOD__, 10);
} else {
UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE), 20, TTi18n::gettext('Not generating final pay stub!'), NULL);
}
//FIXME: Alert the user if they don't have enough information in TimeTrex to get accurate values.
//Get insurable hours, earnings, and vacation pay now that the final pay stub is generated
$ugdlf = TTnew('UserGenericDataListFactory');
$ugdlf->getByCompanyIdAndScriptAndDefault($this->getUserObject()->getCompany(), $this->getTable());
if ($ugdlf->getRecordCount() > 0) {
Debug::Text('Found Company Form Setup!', __FILE__, __LINE__, __METHOD__, 10);
$ugd_obj = $ugdlf->getCurrent();
$setup_data = $ugd_obj->getData();
}
unset($ugd_obj);
$absence_policy_ids = array();
$insurable_earnings_psea_ids = array();
if (isset($setup_data)) {
//var_dump($setup_data);
if (isset($setup_data['insurable_earnings_psea_ids'])) {
$insurable_earnings_psea_ids = $setup_data['insurable_earnings_psea_ids'];
} else {
//Fall back to Total Gross.
$insurable_earnings_psea_ids = $this->getPayStubEntryAccountLinkObject()->getTotalGross();
}
if (isset($setup_data['absence_policy_ids'])) {
$absence_policy_ids = $setup_data['absence_policy_ids'];
}
}
//Find out the date of how far back we have to go to get insurable values.
//Insurable Hours
$insurable_hours_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableHoursReportPayPeriods());
//All worked time and overtime is considered insurable.
$udtlf = TTnew('UserDateTotalListFactory');
$worked_total_time = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($this->getUser(), $insurable_hours_start_date, $this->getLastDate());
Debug::text('Worked Total Time: ' . $worked_total_time, __FILE__, __LINE__, __METHOD__, 10);
//User definable absence policies for insurable hours.
$absence_total_time = $udtlf->getAbsenceTimeSumByUserIDAndAbsenceIDAndStartDateAndEndDate($this->getUser(), $absence_policy_ids, $insurable_hours_start_date, $this->getLastDate());
Debug::text('Absence Total Time: ' . $absence_total_time, __FILE__, __LINE__, __METHOD__, 10);
$total_hours = Misc::MoneyFormat(TTDate::getHours($worked_total_time + $absence_total_time), FALSE);
Debug::Text('Total Insurable Hours: ' . $total_hours, __FILE__, __LINE__, __METHOD__, 10);
$insurable_earnings_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableEarningsReportPayPeriods());
$pself = TTnew('PayStubEntryListFactory');
$total_earnings = $this->getTotalInsurableEarnings();
//Note, this includes the current pay stub we just generated
Debug::Text('Total Insurable Earnings: ' . $total_earnings, __FILE__, __LINE__, __METHOD__, 10);
UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Record of Employment'), 30, TTi18n::gettext('Insurable Hours:') . ' ' . $total_hours . ' ' . TTi18n::gettext('Insurable Earnings:') . ' ' . $total_earnings, NULL);
//ReSave these
if ($this->getId() != '') {
$rlf = TTnew('ROEListFactory');
$rlf->getById($this->getId());
if ($rlf->getRecordCount() > 0) {
$roe_obj = $rlf->getCurrent();
$roe_obj->setInsurableHours($total_hours);
$roe_obj->setInsurableEarnings($total_earnings);
if ($roe_obj->isValid()) {
$roe_obj->Save();
}
}
}
return TRUE;
}
示例5: calcSystemTotalTime
function calcSystemTotalTime()
{
global $profiler;
$profiler->startTimer("UserDateTotal::calcSystemTotalTime() - Part 1");
if (is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()) and $this->getUserDateObject()->getPayPeriodObject()->getStatus() == 20) {
Debug::text(' Pay Period is closed!', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
//Take the worked hours, and calculate Total,Regular,Overtime,Premium hours from that.
//This is where many of the policies will be applied
//Such as any meal/overtime/premium policies.
$return_value = FALSE;
$udtlf = new UserDateTotalListFactory();
$this->deleteSystemTotalTime();
//We can't assign a dock absence to a given branch/dept automatically,
//Because several punches with different branches could fall within a schedule punch pair.
//Just total up entire day, and entire scheduled time to see if we're over/under
//FIXME: Handle multiple schedules on a single day better.
$schedule_total_time = 0;
$meal_policy_obj = NULL;
$slf = new ScheduleListFactory();
$profiler->startTimer("UserDateTotal::calcSystemTotalTime() - Holiday");
//Check for Holidays
$holiday_time = 0;
$hlf = new HolidayListFactory();
$hlf->getByPolicyGroupUserIdAndDate($this->getUserDateObject()->getUser(), $this->getUserDateObject()->getDateStamp());
if ($hlf->getRecordCount() > 0) {
$holiday_obj = $hlf->getCurrent();
Debug::text(' Found Holiday: ' . $holiday_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
if ($holiday_obj->isEligible($this->getUserDateObject()->getUser())) {
Debug::text(' User is Eligible for Holiday: ' . $holiday_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
$holiday_time = $holiday_obj->getHolidayTime($this->getUserDateObject()->getUser());
Debug::text(' User average time for Holiday: ' . TTDate::getHours($holiday_time), __FILE__, __LINE__, __METHOD__, 10);
if ($holiday_time > 0 and $holiday_obj->getHolidayPolicyObject()->getAbsencePolicyID() != FALSE) {
Debug::text(' Adding Holiday hours: ' . TTDate::getHours($holiday_time), __FILE__, __LINE__, __METHOD__, 10);
$udtf = new UserDateTotalFactory();
$udtf->setUserDateID($this->getUserDateID());
$udtf->setStatus(30);
//Absence
$udtf->setType(10);
//Total
$udtf->setBranch($this->getUserDateObject()->getUserObject()->getDefaultBranch());
$udtf->setDepartment($this->getUserDateObject()->getUserObject()->getDefaultDepartment());
$udtf->setAbsencePolicyID($holiday_obj->getHolidayPolicyObject()->getAbsencePolicyID());
$udtf->setTotalTime($holiday_time);
$udtf->setEnableCalcSystemTotalTime(FALSE);
if ($udtf->isValid()) {
$udtf->Save();
}
}
}
$slf->getByUserDateIdAndStatusId($this->getUserDateID(), 20);
$schedule_absence_total_time = 0;
if ($slf->getRecordCount() > 0) {
//Check for schedule policy
foreach ($slf as $s_obj) {
Debug::text(' Schedule Absence Total Time: ' . $s_obj->getTotalTime(), __FILE__, __LINE__, __METHOD__, 10);
$schedule_absence_total_time += $s_obj->getTotalTime();
if (is_object($s_obj->getSchedulePolicyObject()) and $s_obj->getSchedulePolicyObject()->getAbsencePolicyID() > 0) {
$holiday_absence_policy_id = $s_obj->getSchedulePolicyObject()->getAbsencePolicyID();
Debug::text(' Found Absence Policy for docking: ' . $holiday_absence_policy_id, __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text(' NO Absence Policy : ', __FILE__, __LINE__, __METHOD__, 10);
}
}
}
$holiday_total_under_time = $schedule_absence_total_time - $holiday_time;
if (isset($holiday_absence_policy_id) and $holiday_total_under_time > 0) {
Debug::text(' Schedule Under Time Case: ' . $holiday_total_under_time, __FILE__, __LINE__, __METHOD__, 10);
$udtf = new UserDateTotalFactory();
$udtf->setUserDateID($this->getUserDateID());
$udtf->setStatus(30);
//Absence
$udtf->setType(10);
//Total
$udtf->setBranch($this->getUserDateObject()->getUserObject()->getDefaultBranch());
$udtf->setDepartment($this->getUserDateObject()->getUserObject()->getDefaultDepartment());
$udtf->setAbsencePolicyID($holiday_absence_policy_id);
$udtf->setTotalTime($holiday_total_under_time);
$udtf->setEnableCalcSystemTotalTime(FALSE);
if ($udtf->isValid()) {
$udtf->Save();
}
}
unset($holiday_total_under_time, $holiday_absence_policy_id, $schedule_absence_total_time);
}
$profiler->stopTimer("UserDateTotal::calcSystemTotalTime() - Holiday");
//Do this after holiday policies have been applied, so if someone
//schedules a holiday manually, we don't double up on the time.
$slf->getByUserDateId($this->getUserDateID());
if ($slf->getRecordCount() > 0) {
//Check for schedule policy
foreach ($slf as $s_obj) {
Debug::text(' Schedule Total Time: ' . $s_obj->getTotalTime(), __FILE__, __LINE__, __METHOD__, 10);
if ($s_obj->getStatus() == 20 and $s_obj->getAbsencePolicyID() != '') {
Debug::text(' Scheduled Absence Found of Total Time: ' . $s_obj->getTotalTime(), __FILE__, __LINE__, __METHOD__, 10);
//If a holiday policy is applied on this day, ignore the schedule so we don't duplicate it.
//We could take the difference, and use the greatest of the two,
//But I think that will just open the door for errors.
if (!isset($holiday_obj) or $holiday_time == 0 and is_object($holiday_obj) and $holiday_obj->getHolidayPolicyObject()->getAbsencePolicyID() != $s_obj->getAbsencePolicyID()) {
//.........这里部分代码省略.........
示例6: _getData
function _getData($format = NULL)
{
$this->tmp_data = array('schedule' => array(), 'user' => array(), 'total_shift' => array());
$columns = $this->getColumnDataConfig();
$filter_data = $this->getFilterConfig();
if ($this->getPermissionObject()->Check('schedule', 'view') == FALSE or $this->getPermissionObject()->Check('wage', 'view') == FALSE) {
$hlf = TTnew('HierarchyListFactory');
$permission_children_ids = $wage_permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($this->getUserObject()->getCompany(), $this->getUserObject()->getID());
Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10);
} else {
//Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
$permission_children_ids = array();
$wage_permission_children_ids = array();
}
if ($this->getPermissionObject()->Check('schedule', 'view') == FALSE) {
if ($this->getPermissionObject()->Check('schedule', 'view_child') == FALSE) {
$permission_children_ids = array();
}
if ($this->getPermissionObject()->Check('schedule', 'view_own')) {
$permission_children_ids[] = $this->getUserObject()->getID();
}
$filter_data['permission_children_ids'] = $permission_children_ids;
}
//Get Wage Permission Hierarchy Children first, as this can be used for viewing, or editing.
if ($this->getPermissionObject()->Check('wage', 'view') == TRUE) {
$wage_permission_children_ids = TRUE;
} elseif ($this->getPermissionObject()->Check('wage', 'view') == FALSE) {
if ($this->getPermissionObject()->Check('wage', 'view_child') == FALSE) {
$wage_permission_children_ids = array();
}
if ($this->getPermissionObject()->Check('wage', 'view_own')) {
$wage_permission_children_ids[] = $this->getUserObject()->getID();
}
}
//Debug::Text(' Permission Children: '. count($permission_children_ids) .' Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($permission_children_ids, 'Permission Children: '. count($permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($wage_permission_children_ids, 'Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10);
if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) {
$jlf = TTnew('JobListFactory');
$job_status_options = $jlf->getOptions('status');
} else {
$job_status_options = array();
}
$pay_period_ids = array();
if (strpos($format, 'schedule') === FALSE) {
//Avoid running these queries when printing out the schedule.
$slf = TTnew('ScheduleListFactory');
$slf->getScheduleSummaryReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data, NULL, NULL, NULL, array('last_name' => 'asc'));
//Sort by last name mainly for the PDF schedule for printing.
Debug::Text(' Total Rows: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
$this->getProgressBarObject()->start($this->getAMFMessageID(), $slf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
if ($slf->getRecordCount() > 0) {
foreach ($slf as $key => $s_obj) {
$hourly_rate = 0;
if ($wage_permission_children_ids === TRUE or in_array($s_obj->getColumn('user_id'), $wage_permission_children_ids)) {
$hourly_rate = $s_obj->getColumn('user_wage_hourly_rate');
}
$date_stamp_epoch = TTDate::strtotime($s_obj->getColumn('date_stamp'));
$shift_arr = array('user_id' => $s_obj->getColumn('user_id'), 'status_id' => $s_obj->getColumn('status_id'), 'group' => $s_obj->getColumn('group'), 'default_branch' => $s_obj->getColumn('default_branch'), 'default_department' => $s_obj->getColumn('default_department'), 'branch' => $s_obj->getColumn('branch'), 'department' => $s_obj->getColumn('department'), 'job' => $s_obj->getColumn('job'), 'job_status_id' => Option::getByKey($s_obj->getColumn('job_status_id'), $job_status_options, NULL), 'job_manual_id' => $s_obj->getColumn('job_manual_id'), 'job_description' => $s_obj->getColumn('job_description'), 'job_branch' => $s_obj->getColumn('job_branch'), 'job_department' => $s_obj->getColumn('job_department'), 'job_group' => $s_obj->getColumn('job_group'), 'job_item' => $s_obj->getColumn('job_item'), 'quantity' => $s_obj->getColumn('quantity'), 'bad_quantity' => $s_obj->getColumn('bad_quantity'), 'total_time' => $s_obj->getColumn('total_time'), 'total_time_wage' => Misc::MoneyFormat(bcmul(TTDate::getHours($s_obj->getColumn('total_time')), $hourly_rate), FALSE), 'total_time_wage_burden' => Misc::MoneyFormat(bcmul(TTDate::getHours($s_obj->getColumn('total_time')), bcmul($hourly_rate, bcdiv($s_obj->getColumn('user_labor_burden_percent'), 100))), FALSE), 'total_time_wage_with_burden' => Misc::MoneyFormat(bcmul(TTDate::getHours($s_obj->getColumn('total_time')), bcmul($hourly_rate, bcadd(bcdiv($s_obj->getColumn('user_labor_burden_percent'), 100), 1))), FALSE), 'other_id1' => $s_obj->getColumn('other_id1'), 'other_id2' => $s_obj->getColumn('other_id2'), 'other_id3' => $s_obj->getColumn('other_id3'), 'other_id4' => $s_obj->getColumn('other_id4'), 'other_id5' => $s_obj->getColumn('other_id5'), 'date_stamp' => $date_stamp_epoch, 'schedule_policy' => $s_obj->getColumn('schedule_policy'), 'absence_policy' => $s_obj->getColumn('absence_policy'), 'schedule_status' => Option::getByKey($s_obj->getStatus(), $s_obj->getOptions('status'), NULL), 'start_time' => TTDate::strtotime($s_obj->getColumn('start_time')), 'end_time' => TTDate::strtotime($s_obj->getColumn('end_time')), 'user_wage_id' => $s_obj->getColumn('user_wage_id'), 'hourly_rate' => Misc::MoneyFormat($hourly_rate, FALSE), 'pay_period_start_date' => strtotime($s_obj->getColumn('pay_period_start_date')), 'pay_period_end_date' => strtotime($s_obj->getColumn('pay_period_end_date')), 'pay_period_transaction_date' => strtotime($s_obj->getColumn('pay_period_transaction_date')), 'pay_period' => strtotime($s_obj->getColumn('pay_period_transaction_date')), 'pay_period_id' => $s_obj->getColumn('pay_period_id'), 'schedule_note' => $s_obj->getColumn('note'), 'total_shift' => 1);
unset($hourly_rate);
$this->tmp_data['schedule'][$s_obj->getColumn('user_id')][] = $shift_arr;
$this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
}
}
//Debug::Arr($this->tmp_data['schedule'], 'Schedule Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($this->form_data, 'Schedule Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
}
unset($filter_data['status_id']);
//This is for schedule status, not user status.
//If we're printing the schedule, make sure we include the required columns.
if (in_array($format, $this->special_output_format)) {
$this->config['columns_data']['first_name'] = TRUE;
$this->config['columns_data']['last_name'] = TRUE;
}
//Get user data for joining.
$ulf = TTnew('UserListFactory');
$ulf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
Debug::Text(' User Total Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
$this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...'));
foreach ($ulf as $key => $u_obj) {
$this->tmp_data['user'][$u_obj->getId()] = $this->form_data['user'][$u_obj->getId()] = (array) $u_obj->getObjectAsArray($this->getColumnDataConfig());
$this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
}
//Add OPEN user to the list so it can printed on schedules.
$this->tmp_data['user'][0] = $this->form_data['user'][0] = array('first_name' => TTi18n::getText('OPEN'), 'last_name' => '');
//Debug::Arr($this->tmp_data['user'], 'User Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
return TRUE;
}
示例7: isActiveLengthOfService
function isActiveLengthOfService($u_obj, $epoch)
{
if ($this->getMinimumLengthOfServiceUnit() == 50 or $this->getMaximumLengthOfServiceUnit() == 50) {
//Hour based length of service, get users hours up until this period.
$worked_time = TTDate::getHours($this->getWorkedTimeByUserIdAndEndDate($u_obj->getId(), $epoch));
Debug::Text(' Worked Time: ' . $worked_time . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
}
$employed_days = TTDate::getDays($epoch - $u_obj->getHireDate());
Debug::Text(' Employed Days: ' . $employed_days, __FILE__, __LINE__, __METHOD__, 10);
$minimum_length_of_service_result = FALSE;
$maximum_length_of_service_result = FALSE;
//Check minimum length of service
if ($this->getMinimumLengthOfService() == 0 or $this->getMinimumLengthOfServiceUnit() == 50 and $worked_time >= $this->getMinimumLengthOfService() or $this->getMinimumLengthOfServiceUnit() != 50 and $employed_days >= $this->getMinimumLengthOfServiceDays()) {
$minimum_length_of_service_result = TRUE;
}
//Check maximum length of service.
if ($this->getMaximumLengthOfService() == 0 or $this->getMaximumLengthOfServiceUnit() == 50 and $worked_time <= $this->getMaximumLengthOfService() or $this->getMaximumLengthOfServiceUnit() != 50 and $employed_days <= $this->getMaximumLengthOfServiceDays()) {
$maximum_length_of_service_result = TRUE;
}
Debug::Text(' Min Result: : ' . (int) $minimum_length_of_service_result . ' Max Result: ' . (int) $maximum_length_of_service_result, __FILE__, __LINE__, __METHOD__, 10);
if ($minimum_length_of_service_result == TRUE and $maximum_length_of_service_result == TRUE) {
return TRUE;
}
return FALSE;
}
示例8: getAverageTime
function getAverageTime($user_id)
{
$udtlf = new UserDateTotalListFactory();
//Check if Min and Max time is the same, if so we can skip any averaging.
if ($this->getHolidayPolicyObject()->getMinimumTime() > 0 and $this->getHolidayPolicyObject()->getMaximumTime() > 0 and $this->getHolidayPolicyObject()->getMinimumTime() == $this->getHolidayPolicyObject()->getMaximumTime()) {
Debug::text('Min and Max times are equal.', __FILE__, __LINE__, __METHOD__, 10);
return $this->getHolidayPolicyObject()->getMinimumTime();
}
if ($this->getHolidayPolicyObject()->getAverageTimeWorkedDays() == TRUE) {
$last_days_worked_count = $udtlf->getDaysWorkedByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
} else {
Debug::text('NOT Using worked days!', __FILE__, __LINE__, __METHOD__, 10);
$last_days_worked_count = $this->getHolidayPolicyObject()->getAverageTimeDays();
}
Debug::text('Last Days Worked:' . $last_days_worked_count, __FILE__, __LINE__, __METHOD__, 10);
if ($this->getHolidayPolicyObject()->getIncludeOverTime() == TRUE) {
Debug::text('Including OverTime!', __FILE__, __LINE__, __METHOD__, 10);
$total_seconds_worked = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
} else {
Debug::text('NOT Including OverTime!', __FILE__, __LINE__, __METHOD__, 10);
$total_seconds_worked = $udtlf->getRegularTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
}
if ($this->getHolidayPolicyObject()->getIncludePaidAbsenceTime() == TRUE) {
Debug::text('Including Paid Absence Time!', __FILE__, __LINE__, __METHOD__, 10);
$total_seconds_worked += $udtlf->getPaidAbsenceTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
} else {
Debug::text('NOT Including Paid Absence Time!', __FILE__, __LINE__, __METHOD__, 10);
}
if ($last_days_worked_count > 0) {
$avg_seconds_worked_per_day = bcdiv($total_seconds_worked, $last_days_worked_count);
Debug::text('AVG hours worked per day:' . TTDate::getHours($avg_seconds_worked_per_day), __FILE__, __LINE__, __METHOD__, 10);
} else {
$avg_seconds_worked_per_day = 0;
}
if ($this->getHolidayPolicyObject()->getMaximumTime() > 0 and $avg_seconds_worked_per_day > $this->getHolidayPolicyObject()->getMaximumTime()) {
$avg_seconds_worked_per_day = $this->getHolidayPolicyObject()->getMaximumTime();
Debug::text('AVG hours worked per day exceeds maximum regulars hours per day, setting to:' . $avg_seconds_worked_per_day / 60 / 60, __FILE__, __LINE__, __METHOD__, 10);
}
if ($avg_seconds_worked_per_day < $this->getHolidayPolicyObject()->getMinimumTime()) {
$avg_seconds_worked_per_day = $this->getHolidayPolicyObject()->getMinimumTime();
Debug::text('AVG hours worked per day is less then minimum regulars hours per day, setting to:' . $avg_seconds_worked_per_day / 60 / 60, __FILE__, __LINE__, __METHOD__, 10);
}
//Round to nearest 15mins.
if ((int) $this->getHolidayPolicyObject()->getRoundIntervalPolicyID() != 0 and is_object($this->getHolidayPolicyObject()->getRoundIntervalPolicyObject())) {
$avg_seconds_worked_per_day = TTDate::roundTime($avg_seconds_worked_per_day, $this->getHolidayPolicyObject()->getRoundIntervalPolicyObject()->getInterval(), $this->getHolidayPolicyObject()->getRoundIntervalPolicyObject()->getRoundType());
Debug::text('Rounding Stat Time To: ' . $avg_seconds_worked_per_day, __FILE__, __LINE__, __METHOD__, 10);
} else {
Debug::text('NOT Rounding Stat Time!', __FILE__, __LINE__, __METHOD__, 10);
}
return $avg_seconds_worked_per_day;
}
示例9: array
$filter_data['job_item_ids'] = array(-1);
}
//$plf->getReportByStartDateAndEndDateAndUserIdListAndBranchIdAndDepartmentIdAndJobIdListAndJobItemIdList( $filter_data['start_date'], $filter_data['end_date'], $filter_data['user_ids'], $filter_data['punch_branch_ids'], $filter_data['punch_department_ids'], $filter_data['job_ids'], $filter_data['job_item_ids'] );
$plf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
foreach ($plf as $p_obj) {
//Debug::Text('User ID: '. $p_obj->getColumn('user_id') .' Status ID: '. $p_obj->getColumn('status_id') .' Time Stamp: '. TTDate::getDate('DATE+TIME', TTDate::strtotime( $p_obj->getColumn('punch_time_stamp') ) ), __FILE__, __LINE__, __METHOD__,10);
if (!isset($tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')])) {
$hourly_rate = 0;
if ($permission->Check('wage', 'view') == TRUE or in_array($p_obj->getColumn('user_id'), $wage_filter_data['permission_children_ids']) == TRUE) {
$uw_obj = getUserWageObject($p_obj->getColumn('user_wage_id'), $p_obj->getColumn('user_id'));
if (is_object($uw_obj)) {
$hourly_rate = $uw_obj->getHourlyRate();
}
}
$actual_time_diff = (int) $p_obj->getColumn('actual_total_time') - (int) $p_obj->getColumn('total_time');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')] = array('user_id' => $p_obj->getColumn('user_id'), 'group_id' => $p_obj->getColumn('group_id'), 'branch_id' => $p_obj->getColumn('branch_id'), 'department_id' => $p_obj->getColumn('department_id'), 'job_id' => $p_obj->getColumn('job_id'), 'job_name' => $p_obj->getColumn('job_name'), 'job_status_id' => $p_obj->getColumn('job_status_id'), 'job_manual_id' => $p_obj->getColumn('job_manual_id'), 'job_description' => $p_obj->getColumn('job_description'), 'job_branch_id' => $p_obj->getColumn('job_branch_id'), 'job_department_id' => $p_obj->getColumn('job_department_id'), 'job_group_id' => $p_obj->getColumn('job_group_id'), 'job_item_id' => $p_obj->getColumn('job_item_id'), 'quantity' => $p_obj->getColumn('quantity'), 'bad_quantity' => $p_obj->getColumn('bad_quantity'), 'note' => $p_obj->getColumn('note'), 'total_time' => $p_obj->getColumn('total_time'), 'total_time_wage' => Misc::MoneyFormat(bcmul(TTDate::getHours($p_obj->getColumn('total_time')), $hourly_rate), FALSE), 'actual_total_time' => $p_obj->getColumn('actual_total_time'), 'actual_total_time_diff' => $actual_time_diff, 'actual_total_time_wage' => Misc::MoneyFormat(bcmul(TTDate::getHours($p_obj->getColumn('actual_total_time')), $hourly_rate), FALSE), 'actual_total_time_diff_wage' => Misc::MoneyFormat(bcmul(TTDate::getHours($actual_time_diff), $hourly_rate)), 'other_id1' => $p_obj->getColumn('other_id1'), 'other_id2' => $p_obj->getColumn('other_id2'), 'other_id3' => $p_obj->getColumn('other_id3'), 'other_id4' => $p_obj->getColumn('other_id4'), 'other_id5' => $p_obj->getColumn('other_id5'), 'date_stamp' => TTDate::strtotime($p_obj->getColumn('date_stamp')), 'in_time_stamp' => NULL, 'in_actual_time_stamp' => NULL, 'in_type' => NULL, 'out_time_stamp' => NULL, 'out_actual_time_stamp' => NULL, 'out_type' => NULL, 'user_wage_id' => $p_obj->getColumn('user_wage_id'), 'hourly_rate' => Misc::MoneyFormat($hourly_rate, FALSE), 'in_station_type_id' => NULL, 'in_station_station_id' => NULL, 'in_station_source' => NULL, 'in_station_description' => NULL, 'out_station_type_id' => NULL, 'out_station_station_id' => NULL, 'out_station_source' => NULL, 'out_station_description' => NULL);
}
if ($p_obj->getColumn('status_id') == 10) {
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_time_stamp'] = TTDate::strtotime($p_obj->getColumn('time_stamp'));
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_type'] = $p_obj->getColumn('type_id');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_actual_time_stamp'] = TTDate::strtotime($p_obj->getColumn('actual_time_stamp'));
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_station_type_id'] = $p_obj->getColumn('station_type_id');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_station_station_id'] = $p_obj->getColumn('station_station_id');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_station_source'] = $p_obj->getColumn('station_source');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['in_station_description'] = $p_obj->getColumn('station_description');
} else {
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['out_time_stamp'] = TTDate::strtotime($p_obj->getColumn('time_stamp'));
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['out_type'] = $p_obj->getColumn('type_id');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['out_actual_time_stamp'] = TTDate::strtotime($p_obj->getColumn('actual_time_stamp'));
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['out_station_type_id'] = $p_obj->getColumn('station_type_id');
$tmp_rows[$p_obj->getColumn('pay_period_id')][$p_obj->getColumn('user_id')][$p_obj->getColumn('punch_control_id')]['out_station_station_id'] = $p_obj->getColumn('station_station_id');
示例10: bcmul
break;
}
//$policy_hourly_rate = $policy_rates[$column]->getHourlyRate( $hourly_rate );
} else {
//Debug::Text('Column: '. $column .' NOT Premium Policy: Policy Rate: '. $policy_rates[$column], __FILE__, __LINE__, __METHOD__,10);
$policy_hourly_rate = bcmul($policy_rates[$column], $hourly_rate);
}
} elseif ($column == 'regular_time') {
//$rate = 1;
$policy_hourly_rate = $hourly_rate;
} else {
$policy_hourly_rate = 0;
//$rate = 0;
}
//Debug::Text('Column: '. $column .' Total Time: '. $total_time .' Hourly Rate: '. $hourly_rate .' Policy Hourly Rate: '. $policy_hourly_rate .' Amount: '. TTDate::getHours( $total_time ) * $policy_hourly_rate, __FILE__, __LINE__, __METHOD__,10);
$amount = bcmul(TTDate::getHours($total_time), $policy_hourly_rate);
if (in_array($column, $wage_columns)) {
//Debug::Text('...Column: '. $column .' Hourly Wage: '. $hourly_rate .' Rate: '. $rate .' Total Wage: '. ($hourly_rate * $rate), __FILE__, __LINE__, __METHOD__,10);
if (isset($tmp_rows[$x][$column . '_wage'])) {
$tmp_rows[$x][$column . '_wage'] = Misc::MoneyFormat($tmp_rows[$x][$column . '_wage'] + $amount, FALSE);
} else {
$tmp_rows[$x][$column . '_wage'] = Misc::MoneyFormat($amount, FALSE);
}
}
if (isset($tmp_rows[$x]['gross_wage'])) {
//Debug::Text('Adding to Gross, Prev Amount: '. $tmp_rows[$x]['gross_wage'] .' Amount: '. $amount, __FILE__, __LINE__, __METHOD__,10);
$tmp_rows[$x]['gross_wage'] = Misc::MoneyFormat($tmp_rows[$x]['gross_wage'] + $amount, FALSE);
} else {
//Debug::Text('Setting Gross...', __FILE__, __LINE__, __METHOD__,10);
$tmp_rows[$x]['gross_wage'] = Misc::MoneyFormat($amount, FALSE);
}
示例11: getActiveMilestoneObject
function getActiveMilestoneObject($u_obj, $epoch = NULL)
{
if (!is_object($u_obj)) {
return FALSE;
}
if ($epoch == '') {
$epoch = TTDate::getTime();
}
$milestone_obj = FALSE;
$apmlf = new AccrualPolicyMilestoneListFactory();
$apmlf->getByAccrualPolicyId($this->getId(), NULL, array('length_of_service_days' => 'desc'));
Debug::Text(' Total Accrual Policy MileStones: ' . (int) $apmlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
if ($apmlf->getRecordCount() > 0) {
$worked_time = NULL;
$length_of_service_days = NULL;
foreach ($apmlf as $apm_obj) {
if ($apm_obj->getLengthOfServiceUnit() == 50) {
Debug::Text(' MileStone is in Hours...', __FILE__, __LINE__, __METHOD__, 10);
//Hour based
if ($worked_time == NULL) {
//Get users worked time.
$worked_time = TTDate::getHours($this->getWorkedTimeByUserIdAndEndDate($u_obj->getId(), $epoch));
Debug::Text(' Worked Time: ' . $worked_time . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
}
if ($worked_time >= $apm_obj->getLengthOfService()) {
Debug::Text(' bLength Of Service: ' . $apm_obj->getLengthOfService() . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
$milestone_obj = $apmlf->getCurrent();
break;
} else {
Debug::Text(' Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::Text(' MileStone is in Days...', __FILE__, __LINE__, __METHOD__, 10);
//Calendar based
if ($length_of_service_days == NULL) {
$length_of_service_days = TTDate::getDays($epoch - $this->getMilestoneRolloverDate($u_obj->getHireDate()));
if ($length_of_service_days < 0) {
$length_of_service_days = 0;
}
Debug::Text(' Length of Service Days: ' . $length_of_service_days, __FILE__, __LINE__, __METHOD__, 10);
}
if ($length_of_service_days >= $apm_obj->getLengthOfServiceDays()) {
$milestone_obj = $apmlf->getCurrent();
break;
} else {
Debug::Text(' Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10);
}
}
}
}
unset($apmlf, $apm_obj);
return $milestone_obj;
}
示例12: columnFormatter
function columnFormatter($type, $column, $value, $format = NULL)
{
if (is_array($value) and isset($value['display'])) {
//Found sorting array, use display column.
return $value['display'];
} else {
$retval = $value;
if ($format == 'csv' or $format == 'raw') {
//Force specific field formats for exporting to CSV format.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = TTDate::getDate('DATE', $value);
break;
case 'time':
$retval = TTDate::getDate('TIME', $value);
break;
case 'time_stamp':
$retval = TTDate::getDate('DATE+TIME', $value);
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} elseif ($format == 'xml') {
//Use standard XML formats whenever possible.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = date('Y-m-d', $value);
////type="xs:date"
break;
case 'time':
$retval = date('H:i:s', $value);
//type="xs:time"
break;
case 'time_stamp':
$retval = date('c', $value);
//type="xs:dateTime"
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} else {
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
if (is_object($this->getCurrencyObject())) {
//Set MIN decimals to 2 and max to the currency rounding.
$retval = $this->getCurrencyObject()->getSymbol() . TTi18n::formatNumber($value, TRUE, 2, $this->getCurrencyObject()->getRoundDecimalPlaces());
} else {
$retval = TTi18n::formatCurrency($value);
}
break;
case 'percent':
$retval = TTi18n::formatNumber($value, TRUE) . '%';
break;
case 'numeric':
$retval = TTi18n::formatNumber($value, TRUE);
break;
case 'time_unit':
$retval = TTDate::getTimeUnit($value);
//.........这里部分代码省略.........
示例13: calculate
function calculate($epoch = NULL)
{
if ($this->getUserObject() == FALSE) {
return FALSE;
}
if ($this->getPayPeriodObject() == FALSE) {
return FALSE;
}
if ($epoch == NULL or $epoch == '') {
$epoch = TTDate::getTime();
}
//Use User Termination Date instead of ROE.
if ($this->getUserObject()->getTerminationDate() != '' and $this->getUserObject()->getTerminationDate() >= $this->getPayPeriodObject()->getStartDate() and $this->getUserObject()->getTerminationDate() <= $this->getPayPeriodObject()->getEndDate()) {
Debug::text('User has been terminated in this pay period!', __FILE__, __LINE__, __METHOD__, 10);
$is_terminated = TRUE;
} else {
$is_terminated = FALSE;
}
//Allow generating pay stubs for employees who have any status, but if its not ID=10
//Then the termination date must fall within the start/end date of the pay period, or after the end date (if its the current pay period)
//The idea here is to allow employees to be marked terminated (or on leave) and still get their previous or final pay stub generated.
//Also allow pay stubs to be generated in pay periods *before* their termination date.
if ($this->getUserObject()->getStatus() != 10 and ($is_terminated == FALSE and ($this->getUserObject()->getTerminationDate() == '' or $this->getUserObject()->getTerminationDate() < $this->getPayPeriodObject()->getStartDate()))) {
Debug::text('Pay Period is after users termination date (' . $this->getUserObject()->getTerminationDate() . '), or no termination date is set...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
Debug::text('User Id: ' . $this->getUser() . ' Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $this->getPayPeriodObject()->getEndDate()), __FILE__, __LINE__, __METHOD__, 10);
$generic_queue_status_label = $this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub');
$pay_stub = TTnew('PayStubFactory');
$pay_stub->StartTransaction();
$old_pay_stub_id = NULL;
if ($this->getEnableCorrection() == TRUE) {
Debug::text('Correction Enabled!', __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setTemp(TRUE);
//Check for current pay stub ID so we can compare against it.
$pslf = TTnew('PayStubListFactory');
$pslf->getByUserIdAndPayPeriodId($this->getUser(), $this->getPayPeriod());
if ($pslf->getRecordCount() > 0) {
$old_pay_stub_id = $pslf->getCurrent()->getId();
Debug::text('Comparing Against Pay Stub ID: ' . $old_pay_stub_id, __FILE__, __LINE__, __METHOD__, 10);
}
}
$pay_stub->setUser($this->getUser());
$pay_stub->setPayPeriod($this->getPayPeriod());
$pay_stub->setCurrency($this->getUserObject()->getCurrency());
$pay_stub->setStatus(10);
//New
if ($is_terminated == TRUE) {
Debug::text('User is Terminated, assuming final pay, setting End Date to terminated date: ' . TTDate::getDate('DATE+TIME', $this->getUserObject()->getTerminationDate()), __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setStartDate($pay_stub->getPayPeriodObject()->getStartDate());
$pay_stub->setEndDate($this->getUserObject()->getTerminationDate());
//Use the PS generation date instead of terminated date...
//Unlikely they would pay someone before the pay stub is generated.
//Perhaps still use the pay period transaction date for this too?
//Anything we set won't be correct for everyone. Maybe a later date is better though?
//Perhaps add to the user factory under Termination Date a: "Final Transaction Date" for this purpose?
//Use the end of the current date for the transaction date, as if the employee is terminated
//on the same day they are generating the pay stub, the transaction date could be before the end date
//as the end date is at 11:59PM
//For now make sure that the transaction date for a terminated employee is never before their termination date.
if (TTDate::getEndDayEpoch(TTDate::getTime()) < $this->getUserObject()->getTerminationDate()) {
$pay_stub->setTransactionDate($this->getUserObject()->getTerminationDate());
} else {
$pay_stub->setTransactionDate(TTDate::getEndDayEpoch(TTDate::getTime()));
}
} else {
Debug::text('User Termination Date is NOT set, assuming normal pay.', __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->setDefaultDates();
}
//This must go after setting advance
if ($this->getEnableCorrection() == FALSE and $pay_stub->IsUniquePayStub() == FALSE) {
Debug::text('Pay Stub already exists', __FILE__, __LINE__, __METHOD__, 10);
$this->CommitTransaction();
UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 20, TTi18n::gettext('Pay Stub for this employee already exists, skipping...'), NULL);
return FALSE;
}
if ($pay_stub->isValid() == TRUE) {
$pay_stub->Save(FALSE);
$pay_stub->setStatus(25);
//Open
} else {
Debug::text('Pay Stub isValid failed!', __FILE__, __LINE__, __METHOD__, 10);
UserGenericStatusFactory::queueGenericStatus($generic_queue_status_label, 10, $pay_stub->Validator->getTextErrors(), NULL);
$this->FailTransaction();
$this->CommitTransaction();
return FALSE;
}
$pay_stub->loadPreviousPayStub();
$user_date_total_arr = $this->getWageObject()->getUserDateTotalArray();
if (isset($user_date_total_arr['entries']) and is_array($user_date_total_arr['entries'])) {
foreach ($user_date_total_arr['entries'] as $udt_arr) {
//Allow negative amounts so flat rate premium policies can reduce an employees wage if need be.
if ($udt_arr['amount'] != 0) {
Debug::text('Adding Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
$pay_stub->addEntry($udt_arr['pay_stub_entry'], $udt_arr['amount'], TTDate::getHours($udt_arr['total_time']), $udt_arr['rate']);
} else {
Debug::text('NOT Adding ($0 amount) Pay Stub Entry: ' . $udt_arr['pay_stub_entry'] . ' Amount: ' . $udt_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
}
}
} else {
//.........这里部分代码省略.........
示例14: getPayStub
//.........这里部分代码省略.........
}
$pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell(175 - ($column_widths['amount'] + $column_widths['ytd_amount']) - 2, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L', FALSE, '', 1);
$pdf->Cell($column_widths['amount'], 5, TTi18n::formatNumber($pay_stub_entry['amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['ytd_amount'], 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
}
$block_adjust_y = $block_adjust_y + 5;
}
}
//
//Accrual Policy Balances
//
$ablf = TTnew('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', FALSE, '', 1);
$pdf->Cell(25, 5, TTi18n::gettext('Balance (hrs)'), $border, 0, 'R', FALSE, '', 1);
$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', FALSE, '', 1);
$pdf->Cell(25, 5, TTi18n::formatNumber(TTDate::getHours($balance)), $border, 0, 'R', FALSE, '', 1);
$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', FALSE, '', 1);
$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(85, 5, '[' . $pay_stub_entry_description['subscript'] . '] ' . html_entity_decode($pay_stub_entry_description['description']), $border, 0, 'L', FALSE, '', 1);
if ($x % 2 != 0) {
$block_adjust_y = $block_adjust_y + 5;
}
$x++;
}
}
示例15: getDeductionAmount
//.........这里部分代码省略.........
} else {
$user_value8 = $this->getUserValue8();
}
if ($this->getUserValue9() == '') {
$user_value9 = $cd_obj->getUserValue9();
} else {
$user_value9 = $this->getUserValue9();
}
if ($this->getUserValue10() == '') {
$user_value10 = $cd_obj->getUserValue10();
} else {
$user_value10 = $this->getUserValue10();
}
// evaluate math expressions as the company_value1 and user_value1-10 defined by user.
$company_value1 = $cd_obj->getCompanyValue1();
// Custom Formula
$variables = array();
$formula_variables = array_keys((array) TTMath::parseColumnsFromFormula($company_value1));
Debug::Arr($formula_variables, 'Formula Variables: ', __FILE__, __LINE__, __METHOD__, 10);
if (is_array($formula_variables)) {
if (in_array('currency_conversion_rate', $formula_variables) and is_object($this->getUserObject()) and is_object($this->getUserObject()->getCurrencyObject())) {
$currency_iso_code = $this->getUserObject()->getCurrencyObject()->getISOCode();
$currency_conversion_rate = $this->getUserObject()->getCurrencyObject()->getConversionRate();
Debug::Text('Currency Variables: Rate: ' . $currency_conversion_rate . ' ISO: ' . $currency_iso_code, __FILE__, __LINE__, __METHOD__, 10);
}
//First pass to gather any necessary data based on variables
if (in_array('employee_hourly_rate', $formula_variables) or in_array('employee_annual_wage', $formula_variables) or in_array('employee_wage_average_weekly_hours', $formula_variables)) {
$uwlf = TTnew('UserWageListFactory');
$uwlf->getWageByUserIdAndPayPeriodEndDate($this->getUser(), $pay_period_obj->getEndDate());
if ($uwlf->getRecordCount() > 0) {
$uwf = $uwlf->getCurrent();
$employee_hourly_rate = $uwf->getHourlyRate();
$employee_annual_wage = $uwf->getAnnualWage();
$employee_wage_average_weekly_hours = TTDate::getHours($uwf->getWeeklyTime());
} else {
$employee_hourly_rate = 0;
$employee_annual_wage = 0;
$employee_wage_average_weekly_hours = 0;
}
Debug::Text('Employee Hourly Rate: ' . $employee_hourly_rate, __FILE__, __LINE__, __METHOD__, 10);
}
if ($cd_obj->getCompanyValue2() != '' and $cd_obj->getCompanyValue2() > 0 and $cd_obj->getCompanyValue3() != '' and $cd_obj->getCompanyValue3() > 0) {
Debug::Text('Formula Lookback enable: ' . $cd_obj->getCompanyValue2(), __FILE__, __LINE__, __METHOD__, 10);
foreach ($formula_variables as $formula_variable) {
if (strpos($formula_variable, 'lookback_') !== FALSE) {
Debug::Text('Lookback variables exist...', __FILE__, __LINE__, __METHOD__, 10);
$lookback_dates = $cd_obj->getLookbackStartAndEndDates($pay_period_obj);
$lookback_pay_stub_dates = $cd_obj->getLookbackPayStubs($this->getUser(), $pay_period_obj);
break;
}
}
}
//Second pass to define variables.
foreach ($formula_variables as $formula_variable) {
if (!isset($variables[$formula_variable])) {
switch ($formula_variable) {
case 'custom_value1':
$variables[$formula_variable] = $user_value1;
break;
case 'custom_value2':
$variables[$formula_variable] = $user_value2;
break;
case 'custom_value3':
$variables[$formula_variable] = $user_value3;
break;
case 'custom_value4':