本文整理汇总了PHP中TTDate::getEndWeekEpoch方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getEndWeekEpoch方法的具体用法?PHP TTDate::getEndWeekEpoch怎么用?PHP TTDate::getEndWeekEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::getEndWeekEpoch方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTimeSheetDates
/**
* Get all necessary dates for building the TimeSheet in a single call, this is mainly as a performance optimization.
* @param array $data filter data
* @return array
*/
function getTimeSheetDates($base_date)
{
$epoch = TTDate::parseDateTime($base_date);
if ($epoch == '') {
$epoch = TTDate::getTime();
}
$start_date = TTDate::getBeginWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$retarr = array('base_date' => $epoch, 'start_date' => $start_date, 'end_date' => $end_date, 'base_display_date' => TTDate::getAPIDate('DATE', $epoch), 'start_display_date' => TTDate::getAPIDate('DATE', $start_date), 'end_display_date' => TTDate::getAPIDate('DATE', $end_date));
return $retarr;
}
示例2: generateData
//.........这里部分代码省略.........
$job_ids[] = $this->createJob($company_id, 25, $default_task_id, $job_group_ids[5], $branch_ids[1], $department_ids[1]);
} else {
$task_ids[] = 0;
$job_ids[] = 0;
}
//Create Accrual balances
foreach ($user_ids as $user_id) {
foreach ($policy_ids['accrual'] as $accrual_policy_id) {
$this->createAccrualBalance($user_id, $accrual_policy_id);
}
unset($accrual_policy_id);
}
//Create recurring schedule templates
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 10, $policy_ids['schedule_1']);
//Morning shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 20, $policy_ids['schedule_1']);
//Afternoon shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 30, $policy_ids['schedule_1']);
//Evening shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 40);
//Split Shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 50, $policy_ids['schedule_1']);
//Full rotation
$recurring_schedule_start_date = TTDate::getBeginWeekEpoch($current_epoch + 86400 * 7.5);
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[0], $recurring_schedule_start_date, '', array($user_ids[0], $user_ids[1], $user_ids[2], $user_ids[3], $user_ids[4]));
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[1], $recurring_schedule_start_date, '', array($user_ids[5], $user_ids[6], $user_ids[7], $user_ids[8], $user_ids[9]));
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[2], $recurring_schedule_start_date, '', array($user_ids[10], $user_ids[11], $user_ids[12], $user_ids[13], $user_ids[14]));
//Create schedule for each employee.
foreach ($user_ids as $user_id) {
//Create schedule starting 6 weeks ago, up to the end of the week.
$schedule_options_arr = array('status_id' => 10, 'start_time' => '08:00AM', 'end_time' => '05:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']);
//$schedule_date = ($current_epoch-(86400*42));
$schedule_date = $current_epoch - 86400 * 14;
$schedule_end_date = TTDate::getEndWeekEpoch($current_epoch);
//$schedule_date = ($current_epoch-(86400*14));
//$schedule_end_date = ($current_epoch+(86400*28));
while ($schedule_date <= $schedule_end_date) {
//Random departments/branches
$schedule_options_arr['branch_id'] = $branch_ids[rand(0, count($branch_ids) - 1)];
$schedule_options_arr['department_id'] = $department_ids[rand(0, count($department_ids) - 1)];
//Skip weekends.
if (date('w', $schedule_date) != 0 and date('w', $schedule_date) != 6) {
$this->createSchedule($user_id, $schedule_date, $schedule_options_arr);
}
$schedule_date += 86400;
}
//break;
unset($schedule_options_arr, $schedule_date, $schedule_end_date, $user_id);
}
//Punch users in/out randomly.
foreach ($user_ids as $user_id) {
//Pick random jobs/tasks that are used for the entire date range.
//So one employee isn't punching into 15 jobs.
$user_random_job_ids = array_rand($job_ids, 2);
$user_random_task_ids = array_rand($job_ids, 3);
//Create punches starting 6 weeks ago, up to the end of the week.
//$start_date = $punch_date = ($current_epoch-(86400*42));
$start_date = $punch_date = $current_epoch - 86400 * 14;
$end_date = TTDate::getEndWeekEpoch($current_epoch);
//$start_date = $punch_date = ($current_epoch-(86400*14));
//$end_date = ($current_epoch+(86400*28));
$i = 0;
while ($punch_date <= $end_date) {
$date_stamp = TTDate::getDate('DATE', $punch_date);
//$punch_full_time_stamp = strtotime($pc_data['date_stamp'].' '.$pc_data['time_stamp']);
$exception_cutoff_date = $current_epoch - 86400 * 14;
示例3: getScheduleDates
/**
* Get all necessary dates for building the schedule in a single call, this is mainly as a performance optimization.
* @param array $data filter data
* @return array
*/
function getScheduleDates($base_date, $type, $strict = TRUE)
{
$epoch = TTDate::parseDateTime($base_date);
if ($epoch == '') {
$epoch = TTDate::getTime();
}
if ($type == '') {
$type = 'week';
}
switch (strtolower($type)) {
case 'day':
if ($strict == TRUE) {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getEndDayEpoch($epoch);
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 86400);
}
break;
case 'week':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch($epoch, $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 7 * 86400);
}
break;
case 'month':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 30 * 86400);
}
break;
case 'year':
if ($strict == TRUE) {
$start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginMonthEpoch($epoch), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch(TTDate::getEndMonthEpoch(TTDate::getEndMonthEpoch($epoch) + 86400 * 2), $this->getCurrentUserPreferenceObject()->getStartWeekDay());
} else {
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) + 62 * 86400);
}
break;
}
$retarr = array('base_date' => $epoch, 'start_date' => $start_date, 'end_date' => $end_date, 'base_display_date' => TTDate::getAPIDate('DATE', $epoch), 'start_display_date' => TTDate::getAPIDate('DATE', $start_date), 'end_display_date' => TTDate::getAPIDate('DATE', $end_date));
Debug::Arr($retarr, 'Schedule Dates: Base Date: ' . $base_date . ' Type: ' . $type . ' Strict: ' . (int) $strict, __FILE__, __LINE__, __METHOD__, 10);
return $retarr;
}
示例4: createPayStubAmendments
function createPayStubAmendments($epoch = NULL)
{
//Get all recurring pay stub amendments and generate single pay stub amendments if appropriate.
if ($epoch == '') {
$epoch = TTDate::getTime();
}
$ulf = TTnew('UserListFactory');
Debug::text('Recurring PS Amendment ID: ' . $this->getId() . ' Frequency: ' . $this->getFrequency(), __FILE__, __LINE__, __METHOD__, 10);
$this->StartTransaction();
$tmp_user_ids = $this->getUser();
if ($tmp_user_ids[0] == -1) {
$ulf->getByCompanyIdAndStatus($this->getCompany(), 10);
foreach ($ulf as $user_obj) {
$user_ids[] = $user_obj->getId();
}
unset($user_obj);
} else {
$user_ids = $this->getUser();
}
unset($tmp_user_ids);
Debug::text('Total User IDs: ' . count($user_ids), __FILE__, __LINE__, __METHOD__, 10);
if (is_array($user_ids) and count($user_ids) > 0) {
//Make the PS amendment duplicate check start/end date separate
//Make the PS amendment effective date separate.
switch ($this->getFrequency()) {
case 10:
//Get all open pay periods
$pplf = TTnew('PayPeriodListFactory');
//FIXME: Get all non-closed pay periods AFTER the start date.
$pplf->getByUserIdListAndNotStatusAndStartDateAndEndDate($user_ids, 20, $this->getStartDate(), $this->getEndDate());
//All non-closed pay periods
Debug::text('Found Open Pay Periods: ' . $pplf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
foreach ($pplf as $pay_period_obj) {
Debug::text('Working on Pay Period: ' . $pay_period_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
//If near the end of a pay period, or a pay period is already ended, add PS amendment if
//it does not already exist.
if ($epoch >= $pay_period_obj->getEndDate() and $this->checkTimeFrame($epoch)) {
Debug::text('After end of pay period. Start Date: ' . TTDate::getDate('DATE+TIME', $pay_period_obj->getStartDate()) . ' End Date: ' . TTDate::getDate('DATE+TIME', $pay_period_obj->getEndDate()), __FILE__, __LINE__, __METHOD__, 10);
$psalf = TTnew('PayStubAmendmentListFactory');
//Loop through each user of this Pay Period Schedule adding PS amendments if they don't already exist.
$pay_period_schedule_users = $pay_period_obj->getPayPeriodScheduleObject()->getUser();
Debug::text(' Pay Period Schedule Users: ' . count($pay_period_schedule_users), __FILE__, __LINE__, __METHOD__, 10);
foreach ($pay_period_schedule_users as $user_id) {
//Make sure schedule user is in the PS amendment user list and user is active.
Debug::text(' Pay Period Schedule User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//Debug::Arr($user_ids, ' Recurring PS Amendment Selected Users: ', __FILE__, __LINE__, __METHOD__,10);
if ($ulf->getById($user_id)->getCurrent()->getStatus() == 10 and in_array($user_id, $user_ids)) {
//Check to see if the amendment was added already.
if ($psalf->getByUserIdAndRecurringPayStubAmendmentIdAndStartDateAndEndDate($user_id, $this->getId(), $pay_period_obj->getStartDate(), $pay_period_obj->getEndDate())->getRecordCount() == 0) {
//No amendment, good to insert one
Debug::text('Inserting Recurring PS Amendment for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
$psaf = TTnew('PayStubAmendmentFactory');
$psaf->setUser($user_id);
$psaf->setStatus(50);
$psaf->setType($this->getType());
$psaf->setRecurringPayStubAmendmentId($this->getId());
$psaf->setPayStubEntryNameId($this->getPayStubEntryNameId());
if ($this->getType() == 10) {
$psaf->setRate($this->getRate());
$psaf->setUnits($this->getUnits());
$psaf->setAmount($this->getAmount());
} else {
$psaf->setPercentAmount($this->getPercentAmount());
$psaf->setPercentAmountEntryNameID($this->getPercentAmountEntryNameId());
}
$psaf->setDescription($this->getPayStubAmendmentDescription());
$psaf->setEffectiveDate(TTDate::getBeginDayEpoch($pay_period_obj->getEndDate()));
if ($psaf->isValid()) {
$psaf->Save();
}
} else {
//Amendment already inserted!
Debug::text('Recurring PS Amendment already inserted for User: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
}
} else {
Debug::text('Skipping User because they are INACTIVE or are not on the Recurring PS Amendment User List - ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//continue;
}
}
} else {
Debug::text('Not in TimeFrame, not inserting amendments: Epoch: ' . $epoch . ' Pay Period End Date: ' . $pay_period_obj->getEndDate(), __FILE__, __LINE__, __METHOD__, 10);
}
}
break;
case 30:
//Weekly
//Weekly
case 40:
//Monthly
//Monthly
case 70:
//Annually
switch ($this->getFrequency()) {
case 30:
$trigger_date = TTDate::getDateOfNextDayOfWeek(TTDate::getBeginWeekEpoch($epoch), $this->getStartDate());
$start_date = TTDate::getBeginWeekEpoch($epoch);
$end_date = TTDate::getEndWeekEpoch($epoch);
break;
case 40:
$trigger_date = TTDate::getDateOfNextDayOfMonth(TTDate::getBeginMonthEpoch($epoch), $this->getStartDate());
//.........这里部分代码省略.........
示例5: generateData
//.........这里部分代码省略.........
$this->createJobApplicantLicense($job_applicant_id, $qualification_ids['license'][rand(0, count($qualification_ids['license']) - 1)]);
$this->createJobApplicantLanguage($job_applicant_id, $qualification_ids['language'][rand(0, count($qualification_ids['language']) - 1)]);
$this->createJobApplicantMembership($job_applicant_id, $qualification_ids['membership'][rand(0, count($qualification_ids['membership']) - 1)], $currency_ids[0]);
$n++;
}
}
$x++;
}
}
//Create recurring schedule templates
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 10, $policy_ids['schedule_1']);
//Morning shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 20, $policy_ids['schedule_1']);
//Afternoon shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 30, $policy_ids['schedule_1']);
//Evening shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 40);
//Split Shift
$recurring_schedule_ids[] = $this->createRecurringScheduleTemplate($company_id, 50, $policy_ids['schedule_1']);
//Full rotation
$recurring_schedule_start_date = TTDate::getBeginWeekEpoch($current_epoch + 86400 * 7.5);
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[0], $recurring_schedule_start_date, '', array($user_ids[0], $user_ids[1], $user_ids[2], $user_ids[3], $user_ids[4]));
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[1], $recurring_schedule_start_date, '', array($user_ids[5], $user_ids[6], $user_ids[7], $user_ids[8], $user_ids[9]));
$this->createRecurringSchedule($company_id, $recurring_schedule_ids[2], $recurring_schedule_start_date, '', array($user_ids[10], $user_ids[11], $user_ids[12], $user_ids[13], $user_ids[14]));
//Create different schedule shifts.
$schedule_options_arr = array(array('status_id' => 10, 'start_time' => '06:00AM', 'end_time' => '03:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']), array('status_id' => 10, 'start_time' => '10:00AM', 'end_time' => '07:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']), array('status_id' => 10, 'start_time' => '2:00PM', 'end_time' => '11:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']), array('status_id' => 10, 'start_time' => '08:00AM', 'end_time' => '05:00PM', 'schedule_policy_id' => $policy_ids['schedule_1']));
//Create schedule for each employee.
$x = 0;
foreach ($user_ids as $user_id) {
//Create schedule starting 6 weeks ago, up to the end of the week.
Debug::Text('Creating schedule for User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
//$schedule_date = ($current_epoch-(86400*42));
$schedule_date = $current_epoch - 86400 * 14;
$schedule_end_date = TTDate::getEndWeekEpoch($current_epoch);
//$schedule_date = ($current_epoch-(86400*14));
//$schedule_end_date = ($current_epoch+(86400*28));
while ($schedule_date <= $schedule_end_date) {
if ($x % 5 == 0) {
$schedule_options_key = 3;
//Common shift
} else {
$schedule_options_key = array_rand($schedule_options_arr);
}
Debug::Text(' Schedule Date: ' . $schedule_date . ' Schedule Options Key: ' . $schedule_options_key, __FILE__, __LINE__, __METHOD__, 10);
//Random departments/branches
$schedule_options_arr[$schedule_options_key]['branch_id'] = $branch_ids[rand(0, count($branch_ids) - 1)];
$schedule_options_arr[$schedule_options_key]['department_id'] = $department_ids[rand(0, count($department_ids) - 1)];
//Schedule just weekdays for users 1-4, then weekends and not mon/tue for user 5.
if ($x % 5 != 0 and date('w', $schedule_date) != 0 and date('w', $schedule_date) != 6 or $x % 5 == 0 and date('w', $schedule_date) != 1 and date('w', $schedule_date) != 2) {
$this->createSchedule($company_id, $user_id, $schedule_date, $schedule_options_arr[$schedule_options_key]);
}
$schedule_date += 86400;
}
//break;
unset($schedule_date, $schedule_end_date, $user_id);
$x++;
}
unset($schedule_options_arr, $schedule_options_key);
//Punch users in/out randomly.
foreach ($user_ids as $user_id) {
//Pick random jobs/tasks that are used for the entire date range.
//So one employee isn't punching into 15 jobs.
$user_random_job_ids = array_rand($job_ids, 2);
$user_random_task_ids = array_rand($job_ids, 3);
//Create punches starting 6 weeks ago, up to the end of the week.
//$start_date = $punch_date = ($current_epoch-(86400*42));
示例6: TTnew
}
}
default:
if ($permission->Check('schedule', 'view')) {
Debug::text('Viewing all users schedule', __FILE__, __LINE__, __METHOD__, 10);
if ($filter_user_id != '') {
$user_id = $filter_user_id;
} else {
$user_id = $current_user->getId();
}
} else {
$user_id = $current_user->getId();
}
if ($filter_start_date == '' or $filter_end_date == '') {
$start_date = $filter_start_date = TTDate::getBeginWeekEpoch(TTDate::getTime() - 86400, $current_user_prefs->getStartWeekDay());
$end_date = $filter_end_date = TTDate::getEndWeekEpoch(TTDate::getTime() + 86400 * 28, $current_user_prefs->getStartWeekDay());
}
//$start_date = $filter_start_date = TTDate::getBeginWeekEpoch( $start_date, 'mon');
//$end_date = $filter_end_date = TTDate::getEndWeekEpoch( $end_date, 'mon' );
Debug::text(' Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
$sf = TTnew('ScheduleFactory');
$default_schedule_shifts = $sf->getScheduleArray($user_id, $start_date, $end_date);
//var_dump($default_schedule_shifts);
$calendar_array = TTDate::getCalendarArray($start_date, $end_date, $current_user_prefs->getStartWeekDay());
$smarty->assign_by_ref('calendar_array', $calendar_array);
//$smarty->assign_by_ref('pay_period_locked_rows', $pay_period_locked_rows);
$ulf = TTnew('UserListFactory');
$user_obj = $ulf->getById($user_id)->getCurrent();
/*
$holiday = new Holiday();
$holiday->GetByCountryAndProvince($user_obj->getCountry(), $user_obj->getProvince() );
示例7: getCalendarArray
function getCalendarArray($start_date, $end_date, $start_day_of_week = 0, $force_weeks = TRUE)
{
if ($start_date == '' or $end_date == '') {
return FALSE;
}
//Which day begins the week, Mon or Sun?
//0 = Sun 1 = Mon
/*
if ( strtolower($start_day_of_week) == 'mon' OR $start_day_of_week == 1) {
$start_day_of_week = 1;
} else {
$start_day_of_week = 0;
}
*/
Debug::text(' Start Day Of Week: ' . $start_day_of_week, __FILE__, __LINE__, __METHOD__, 10);
Debug::text(' Raw Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' Raw End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
if ($force_weeks == TRUE) {
$cal_start_date = TTDate::getBeginWeekEpoch($start_date, $start_day_of_week);
//$cal_end_date = TTDate::getEndWeekEpoch($end_date, $start_day_of_week);
$cal_end_date = TTDate::getEndWeekEpoch($end_date, $start_day_of_week);
} else {
$cal_start_date = $start_date;
$cal_end_date = $end_date;
}
Debug::text(' Cal Start Date: ' . TTDate::getDate('DATE+TIME', $cal_start_date) . ' Cal End Date: ' . TTDate::getDate('DATE+TIME', $cal_end_date), __FILE__, __LINE__, __METHOD__, 10);
$prev_month = NULL;
//$prev_week=NULL;
$x = 0;
//Gotta add more then 86400 because of day light savings time.
//Causes infinite loop without it.
//Don't add 7200 to Cal End Date because that could cause more then one
//week to be displayed.
//for($i=$cal_start_date; $i <= $cal_end_date; $i+=86400) {
//for($i=$cal_start_date; $i <= ($cal_end_date+7200); $i+=93600) {
for ($i = $cal_start_date; $i <= $cal_end_date; $i += 93600) {
if ($x > 200) {
break;
}
$i = TTDate::getBeginDayEpoch($i);
$current_month = date('n', $i);
//$current_week = date('W', $i);
$current_day_of_week = date('w', $i);
if ($current_month != $prev_month and $i >= $start_date) {
$isNewMonth = TRUE;
} else {
$isNewMonth = FALSE;
}
//if ( $current_week != $prev_week ) {
if ($current_day_of_week == $start_day_of_week) {
$isNewWeek = TRUE;
} else {
$isNewWeek = FALSE;
}
//Display only blank boxes if the date is before the filter start date, or after.
if ($i >= $start_date and $i <= $end_date) {
$day_of_week = TTi18n::gettext(date('D', $i));
// i18n: these short day strings may not be in .po file.
$day_of_month = date('j', $i);
$month_name = TTi18n::gettext(date('F', $i));
// i18n: these short month strings may not be defined in .po file.
} else {
//Always have the day of the week at least.
//$day_of_week = TTi18n::gettext( date('D', $i) ); // i18n: these short day strings may not be in .po file.
$day_of_week = NULL;
$day_of_month = NULL;
$month_name = NULL;
}
$retarr[] = array('epoch' => $i, 'date_stamp' => TTDate::getISODateStamp($i), 'start_day_of_week' => $start_day_of_week, 'day_of_week' => $day_of_week, 'day_of_month' => $day_of_month, 'month_name' => $month_name, 'month_short_name' => substr($month_name, 0, 3), 'month' => $current_month, 'isNewMonth' => $isNewMonth, 'isNewWeek' => $isNewWeek);
$prev_month = $current_month;
//$prev_week = $current_week;
//Debug::text('i: '. $i .' Date: '. TTDate::getDate('DATE+TIME', $i), __FILE__, __LINE__, __METHOD__,10);
$x++;
}
return $retarr;
}
示例8: smartReCalculate
static function smartReCalculate($user_id, $user_date_ids, $enable_exception = TRUE, $enable_premature_exceptions = FALSE, $enable_future_exceptions = TRUE)
{
if ($user_id == '') {
return FALSE;
}
//Debug::Arr($user_date_ids, 'aUser Date IDs: ', __FILE__, __LINE__, __METHOD__, 10);
if (!is_array($user_date_ids) and is_numeric($user_date_ids) and $user_date_ids > 0) {
$user_date_ids = array($user_date_ids);
}
if (!is_array($user_date_ids)) {
Debug::Text('Returning FALSE... User Date IDs not an array...', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
$user_date_ids = array_unique($user_date_ids);
//Debug::Arr($user_date_ids, 'bUser Date IDs: ', __FILE__, __LINE__, __METHOD__, 10);
$start_week_day_id = 0;
$ppslf = TTnew('PayPeriodScheduleListFactory');
$ppslf->getByUserId($user_id);
if ($ppslf->getRecordCount() == 1) {
$pps_obj = $ppslf->getCurrent();
$start_week_day_id = $pps_obj->getStartWeekDay();
}
Debug::text('Start Week Day ID: ' . $start_week_day_id, __FILE__, __LINE__, __METHOD__, 10);
//Get date stamps for all user_date_ids.
$udlf = TTnew('UserDateListFactory');
$udlf->getByIds($user_date_ids, NULL, array('date_stamp' => 'asc'));
//Order by date asc
if ($udlf->getRecordCount() > 0) {
//Order them, and get the one or more sets of date ranges that need to be recalculated.
//Need to consider re-calculating multiple weeks at once.
$i = 0;
foreach ($udlf as $ud_obj) {
$start_week_epoch = TTDate::getBeginWeekEpoch($ud_obj->getDateStamp(), $start_week_day_id);
$end_week_epoch = TTDate::getEndWeekEpoch($ud_obj->getDateStamp(), $start_week_day_id);
Debug::text('Current Date: ' . TTDate::getDate('DATE', $ud_obj->getDateStamp()) . ' Start Week: ' . TTDate::getDate('DATE', $start_week_epoch) . ' End Week: ' . TTDate::getDate('DATE', $end_week_epoch), __FILE__, __LINE__, __METHOD__, 10);
if ($i == 0) {
$range_arr[$start_week_epoch] = array('start_date' => $ud_obj->getDateStamp(), 'end_date' => $end_week_epoch);
} else {
//Loop through each range extending it if needed.
foreach ($range_arr as $tmp_start_week_epoch => $tmp_range) {
if ($ud_obj->getDateStamp() >= $tmp_range['start_date'] and $ud_obj->getDateStamp() <= $tmp_range['end_date']) {
//Date falls within already existing range
continue;
} elseif ($ud_obj->getDateStamp() < $tmp_range['start_date'] and $ud_obj->getDateStamp() >= $tmp_start_week_epoch) {
//Date falls within the same week, but before the current start date.
$range_arr[$tmp_start_week_epoch]['start_date'] = $ud_obj->getDateStamp();
Debug::text('Pushing Start Date back...', __FILE__, __LINE__, __METHOD__, 10);
} else {
//Outside current range. Check to make sure it isn't within another range.
if (isset($range_arr[$start_week_epoch])) {
//Within another existing week, check to see if we need to extend it.
if ($ud_obj->getDateStamp() < $range_arr[$start_week_epoch]['start_date']) {
Debug::text('bPushing Start Date back...', __FILE__, __LINE__, __METHOD__, 10);
$range_arr[$start_week_epoch]['start_date'] = $ud_obj->getDateStamp();
}
} else {
//Not within another existing week
Debug::text('Adding new range...', __FILE__, __LINE__, __METHOD__, 10);
$range_arr[$start_week_epoch] = array('start_date' => $ud_obj->getDateStamp(), 'end_date' => $end_week_epoch);
}
}
}
unset($tmp_range, $tmp_start_week_epoch);
}
$i++;
}
unset($start_week_epoch, $end_week_epoch, $udlf, $ud_obj);
if (is_array($range_arr)) {
ksort($range_arr);
//Sort range by start week, so recalculating goes in date order.
//Debug::Arr($range_arr, 'Range Array: ', __FILE__, __LINE__, __METHOD__, 10);
foreach ($range_arr as $week_range) {
$udlf = TTnew('UserDateListFactory');
$udlf->getByUserIdAndStartDateAndEndDate($user_id, $week_range['start_date'], $week_range['end_date']);
if ($udlf->getRecordCount() > 0) {
Debug::text('Found days to re-calculate: ' . $udlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
$udlf->StartTransaction();
$z = 1;
$z_max = $udlf->getRecordCount();
foreach ($udlf as $ud_obj) {
//We only need to re-calculate exceptions on the exact days specified by user_date_ids.
//This was the case before we Over Weekly Time/Over Scheduled Weekly Time exceptions,
//Now we have to enable calculating exceptions for the entire week.
Debug::text('Re-calculating day with exceptions: ' . $ud_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
if ($z == $z_max) {
//Enable recalculating holidays at the end of each week.
UserDateTotalFactory::reCalculateDay($ud_obj->getId(), $enable_exception, $enable_premature_exceptions, $enable_future_exceptions, TRUE);
} else {
UserDateTotalFactory::reCalculateDay($ud_obj->getId(), $enable_exception, $enable_premature_exceptions, $enable_future_exceptions);
}
$z++;
}
$udlf->CommitTransaction();
}
}
//Use the last date to base the future week calculation on. Make sure we don't unset $week_range['end_date']
//When BiWeekly overtime policies are calculated, it sets getEnableCalcFutureWeek() to TRUE.
if (isset($week_range['end_date']) and UserDateTotalFactory::getEnableCalcFutureWeek() == TRUE) {
$future_week_date = $week_range['end_date'] + 86400 * 7;
Debug::text('Found Biweekly overtime policy, calculate one week into the future: ' . TTDate::getDate('DATE', $future_week_date), __FILE__, __LINE__, __METHOD__, 10);
//.........这里部分代码省略.........
示例9: getTimePeriodDates
public static function getTimePeriodDates($time_period, $epoch = NULL, $user_obj = NULL, $params = NULL)
{
$time_period = Misc::trimSortPrefix($time_period);
if ($epoch == NULL or $epoch == '' or !is_numeric($epoch)) {
$epoch = self::getTime();
}
$start_week_day = 0;
if (is_object($user_obj)) {
$user_prefs = $user_obj->getUserPreferenceObject();
if (is_object($user_prefs)) {
$start_week_day = $user_prefs->getStartWeekDay();
}
}
switch ($time_period) {
case 'custom_date':
//Params must pass start_date/end_date
if (isset($params['start_date'])) {
$start_date = TTDate::getBeginDayEpoch($params['start_date']);
}
if (isset($params['end_date'])) {
$end_date = TTDate::getEndDayEpoch($params['end_date']);
}
break;
case 'custom_time':
//Params must pass start_date/end_date
if (isset($params['start_date'])) {
$start_date = $params['start_date'];
}
if (isset($params['end_date'])) {
$end_date = $params['end_date'];
}
break;
case 'custom_pay_period':
//Params must pass pay_period_ids
if (isset($params['pay_period_id'])) {
$pay_period_ids = (array) $params['pay_period_id'];
}
break;
case 'today':
$start_date = TTDate::getBeginDayEpoch($epoch);
$end_date = TTDate::getEndDayEpoch($epoch);
break;
case 'yesterday':
$start_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400);
$end_date = TTDate::getEndDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400);
break;
case 'last_24_hours':
$start_date = $epoch - 86400;
$end_date = $epoch;
break;
case 'last_48_hours':
$start_date = $epoch - 86400 * 2;
$end_date = $epoch;
break;
case 'last_72_hours':
$start_date = $epoch - 86400 * 3;
$end_date = $epoch;
break;
case 'this_week':
$start_date = TTDate::getBeginWeekEpoch($epoch, $start_week_day);
$end_date = TTDate::getEndWeekEpoch($epoch, $start_week_day);
break;
case 'last_week':
$start_date = TTDate::getBeginWeekEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 7, $start_week_day);
$end_date = TTDate::getEndWeekEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 7, $start_week_day);
break;
case 'last_2_weeks':
$start_date = TTDate::getBeginWeekEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 14, $start_week_day);
$end_date = TTDate::getEndWeekEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 7, $start_week_day);
break;
case 'last_7_days':
$start_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 7);
$end_date = TTDate::getEndDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400);
break;
case 'last_14_days':
$start_date = TTDate::getBeginDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400 * 14);
$end_date = TTDate::getEndDayEpoch(TTDate::getMiddleDayEpoch($epoch) - 86400);
break;
//Params must be passed if more than one pay period schedule exists.
//Params must be passed if more than one pay period schedule exists.
case 'no_pay_period':
case 'this_pay_period':
case 'last_pay_period':
Debug::text('Time Period for Pay Period Schedule selected...', __FILE__, __LINE__, __METHOD__, 10);
//Make sure user_obj is set.
if (!is_object($user_obj)) {
Debug::text('User Object was not passsed...', __FILE__, __LINE__, __METHOD__, 10);
break;
}
if (!isset($params['pay_period_schedule_id'])) {
$params['pay_period_schedule_id'] = NULL;
}
$pay_period_ids = array();
//Since we allow multiple pay_period schedules to be selected, we have to return pay_period_ids, not start/end dates.
if ($time_period == 'this_pay_period') {
Debug::text('this_pay_period', __FILE__, __LINE__, __METHOD__, 10);
$pplf = TTnew('PayPeriodListFactory');
$pplf->getThisPayPeriodByCompanyIdAndPayPeriodScheduleIdAndDate($user_obj->getCompany(), $params['pay_period_schedule_id'], time());
if ($pplf->getRecordCount() > 0) {
foreach ($pplf as $pp_obj) {
//.........这里部分代码省略.........
示例10: calcExceptions
//.........这里部分代码省略.........
}
}
Debug::text(' Daily Total Time: ' . $daily_total_time . ' Watch Window: ' . $ep_obj->getWatchWindow() . ' User Date ID: ' . $user_date_id, __FILE__, __LINE__, __METHOD__, 10);
if ($daily_total_time > 0 and $daily_total_time > $ep_obj->getWatchWindow()) {
Debug::text(' Worked Over Daily Hours', __FILE__, __LINE__, __METHOD__, 10);
$current_exceptions[] = array('user_date_id' => $user_date_id, 'exception_policy_id' => $ep_obj->getId(), 'type_id' => $type_id, 'punch_id' => FALSE, 'punch_control_id' => FALSE);
} else {
Debug::text(' DID NOT Work Over Scheduled Hours', __FILE__, __LINE__, __METHOD__, 10);
}
}
break;
case 'o2':
//Over Weekly Time.
//Over Weekly Time.
case 's9':
//Over Weekly Scheduled Time.
if ($plf->getRecordCount() > 0) {
//FIXME: Assign this exception to the last punch of the day, so it can be related back to a punch branch/department?
//Get Pay Period Schedule info
//FIXME: Do we want to trigger this before their last out punch?
if (is_object($user_date_obj->getPayPeriodObject()) and is_object($user_date_obj->getPayPeriodObject()->getPayPeriodScheduleObject())) {
$start_week_day_id = $user_date_obj->getPayPeriodObject()->getPayPeriodScheduleObject()->getStartWeekDay();
} else {
$start_week_day_id = 0;
}
Debug::text('Start Week Day ID: ' . $start_week_day_id, __FILE__, __LINE__, __METHOD__, 10);
$weekly_scheduled_total_time = 0;
//Currently we only consider committed scheduled shifts. We may need to change this to take into account
//recurring scheduled shifts that haven't been committed yet as well.
//In either case though we should take into account the entires week worth of scheduled time even if we are only partially through
//the week, that way we won't be triggering s9 exceptions on a Wed and a Fri or something, it will only occur on the last days of the week.
if (strtolower($ep_obj->getType()) == 's9') {
$tmp_slf = TTnew('ScheduleListFactory');
$tmp_slf->getByUserIdAndStartDateAndEndDate($user_date_obj->getUser(), TTDate::getBeginWeekEpoch($user_date_obj->getDateStamp(), $start_week_day_id), TTDate::getEndWeekEpoch($user_date_obj->getDateStamp(), $start_week_day_id));
if ($tmp_slf->getRecordCount() > 0) {
foreach ($tmp_slf as $s_obj) {
if ($s_obj->getStatus() == 10) {
//Only working shifts.
$weekly_scheduled_total_time += $s_obj->getTotalTime();
}
}
}
unset($tmp_slf, $s_obj);
}
//This ONLY takes in to account WORKED hours, not paid absence hours.
$weekly_total_time = 0;
//Get daily total time.
$udtlf = TTnew('UserDateTotalListFactory');
$weekly_total_time = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($user_date_obj->getUser(), TTDate::getBeginWeekEpoch($user_date_obj->getDateStamp(), $start_week_day_id), $user_date_obj->getDateStamp());
Debug::text(' Weekly Total Time: ' . $weekly_total_time . ' Weekly Scheduled Total Time: ' . $weekly_scheduled_total_time . ' Watch Window: ' . $ep_obj->getWatchWindow() . ' Grace: ' . $ep_obj->getGrace() . ' User Date ID: ' . $user_date_id, __FILE__, __LINE__, __METHOD__, 10);
//Don't trigger either of these exceptions unless both the worked and scheduled time is greater than 0. If they aren't scheduled at all
//it should trigger a Unscheduled Absence exception instead of a over weekly scheduled time exception.
if (strtolower($ep_obj->getType()) == 'o2' and $weekly_total_time > 0 and $weekly_total_time > $ep_obj->getWatchWindow() or strtolower($ep_obj->getType()) == 's9' and $weekly_scheduled_total_time > 0 and $weekly_total_time > 0 and $weekly_total_time > $weekly_scheduled_total_time + $ep_obj->getGrace()) {
Debug::text(' Worked Over Weekly Hours', __FILE__, __LINE__, __METHOD__, 10);
$current_exceptions[] = array('user_date_id' => $user_date_id, 'exception_policy_id' => $ep_obj->getId(), 'type_id' => $type_id, 'punch_id' => FALSE, 'punch_control_id' => FALSE);
} else {
Debug::text(' DID NOT Work Over Scheduled Hours', __FILE__, __LINE__, __METHOD__, 10);
}
}
break;
case 'l1':
//Long Lunch
//Long Lunch
case 'l2':
//Short Lunch
if ($plf->getRecordCount() > 0) {
示例11: urlencode
break;
case 'recalculate_company':
Debug::Text('Recalculating company timesheet!', __FILE__, __LINE__, __METHOD__, 10);
//Redirect::Page( URLBuilder::getURL( array('action' => 'recalculate_company', 'pay_period_ids' => $pay_period_id, 'next_page' => urlencode( URLBuilder::getURL( array('filter_date' => $filter_date ), '../timesheet/ViewUserTimeSheet.php') ) ), '../progress_bar/ProgressBarControl.php') );
Redirect::Page(URLBuilder::getURL(array('action' => 'recalculate_company', 'pay_period_ids' => $pay_period_id, 'next_page' => urlencode(URLBuilder::getURL(NULL, '../timesheet/ViewUserTimeSheet.php'))), '../progress_bar/ProgressBarControl.php'), FALSE);
break;
case 'recalculate_employee':
Debug::Text('Recalculating employee timesheet!', __FILE__, __LINE__, __METHOD__, 10);
Redirect::Page(URLBuilder::getURL(array('action' => 'recalculate_employee', 'pay_period_ids' => $pay_period_id, 'filter_user_id' => $filter_data['user_id'], 'next_page' => urlencode(URLBuilder::getURL(NULL, '../timesheet/ViewUserTimeSheet.php'))), '../progress_bar/ProgressBarControl.php'), FALSE);
break;
case 'submit':
default:
BreadCrumb::setCrumb($title);
Debug::Text('Default Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10);
$start_date = TTDate::getBeginWeekEpoch($filter_data['date'], $current_user_prefs->getStartWeekDay());
$end_date = TTDate::getEndWeekEpoch($filter_data['date'], $current_user_prefs->getStartWeekDay());
Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
$calendar_array = TTDate::getCalendarArray($start_date, $end_date, $current_user_prefs->getStartWeekDay());
//var_dump($calendar_array);
//Get all punches, put in array by date epoch.
$plf = TTnew('PunchListFactory');
$plf->getByCompanyIDAndUserIdAndStartDateAndEndDate($current_company->getId(), $user_id, $start_date, $end_date);
if ($plf->getRecordCount() > 0) {
foreach ($plf as $punch_obj) {
$user_date_stamp = TTDate::strtotime($punch_obj->getColumn('user_date_stamp'));
if ($punch_obj->getColumn('note') != '') {
$has_note = TRUE;
} else {
$has_note = FALSE;
}
$punches[$user_date_stamp][] = array('date_stamp' => $punch_obj->getColumn('user_date_stamp'), 'id' => $punch_obj->getId(), 'punch_control_id' => $punch_obj->getPunchControlId(), 'time_stamp' => $punch_obj->getTimeStamp(), 'status_id' => $punch_obj->getStatus(), 'type_id' => $punch_obj->getType(), 'type_code' => $punch_obj->getTypeCode(), 'has_note' => $has_note);
示例12: getPunch
/**
* Get punch data for one or more punches.
* @param array $data filter data
* @return array
*/
function getPunch($data = NULL, $disable_paging = FALSE)
{
if (!$this->getPermissionObject()->Check('punch', 'enabled') or !($this->getPermissionObject()->Check('punch', 'view') or $this->getPermissionObject()->Check('punch', 'view_own') or $this->getPermissionObject()->Check('punch', 'view_child'))) {
return $this->getPermissionObject()->PermissionDenied();
}
$data = $this->initializeFilterAndPager($data, $disable_paging);
$data['filter_data']['permission_children_ids'] = $this->getPermissionObject()->getPermissionChildren('punch', 'view');
//As a performance optimization to prevent the API from having to do additional date lookups, accept a single "date" field, that converts
//into start/end dates.
if (isset($data['filter_data']['date']) and $data['filter_data']['date'] != '') {
$data['filter_data']['start_date'] = TTDate::getBeginWeekEpoch($data['filter_data']['date'], $this->getCurrentUserPreferenceObject()->getStartWeekDay());
$data['filter_data']['end_date'] = TTDate::getEndWeekEpoch($data['filter_data']['date'], $this->getCurrentUserPreferenceObject()->getStartWeekDay());
}
//No filter data, restrict to last pay period as a performance optimization when hundreds of thousands of punches exist.
//The issue with this though is that the API doesn't know what the filter criteria is, so it can't display this to the user.
if (count($data['filter_data']) == 1 and !isset($data['filter_data']['pay_period_ids'])) {
Debug::Text('Adding default filter data...', __FILE__, __LINE__, __METHOD__, 10);
$pplf = TTnew('PayPeriodListFactory');
$pplf->getByCompanyId($this->getCurrentCompanyObject()->getId());
$pay_period_ids = array_keys((array) $pplf->getArrayByListFactory($pplf, FALSE, FALSE));
if (isset($pay_period_ids[0]) and isset($pay_period_ids[1])) {
$data['filter_data']['pay_period_ids'] = array($pay_period_ids[0], $pay_period_ids[1]);
}
unset($pplf, $pay_period_ids);
}
$blf = TTnew('PunchListFactory');
$blf->getAPISearchByCompanyIdAndArrayCriteria($this->getCurrentCompanyObject()->getId(), $data['filter_data'], $data['filter_items_per_page'], $data['filter_page'], NULL, $data['filter_sort']);
Debug::Text('Record Count: ' . $blf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
if ($blf->getRecordCount() > 0) {
$this->getProgressBarObject()->start($this->getAMFMessageID(), $blf->getRecordCount());
$this->setPagerObject($blf);
foreach ($blf as $b_obj) {
$retarr[] = $b_obj->getObjectAsArray($data['filter_columns'], $data['filter_data']['permission_children_ids']);
$this->getProgressBarObject()->set($this->getAMFMessageID(), $blf->getCurrentRow());
}
$this->getProgressBarObject()->stop($this->getAMFMessageID());
return $this->returnHandler($retarr);
}
return $this->returnHandler(TRUE);
//No records returned.
}