本文整理汇总了PHP中TTDate::getMiddleDayEpoch方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getMiddleDayEpoch方法的具体用法?PHP TTDate::getMiddleDayEpoch怎么用?PHP TTDate::getMiddleDayEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getMiddleDayEpoch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_hire_date
function parse_hire_date($input, $default_value = NULL, $parse_hint = NULL)
{
if (isset($parse_hint) and $parse_hint != '') {
TTDate::setDateFormat($parse_hint);
return TTDate::getMiddleDayEpoch(TTDate::parseDateTime($input));
} else {
return TTDate::getMiddleDayEpoch(TTDate::strtotime($input));
}
}
示例2: dirname
*/
/*
* Calculate Exceptions for the previous day. This helps especially for
* the "Unscheuled Absence" exception.
*
* Run this once a day. AFTER AddUserDate
*/
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';
//Debug::setVerbosity(5);
$execution_time = time();
//Calculate exceptions just for today and yesterday, because some shifts may start late in the day and need to be handled first thing in the morning.
//Make sure we also go one day in the future too, since the servers can be PST and if its 11:00PM, it will stop at midnight for that day, so
//shifts that would have already started in a different timezone (say EST) will not receive exceptions until we have moved into the next day for PST (3hrs late)
$start_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($execution_time) - 86400);
$end_date = TTDate::getEndDayEpoch(TTDate::getMiddleDayEpoch($execution_time) + 86400);
$udlf = new UserDateListFactory();
//Use optimized query to speed this process up significantly.
$udlf->getMidDayExceptionsByStartDateAndEndDateAndPayPeriodStatus($start_date, $end_date, array(10, 12, 15, 30));
Debug::text(' calcQuickExceptions: Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date) . ' User Date Rows: ' . $udlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 5);
if ($udlf->getRecordCount() > 0) {
$i = 0;
foreach ($udlf as $ud_obj) {
$user_obj_prefs = $ud_obj->getUserObject()->getUserPreferenceObject();
if (is_object($user_obj_prefs)) {
$user_obj_prefs->setTimeZonePreferences();
} else {
//Use system timezone.
TTDate::setTimeZone();
}
Debug::text('(' . $i . '). User: ' . $ud_obj->getUser() . ' Date: ' . TTDate::getDate('DATE+TIME', $ud_obj->getDateStamp()) . ' User Date ID: ' . $ud_obj->getId(), __FILE__, __LINE__, __METHOD__, 5);
示例3: foreach
$i = 0;
foreach ($udlf as $ud_obj) {
//Recalculate system time, and exceptions for the day.
//Because if its a Monday, it will also recalculate the rest of the days in the week.
//Shouldn't be a big deal though.
//This isn't needed, since we now do it in AddRecurringScheduleShift, so dock time is
//applied at the beginning of the day.
//The problem is that AddRecurringScheduleShift does it, then for the entire day someone with
//a dock policy shows up as dock time. Some users have complained about this a few times.
//Reason for doing two days ago is that if someone starts a shift at 11pm, but doesn't end it in
//time, it still needs to be re-calculated a day later.
//Could maybe get around this by getting all punches of yesterday, and getting their date_ids
//and just recalculating those.
//Enable pre-mature exceptions if we're recalculating just one day ago.
$enable_premature_exceptions = FALSE;
if ($end_date == TTDate::getMiddleDayEpoch($ud_obj->getDateStamp())) {
$enable_premature_exceptions = TRUE;
}
Debug::text($x . '(' . $i . '). User: ' . $ud_obj->getUser() . ' Date: ' . TTDate::getDate('DATE+TIME', $ud_obj->getDateStamp()) . ' User Date ID: ' . $ud_obj->getId() . ' Enable PreMature Exceptions: ' . (int) $enable_premature_exceptions, __FILE__, __LINE__, __METHOD__, 5);
UserDateTotalFactory::reCalculateDay($ud_obj->getId(), TRUE, $enable_premature_exceptions);
$i++;
$x++;
}
}
Debug::text('Company: ' . $c_obj->getName() . '(' . $c_obj->getId() . ') Finished In: ' . (microtime(TRUE) - $company_start_time) . 's', __FILE__, __LINE__, __METHOD__, 5);
}
}
}
/*
//Two days ago.
$date = TTDate::getMiddleDayEpoch( time() ) - (86400*2);
示例4: getNextPayPeriod
function getNextPayPeriod($end_date = NULL)
{
if (!$this->Validator->isValid()) {
return FALSE;
}
//Manual Pay Period Schedule, skip repeating...
if ($this->getType() == 5) {
return FALSE;
}
$pplf = new PayPeriodListFactory();
//Debug::text('PP Schedule ID: '. $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('PP Schedule Name: '. $this->getName(), __FILE__, __LINE__, __METHOD__, 10);
Debug::text('PP Schedule Type (' . $this->getType() . '): ' . Option::getByKey($this->getType(), $this->getOptions('type')), __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('Anchor Date: '. $this->getAnchorDate() ." - ". TTDate::getDate('DATE+TIME', $this->getAnchorDate() ), __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('Primary Date: '. $this->getPrimaryDate() ." - ". TTDate::getDate('DATE+TIME', $this->getPrimaryDate() ), __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('Secondary Date: '. $this->getSecondaryDate() ." - ". TTDate::getDate('DATE+TIME', $this->getPrimaryDate() ), __FILE__, __LINE__, __METHOD__, 10);
$last_pay_period_is_new = FALSE;
if ($end_date != '' and $end_date != 0) {
Debug::text('End Date is set: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
$last_pay_period_end_date = $end_date;
} else {
Debug::text('Checking for Previous pay periods...', __FILE__, __LINE__, __METHOD__, 10);
//Get the last pay period schedule in the database.
$pplf->getByPayPeriodScheduleId($this->getId(), NULL, NULL, NULL, array('start_date' => 'desc'));
$last_pay_period = $pplf->getCurrent();
if ($last_pay_period->isNew()) {
$last_pay_period_is_new = TRUE;
Debug::text('No Previous pay periods...', __FILE__, __LINE__, __METHOD__, 10);
//Do this so a rollover doesn't happen while we're calculating.
//$last_pay_period_end_date = TTDate::getTime();
//This causes the pay period schedule to jump ahead one month. So set this to be beginning of the month.
$last_pay_period_end_date = TTDate::getBeginMonthEpoch();
} else {
Debug::text('Previous pay periods found... ID: ' . $last_pay_period->getId(), __FILE__, __LINE__, __METHOD__, 10);
$last_pay_period_end_date = $last_pay_period->getEndDate();
}
unset($last_pay_period, $pplf);
}
Debug::text('aLast Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $last_pay_period_end_date) . ' (' . $last_pay_period_end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
//FIXME: This breaks having pay periods with different daily start times.
//However, without it, I think DST breaks pay periods.
//$last_pay_period_end_date = TTDate::getEndDayEpoch( $last_pay_period_end_date + 1 ) - 86400;
$last_pay_period_end_date = TTDate::getEndDayEpoch($last_pay_period_end_date - 86400 / 2);
Debug::text('bLast Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $last_pay_period_end_date) . ' (' . $last_pay_period_end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
if ($this->getDayStartTime() != 0) {
Debug::text('Daily Start Time is set, adjusting Last Pay Period End Date by: ' . TTDate::getHours($this->getDayStartTime()), __FILE__, __LINE__, __METHOD__, 10);
//Next adjust last_pay_period_end_date (which becomes the start date) to DayStartTime because then there could be a gap if they
//change this mid-schedule. The End Date will take care of it after the first pay period.
$last_pay_period_end_date = TTDate::getTimeLockedDate(TTDate::getBeginDayEpoch($last_pay_period_end_date) + $this->getDayStartTime(), $last_pay_period_end_date);
Debug::text('cLast Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $last_pay_period_end_date) . ' (' . $last_pay_period_end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
}
$insert_pay_period = 1;
//deprecate primary pay periods.
switch ($this->getType()) {
case 10:
//Weekly
//Weekly
case 20:
//Bi-Weekly
$last_pay_period_end_day_of_week = TTDate::getDayOfWeek($last_pay_period_end_date);
Debug::text('Last Pay Period End Day Of Week: ' . $last_pay_period_end_day_of_week . ' Start Day Of Week: ' . $this->getStartDayOfWeek(), __LINE__, __METHOD__, 10);
if ($last_pay_period_end_day_of_week != $this->getStartDayOfWeek()) {
Debug::text('zTmp Pay Period End Date: ' . 'next ' . TTDate::getDayOfWeekByInt($this->getStartDayOfWeek()), __FILE__, __LINE__, __METHOD__, 10);
//$tmp_pay_period_end_date = strtotime('next '. TTDate::getDayOfWeekByInt( $this->getStartDayOfWeek() ), $last_pay_period_end_date )-1;
$tmp_pay_period_end_date = strtotime('next ' . TTDate::getDayOfWeekByInt($this->getStartDayOfWeek(), FALSE), $last_pay_period_end_date);
//strtotime doesn't keep time when using "next", it resets it to midnight on the day, so we need to adjust for that.
$tmp_pay_period_end_date = TTDate::getTimeLockedDate(TTDate::getBeginDayEpoch($tmp_pay_period_end_date) + $this->getDayStartTime(), $tmp_pay_period_end_date) - 1;
} else {
$tmp_pay_period_end_date = $last_pay_period_end_date;
//This should fix a bug where if they are creating a new pay period schedule
//starting on Monday with the anchor date of 01-Jul-08, it would start on 01-Jul-08 (Tue)
//rather moving back to the Monday.
if (TTDate::getDayOfMonth($tmp_pay_period_end_date) != TTDate::getDayOfMonth($tmp_pay_period_end_date + 1)) {
Debug::text('Right on day boundary, minus an additional second to account for difference...', __FILE__, __LINE__, __METHOD__, 10);
$tmp_pay_period_end_date--;
}
}
Debug::text('aTmp Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $tmp_pay_period_end_date) . ' (' . $tmp_pay_period_end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
$start_date = $tmp_pay_period_end_date + 1;
if ($this->getType() == 10) {
//Weekly
$tmp_pay_period_end_date = TTDate::getMiddleDayEpoch($start_date) + 86400 * 7;
//Add one week
} elseif ($this->getType() == 20) {
//Bi-Weekly
$tmp_pay_period_end_date = TTDate::getMiddleDayEpoch($start_date) + 86400 * 14;
//Add two weeks
}
//Use Begin Day Epoch to nullify DST issues.
$end_date = TTDate::getBeginDayEpoch($tmp_pay_period_end_date) - 1;
$transaction_date = TTDate::getMiddleDayEpoch(TTDate::getMiddleDayEpoch($end_date) + $this->getTransactionDate() * 86400);
break;
case 30:
//Semi-monthly
$tmp_last_pay_period_end_day_of_month = TTDate::getDayOfMonth($last_pay_period_end_date + 1);
Debug::text('bLast Pay Period End Day Of Month: ' . $tmp_last_pay_period_end_day_of_month, __FILE__, __LINE__, __METHOD__, 10);
if ($tmp_last_pay_period_end_day_of_month == $this->convertLastDayOfMonth($this->getPrimaryDayOfMonth())) {
$insert_pay_period = 1;
$primary = TRUE;
} elseif ($tmp_last_pay_period_end_day_of_month == $this->convertLastDayOfMonth($this->getSecondaryDayOfMonth())) {
//.........这里部分代码省略.........
示例5:
//Because if its a Monday, it will also recalculate the rest of the days in the week.
//Shouldn't be a big deal though.
//This isn't needed, since we now do it in AddRecurringScheduleShift, so dock time is
//applied at the beginning of the day.
//The problem is that AddRecurringScheduleShift does it, then for the entire day someone with
//a dock policy shows up as dock time. Some users have complained about this a few times.
//Reason for doing two days ago is that if someone starts a shift at 11pm, but doesn't end it in
//time, it still needs to be re-calculated a day later.
//Could maybe get around this by getting all punches of yesterday, and getting their date_ids
//and just recalculating those.
//Enable pre-mature exceptions if we're recalculating just one day ago.
//Problem is a late shift on say Monday: 2:00PM to 11:00PM won't trigger the exception at 1AM the next day,
//but by 1AM the following day (2days later) its too late and emails are disabled if enable_premature_exceptions are disabled.
$enable_premature_exceptions = FALSE;
//if ( $end_date == TTDate::getMiddleDayEpoch( $ud_obj->getDateStamp() ) ) {
if (TTDate::getMiddleDayEpoch($ud_obj->getDateStamp()) >= TTDate::getMiddleDayEpoch($execution_time) - 86400 * 2) {
$enable_premature_exceptions = TRUE;
}
Debug::text($x . '(' . $i . '). User: ' . $ud_obj->getUser() . ' Date: ' . TTDate::getDate('DATE+TIME', $ud_obj->getDateStamp()) . ' User Date ID: ' . $ud_obj->getId() . ' Enable PreMature Exceptions: ' . (int) $enable_premature_exceptions, __FILE__, __LINE__, __METHOD__, 5);
UserDateTotalFactory::reCalculateDay($ud_obj->getId(), TRUE, $enable_premature_exceptions);
TTDate::setTimeZone();
$i++;
$x++;
}
}
Debug::text('Company: ' . $c_obj->getName() . '(' . $c_obj->getId() . ') Finished In: ' . (microtime(TRUE) - $company_start_time) . 's', __FILE__, __LINE__, __METHOD__, 5);
}
}
}
Debug::writeToLog();
Debug::Display();
示例6: findOrInsertUserDate
static function findOrInsertUserDate($user_id, $date, $timezone = NULL)
{
$date = TTDate::getMiddleDayEpoch($date);
//Use mid day epoch so the timezone conversion across DST doesn't affect the date.
if ($timezone == NULL) {
//Find the employees preferred timezone, base the user date off that instead of the pay period timezone,
//as it can be really confusing to the user if they punch in at 10AM on Sept 27th, but it records as Sept 26th because
//the PP Schedule timezone is 12hrs different or something.
$uplf = new UserPreferenceListFactory();
$uplf->getByUserID($user_id);
if ($uplf->getRecordCount() > 0) {
$timezone = $uplf->getCurrent()->getTimeZone();
}
}
$date = TTDate::convertTimeZone($date, $timezone);
Debug::text(' Using TimeZone: ' . $timezone . ' Date: ' . TTDate::getDate('DATE+TIME', $date) . '(' . $date . ')', __FILE__, __LINE__, __METHOD__, 10);
$udlf = new UserDateListFactory();
$udlf->getByUserIdAndDate($user_id, $date);
if ($udlf->getRecordCount() == 1) {
$id = $udlf->getCurrent()->getId();
Debug::text(' Found Already Existing User Date ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
return $id;
} elseif ($udlf->getRecordCount() == 0) {
Debug::text(' Inserting new UserDate row.', __FILE__, __LINE__, __METHOD__, 10);
//Insert new row
$udf = new UserDateFactory();
$udf->setUser($user_id);
$udf->setDateStamp($date);
$udf->setPayPeriod();
if ($udf->isValid()) {
return $udf->Save();
} else {
Debug::text(' INVALID user date row. Pay Period Locked?', __FILE__, __LINE__, __METHOD__, 10);
}
} elseif ($udlf->getRecordCount() > 1) {
Debug::text(' More then 1 user date row was detected!!: ' . $udlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
}
Debug::text(' Cant find or insert User Date ID. User ID: ' . $user_id . ' Date: ' . $date, __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
示例7: generatePayStubs
function generatePayStubs($pay_period_ids, $user_ids = NULL, $enable_correction = FALSE)
{
global $profiler;
Debug::Text('Generate Pay Stubs!', __FILE__, __LINE__, __METHOD__, 10);
if (!$this->getPermissionObject()->Check('pay_period_schedule', 'enabled') or !($this->getPermissionObject()->Check('pay_period_schedule', 'edit') or $this->getPermissionObject()->Check('pay_period_schedule', 'edit_own'))) {
return $this->getPermissionObject()->PermissionDenied();
}
if (!is_array($pay_period_ids)) {
$pay_period_ids = array($pay_period_ids);
}
if ($user_ids !== NULL and !is_array($user_ids) and $user_ids > 0) {
$user_ids = array($user_ids);
} elseif (is_array($user_ids) and isset($user_ids[0]) and $user_ids[0] == 0) {
$user_ids = NULL;
}
foreach ($pay_period_ids as $pay_period_id) {
Debug::text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
$pplf = TTnew('PayPeriodListFactory');
$pplf->getByIdAndCompanyId($pay_period_id, $this->getCurrentCompanyObject()->getId());
$epoch = TTDate::getTime();
foreach ($pplf as $pay_period_obj) {
Debug::text('Pay Period Schedule ID: ' . $pay_period_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10);
if ($pay_period_obj->isPreviousPayPeriodClosed() == TRUE) {
//Grab all users for pay period
$ppsulf = TTnew('PayPeriodScheduleUserListFactory');
if (is_array($user_ids) and count($user_ids) > 0) {
Debug::text('Generating pay stubs for specific users...', __FILE__, __LINE__, __METHOD__, 10);
TTLog::addEntry($this->getCurrentCompanyObject()->getId(), 500, TTi18n::gettext('Calculating Company Pay Stubs for Pay Period') . ': ' . $pay_period_id, $this->getCurrentUserObject()->getId(), 'pay_stub');
//Notice
$ppsulf->getByCompanyIDAndPayPeriodScheduleIdAndUserID($this->getCurrentCompanyObject()->getId(), $pay_period_obj->getPayPeriodSchedule(), $user_ids);
} else {
TTLog::addEntry($this->getCurrentCompanyObject()->getId(), 500, TTi18n::gettext('Calculating Employee Pay Stub for Pay Period') . ': ' . $pay_period_id, $this->getCurrentUserObject()->getId(), 'pay_stub');
$ppsulf->getByCompanyIDAndPayPeriodScheduleId($this->getCurrentCompanyObject()->getId(), $pay_period_obj->getPayPeriodSchedule());
}
$total_pay_stubs = $ppsulf->getRecordCount();
$this->getProgressBarObject()->start($this->getAMFMessageID(), $total_pay_stubs, NULL, TTi18n::getText('Generating Paystubs...'));
//Delete existing pay stub. Make sure we only
//delete pay stubs that are the same as what we're creating.
$pslf = TTnew('PayStubListFactory');
$pslf->getByPayPeriodId($pay_period_obj->getId());
foreach ($pslf as $pay_stub_obj) {
if (is_array($user_ids) and count($user_ids) > 0 and in_array($pay_stub_obj->getUser(), $user_ids) == FALSE) {
continue;
//Only generating pay stubs for individual employees, skip ones not in the list.
}
Debug::text('Existing Pay Stub: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
//Check PS End Date to match with PP End Date
//So if an ROE was generated, it won't get deleted when they generate all other Pay Stubs
//later on.
if ($pay_stub_obj->getStatus() <= 25 and $pay_stub_obj->getTainted() === FALSE and TTDate::getMiddleDayEpoch($pay_stub_obj->getEndDate()) == TTDate::getMiddleDayEpoch($pay_period_obj->getEndDate())) {
Debug::text('Deleting pay stub: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
$pay_stub_obj->setDeleted(TRUE);
$pay_stub_obj->Save();
} else {
Debug::text('Pay stub does not need regenerating, or it is LOCKED! ID: ' . $pay_stub_obj->getID() . ' Status: ' . $pay_stub_obj->getStatus() . ' Tainted: ' . (int) $pay_stub_obj->getTainted() . ' Pay Stub End Date: ' . $pay_stub_obj->getEndDate() . ' Pay Period End Date: ' . $pay_period_obj->getEndDate(), __FILE__, __LINE__, __METHOD__, 10);
}
}
$i = 1;
foreach ($ppsulf as $pay_period_schdule_user_obj) {
Debug::text('Pay Period User ID: ' . $pay_period_schdule_user_obj->getUser(), __FILE__, __LINE__, __METHOD__, 10);
Debug::text('Total Pay Stubs: ' . $total_pay_stubs . ' - ' . ceil(1 / (100 / $total_pay_stubs)), __FILE__, __LINE__, __METHOD__, 10);
$profiler->startTimer('Calculating Pay Stub');
//Calc paystubs.
$cps = new CalculatePayStub();
$cps->setEnableCorrection((bool) $enable_correction);
$cps->setUser($pay_period_schdule_user_obj->getUser());
$cps->setPayPeriod($pay_period_obj->getId());
$cps->calculate();
unset($cps);
$profiler->stopTimer('Calculating Pay Stub');
$this->getProgressBarObject()->set($this->getAMFMessageID(), $i);
//sleep(1); /////////////////////////////// FOR TESTING ONLY //////////////////
$i++;
}
unset($ppsulf);
$this->getProgressBarObject()->stop($this->getAMFMessageID());
} else {
UserGenericStatusFactory::queueGenericStatus(TTi18n::gettext('ERROR'), 10, TTi18n::gettext('Pay period prior to %1 is not closed, please close all previous pay periods and try again...', array(TTDate::getDate('DATE', $pay_period_obj->getStartDate()) . ' -> ' . TTDate::getDate('DATE', $pay_period_obj->getEndDate()))), NULL);
}
}
}
if (UserGenericStatusFactory::isStaticQueue() == TRUE) {
$ugsf = TTnew('UserGenericStatusFactory');
$ugsf->setUser($this->getCurrentUserObject()->getId());
$ugsf->setBatchID($ugsf->getNextBatchId());
$ugsf->setQueue(UserGenericStatusFactory::getStaticQueue());
$ugsf->saveQueue();
$user_generic_status_batch_id = $ugsf->getBatchID();
} else {
$user_generic_status_batch_id = FALSE;
}
unset($ugsf);
return $this->returnHandler(TRUE, TRUE, FALSE, FALSE, FALSE, $user_generic_status_batch_id);
}
示例8: addAccrualPolicyTime
function addAccrualPolicyTime($epoch = NULL, $offset = 79200, $daily_total_time = NULL)
{
//22hr offset
if ($epoch == '') {
$epoch = TTDate::getTime();
}
Debug::Text('Accrual Policy ID: ' . $this->getId() . ' Current EPOCH: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
$pglf = new PolicyGroupListFactory();
$pglf->StartTransaction();
$pglf->getSearchByCompanyIdAndArrayCriteria($this->getCompany(), array('accrual_policy_id' => array($this->getId())));
if ($pglf->getRecordCount() > 0) {
Debug::Text('Found Policy Group...', __FILE__, __LINE__, __METHOD__, 10);
foreach ($pglf as $pg_obj) {
//Get all users assigned to this policy group.
$policy_group_users = $pg_obj->getUser();
if (is_array($policy_group_users) and count($policy_group_users) > 0) {
Debug::Text('Found Policy Group Users: ' . count($policy_group_users), __FILE__, __LINE__, __METHOD__, 10);
foreach ($policy_group_users as $user_id) {
Debug::Text('Policy Group User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//Get User Object
$ulf = new UserListFactory();
$ulf->getByIDAndCompanyID($user_id, $this->getCompany());
if ($ulf->getRecordCount() == 1) {
$u_obj = $ulf->getCurrent();
Debug::Text('User: ' . $u_obj->getFullName() . ' Status: ' . $u_obj->getStatus(), __FILE__, __LINE__, __METHOD__, 10);
//Make sure only active employees accrue time. Will this negative affect
//Employees who may be on leave?
if ($u_obj->getStatus() == 10 and ($this->getMinimumEmployedDays() == 0 or TTDate::getDays($epoch - $u_obj->getHireDate()) >= $this->getMinimumEmployedDays())) {
Debug::Text(' User is active and has been employed long enough.', __FILE__, __LINE__, __METHOD__, 10);
$annual_pay_periods = 0;
$in_apply_frequency_window = FALSE;
$accrual_balance = 0;
$accrual_amount = 0;
if ($this->getType() == 30) {
Debug::Text(' Accrual policy is hour based, real-time window.', __FILE__, __LINE__, __METHOD__, 10);
//Hour based, apply frequency is real-time.
$in_apply_frequency_window = TRUE;
} else {
if ($this->getApplyFrequency() == 10) {
//Because of pay period frequencies, and users being assigned to different
//pay period schedules we need to get the last pay period of each user individually.
//This will return the pay period that just ended in the offset time.
$pplf = new PayPeriodListFactory();
$pplf->getByUserIdAndEndDate($user_id, $epoch - $offset);
if ($pplf->getRecordCount() > 0) {
foreach ($pplf as $pp_obj) {
Debug::Text(' Pay Period End Date: ' . TTDate::getDate('DATE+TIME', $pp_obj->getEndDate()), __FILE__, __LINE__, __METHOD__, 10);
if ($this->inApplyFrequencyWindow($epoch, $offset, $pp_obj->getEndDate()) == TRUE) {
$in_apply_frequency_window = TRUE;
$annual_pay_periods = $pp_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods();
break;
} else {
Debug::Text(' User not in Apply Frequency Window: ', __FILE__, __LINE__, __METHOD__, 10);
}
}
} else {
Debug::Text(' No Pay Period Found.', __FILE__, __LINE__, __METHOD__, 10);
}
} elseif ($this->inApplyFrequencyWindow($epoch, $offset) == TRUE) {
Debug::Text(' User IS in NON-PayPeriod Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
$in_apply_frequency_window = TRUE;
} else {
Debug::Text(' User is not in Apply Frequency Window.', __FILE__, __LINE__, __METHOD__, 10);
$in_apply_frequency_window = FALSE;
}
}
if ($in_apply_frequency_window == TRUE) {
$milestone_obj = $this->getActiveMilestoneObject($u_obj, $epoch);
if (isset($milestone_obj) and is_object($milestone_obj)) {
Debug::Text(' Found Matching Milestone, Accrual Rate: (ID: ' . $milestone_obj->getId() . ') ' . $milestone_obj->getAccrualRate() . '/year', __FILE__, __LINE__, __METHOD__, 10);
$accrual_balance = $this->getCurrentAccrualBalance($user_id, $this->getId());
if ($accrual_balance < $milestone_obj->getMaximumTime()) {
$accrual_amount = $this->calcAccrualAmount($milestone_obj, 0, $annual_pay_periods);
if ($accrual_amount > 0) {
$new_accrual_balance = bcadd($accrual_balance, $accrual_amount);
//If Maximum time is set to 0, make that unlimited.
if ($milestone_obj->getMaximumTime() > 0 and $new_accrual_balance > $milestone_obj->getMaximumTime()) {
$accrual_amount = bcsub($milestone_obj->getMaximumTime(), $accrual_balance, 0);
}
Debug::Text(' Min/Max Adjusted Accrual Amount: ' . $accrual_amount . ' Limits: Min: ' . $milestone_obj->getMinimumTime() . ' Max: ' . $milestone_obj->getMaximumTime(), __FILE__, __LINE__, __METHOD__, 10);
//Check to make sure there isn't an identical entry already made.
$alf = new AccrualListFactory();
$alf->getByCompanyIdAndUserIdAndAccrualPolicyIDAndTimeStampAndAmount($u_obj->getCompany(), $user_id, $this->getId(), TTDate::getMiddleDayEpoch($epoch), $accrual_amount);
if ($alf->getRecordCount() == 0) {
//Round to nearest 1min
$af = new AccrualFactory();
$af->setUser($user_id);
$af->setType(75);
//Accrual Policy
$af->setAccrualPolicyID($this->getId());
$af->setAmount($accrual_amount);
$af->setTimeStamp(TTDate::getMiddleDayEpoch($epoch));
$af->setEnableCalcBalance(TRUE);
if ($af->isValid()) {
$af->Save();
}
} else {
Debug::Text(' Found duplicate accrual entry, skipping...', __FILE__, __LINE__, __METHOD__, 10);
}
unset($accrual_amount, $accrual_balance, $new_accrual_balance);
//.........这里部分代码省略.........
示例9: displayVerifyButton
function displayVerifyButton($current_user_id = NULL, $user_id = NULL)
{
if ($current_user_id == '') {
$current_user_id = $this->getCurrentUser();
}
if ($current_user_id == '') {
return FALSE;
}
if ($user_id == '') {
$user_id = $this->getUser();
}
$pay_period_verify_type_id = $this->getVerificationType();
$is_timesheet_superior = $this->isHierarchySuperior($current_user_id, $user_id);
Debug::text('Current User ID: ' . $current_user_id . ' User ID: ' . $user_id . ' Verification Type ID: ' . $pay_period_verify_type_id . ' TimeSheet Superior: ' . (int) $is_timesheet_superior, __FILE__, __LINE__, __METHOD__, 10);
//Debug::text('Hire Date: '. TTDate::getDATE('DATE+TIME', $this->getUserObject()->getHireDate() ) .' Termination Date: '. TTDate::getDATE('DATE+TIME', $this->getUserObject()->getTerminationDate() ), __FILE__, __LINE__, __METHOD__,10);
if (($pay_period_verify_type_id == 20 and $current_user_id == $user_id or $pay_period_verify_type_id == 30 and $this->getStatus() != 50 and ($is_timesheet_superior == TRUE and $current_user_id != $user_id and !in_array($current_user_id, (array) $this->getAuthorizedUsers())) or $pay_period_verify_type_id == 40 and ($this->getStatus() == 55 or $current_user_id == $user_id and $this->getUserVerified() == 0 or $is_timesheet_superior == TRUE and !in_array($current_user_id, (array) $this->getAuthorizedUsers()))) and (is_object($this->getUserObject()) and TTDate::getMiddleDayEpoch($this->getUserObject()->getHireDate()) <= TTDate::getMiddleDayEpoch($this->getPayPeriodObject()->getEndDate()) and ($this->getUserObject()->getTerminationDate() == '' or $this->getUserObject()->getTerminationDate() != '' and TTDate::getMiddleDayEpoch($this->getUserObject()->getTerminationDate()) >= TTDate::getMiddleDayEpoch($this->getPayPeriodObject()->getStartDate())) and TTDate::getTime() >= $this->getPayPeriodObject()->getTimeSheetVerifyWindowStartDate() and TTDate::getTime() <= $this->getPayPeriodObject()->getTimeSheetVerifyWindowEndDate() and $this->getStatus() != 50)) {
return TRUE;
}
return FALSE;
}
示例10: setBirthDate
function setBirthDate($epoch)
{
if ($epoch !== FALSE and $epoch == '' or $this->Validator->isDate('birth_date', $epoch, TTi18n::gettext('Birth date is invalid, try specifying the year with four digits.'))) {
//Allow for negative epochs, for birthdates less than 1960's
$this->data['birth_date'] = ($epoch != 0 and $epoch != '') ? TTDate::getMiddleDayEpoch($epoch) : '';
//Allow blank birthdate.
return TRUE;
}
return FALSE;
}
示例11: _getData
function _getData($format = NULL)
{
$this->tmp_data = array('pay_stub_entry' => array());
$columns = $this->getColumnDataConfig();
$filter_data = $this->getFilterConfig();
$form_data = $this->formatFormConfig();
require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
$pd_obj = new PayrollDeduction('US', 'WA');
//State doesn't matter.
$pd_obj->setDate($filter_data['end_date']);
$social_security_wage_limit = $pd_obj->getSocialSecurityMaximumEarnings();
$medicare_additional_threshold_limit = $pd_obj->getMedicareAdditionalEmployerThreshold();
Debug::Text('Social Security Wage Limit: ' . $social_security_wage_limit . ' Medicare Threshold: ' . $medicare_additional_threshold_limit . ' Date: ' . TTDate::getDate('DATE', $filter_data['end_date']), __FILE__, __LINE__, __METHOD__, 10);
//Need to get totals up to the beginning of this quarter so we can determine if any employees have exceeded the social security limit.
$pself = TTnew('PayStubEntryListFactory');
$ytd_filter_data = $filter_data;
$ytd_filter_data['end_date'] = $ytd_filter_data['start_date'] - 1;
$ytd_filter_data['start_date'] = TTDate::getBeginYearEpoch($ytd_filter_data['start_date']);
$pself->getAPIReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $ytd_filter_data);
//Debug::Arr($ytd_filter_data, 'YTD Filter Data: Row Count: '. $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__,10);
if ($pself->getRecordCount() > 0) {
foreach ($pself as $pse_obj) {
$user_id = $pse_obj->getColumn('user_id');
//Make sure we don't add this to the unique user_id list.
//Always use middle day epoch, otherwise multiple entries could exist for the same day.
$date_stamp = TTDate::getMiddleDayEpoch(TTDate::strtotime($pse_obj->getColumn('pay_stub_transaction_date')));
$branch = $pse_obj->getColumn('default_branch');
$department = $pse_obj->getColumn('default_department');
$pay_stub_entry_name_id = $pse_obj->getPayStubEntryNameId();
if (!isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp] = array('pay_period_start_date' => strtotime($pse_obj->getColumn('pay_stub_start_date')), 'pay_period_end_date' => strtotime($pse_obj->getColumn('pay_stub_end_date')), 'pay_period_transaction_date' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')), 'pay_period' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')));
}
if (isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = bcadd($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id], $pse_obj->getColumn('amount'));
} else {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
}
}
if (isset($this->tmp_data['pay_stub_entry']) and is_array($this->tmp_data['pay_stub_entry'])) {
foreach ($this->tmp_data['pay_stub_entry'] as $user_id => $data_a) {
foreach ($data_a as $date_stamp => $data_b) {
if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'])) {
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = 0;
}
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']);
//Include tips in this amount as well.
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_tips']['include_pay_stub_entry_account'], $form_data['social_security_tips']['exclude_pay_stub_entry_account']);
//Handle additional medicare wages in excess of 200,000
if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'])) {
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] = 0;
}
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['medicare_wages'] += Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['medicare_wages']['include_pay_stub_entry_account'], $form_data['medicare_wages']['exclude_pay_stub_entry_account']);
}
}
}
//Debug::Arr($this->tmp_data['ytd_pay_stub_entry'], 'YTD Tmp Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
}
unset($pse_obj, $user_id, $date_stamp, $branch, $department, $pay_stub_entry_name_id, $this->tmp_data['pay_stub_entry']);
//Get just the data for the quarter now.
$pself->getAPIReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
if ($pself->getRecordCount() > 0) {
foreach ($pself as $pse_obj) {
$user_id = $this->user_ids[] = $pse_obj->getColumn('user_id');
//Always use middle day epoch, otherwise multiple entries could exist for the same day.
$date_stamp = TTDate::getMiddleDayEpoch(TTDate::strtotime($pse_obj->getColumn('pay_stub_transaction_date')));
$branch = $pse_obj->getColumn('default_branch');
$department = $pse_obj->getColumn('default_department');
$pay_stub_entry_name_id = $pse_obj->getPayStubEntryNameId();
if (!isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp] = array('pay_period_start_date' => strtotime($pse_obj->getColumn('pay_stub_start_date')), 'pay_period_end_date' => strtotime($pse_obj->getColumn('pay_stub_end_date')), 'pay_period_transaction_date' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')), 'pay_period' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')));
}
if (isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = bcadd($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id], $pse_obj->getColumn('amount'));
} else {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
}
}
if (isset($this->tmp_data['pay_stub_entry']) and is_array($this->tmp_data['pay_stub_entry'])) {
foreach ($this->tmp_data['pay_stub_entry'] as $user_id => $data_a) {
foreach ($data_a as $date_stamp => $data_b) {
$quarter_month = TTDate::getYearQuarterMonthNumber($date_stamp);
//Debug::Text('Quarter Month: '. $quarter_month .' Epoch: '. TTDate::getDate('DATE', $date_stamp), __FILE__, __LINE__, __METHOD__,10);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['wages']['include_pay_stub_entry_account'], $form_data['wages']['exclude_pay_stub_entry_account']);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['income_tax'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['income_tax']['include_pay_stub_entry_account'], $form_data['income_tax']['exclude_pay_stub_entry_account']);
//FIXME: If employees are excluded from Social Security, it will still include total wages
//resulting in the 941 form being incorrect in its calculation.
//Add Form Setup tab field to select the Social Security tax/deductions?
//However there can often be two of them, is just the employee one enough? We could use the employees and include/exclude accounts from that at least then.
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']);
//Handle social security wage limit.
if (!isset($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'])) {
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = 0;
}
if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] < $social_security_wage_limit) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_wages']['include_pay_stub_entry_account'], $form_data['social_security_wages']['exclude_pay_stub_entry_account']);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['social_security_tips']['include_pay_stub_entry_account'], $form_data['social_security_tips']['exclude_pay_stub_entry_account']);
if ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] > $social_security_wage_limit) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] = $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] - ($this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_wages'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] - $social_security_wage_limit);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['social_security_tips'] = 0;
$this->tmp_data['ytd_pay_stub_entry'][$user_id]['social_security_wages'] = $social_security_wage_limit;
//.........这里部分代码省略.........
示例12: dragNdropPunch
static function dragNdropPunch($company_id, $src_punch_id, $dst_punch_id, $dst_status_id = NULL, $position = 0, $action = 0, $dst_date = NULL)
{
/*
FIXME: This needs to handle batches to be able to handle all the differnet corner cases.
Operations to handle:
- Moving punch from Out to In, or In to Out in same punch pair, this is ALWAYS a move, and not a copy.
- Move punch from one pair to another in the same day, this can be a copy or move.
- Check moving AND copying Out punch from one punch pair to In in another on the same day. ie: In 8:00AM, Out 1:00PM, Out 5:00PM. Move the 1PM punch to pair with 5PM.
- Move punch from one day to another, inserting inbetween other punches if necessary.
- Move punch from one day to another without any other punches.
- Inserting BEFORE on a dst_punch_id that is an In punch doesn't do any splitting.
- Inserting AFTER on a dst_punch_id that is on a Out punch doesn't do any splitting.
- Overwriting should just take the punch time and overwrite the existing punch time.
- The first thing this function does it check if there are two punches assigned to the punch control of the destination punch, if there is, it splits the punches
across two punch_controls, it then attaches the src_punch_id to the same punch_control_id as the dst_punch_id.
- If no dst_punch_id is specified, assume copying to a blank cell, just copy the punch to that date along with the punch_control?
- Copying punches that span midnight work, however moving punches does not always
since we don't move punches in batches, we do it one at a time, and when the first punch punch
gets moved, it can cause other punches to follow it automatically.
*/
$dst_date = TTDate::getMiddleDayEpoch($dst_date);
Debug::text('Src Punch ID: ' . $src_punch_id . ' Dst Punch ID: ' . $dst_punch_id . ' Dst Status ID: ' . $dst_status_id . ' Position: ' . $position . ' Action: ' . $action . ' Dst Date: ' . $dst_date, __FILE__, __LINE__, __METHOD__, 10);
$retval = FALSE;
//Get source and destination punch objects.
$plf = TTnew('PunchListFactory');
$plf->StartTransaction();
$plf->getByCompanyIDAndId($company_id, $src_punch_id);
if ($plf->getRecordCount() == 1) {
$src_punch_obj = $plf->getCurrent();
$src_punch_date = TTDate::getMiddleDayEpoch($src_punch_obj->getPunchControlObject()->getUserDateObject()->getDateStamp());
Debug::text('Found SRC punch ID: ' . $src_punch_id . ' Source Punch Date: ' . $src_punch_date, __FILE__, __LINE__, __METHOD__, 10);
//Get the PunchControlObject as early as possible, before the punch is deleted, as it will be cleared even if Save(FALSE) is called below.
$src_punch_control_obj = clone $src_punch_obj->getPunchControlObject();
if (TTDate::getMiddleDayEpoch($src_punch_date) != TTDate::getMiddleDayEpoch($src_punch_obj->getTimeStamp())) {
Debug::text('Punch spans midnight... Source Punch Date: ' . TTDate::getDATE('DATE+TIME', $src_punch_date) . ' Source Punch TimeStamp: ' . TTDate::getDATE('DATE+TIME', $src_punch_obj->getTimeStamp()), __FILE__, __LINE__, __METHOD__, 10);
$dst_date_modifier = 86400;
//Bump day by 24hrs.
} else {
$dst_date_modifier = 0;
}
//If we are moving the punch, we need to delete the source punch first so it doesn't conflict with the new punch.
//Especially if we are just moving a punch to fill a gap in the same day.
//If the punch being moved is in the same day, or within the same punch pair, we don't want to delete the source punch, instead we just modify
//the necessary bits later on. So we need to short circuit the move functionality when copying/moving punches within the same day.
if ($action == 1 and $src_punch_id != $dst_punch_id and $src_punch_date != $dst_date or $action == 1 and $src_punch_id != $dst_punch_id and $src_punch_date == $dst_date) {
//Move
Debug::text('Deleting original punch...: ' . $src_punch_id, __FILE__, __LINE__, __METHOD__, 10);
$src_punch_obj->setUser($src_punch_control_obj->getUserDateObject()->getUser());
$src_punch_obj->setDeleted(TRUE);
//These aren't doing anything because they aren't acting on the PunchControl object?
$src_punch_obj->setEnableCalcTotalTime(TRUE);
$src_punch_obj->setEnableCalcSystemTotalTime(TRUE);
$src_punch_obj->setEnableCalcWeeklySystemTotalTime(TRUE);
$src_punch_obj->setEnableCalcUserDateTotal(TRUE);
$src_punch_obj->setEnableCalcException(TRUE);
$src_punch_obj->Save(FALSE);
//Keep object around for later.
} else {
Debug::text('NOT Deleting original punch, either in copy mode or condition is not met...', __FILE__, __LINE__, __METHOD__, 10);
}
if ($src_punch_id == $dst_punch_id or $dst_punch_id == '') {
//Assume we are just moving a punch within the same punch pair, unless a new date is specfied.
//However if we're simply splitting an existing punch pair, like dragging the Out punch from an In/Out pair into its own separate pair.
if ($src_punch_date != $dst_date or $src_punch_date == $dst_date and $dst_punch_id == '') {
Debug::text('aCopying punch to new day...', __FILE__, __LINE__, __METHOD__, 10);
//Moving punch to a new date.
//Copy source punch to proper location by destination punch.
$src_punch_obj->setId(FALSE);
$src_punch_obj->setPunchControlId((int) $src_punch_control_obj->getNextInsertId());
$src_punch_obj->setDeleted(FALSE);
//Just in case it was marked deleted by the MOVE action.
$new_time_stamp = TTDate::getTimeLockedDate($src_punch_obj->getTimeStamp(), $dst_date + $dst_date_modifier);
Debug::text('SRC TimeStamp: ' . TTDate::getDate('DATE+TIME', $src_punch_obj->getTimeStamp()) . ' DST TimeStamp: ' . TTDate::getDate('DATE+TIME', $new_time_stamp), __FILE__, __LINE__, __METHOD__, 10);
$src_punch_obj->setTimeStamp($new_time_stamp, FALSE);
$src_punch_obj->setActualTimeStamp($new_time_stamp);
$src_punch_obj->setOriginalTimeStamp($new_time_stamp);
if ($dst_status_id != '') {
$src_punch_obj->setStatus($dst_status_id);
//Change the status to fit in the proper place.
}
$src_punch_obj->setStation(NULL);
//When drag&drop copying punches, clear the station.
if ($src_punch_obj->isValid() == TRUE) {
$insert_id = $src_punch_obj->Save(FALSE);
$src_punch_control_obj->shift_data = NULL;
//Need to clear the shift data so its obtained from the DB again, otherwise shifts will appear on strange days.
$src_punch_control_obj->user_date_obj = NULL;
//Need to clear user_date_obj from cache so a new one is obtained.
$src_punch_control_obj->setId($src_punch_obj->getPunchControlID());
$src_punch_control_obj->setPunchObject($src_punch_obj);
if ($src_punch_control_obj->isValid() == TRUE) {
Debug::Text(' Punch Control is valid, saving...: ', __FILE__, __LINE__, __METHOD__, 10);
//We need to calculate new total time for the day and exceptions because we are never guaranteed that the gaps will be filled immediately after
//in the case of a drag & drop or something.
$src_punch_control_obj->setEnableStrictJobValidation(TRUE);
$src_punch_control_obj->setEnableCalcUserDateID(TRUE);
$src_punch_control_obj->setEnableCalcTotalTime(TRUE);
$src_punch_control_obj->setEnableCalcSystemTotalTime(TRUE);
//.........这里部分代码省略.........
示例13: _outputPDFTimesheet
function _outputPDFTimesheet($format)
{
Debug::Text(' Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
$border = 0;
$current_company = $this->getUserObject()->getCompanyObject();
if (!is_object($current_company)) {
Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
$pdf_created_date = time();
$adjust_x = 10;
$adjust_y = 10;
//Debug::Arr($this->form_data, 'Form Data: ', __FILE__, __LINE__, __METHOD__,10);
if (isset($this->form_data) and count($this->form_data) > 0) {
//Make sure we sort the form data for printable timesheets.
$this->form_data['user_date_total'] = Sort::arrayMultiSort($this->form_data['user_date_total'], $this->getSortConfig());
//Get pay period schedule data for each pay period.
$this->pdf = new TTPDF($this->config['other']['page_orientation'], 'mm', $this->config['other']['page_format'], $this->getUserObject()->getCompanyObject()->getEncoding());
$this->pdf->SetAuthor(APPLICATION_NAME);
$this->pdf->SetTitle($this->title);
$this->pdf->SetSubject(APPLICATION_NAME . ' ' . TTi18n::getText('Report'));
$this->pdf->setMargins($this->config['other']['left_margin'], $this->config['other']['top_margin'], $this->config['other']['right_margin']);
//Debug::Arr($this->config['other'], 'Margins: ', __FILE__, __LINE__, __METHOD__,10);
$this->pdf->SetAutoPageBreak(FALSE);
$this->pdf->SetFont($this->config['other']['default_font'], '', $this->_pdf_fontSize(10));
//Debug::Arr($this->form_data, 'zabUser Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
$filter_data = $this->getFilterConfig();
$columns = Misc::trimSortPrefix($this->getOptions('columns'));
$this->getProgressBarObject()->start($this->getAMFMessageID(), 2, NULL, TTi18n::getText('Querying Database...'));
//Iterations need to be 2, otherwise progress bar is not created.
$this->getProgressBarObject()->set($this->getAMFMessageID(), 2);
if ($format == 'pdf_timesheet_detail') {
$plf = TTnew('PunchListFactory');
$plf->getSearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
Debug::Text('Got punch data... Total Rows: ' . $plf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
$this->getProgressBarObject()->start($this->getAMFMessageID(), $plf->getRecordCount(), NULL, TTi18n::getText('Retrieving Punch Data...'));
if ($plf->getRecordCount() > 0) {
foreach ($plf as $key => $p_obj) {
$this->form_data['user_date_total'][$p_obj->getColumn('user_id')]['punch_rows'][$p_obj->getColumn('pay_period_id')][TTDate::strtotime($p_obj->getColumn('date_stamp'))][$p_obj->getPunchControlID()][$p_obj->getStatus()] = array('status_id' => $p_obj->getStatus(), 'type_id' => $p_obj->getType(), 'type_code' => $p_obj->getTypeCode(), 'time_stamp' => $p_obj->getTimeStamp());
$this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
}
}
unset($plf, $p_obj);
}
Debug::Text('Drawing timesheets...', __FILE__, __LINE__, __METHOD__, 10);
$this->getProgressBarObject()->start($this->getAMFMessageID(), count($this->form_data['user_date_total']), NULL, TTi18n::getText('Generating TimeSheets...'));
$key = 0;
foreach ($this->form_data['user_date_total'] as $user_data) {
if ($this->_pdf_checkMaximumPageLimit() == FALSE) {
Debug::Text('Exceeded maximum page count...', __FILE__, __LINE__, __METHOD__, 10);
//Exceeded maximum pages, stop processing.
$this->_pdf_displayMaximumPageLimitError();
break;
}
if (isset($user_data['first_name']) and isset($user_data['last_name']) and isset($user_data['employee_number'])) {
$this->pdf->AddPage($this->config['other']['page_orientation'], 'Letter');
$this->timesheetHeader($user_data);
//Start displaying dates/times here. Start with header.
$column_widths = array('line' => 5, 'date_stamp' => 20, 'dow' => 10, 'in_punch_time_stamp' => 20, 'out_punch_time_stamp' => 20, 'worked_time' => 20, 'regular_time' => 20, 'over_time' => 40.6, 'absence_time' => 45);
if (isset($user_data['data']) and is_array($user_data['data'])) {
$user_data['data'] = Sort::arrayMultiSort($user_data['data'], array('time_stamp' => SORT_ASC));
$this->timesheet_week_totals = Misc::preSetArrayValues(NULL, array('worked_time', 'absence_time', 'regular_time', 'over_time'), 0);
$this->timesheet_totals = array();
$this->timesheet_totals = Misc::preSetArrayValues($this->timesheet_totals, array('worked_time', 'absence_time', 'regular_time', 'over_time'), 0);
$this->counter_i = 1;
//Overall row counter.
$this->counter_x = 1;
//Row counter, starts over each week.
$this->counter_y = 1;
//Week counter.
$this->max_i = count($user_data['data']);
$prev_data = FALSE;
foreach ($user_data['data'] as $data) {
if ($this->_pdf_checkMaximumPageLimit() == FALSE) {
Debug::Text('Exceeded maximum page count...', __FILE__, __LINE__, __METHOD__, 10);
//Exceeded maximum pages, stop processing.
$this->_pdf_displayMaximumPageLimitError();
break 2;
}
if (isset($this->form_data['pay_period'][$data['pay_period_id']])) {
//Debug::Arr( $data, 'Data: i: '. $this->counter_i .' x: '. $this->counter_x .' Max I: '. $this->max_i, __FILE__, __LINE__, __METHOD__,10);
$data = Misc::preSetArrayValues($data, array('time_stamp', 'in_punch_time_stamp', 'out_punch_time_stamp', 'worked_time', 'absence_time', 'regular_time', 'over_time'), '--');
$data['start_week_day'] = $this->form_data['pay_period'][$data['pay_period_id']]['start_week_day'];
$row_date_gap = $prev_data !== FALSE ? TTDate::getMiddleDayEpoch($data['time_stamp']) - TTDate::getMiddleDayEpoch($prev_data['time_stamp']) : 0;
//Take into account DST by using mid-day epochs.
//Debug::Text('Row Gap: '. $row_date_gap, __FILE__, __LINE__, __METHOD__,10);
if ($prev_data !== FALSE and $row_date_gap > 86400) {
//Handle gaps between individual days with hours.
$prev_data = $this->timesheetHandleDayGaps($prev_data['time_stamp'] + 86400, $data['time_stamp'], $format, $columns, $column_widths, $user_data, $data, $prev_data);
} elseif ($this->counter_i == 1 and TTDate::getMiddleDayEpoch($data['time_stamp']) - TTDate::getMiddleDayEpoch($data['pay_period_start_date']) >= 86400) {
//Always fill gaps between the pay period start date and the date with time, even if not filtering by pay period.
//Handle gaps before the first date with hours is displayed, only when filtering by pay period though.
$prev_data = $this->timesheetHandleDayGaps($data['pay_period_start_date'], $data['time_stamp'], $format, $columns, $column_widths, $user_data, $data, $prev_data);
}
//Check for gaps at the end of the date range and before the end of the pay period.
//If we find one we have to increase $max_i by one so the last timesheetDayRow doesn't display the week totals.
if ($this->counter_i == $this->max_i and TTDate::getMiddleDayEpoch($data['pay_period_end_date']) - TTDate::getMiddleDayEpoch($data['time_stamp']) >= 86400) {
$this->max_i++;
}
$this->timesheetDayRow($format, $columns, $column_widths, $user_data, $data, $prev_data);
//.........这里部分代码省略.........
示例14: setHireDate
function setHireDate($epoch)
{
if (empty($epoch)) {
$epoch = NULL;
}
if ($epoch == '' or $this->Validator->isDate('hire_date', $epoch, TTi18n::gettext('Hire date is invalid'))) {
$this->data['hire_date'] = TTDate::getMiddleDayEpoch($epoch);
return TRUE;
}
return FALSE;
}
示例15: _getData
function _getData($format = NULL)
{
$this->tmp_data = array('user' => array(), 'pay_stub_entry' => array(), 'pay_period' => array());
$columns = $this->getColumnDataConfig();
$filter_data = $this->getFilterConfig();
$form_data = $this->formatFormConfig();
$pseallf = TTnew('PayStubEntryAccountLinkListFactory');
$pseallf->getByCompanyId($this->getUserObject()->getCompany());
if ($pseallf->getRecordCount() > 0) {
$pseal_obj = $pseallf->getCurrent();
}
$pself = TTnew('PayStubEntryListFactory');
$pself->getAPIReportByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data);
if ($pself->getRecordCount() > 0) {
foreach ($pself as $pse_obj) {
$user_id = $this->user_ids[] = $pse_obj->getColumn('user_id');
$date_stamp = TTDate::strtotime($pse_obj->getColumn('pay_stub_transaction_date'));
$branch = $pse_obj->getColumn('default_branch');
$department = $pse_obj->getColumn('default_department');
$pay_stub_entry_name_id = $pse_obj->getPayStubEntryNameId();
if (!isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp] = array('pay_period_start_date' => strtotime($pse_obj->getColumn('pay_stub_start_date')), 'pay_period_end_date' => strtotime($pse_obj->getColumn('pay_stub_end_date')), 'pay_period_transaction_date' => TTDate::getMiddleDayEpoch(strtotime($pse_obj->getColumn('pay_stub_transaction_date'))), 'pay_period' => strtotime($pse_obj->getColumn('pay_stub_transaction_date')));
$this->form_data['pay_period'][] = strtotime($pse_obj->getColumn('pay_stub_transaction_date'));
}
if (isset($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id])) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = bcadd($this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id], $pse_obj->getColumn('amount'));
} else {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['psen_ids'][$pay_stub_entry_name_id] = $pse_obj->getColumn('amount');
}
}
if (isset($this->tmp_data['pay_stub_entry']) and is_array($this->tmp_data['pay_stub_entry'])) {
foreach ($this->tmp_data['pay_stub_entry'] as $user_id => $data_a) {
foreach ($data_a as $date_stamp => $data_b) {
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['ei_total'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['ei']['include_pay_stub_entry_account'], $form_data['ei']['exclude_pay_stub_entry_account']);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['cpp_total'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['cpp']['include_pay_stub_entry_account'], $form_data['cpp']['exclude_pay_stub_entry_account']);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['tax_total'] = Misc::calculateMultipleColumns($data_b['psen_ids'], $form_data['tax']['include_pay_stub_entry_account'], $form_data['tax']['exclude_pay_stub_entry_account']);
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['total'] = $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['ei_total'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['cpp_total'] + $this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['tax_total'];
$this->tmp_data['pay_stub_entry'][$user_id][$date_stamp]['gross_payroll'] = Misc::calculateMultipleColumns($data_b['psen_ids'], (array) $pseal_obj->getTotalGross(), array());
}
}
}
}
$this->user_ids = array_unique($this->user_ids);
//Used to get the total number of employees.
//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()] = (array) $u_obj->getObjectAsArray($this->getColumnDataConfig());
$this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
}
//Debug::Arr($this->tmp_data['user'], 'User Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
return TRUE;
}