当前位置: 首页>>代码示例>>PHP>>正文


PHP TTDate::getBeginWeekEpoch方法代码示例

本文整理汇总了PHP中TTDate::getBeginWeekEpoch方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::getBeginWeekEpoch方法的具体用法?PHP TTDate::getBeginWeekEpoch怎么用?PHP TTDate::getBeginWeekEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TTDate的用法示例。


在下文中一共展示了TTDate::getBeginWeekEpoch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRecurringScheduleControlDefaultData

 /**
  * Get default recurring_schedule_control data for creating new recurring_schedule_controles.
  * @return array
  */
 function getRecurringScheduleControlDefaultData()
 {
     $company_obj = $this->getCurrentCompanyObject();
     Debug::Text('Getting recurring_schedule_control default data...', __FILE__, __LINE__, __METHOD__, 10);
     $data = array('company_id' => $company_obj->getId(), 'start_week' => 1, 'start_date' => TTDate::getAPIDate('DATE', TTDate::getBeginWeekEpoch(TTDate::getTime())), 'end_date' => NULL);
     return $this->returnHandler($data);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:11,代码来源:APIRecurringScheduleControl.class.php

示例2: 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;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:16,代码来源:APITimeSheet.class.php

示例3: generateData


//.........这里部分代码省略.........
                     $job_applicant_id = $this->createJobApplicant($company_id);
                     $y = 1;
                     while ($y <= rand(75, 150)) {
                         $this->createJobApplication($job_applicant_id, $job_vacancy_id, $user_id);
                         $y++;
                     }
                     $n = 1;
                     while ($n <= rand(2, 5)) {
                         $this->createJobApplicantLocation($job_applicant_id);
                         $this->createJobApplicantEmployment($job_applicant_id, $n * 10);
                         $this->createJobApplicantReference($job_applicant_id);
                         $this->createJobApplicantSkill($job_applicant_id, $qualification_ids['skill'][rand(0, count($qualification_ids['skill']) - 1)]);
                         $this->createJobApplicantEducation($job_applicant_id, $qualification_ids['education'][rand(0, count($qualification_ids['education']) - 1)]);
                         $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;
             }
开发者ID:alachaum,项目名称:timetrex,代码行数:67,代码来源:DemoData.class.php

示例4: testScheduleB

 function testScheduleB()
 {
     global $dd;
     $this->createPayPeriodSchedule(10);
     $this->createPayPeriods();
     $this->getAllPayPeriods();
     $date_epoch = TTDate::getBeginWeekEpoch(time());
     //Use current year
     $date_stamp = TTDate::getDate('DATE', $date_epoch);
     $date_epoch2 = TTDate::getBeginWeekEpoch(time()) + 86400;
     //Use current year
     $date_stamp2 = TTDate::getDate('DATE', $date_epoch2);
     $meal_policy_id = $this->createMealPolicy(10);
     //60min autodeduct
     $schedule_policy_id = $this->createSchedulePolicy($meal_policy_id);
     $schedule_id = $this->createSchedule($this->user_id, $date_epoch, array('schedule_policy_id' => $schedule_policy_id, 'start_time' => ' 11:00PM', 'end_time' => '8:00AM'));
     $slf = TTNew('ScheduleListFactory');
     $slf->getByID($schedule_id);
     if ($slf->getRecordCount() == 1) {
         $s_obj = $slf->getCurrent();
         $this->assertEquals($date_stamp, TTDate::getDate('DATE', $s_obj->getStartTime()));
         $this->assertEquals($date_stamp2, TTDate::getDate('DATE', $s_obj->getEndTime()));
         $this->assertEquals(8 * 3600, $s_obj->getTotalTime());
     } else {
         $this->assertEquals(TRUE, FALSE);
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:28,代码来源:ScheduleTest.php

示例5: getShiftsByStartDateAndEndDate

 function getShiftsByStartDateAndEndDate($start_date, $end_date)
 {
     //Make sure timezone isn't in the time format. Because recurring schedules
     //are timezone agnostic. 7:00AM in PST is also 7:00AM in EST.
     //This causes an issue where the previous users timezone carries over to the next
     //users timezone, causing errors.
     //TTDate::setTimeFormat('g:i A');
     if ($start_date == '') {
         return FALSE;
     }
     if ($end_date == '') {
         return FALSE;
     }
     if ($start_date < $this->getStartDate()) {
         $start_date = $this->getStartDate();
     }
     if ($this->getEndDate(TRUE) != NULL and $end_date > $this->getEndDate()) {
         $end_date = $this->getEndDate();
     }
     Debug::text('Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . '(' . $start_date . ') End Date: ' . TTDate::getDate('DATE+TIME', $end_date) . '(' . $end_date . ')', __FILE__, __LINE__, __METHOD__, 10);
     //Get week data
     $rstlf = TTnew('RecurringScheduleTemplateListFactory');
     $rstlf->getByRecurringScheduleTemplateControlId($this->getRecurringScheduleTemplateControl())->getCurrent();
     $max_week = 1;
     $weeks = array();
     if ($rstlf->getRecordCount() > 0) {
         foreach ($rstlf as $rst_obj) {
             //Debug::text('Week: '. $rst_obj->getWeek(), __FILE__, __LINE__, __METHOD__, 10);
             $template_week_rows[$rst_obj->getWeek()][] = $rst_obj->getObjectAsArray();
             $weeks[$rst_obj->getWeek()] = $rst_obj->getWeek();
             if ($rst_obj->getWeek() > $max_week) {
                 $max_week = $rst_obj->getWeek();
             }
         }
     }
     $weeks = $this->ReMapWeeks($weeks);
     //Get week of start_date
     $start_date_week = TTDate::getBeginWeekEpoch($this->getStartDate(), 0);
     //Start week on Sunday to match Recurring Schedule.
     //Debug::text('Week of Start Date: '. $start_date_week .' Date: '. TTDate::getDate('DATE+TIME', $this->getStartDate() ) ,__FILE__, __LINE__, __METHOD__, 10);
     //Since we add 43200 to each iteration (even though its removed right after), we need to add 43200 to the end_date as well so we loop the
     //proper amount of times, otherwise schedules may be added too late.
     for ($i = $start_date; $i <= $end_date + 43200; $i += 86400 + 43200) {
         //Handle DST by adding 12hrs to the date to get the mid-day epoch, then forcing it back to the beginning of the day.
         $i = TTDate::getBeginDayEpoch($i);
         //This needs to take into account weeks spanning January 1st of each year. Where the week goes from 53 to 1.
         //Rather then use the week of the year, calculate the weeks between the recurring schedule start date and now.
         $current_week = round((TTDate::getBeginWeekEpoch($i, 0) - $start_date_week) / 604800);
         //Find out which week we are on based on the recurring schedule start date. Use round due to DST the week might be 6.9 or 7.1, so we need to round to the nearest full week.
         //Debug::text('I: '. $i .' User ID: '. $this->getColumn('user_id') .' Current Date: '. TTDate::getDate('DATE+TIME', $i) .' Current Week: '. $current_week .' Start Week: '. $start_date_week,__FILE__, __LINE__, __METHOD__, 10);
         $template_week = $current_week % $max_week + 1;
         //Debug::text('Template Week: '. $template_week .' Max Week: '. $max_week,__FILE__, __LINE__, __METHOD__, 10);
         $day_of_week = strtolower(date('D', $i));
         //Debug::text('Day Of Week: '. $day_of_week,__FILE__, __LINE__, __METHOD__, 10);
         if (isset($weeks[$template_week])) {
             $mapped_template_week = $weeks[$template_week];
             //Debug::text('&nbsp;&nbsp;Mapped Template Week: '. $mapped_template_week,__FILE__, __LINE__, __METHOD__, 10);
             if (isset($template_week_rows[$mapped_template_week])) {
                 //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;Starting Looping...!',__FILE__, __LINE__, __METHOD__, 10);
                 foreach ($template_week_rows[$mapped_template_week] as $template_week_arr) {
                     if ($template_week_arr['days'][$day_of_week] == TRUE) {
                         //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Found Scheduled Time: Start Time: '. TTDate::getDate('DATE+TIME', TTDate::getTimeLockedDate( $template_week_arr['start_time'], $i ) ),__FILE__, __LINE__, __METHOD__, 10);
                         $start_time = TTDate::getTimeLockedDate($template_week_arr['raw_start_time'], $i);
                         $end_time = TTDate::getTimeLockedDate($template_week_arr['raw_end_time'], $i);
                         if ($end_time < $start_time) {
                             //Spans the day boundary, add 86400 to end_time
                             $end_time = $end_time + 86400;
                             //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Schedule spans day boundary, bumping endtime to next day: ',__FILE__, __LINE__, __METHOD__, 10);
                         }
                         //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start Date: '. TTDate::getDate('DATE+TIME', $start_time) .' End Date: '. TTDate::getDate('DATE+TIME', $end_time),__FILE__, __LINE__, __METHOD__, 10);
                         //$shifts[TTDate::getBeginDayEpoch($i)][] = array(
                         $shifts[TTDate::getISODateStamp($i)][] = array('status_id' => $template_week_arr['status_id'], 'start_time' => $start_time, 'raw_start_time' => TTDate::getDate('DATE+TIME', $start_time), 'end_time' => $end_time, 'raw_end_time' => TTDate::getDate('DATE+TIME', $end_time), 'total_time' => $template_week_arr['total_time'], 'schedule_policy_id' => $template_week_arr['schedule_policy_id'], 'branch_id' => $template_week_arr['branch_id'], 'department_id' => $template_week_arr['department_id'], 'job_id' => $template_week_arr['job_id'], 'job_item_id' => $template_week_arr['job_item_id']);
                         unset($start_time, $end_time);
                     } else {
                         //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aSkipping!',__FILE__, __LINE__, __METHOD__, 10);
                     }
                 }
             } else {
                 //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;bSkipping!',__FILE__, __LINE__, __METHOD__, 10);
             }
         } else {
             //Debug::text('&nbsp;&nbsp;cSkipping!',__FILE__, __LINE__, __METHOD__, 10);
         }
     }
     //var_dump($shifts);
     if (isset($shifts)) {
         return $shifts;
     }
     return FALSE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:90,代码来源:RecurringScheduleControlFactory.class.php

示例6: getShifts

 function getShifts($start_date, $end_date, &$holiday_data = array(), &$branch_options = array(), &$department_options = array(), &$n, &$shifts = array(), &$shifts_index = array(), $open_shift_conflict_index = array(), $permission_children_ids = NULL)
 {
     //Debug::text('Start Date: '. TTDate::getDate('DATE+TIME', $start_date) .' End Date: '. TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
     $recurring_schedule_control_start_date = TTDate::strtotime($this->getColumn('recurring_schedule_control_start_date'));
     //Debug::text('Recurring Schedule Control Start Date: '. TTDate::getDate('DATE+TIME', $recurring_schedule_control_start_date),__FILE__, __LINE__, __METHOD__, 10);
     $current_template_week = $this->getColumn('remapped_week');
     $max_week = $this->getColumn('max_week');
     //Debug::text('Template Week: '. $current_template_week .' Max Week: '. $this->getColumn('max_week') .' ReMapped Week: '. $this->getColumn('remapped_week') ,__FILE__, __LINE__, __METHOD__, 10);
     if ($recurring_schedule_control_start_date == '') {
         return FALSE;
     }
     //Get week of start_date
     $start_date_week = TTDate::getBeginWeekEpoch($recurring_schedule_control_start_date, 0);
     //Start week on Sunday to match Recurring Schedule.
     //Debug::text('Week of Start Date: '. $start_date_week ,__FILE__, __LINE__, __METHOD__, 10);
     $apf = TTnew('AbsencePolicyFactory');
     $absence_policy_paid_type_options = $apf->getOptions('paid_type');
     for ($i = $start_date; $i <= $end_date; $i += 86400 + 43200) {
         //Handle DST by adding 12hrs to the date to get the mid-day epoch, then forcing it back to the beginning of the day.
         $i = TTDate::getBeginDayEpoch($i);
         if ($this->getColumn('hire_date') != '' and $i < $this->getColumn('hire_date') or $this->getColumn('termination_date') != '' and $i > $this->getColumn('termination_date')) {
             //Debug::text('Skipping due to Hire/Termination date: User ID: '. $this->getColumn('user_id') .' I: '. $i .' Hire Date: '. $this->getColumn('hire_date') .' Termination Date: '. $this->getColumn('termination_date') ,__FILE__, __LINE__, __METHOD__, 10);
             continue;
         }
         //This needs to take into account weeks spanning January 1st of each year. Where the week goes from 53 to 1.
         //Rather then use the week of the year, calculate the weeks between the recurring schedule start date and now.
         $current_week = round((TTDate::getBeginWeekEpoch($i, 0) - $start_date_week) / 604800);
         //Find out which week we are on based on the recurring schedule start date. Use round due to DST the week might be 6.9 or 7.1, so we need to round to the nearest full week.
         //Debug::text('I: '. $i .' User ID: '. $this->getColumn('user_id') .' Current Date: '. TTDate::getDate('DATE+TIME', $i) .' Current Week: '. $current_week .' Start Week: '. $start_date_week,__FILE__, __LINE__, __METHOD__, 10);
         $template_week = $current_week % $max_week + 1;
         //Debug::text('Template Week: '. $template_week .' Max Week: '. $max_week,__FILE__, __LINE__, __METHOD__, 10);
         if ($template_week == $current_template_week) {
             //Debug::text('Current Date: '. TTDate::getDate('DATE+TIME', $i) .' Current Week: '. $current_week,__FILE__, __LINE__, __METHOD__, 10);
             //Debug::text('&nbsp;Template Week: '. $template_week .' Max Week: '. $max_week,__FILE__, __LINE__, __METHOD__, 10);
             if ($this->isActiveShiftDay($i)) {
                 //Debug::text('&nbsp;&nbsp;Active Shift on this day...',__FILE__, __LINE__, __METHOD__, 10);
                 $start_time = TTDate::getTimeLockedDate($this->getStartTime(), $i);
                 $end_time = TTDate::getTimeLockedDate($this->getEndTime(), $i);
                 if ($end_time < $start_time) {
                     //Spans the day boundary, add 86400 to end_time
                     $end_time = $end_time + 86400;
                     //Debug::text('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Schedule spans day boundary, bumping endtime to next day: ',__FILE__, __LINE__, __METHOD__, 10);
                 }
                 $iso_date_stamp = TTDate::getISODateStamp(PayPeriodScheduleFactory::getShiftAssignedDate($start_time, $end_time, $this->getColumn('shift_assigned_day_id')));
                 //$iso_date_stamp = TTDate::getISODateStamp( $i );
                 $open_shift_multiplier = $this->getColumn('user_id') == 0 ? $this->getOpenShiftMultiplier() : 1;
                 //Debug::text('Open Shift Multiplier: '. $open_shift_multiplier,__FILE__, __LINE__, __METHOD__, 10);
                 for ($x = 0; $x < $open_shift_multiplier; $x++) {
                     //Check all non-OPEN shifts for conflicts.
                     if ($this->getColumn('user_id') > 0 and isset($shifts_index[$iso_date_stamp][$this->getColumn('user_id')])) {
                         //User has previous recurring schedule shifts, check for overlap.
                         //Loop over each employees shift for this day and check for conflicts
                         foreach ($shifts_index[$iso_date_stamp][$this->getColumn('user_id')] as $shift_key) {
                             if (isset($shifts[$iso_date_stamp][$shift_key])) {
                                 //Must use parseDateTime() when called from the API due to date formats that strtotime() fails on.
                                 if (TTDate::isTimeOverLap(defined('TIMETREX_API') ? TTDate::parseDateTime($shifts[$iso_date_stamp][$shift_key]['start_date']) : $shifts[$iso_date_stamp][$shift_key]['start_date'], defined('TIMETREX_API') ? TTDate::parseDateTime($shifts[$iso_date_stamp][$shift_key]['end_date']) : $shifts[$iso_date_stamp][$shift_key]['end_date'], $start_time, $end_time) == TRUE) {
                                     //Debug::text('&nbsp;&nbsp;Found overlapping recurring schedules! User ID: '. $this->getColumn('user_id') .' Start Time: '. $start_time,__FILE__, __LINE__, __METHOD__, 10);
                                     continue 2;
                                 }
                             }
                         }
                         unset($shift_key);
                     } elseif ($this->getColumn('user_id') == 0 and isset($shifts_index[$iso_date_stamp])) {
                         //Debug::text('    Checking OPEN shift conflicts... Date: '. $iso_date_stamp,__FILE__, __LINE__, __METHOD__, 10);
                         //Check all OPEN shifts for conflicts.
                         //This is special, since there can be multiple open shifts for the same branch,department,job,task, so we need to check if are conflicts with *any* employee.
                         //Do we allow conflicting shifts between committed and recurring OPEN shifts? For example what if there are two open shifts on the same day
                         //6AM-3PM (x2) and they want to override one of those shifts to 7AM-4PM? If we use this check:
                         //   ( $shifts[$iso_date_stamp][$shift_key]['user_id'] > 0 OR ( isset($shifts[$iso_date_stamp][$shift_key]['id']) AND $shifts[$iso_date_stamp][$shift_key]['id'] > 0 ) )
                         //That allows committed OPEN shifts to override recurring open shifts, which is great, but it prevents adding additional open shifts that may
                         //also overlap unless they override all recurring shifts first. I think this is the trade-off we have to make as its more likely that they
                         //will adjust an open shift time rather than add/remove specific shifts. Removing recurring OPEN shifts can be done by making them ABSENT.
                         //This will also affect when recurring OPEN shifts are committed by preventing the shifts from doubling up.
                         foreach ($shifts_index[$iso_date_stamp] as $tmp_index_user_id => $tmp_index_arr) {
                             foreach ($tmp_index_arr as $shift_key) {
                                 $tmp_start_date = defined('TIMETREX_API') ? TTDate::parseDateTime($shifts[$iso_date_stamp][$shift_key]['start_date']) : $shifts[$iso_date_stamp][$shift_key]['start_date'];
                                 $tmp_end_date = defined('TIMETREX_API') ? TTDate::parseDateTime($shifts[$iso_date_stamp][$shift_key]['end_date']) : $shifts[$iso_date_stamp][$shift_key]['end_date'];
                                 if (($shifts[$iso_date_stamp][$shift_key]['user_id'] > 0 or isset($shifts[$iso_date_stamp][$shift_key]['id']) and $shifts[$iso_date_stamp][$shift_key]['id'] > 0) and (!isset($open_shift_conflict_index['open'][$this->getID()][$shift_key]) and (isset($shifts[$iso_date_stamp][$shift_key]['id']) and !isset($open_shift_conflict_index['scheduled'][$shifts[$iso_date_stamp][$shift_key]['id']]))) and $this->getColumn('schedule_branch_id') == $shifts[$iso_date_stamp][$shift_key]['branch_id'] and $this->getColumn('schedule_department_id') == $shifts[$iso_date_stamp][$shift_key]['department_id'] and $this->getColumn('job_id') == $shifts[$iso_date_stamp][$shift_key]['job_id'] and $this->getColumn('job_item_id') == $shifts[$iso_date_stamp][$shift_key]['job_item_id'] and ($tmp_start_date == $start_time and $tmp_end_date == $end_time)) {
                                     //Debug::text('      Found OPEN shift conflict... Skipping...! Shift Key: '. $shift_key,__FILE__, __LINE__, __METHOD__, 10);
                                     //We need to track each shift_key that caused a conflict so it can't cause another conflict later on.
                                     //  Make sure we just track it on a per template basis though, otherwise the same $shift_key from a previous template can affect other templates.
                                     //  The above issue would show up as OPEN shifts not being overridden.
                                     //We also need to track which scheduled shift that caused a conflict so it can't cause another one later on.
                                     //  This prevents a single scheduled shift from overriding multiple OPEN shifts of different times.
                                     //However we need to be smarter about which shifts override which OPEN shifts...
                                     //  So if there are two open shifts, 10AM-4PM and 3:50PM-9PM, a 10AM-4PM scheduled shift overrides the OPEN shift that best fits it (10AM to 4PM, *not* 3:50-9PM)
                                     //  For now require an exact match to override an OPEN shift, if we start using partial schedules it gets much more complicated.
                                     //  Or we could introduce a hardcoded "fudge factor" setting (ie: 5 mins) that is always used instead.
                                     $open_shift_conflict_index['open'][$this->getID()][$shift_key] = TRUE;
                                     $open_shift_conflict_index['scheduled'][$shifts[$iso_date_stamp][$shift_key]['id']] = TRUE;
                                     continue 3;
                                 }
                                 unset($tmp_start_date, $tmp_end_date);
                             }
                         }
                         unset($tmp_index_user_id, $tmp_index_arr);
                     }
                     //This check has to occurr after the committed schedule check, otherwise no committed schedules will appear.
                     if ($this->getColumn('recurring_schedule_control_start_date') != '' and $i < TTDate::strtotime($this->getColumn('recurring_schedule_control_start_date')) or $this->getColumn('recurring_schedule_control_end_date') != '' and $i > TTDate::strtotime($this->getColumn('recurring_schedule_control_end_date'))) {
                         //Debug::text('Skipping due to Recurring Schedule Start/End date: ID: '. $this->getColumn('id') .' User ID: '. $this->getColumn('user_id') .' I: '. $i .' Start Date: '. $this->getColumn('recurring_schedule_control_start_date') .' ('. TTDate::strtotime( $this->getColumn('recurring_schedule_control_start_date') ) .') End Date: '. $this->getColumn('recurring_schedule_control_end_date') ,__FILE__, __LINE__, __METHOD__, 10);
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:RecurringScheduleTemplateFactory.class.php

示例7: createPayPeriodSchedule

 function createPayPeriodSchedule()
 {
     $ppsf = new PayPeriodScheduleFactory();
     $ppsf->setCompany($this->company_id);
     //$ppsf->setName( 'Bi-Weekly'.rand(1000,9999) );
     $ppsf->setName('Bi-Weekly');
     $ppsf->setDescription('Pay every two weeks');
     $ppsf->setType(20);
     $ppsf->setStartWeekDay(0);
     $anchor_date = TTDate::getBeginWeekEpoch(TTDate::getBeginYearEpoch());
     //Start 6 weeks ago
     $ppsf->setAnchorDate($anchor_date);
     $ppsf->setStartDayOfWeek(TTDate::getDayOfWeek($anchor_date));
     $ppsf->setTransactionDate(7);
     $ppsf->setTransactionDateBusinessDay(TRUE);
     $ppsf->setDayStartTime(0);
     $ppsf->setNewDayTriggerTime(4 * 3600);
     $ppsf->setMaximumShiftTime(16 * 3600);
     $ppsf->setShiftAssignedDay(10);
     //$ppsf->setContinuousTime( (4*3600) );
     $ppsf->setEnableInitialPayPeriods(FALSE);
     if ($ppsf->isValid()) {
         $insert_id = $ppsf->Save(FALSE);
         Debug::Text('Pay Period Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         $ppsf->setUser(array($this->user_id));
         $ppsf->Save();
         $this->pay_period_schedule_id = $insert_id;
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:32,代码来源:PremiumPolicyTest.php

示例8: 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());
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:RecurringPayStubAmendmentFactory.class.php

示例9: createPayPeriods

 function createPayPeriods($start_date = NULL)
 {
     if ($start_date == '') {
         $start_date = TTDate::getBeginWeekEpoch(TTDate::getBeginYearEpoch(time()) - 86400 * (7 * 6));
     }
     $max_pay_periods = 192;
     //Make a lot of pay periods as we need to test 6 years worth of accruals for different milestones.
     $ppslf = new PayPeriodScheduleListFactory();
     $ppslf->getById($this->pay_period_schedule_id);
     if ($ppslf->getRecordCount() > 0) {
         $pps_obj = $ppslf->getCurrent();
         for ($i = 0; $i < $max_pay_periods; $i++) {
             if ($i == 0) {
                 //$end_date = TTDate::getBeginYearEpoch( strtotime('01-Jan-07') );
                 $end_date = $start_date;
             } else {
                 $end_date = $end_date + 86400 * 14;
             }
             Debug::Text('I: ' . $i . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
             $pps_obj->createNextPayPeriod($end_date, 86400 * 3600);
         }
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:24,代码来源:AccrualPolicyTest.php

示例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) {
开发者ID:alachaum,项目名称:timetrex,代码行数:67,代码来源:ExceptionPolicyFactory.class.php

示例11: testAutoAddMultipleBreakPolicyE

 function testAutoAddMultipleBreakPolicyE()
 {
     global $dd;
     $policy_ids['break'][] = $this->createBreakPolicy($this->company_id, 150);
     $policy_ids['break'][] = $this->createBreakPolicy($this->company_id, 152);
     $policy_ids['break'][] = $this->createBreakPolicy($this->company_id, 154);
     $policy_ids['break'][] = $this->createBreakPolicy($this->company_id, 156);
     //This one shouldn't apply
     //Create Policy Group
     $dd->createPolicyGroup($this->company_id, NULL, NULL, NULL, NULL, NULL, NULL, array($this->user_id), $policy_ids['break']);
     $date_epoch = TTDate::getBeginWeekEpoch(time());
     $date_stamp = TTDate::getDate('DATE', $date_epoch);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 8:00AM'), strtotime($date_stamp . ' 10:00AM'), array('in_type_id' => 10, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 10:06AM'), strtotime($date_stamp . ' 12:00PM'), array('in_type_id' => 30, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 12:06PM'), strtotime($date_stamp . ' 2:15PM'), array('in_type_id' => 30, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 2:21PM'), strtotime($date_stamp . ' 4:30PM'), array('in_type_id' => 30, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 4:36PM'), strtotime($date_stamp . ' 5:30PM'), array('in_type_id' => 30, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $udt_arr = $this->getUserDateTotalArray($date_epoch, $date_epoch);
     //print_r($udt_arr);
     //Total Time
     $this->assertEquals($udt_arr[$date_epoch][0]['status_id'], 10);
     $this->assertEquals($udt_arr[$date_epoch][0]['type_id'], 10);
     $this->assertEquals($udt_arr[$date_epoch][0]['total_time'], 9.5 * 3600);
     //Regular Time
     $this->assertEquals($udt_arr[$date_epoch][1]['status_id'], 10);
     $this->assertEquals($udt_arr[$date_epoch][1]['type_id'], 20);
     $this->assertEquals($udt_arr[$date_epoch][1]['total_time'], 9.5 * 3600);
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:29,代码来源:MealBreakPolicyTest.php

示例12: urlencode

     Redirect::Page(URLBuilder::getURL(array('filter_user_id' => $filter_data['user_id']), '../pay_stub_amendment/PayStubAmendmentList.php'));
     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;
             }
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:ViewUserTimeSheet.php

示例13: testRoundingD

 function testRoundingD()
 {
     global $dd;
     $this->createPayPeriodSchedule(10);
     $this->createPayPeriods();
     $this->getAllPayPeriods();
     $policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 30);
     //Day Total
     $policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 40);
     //Lunch Total
     $policy_ids['round'][] = $dd->createRoundingPolicy($this->company_id, 50);
     //Break Total
     //Create Policy Group
     $dd->createPolicyGroup($this->company_id, NULL, NULL, NULL, NULL, NULL, $policy_ids['round'], array($this->user_id));
     $date_epoch = TTDate::getBeginWeekEpoch(time());
     $date_stamp = TTDate::getDate('DATE', $date_epoch);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 8:03AM'), NULL, array('in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, NULL, strtotime($date_stamp . ' 12:06PM'), array('in_type_id' => 10, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 1:12PM'), NULL, array('in_type_id' => 30, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, NULL, strtotime($date_stamp . ' 5:07PM'), array('in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_arr = $this->getPunchDataArray(TTDate::getBeginDayEpoch($date_epoch), TTDate::getEndDayEpoch($date_epoch));
     //print_r($punch_arr);
     $this->assertEquals(2, count($punch_arr[$date_epoch]));
     $this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][0]['time_stamp'], strtotime($date_stamp . ' 8:03AM'));
     $this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][1]['time_stamp'], strtotime($date_stamp . ' 12:06PM'));
     $this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][2]['time_stamp'], strtotime($date_stamp . ' 1:06PM'));
     $this->assertEquals($punch_arr[$date_epoch][0]['shift_data']['punches'][3]['time_stamp'], strtotime($date_stamp . ' 5:03PM'));
     $udt_arr = $this->getUserDateTotalArray($date_epoch, $date_epoch);
     //Total Time
     $this->assertEquals(10, $udt_arr[$date_epoch][0]['status_id']);
     $this->assertEquals(10, $udt_arr[$date_epoch][0]['type_id']);
     $this->assertEquals(8 * 3600, $udt_arr[$date_epoch][0]['total_time']);
     return TRUE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:34,代码来源:PunchTest.php

示例14: testMaximumShiftTimeD

 function testMaximumShiftTimeD()
 {
     global $dd;
     $this->createPayPeriodSchedule(10);
     $this->createPayPeriods();
     $this->getAllPayPeriods();
     $date_epoch = TTDate::getBeginWeekEpoch(time());
     $date_stamp = TTDate::getDate('DATE', $date_epoch);
     $date_epoch2 = TTDate::getBeginDayEpoch(TTDate::getBeginWeekEpoch(time()) + 86400 + 3600);
     $date_stamp2 = TTDate::getDate('DATE', $date_epoch2);
     //Create two punch pairs with LESS than the minimum time between shifts, so they both fall on the same day, but are considered ONE shift and therefore fails.
     //However the last punch must be more than 16hrs away from the previous OUT punch (2:30PM)
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 1:00AM'), strtotime($date_stamp . ' 2:30PM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $dd->createPunchPair($this->user_id, strtotime($date_stamp . ' 6:15PM'), strtotime($date_stamp2 . ' 8:00AM'), array('in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_arr = $this->getPunchDataArray(TTDate::getBeginDayEpoch($date_epoch), TTDate::getEndDayEpoch($date_epoch2));
     //print_r($punch_arr);
     $this->assertEquals(2, count($punch_arr[$date_epoch][0]['shift_data']['punches']));
     $this->assertEquals(1, count($punch_arr[$date_epoch][0]['shift_data']['punch_control_ids']));
     //$this->assertEquals( $date_epoch, $punch_arr[$date_epoch][0]['date_stamp'] );
     $udt_arr = $this->getUserDateTotalArray($date_epoch, $date_epoch2);
     //Total Time
     $this->assertEquals(10, $udt_arr[$date_epoch][0]['status_id']);
     $this->assertEquals(10, $udt_arr[$date_epoch][0]['type_id']);
     $this->assertEquals(13.5 * 3600, $udt_arr[$date_epoch][0]['total_time']);
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:26,代码来源:PunchTest.php

示例15: calcExceptions


//.........这里部分代码省略.........
                             Debug::text(' Worked Over Daily Hours', __FILE__, __LINE__, __METHOD__, 10);
                             $ef = new ExceptionFactory();
                             $ef->setUserDateID($user_date_id);
                             $ef->setExceptionPolicyID($ep_obj->getId());
                             $ef->setType($type_id);
                             $ef->setEnableDemerits(TRUE);
                             if ($ef->isValid()) {
                                 if ($enable_premature_exceptions == TRUE) {
                                     $ef->emailException($user_date_obj->getUserObject(), $user_date_obj, $ep_obj);
                                 }
                                 $ef->Save();
                             }
                         } 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) {
                         //Get Pay Period Schedule info
                         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;
                         if (strtolower($ep_obj->getType()) == 's9') {
                             $tmp_slf = new ScheduleListFactory();
                             $tmp_slf->getByUserIdAndStartDateAndEndDate($user_date_obj->getUser(), TTDate::getBeginWeekEpoch($user_date_obj->getDateStamp(), $start_week_day_id), $user_date_obj->getDateStamp());
                             if ($tmp_slf->getRecordCount() > 0) {
                                 foreach ($tmp_slf as $s_obj) {
                                     $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 = new 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);
                         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_total_time > 0 and $weekly_total_time > $weekly_scheduled_total_time + $ep_obj->getGrace()) {
                             Debug::text(' Worked Over Weekly Hours', __FILE__, __LINE__, __METHOD__, 10);
                             $ef = new ExceptionFactory();
                             $ef->setUserDateID($user_date_id);
                             $ef->setExceptionPolicyID($ep_obj->getId());
                             $ef->setType($type_id);
                             $ef->setEnableDemerits(TRUE);
                             if ($ef->isValid()) {
                                 if ($enable_premature_exceptions == TRUE) {
                                     $ef->emailException($user_date_obj->getUserObject(), $user_date_obj, $ep_obj);
                                 }
                                 $ef->Save();
                             }
                         } else {
                             Debug::text(' DID NOT Work Over Scheduled Hours', __FILE__, __LINE__, __METHOD__, 10);
                         }
                     }
                     break;
                 case 'l1':
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:67,代码来源:ExceptionPolicyFactory.class.php


注:本文中的TTDate::getBeginWeekEpoch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。