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


PHP TTDate::getBeginDayEpoch方法代码示例

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


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

示例1: getShiftData

 function getShiftData($user_date_id = NULL, $user_id = NULL, $epoch = NULL, $filter = NULL, $tmp_punch_control_obj = NULL, $maximum_shift_time = NULL, $new_shift_trigger_time = NULL, $plf = NULL)
 {
     global $profiler;
     $profiler->startTimer('PayPeriodScheduleFactory::getShiftData()');
     if (is_numeric($user_date_id) and $user_date_id > 0) {
         $user_id = $epoch = NULL;
     }
     if ($user_date_id == '' and $user_id == '' and $epoch == '') {
         return FALSE;
     }
     if ($maximum_shift_time === NULL) {
         $maximum_shift_time = $this->getMaximumShiftTime();
     }
     //Debug::text('User Date ID: '. $user_date_id .' User ID: '. $user_id .' TimeStamp: '. TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
     if ($new_shift_trigger_time === NULL) {
         $new_shift_trigger_time = $this->getNewDayTriggerTime();
     }
     if (!is_object($plf)) {
         $plf = TTnew('PunchListFactory');
         if ($user_date_id != '') {
             $plf->getByUserDateId($user_date_id);
         } else {
             //Get punches by time stamp.
             $punch_control_id = 0;
             if (is_object($tmp_punch_control_obj)) {
                 $punch_control_id = $tmp_punch_control_obj->getId();
             }
             //We need to double the maximum shift time when searching for punches.
             //Assuming a maximum punch time of 14hrs:
             // In: 10:00AM Out: 2:00PM
             // In: 6:00PM Out: 6:00AM (next day)
             // The above scenario when adding the last 6:00AM punch on the next day will only look back 14hrs and not find the first
             // punch pair, therefore allowing more than 14hrs on the same day.
             // So we need to extend the maximum shift time just when searching for punches and let getShiftData() sort out the proper maximum shift time itself.
             $plf->getShiftPunchesByUserIDAndEpoch($user_id, $epoch, $punch_control_id, $maximum_shift_time * 2);
             unset($punch_control_id);
         }
     }
     Debug::text('Punch Rows: ' . $plf->getRecordCount() . ' UserID: ' . $user_id . ' Date: ' . TTDate::getDate('DATE+TIME', $epoch) . '(' . $epoch . ') MaximumShiftTime: ' . $maximum_shift_time . ' Filter: ' . $filter, __FILE__, __LINE__, __METHOD__, 10);
     if ($plf->getRecordCount() > 0) {
         $shift = 0;
         $i = 0;
         $nearest_shift_id = 0;
         $nearest_punch_difference = FALSE;
         $prev_punch_obj = FALSE;
         foreach ($plf as $p_obj) {
             //Debug::text('Shift: '. $shift .' Punch ID: '. $p_obj->getID() .' Punch Control ID: '. $p_obj->getPunchControlID() .' TimeStamp: '. TTDate::getDate('DATE+TIME', $p_obj->getTimeStamp() ), __FILE__, __LINE__, __METHOD__, 10);
             //If we're editing a punch, we need to use the object passed to this function instead of the one
             //from the database.
             if ($epoch == NULL) {
                 //If user_date_id is passed without epoch, set epoch to the first punch we find.
                 $epoch = $p_obj->getTimeStamp();
             }
             if (isset($prev_punch_arr) and $p_obj->getTimeStamp() > $prev_punch_arr['time_stamp']) {
                 $shift_data[$shift]['previous_punch_key'] = $i - 1;
                 if ($shift_data[$shift]['previous_punch_key'] < 0) {
                     $shift_data[$shift]['previous_punch_key'] = NULL;
                 }
             }
             //Determine if a non-saved PunchControl object was passed, and if so, match the IDs to use that instead.
             if (is_object($tmp_punch_control_obj) and $p_obj->getPunchControlID() == $tmp_punch_control_obj->getId()) {
                 Debug::text('Passed non-saved punch control object that matches, using that instead... Using ID: ' . (int) $tmp_punch_control_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $punch_control_obj = $tmp_punch_control_obj;
             } else {
                 $punch_control_obj = $p_obj->getPunchControlObject();
             }
             //Can't use PunchControl object total_time because the record may not be saved yet when editing
             //an already existing punch.
             //When editing, simply pass the existing PunchControl object to this function so we can
             //use it instead of the one in the database perhaps?
             $total_time = $punch_control_obj->getTotalTime();
             //We can't skip records with total_time == 0, because then when deleting one of the two
             //punches in a pair, the remaining punch is ignored and causing punches to jump around between days in some cases.
             if ($i > 0 and isset($shift_data[$shift]['last_out']) and ($p_obj->getStatus() == 10 or $p_obj->getStatus() == $prev_punch_arr['status_id'])) {
                 Debug::text('Checking for new shift... This Control ID: ' . $p_obj->getPunchControlID() . ' Last Out Control ID: ' . $shift_data[$shift]['last_out']['punch_control_id'] . ' Last Out Time: ' . TTDate::getDate('DATE+TIME', $shift_data[$shift]['last_out']['time_stamp']), __FILE__, __LINE__, __METHOD__, 10);
                 //Assume that if two punches are assigned to the same punch_control_id are the same shift, even if the time between
                 //them exceeds the new_shift_trigger_time. This helps fix the bug where you could add a In punch then add a Out
                 //punch BEFORE the In punch as long as it was more than the Maximum Shift Time before the In Punch.
                 //ie: Add: In Punch 10-Dec-09 @ 8:00AM, Add: Out Punch 09-Dec-09 @ 5:00PM.
                 //Basically it just helps the validation checks to determine the error.
                 //
                 //It used to be that if shifts are split at midnight, new_shift_trigger_time must be 0, so the "split" punch can occur at midnight.
                 //However we have since added a check to see if punches span midnight and trigger a new shift based on that, regardless of the new shift trigger time.
                 //As the new_shift_trigger_time of 0 also affected lunch/break automatic detection by Punch Time, since an Out punch and a In punch of any time
                 //would trigger a new shift, and it wouldn't be detected as lunch/break.
                 //
                 //What happens when the employee takes lunch/break over midnight? Lunch out at 11:30PM Lunch IN at 12:30AM
                 //  We need to split those into two lunches, or two breaks? But then that can affect those policies if they are only allowed one break.
                 // 	Or do we not split the shift at all when this occurs? Currently we don't split at all.
                 if ($p_obj->getPunchControlID() != $shift_data[$shift]['last_out']['punch_control_id'] and ($p_obj->getTimeStamp() - $shift_data[$shift]['last_out']['time_stamp'] >= $new_shift_trigger_time or $this->getShiftAssignedDay() == 40 and $p_obj->getType() == 10 and $shift_data[$shift]['last_out']['type_id'] == 10 and TTDate::doesRangeSpanMidnight($shift_data[$shift]['last_out']['time_stamp'], $p_obj->getTimeStamp(), TRUE) == TRUE)) {
                     $shift++;
                 }
             } elseif ($i > 0 and isset($prev_punch_arr['time_stamp']) and $prev_punch_arr['punch_control_id'] != $p_obj->getPunchControlId() and abs($prev_punch_arr['time_stamp'] - $p_obj->getTimeStamp()) > $maximum_shift_time) {
                 //Debug::text('  New shift because two punch_control records exist and punch timestamp exceed maximum shift time.', __FILE__, __LINE__, __METHOD__, 10);
                 $shift++;
             }
             if (!isset($shift_data[$shift]['total_time'])) {
                 $shift_data[$shift]['total_time'] = 0;
             }
             $punch_day_epoch = TTDate::getBeginDayEpoch($p_obj->getTimeStamp());
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:PayPeriodScheduleFactory.class.php

示例2: array

if ($permission->Check('schedule', 'view') == FALSE) {
    if ($permission->Check('schedule', 'view_child') == FALSE) {
        $permission_children_ids = array();
    }
    if ($permission->Check('schedule', 'view_own')) {
        $permission_children_ids[] = $current_user->getId();
    }
    $filter_data['permission_children_ids'] = $permission_children_ids;
}
$do = Misc::findSubmitButton('do');
switch ($do) {
    case 'view_schedule':
    default:
        $user_ids = array();
        if ($filter_data['start_date'] != '' and $filter_data['show_days'] != '') {
            $start_date = $filter_data['start_date'] = TTDate::getBeginDayEpoch(TTDate::parseDateTime($filter_data['start_date']));
            $end_date = $filter_data['end_date'] = $start_date + ($filter_data['show_days'] * 86400 - 3601);
        } else {
            $start_date = $filter_data['start_date'] = TTDate::getBeginWeekEpoch(TTDate::getTime(), $current_user_prefs->getStartWeekDay());
            $end_date = $filter_data['end_date'] = $start_date + $filter_data['show_days'] * (86400 - 3601);
        }
        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');
        $raw_schedule_shifts = $sf->getScheduleArray($filter_data);
        if (is_array($raw_schedule_shifts)) {
            foreach ($raw_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                foreach ($day_schedule_shifts as $day_schedule_shift) {
                    $user_ids[] = $day_schedule_shift['user_id'];
                    $day_schedule_shift['is_owner'] = $permission->isOwner($day_schedule_shift['user_created_by'], $day_schedule_shift['user_id']);
                    $day_schedule_shift['is_child'] = $permission->isChild($day_schedule_shift['user_id'], $permission_children_ids);
                    $tmp_schedule_shifts[$day_epoch][$day_schedule_shift['branch']][$day_schedule_shift['department']][] = $day_schedule_shift;
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:ViewScheduleWeek.php

示例3: isActiveDate

 function isActiveDate($epoch)
 {
     $epoch = TTDate::getBeginDayEpoch($epoch);
     if ($this->getStartDate() == '' and $this->getEndDate() == '') {
         return TRUE;
     }
     if ($epoch >= (int) $this->getStartDate() and ($epoch <= (int) $this->getEndDate() or $this->getEndDate() == '')) {
         Debug::text('Within Start/End Date.', __FILE__, __LINE__, __METHOD__, 10);
         return TRUE;
     }
     Debug::text('Outside Start/End Date.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:13,代码来源:CompanyDeductionFactory.class.php

示例4: array

     $pclf->getById($punch_control_id);
     if ($pclf->getRecordCount() > 0) {
         $pc_obj = $pclf->getCurrent();
         if ($date_stamp == NULL) {
             $date_stamp = $pc_obj->getUserDateObject()->getDateStamp();
         }
         $pc_data = array('id' => $pc_obj->getId(), 'user_id' => $pc_obj->getUserDateObject()->getUser(), 'user_full_name' => $pc_obj->getUserDateObject()->getUserObject()->getFullName(), 'date_stamp' => $date_stamp, 'user_date_id' => $pc_obj->getUserDateObject()->getId(), 'time_stamp' => $time_stamp, 'branch_id' => $pc_obj->getBranch(), 'department_id' => $pc_obj->getDepartment(), 'job_id' => $pc_obj->getJob(), 'job_item_id' => $pc_obj->getJobItem(), 'quantity' => (double) $pc_obj->getQuantity(), 'bad_quantity' => (double) $pc_obj->getBadQuantity(), 'note' => $pc_obj->getNote(), 'other_id1' => $pc_obj->getOtherID1(), 'other_id2' => $pc_obj->getOtherID2(), 'other_id3' => $pc_obj->getOtherID3(), 'other_id4' => $pc_obj->getOtherID4(), 'other_id5' => $pc_obj->getOtherID5(), 'status_id' => $status_id);
     }
 } elseif ($user_id != '') {
     Debug::Text(' User ID was passed: ' . $user_id . ' Date Stamp: ' . $date_stamp, __FILE__, __LINE__, __METHOD__, 10);
     //Don't guess too much. If they click a day to add a punch. Make sure that punch is on that day.
     if (isset($date_stamp) and $date_stamp != '') {
         $time_stamp = $date_stamp + 3600 * 12;
         //Noon
     } else {
         $time_stamp = TTDate::getBeginDayEpoch(TTDate::getTime()) + 3600 * 12;
         //Noon
     }
     /*
     if ( isset($date_stamp) AND $date_stamp != '' ) {
     	$epoch = $date_stamp;
     } else {
     	$epoch = TTDate::getTime();
     }
     //Get previous punch, and default timestamp to that.
     $plf = new PunchListFactory();
     $plf->getPreviousPunchByUserIDAndEpoch( $user_id, $epoch );
     if ( $plf->getRecordCount() > 0 ) {
     	Debug::Text(' Found Previous punch: ', __FILE__, __LINE__, __METHOD__,10);
     	$prev_punch_obj = $plf->getCurrent();
     	$time_stamp = $prev_punch_obj->getTimeStamp()+3600;
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:31,代码来源:EditPunch.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: _outputPDFSchedule

 function _outputPDFSchedule($format)
 {
     Debug::Text(' Format: ' . $format, __FILE__, __LINE__, __METHOD__, 10);
     $current_company = $this->getUserObject()->getCompanyObject();
     if (!is_object($current_company)) {
         Debug::Text('Invalid company object...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $filter_data = $this->getFilterConfig();
     $columns = Misc::trimSortPrefix($this->getOptions('columns'));
     $adjust_x = 10;
     $adjust_y = 10;
     //Required fields
     // 'first_name', 'last_name', 'branch', 'department', 'start_time', 'end_time'
     $start_week_day = 0;
     if (is_object($this->getUserObject()) and is_object($this->getUserObject()->getUserPreferenceObject())) {
         $start_week_day = $this->getUserObject()->getUserPreferenceObject()->getStartWeekDay();
     }
     //Debug::Arr($this->form_data, 'Form Data: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($this->data, 'Data: ', __FILE__, __LINE__, __METHOD__,10);
     $this->getProgressBarObject()->start($this->getAMFMessageID(), 2, NULL, TTi18n::getText('Querying Database...'));
     //Iterations need to be 2, otherwise progress bar is not created.
     $this->getProgressBarObject()->set($this->getAMFMessageID(), 2);
     $sf = TTNew('ScheduleFactory');
     //getScheduleArray() doesn't accept pay_period_ids, so no data is returned if a time period of "last_pay_period" is selected.
     if (isset($filter_data['pay_period_id'])) {
         unset($filter_data['pay_period_id']);
         $filter_data['start_date'] = TTDate::getBeginDayEpoch(time() - 86400 * 14);
         //Default to the last 14days.
         $filter_data['end_date'] = TTDate::getEndDayEpoch(time() - 86400);
     }
     $raw_schedule_shifts = $sf->getScheduleArray($filter_data);
     if (is_array($raw_schedule_shifts)) {
         //Debug::Arr($raw_schedule_shifts, 'Raw Schedule Shifts: ', __FILE__, __LINE__, __METHOD__,10);
         $this->getProgressBarObject()->start($this->getAMFMessageID(), count($raw_schedule_shifts, COUNT_RECURSIVE), NULL, TTi18n::getText('Retrieving Data...'));
         $key = 0;
         foreach ($raw_schedule_shifts as $date_stamp => $day_schedule_shifts) {
             foreach ($day_schedule_shifts as $shift_arr) {
                 $this->form_data['schedule_by_branch'][$shift_arr['branch']][$shift_arr['department']][$shift_arr['last_name'] . $shift_arr['first_name']][$date_stamp][] = $shift_arr;
                 //Need to be able to sort employees by last name first. Use names as keys instead of user_ids.
                 //$this->form_data['schedule_by_user'][$shift_arr['user_id']][$date_stamp][$shift_arr['branch']][$shift_arr['department']][] = $shift_arr;
                 $this->form_data['schedule_by_user'][$shift_arr['last_name'] . '_' . $shift_arr['first_name']][$date_stamp][$shift_arr['branch']][$shift_arr['department']][] = $shift_arr;
                 if (!isset($this->form_data['dates']['start_date']) or $this->form_data['dates']['start_date'] > $date_stamp) {
                     $this->form_data['dates']['start_date'] = $date_stamp;
                 }
                 if (!isset($this->form_data['dates']['end_date']) or $this->form_data['dates']['end_date'] < $date_stamp) {
                     $this->form_data['dates']['end_date'] = $date_stamp;
                 }
                 $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
                 $key++;
             }
         }
         unset($date_stamp, $raw_schedule_shifts, $day_schedule_shifts);
     } else {
         Debug::Text('No schedule shifts returned...', __FILE__, __LINE__, __METHOD__, 10);
     }
     //Initialize array element if it doesn't exist to prevent PHP warning.
     if (!isset($this->form_data['schedule_by_user'])) {
         $this->form_data['schedule_by_user'] = array();
     }
     //Debug::Arr($this->form_data['schedule_by_branch'], '2Raw Schedule Shifts: ', __FILE__, __LINE__, __METHOD__,10);
     //Debug::Arr($this->form_data['dates'], 'Dates: ', __FILE__, __LINE__, __METHOD__,10);
     //If pay periods are requested, we need to convert those to start/end dates.
     if (isset($this->form_data['dates']['start_date']) and isset($this->form_data['dates']['end_date']) and (!isset($filter_data['start_date']) or !isset($filter_data['end_date']))) {
         $filter_data['start_date'] = strtotime($this->form_data['dates']['start_date']);
         $filter_data['end_date'] = strtotime($this->form_data['dates']['end_date']);
     }
     if (isset($filter_data['start_date']) and isset($filter_data['end_date'])) {
         $pdf_created_date = time();
         $this->pdf = new TTPDF($this->config['other']['page_orientation'], 'mm', $this->config['other']['page_format'], $this->getUserObject()->getCompanyObject()->getEncoding());
         $this->pdf->SetAuthor(APPLICATION_NAME);
         $this->pdf->SetTitle($this->title);
         $this->pdf->SetSubject(APPLICATION_NAME . ' ' . TTi18n::getText('Report'));
         $this->pdf->setMargins($this->config['other']['left_margin'], $this->config['other']['top_margin'], $this->config['other']['right_margin']);
         //Debug::Arr($this->config['other'], 'Margins: ', __FILE__, __LINE__, __METHOD__,10);
         $this->pdf->SetAutoPageBreak(FALSE, 0);
         $this->pdf->SetFont($this->config['other']['default_font'], '', $this->_pdf_fontSize(10));
         //Debug::Arr($this->form_data, 'zabUser Raw Data: ', __FILE__, __LINE__, __METHOD__,10);
         $calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
         //Debug::Arr($calendar_array, 'Calendar Array: ', __FILE__, __LINE__, __METHOD__,10);
         switch ($format) {
             case 'pdf_schedule_group':
             case 'pdf_schedule_group_print':
             case 'pdf_schedule_group_pagebreak':
             case 'pdf_schedule_group_pagebreak_print':
                 //
                 // Group - Separate (branch/department on their own pages)
                 //
                 //Start displaying dates/times here. Start with header.
                 $column_widths = array('line' => 5, 'label' => 30, 'day' => ($this->pdf->getPageWidth() - $this->config['other']['left_margin'] - $this->config['other']['right_margin'] - 30) / 7);
                 if (isset($this->form_data['schedule_by_branch'])) {
                     $this->pdf->AddPage($this->config['other']['page_orientation'], 'Letter');
                     $n = 0;
                     ksort($this->form_data['schedule_by_branch']);
                     foreach ($this->form_data['schedule_by_branch'] as $branch => $level_2) {
                         ksort($level_2);
                         foreach ($level_2 as $department => $level_3) {
                             ksort($level_3);
                             if ($format == 'pdf_schedule_group_pagebreak' or $format == 'pdf_schedule_group_pagebreak_print') {
                                 //Insert page breaks after each branch/department in this mode.
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:ScheduleSummaryReport.class.php

示例7: 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

示例8: getPreviousPunchByUserIdAndEpoch

    function getPreviousPunchByUserIdAndEpoch($user_id, $epoch, $order = NULL)
    {
        Debug::Text(' User ID: ' . $user_id . ' Epoch: ' . $epoch, __FILE__, __LINE__, __METHOD__, 10);
        if ($user_id == '') {
            return FALSE;
        }
        if ($epoch == '') {
            return FALSE;
        }
        $maximum_shift_time = $this->getPayPeriodMaximumShiftTime($user_id);
        $begin_day_epoch = TTDate::getBeginDayEpoch($epoch);
        $start_time = $epoch - $maximum_shift_time;
        Debug::Text(' Start Time: ' . TTDate::getDate('DATE+TIME', $start_time), __FILE__, __LINE__, __METHOD__, 10);
        $udf = new UserDateFactory();
        $pcf = new PunchControlFactory();
        $ph = array('user_id' => $user_id, 'start_date' => $this->db->BindDate($start_time), 'end_date' => $this->db->BindDate($epoch), 'start_time' => $this->db->BindTimeStamp($start_time), 'end_time' => $this->db->BindTimeStamp($epoch));
        //Status order matters, because if its a.status_id desc, OUT comes first, but if the last
        //punch doesn't have OUT yet, it defaults to IN
        // with a.status_id asc...
        //Include date_stamp filter on user_date table as this greatly speeds up the query when its not already cached.
        $query = '
					select 	a.*
					from 	' . $this->getTable() . ' as a,
							' . $pcf->getTable() . ' as b,
							' . $udf->getTable() . ' as c
					where	a.punch_control_id = b.id
						AND b.user_date_id = c.id
						AND c.user_id = ?
						AND c.date_stamp >= ?
						AND c.date_stamp <= ?
						AND a.time_stamp >= ?
						AND a.time_stamp <= ?
						AND ( a.deleted = 0 AND b.deleted=0 AND c.deleted=0)
					ORDER BY a.time_stamp desc, a.status_id asc
					LIMIT 1
					';
        $query .= $this->getSortSQL($order);
        //Debug::Text(' Query: '. $query, __FILE__, __LINE__, __METHOD__,10);
        $this->ExecuteSQL($query, $ph);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:41,代码来源:PunchListFactory.class.php

示例9: testBreakPunchTimeWindowD

 function testBreakPunchTimeWindowD()
 {
     global $dd;
     $policy_ids['break'][] = $this->createBreakPolicy($this->company_id, 110);
     //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->createPunch($this->user_id, 10, 10, strtotime($date_stamp . ' 8:00AM'), array('branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_time = strtotime($date_stamp . ' 10:00AM');
     $prev_punch_obj = $this->getPreviousPunch($punch_time);
     $punch_type_id = $prev_punch_obj->getNextType($punch_time);
     $punch_status_id = $prev_punch_obj->getNextStatus();
     $this->assertEquals($punch_type_id, 10);
     //Normal - Because when using punch time it can't be detected on the first out punch.
     $this->assertEquals($punch_status_id, 20);
     //Out
     $dd->createPunch($this->user_id, $punch_type_id, $punch_status_id, $punch_time, array('branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_time = strtotime($date_stamp . ' 10:15AM');
     $prev_punch_obj = $this->getPreviousPunch($punch_time);
     $punch_type_id = $prev_punch_obj->getNextType($punch_time);
     $punch_status_id = $prev_punch_obj->getNextStatus();
     $this->assertEquals($punch_type_id, 30);
     //Break
     $this->assertEquals($punch_status_id, 10);
     //In
     $dd->createPunch($this->user_id, $punch_type_id, $punch_status_id, $punch_time, array('branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_time = strtotime($date_stamp . ' 2:00PM');
     $prev_punch_obj = $this->getPreviousPunch($punch_time);
     $punch_type_id = $prev_punch_obj->getNextType($punch_time);
     $punch_status_id = $prev_punch_obj->getNextStatus();
     $this->assertEquals($punch_type_id, 10);
     //Normal - Because when using punch time it can't be detected on the first out punch.
     $this->assertEquals($punch_status_id, 20);
     //Out
     $dd->createPunch($this->user_id, $punch_type_id, $punch_status_id, $punch_time, array('branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_time = strtotime($date_stamp . ' 2:15PM');
     $prev_punch_obj = $this->getPreviousPunch($punch_time);
     $punch_type_id = $prev_punch_obj->getNextType($punch_time);
     $punch_status_id = $prev_punch_obj->getNextStatus();
     $this->assertEquals($punch_type_id, 30);
     //Break
     $this->assertEquals($punch_status_id, 10);
     //In
     $dd->createPunch($this->user_id, $punch_type_id, $punch_status_id, $punch_time, array('branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0), TRUE);
     $punch_time = strtotime($date_stamp . ' 5:00PM');
     $prev_punch_obj = $this->getPreviousPunch($punch_time);
     $punch_type_id = $prev_punch_obj->getNextType($punch_time);
     $punch_status_id = $prev_punch_obj->getNextStatus();
     $this->assertEquals($punch_type_id, 10);
     //Normal
     $this->assertEquals($punch_status_id, 20);
     //Out
     $dd->createPunch($this->user_id, $punch_type_id, $punch_status_id, $punch_time, array('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(3, count($punch_arr[$date_epoch]));
     $this->assertEquals($date_epoch, $punch_arr[$date_epoch][0]['date_stamp']);
     $this->assertEquals(6, count($punch_arr[$date_epoch][0]['shift_data']['punches']));
     $this->assertEquals(10, $punch_arr[$date_epoch][0]['shift_data']['punches'][0]['type_id']);
     $this->assertEquals(10, $punch_arr[$date_epoch][0]['shift_data']['punches'][0]['status_id']);
     $this->assertEquals(30, $punch_arr[$date_epoch][0]['shift_data']['punches'][1]['type_id']);
     $this->assertEquals(20, $punch_arr[$date_epoch][0]['shift_data']['punches'][1]['status_id']);
     $this->assertEquals(30, $punch_arr[$date_epoch][0]['shift_data']['punches'][2]['type_id']);
     $this->assertEquals(10, $punch_arr[$date_epoch][0]['shift_data']['punches'][2]['status_id']);
     $this->assertEquals(30, $punch_arr[$date_epoch][0]['shift_data']['punches'][3]['type_id']);
     $this->assertEquals(20, $punch_arr[$date_epoch][0]['shift_data']['punches'][3]['status_id']);
     $this->assertEquals(30, $punch_arr[$date_epoch][0]['shift_data']['punches'][4]['type_id']);
     $this->assertEquals(10, $punch_arr[$date_epoch][0]['shift_data']['punches'][4]['status_id']);
     $this->assertEquals(10, $punch_arr[$date_epoch][0]['shift_data']['punches'][5]['type_id']);
     $this->assertEquals(20, $punch_arr[$date_epoch][0]['shift_data']['punches'][5]['status_id']);
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:73,代码来源:PunchDetectionTest.php

示例10: getScheduleArray

 function getScheduleArray($filter_data)
 {
     global $current_user, $current_user_prefs;
     //Get all schedule data by general filter criteria.
     Debug::Arr($filter_data, 'Filter Data: ', __FILE__, __LINE__, __METHOD__, 10);
     if (!isset($filter_data['start_date']) or $filter_data['start_date'] == '') {
         return FALSE;
     }
     if (!isset($filter_data['end_date']) or $filter_data['end_date'] == '') {
         return FALSE;
     }
     $filter_data['start_date'] = TTDate::getBeginDayEpoch($filter_data['start_date']);
     $filter_data['end_date'] = TTDate::getEndDayEpoch($filter_data['end_date']);
     $blf = new BranchListFactory();
     $branch_options = $blf->getByCompanyIdArray($current_user->getCompany(), FALSE);
     $dlf = new DepartmentListFactory();
     $department_options = $dlf->getByCompanyIdArray($current_user->getCompany(), FALSE);
     $slf = new ScheduleListFactory();
     $slf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
     Debug::text('Found Scheduled Rows: ' . $slf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($slf->getRecordCount() > 0) {
         foreach ($slf as $s_obj) {
             Debug::text('Schedule ID: ' . $s_obj->getId() . ' User ID: ' . $s_obj->getColumn('user_id') . ' Start Time: ' . $s_obj->getStartTime(), __FILE__, __LINE__, __METHOD__, 10);
             if (is_object($s_obj->getAbsencePolicyObject())) {
                 $absence_policy_name = (string) $s_obj->getAbsencePolicyObject()->getName();
             } else {
                 $absence_policy_name = 'N/A';
             }
             $iso_date_stamp = TTDate::getISODateStamp($s_obj->getStartTime());
             $schedule_shifts[$iso_date_stamp][$s_obj->getColumn('user_id') . $s_obj->getStartTime()] = array('id' => (int) $s_obj->getID(), 'user_id' => (int) $s_obj->getColumn('user_id'), 'user_created_by' => (int) $s_obj->getColumn('user_created_by'), 'user_full_name' => Misc::getFullName($s_obj->getColumn('first_name'), NULL, $s_obj->getColumn('last_name'), FALSE, FALSE), 'first_name' => $s_obj->getColumn('first_name'), 'last_name' => $s_obj->getColumn('last_name'), 'status_id' => (int) $s_obj->getStatus(), 'date_stamp' => TTDate::getAPIDate('DATE', TTDate::parseDateTime($s_obj->getColumn('date_stamp'))), 'start_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_date' => defined('TIMETREX_API') ? TTDate::getAPIDate('DATE+TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'start_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getStartTime()) : $s_obj->getStartTime(), 'end_time' => defined('TIMETREX_API') ? TTDate::getAPIDate('TIME', $s_obj->getEndTime()) : $s_obj->getEndTime(), 'total_time' => $s_obj->getTotalTime(), 'schedule_policy_id' => (int) $s_obj->getSchedulePolicyID(), 'absence_policy_id' => (int) $s_obj->getAbsencePolicyID(), 'absence_policy' => $absence_policy_name, 'branch_id' => (int) $s_obj->getBranch(), 'branch' => Option::getByKey($s_obj->getBranch(), $branch_options, NULL), 'department_id' => (int) $s_obj->getDepartment(), 'department' => Option::getByKey($s_obj->getDepartment(), $department_options, NULL));
             $schedule_shifts_index[$iso_date_stamp][$s_obj->getColumn('user_id')][] = $s_obj->getColumn('user_id') . $s_obj->getStartTime();
             unset($absence_policy_name);
         }
         //Debug::Arr($schedule_shifts, 'Committed Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
         //Debug::Arr($schedule_shifts_index, 'Committed Schedule Shifts Index: ', __FILE__, __LINE__, __METHOD__, 10);
     } else {
         $schedule_shifts = array();
     }
     unset($slf);
     //Get holidays
     //FIXME: What if there are two holiday policies, one that defaults to working, and another that defaults to not working, and they are assigned
     //to two different groups of employees? For that matter what if the holiday policy isn't assigned to a specific user at all.
     $holiday_data = array();
     $hlf = new HolidayListFactory();
     $hlf->getByCompanyIdAndStartDateAndEndDate($current_user->getCompany(), $filter_data['start_date'], $filter_data['end_date']);
     Debug::text('Found Holiday Rows: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     foreach ($hlf as $h_obj) {
         if (is_object($h_obj->getHolidayPolicyObject()) and is_object($h_obj->getHolidayPolicyObject()->getAbsencePolicyObject())) {
             $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => (int) $h_obj->getHolidayPolicyObject()->getDefaultScheduleStatus(), 'absence_policy_id' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyID(), 'absence_policy' => $h_obj->getHolidayPolicyObject()->getAbsencePolicyObject()->getName());
         } else {
             $holiday_data[TTDate::getISODateStamp($h_obj->getDateStamp())] = array('status_id' => 10);
             //Working
         }
     }
     unset($hlf);
     $recurring_schedule_shifts = array();
     $recurring_schedule_shifts_index = array();
     $rstlf = new RecurringScheduleTemplateListFactory();
     $rstlf->getSearchByCompanyIdAndArrayCriteria($current_user->getCompany(), $filter_data);
     Debug::text('Found Recurring Schedule Template Rows: ' . $rstlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
     if ($rstlf->getRecordCount() > 0) {
         foreach ($rstlf as $rst_obj) {
             //Debug::text('Recurring Schedule Template ID: '. $rst_obj->getID() , __FILE__, __LINE__, __METHOD__, 10);
             $rst_obj->getShifts($filter_data['start_date'], $filter_data['end_date'], $holiday_data, $branch_options, $department_options, &$schedule_shifts, &$schedule_shifts_index);
         }
     } else {
         Debug::text('DID NOT find Recurring Schedule for this time period: ', __FILE__, __LINE__, __METHOD__, 10);
     }
     //Debug::Arr($schedule_shifts, 'Schedule Shifts: ', __FILE__, __LINE__, __METHOD__, 10);
     unset($schedule_shifts_index, $recurring_schedule_shifts_index);
     if (isset($schedule_shifts)) {
         return $schedule_shifts;
     }
     return FALSE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:75,代码来源:ScheduleFactory.class.php

示例11: calcExperience

 function calcExperience()
 {
     if ($this->getFirstUsedDate() != '') {
         $last_used_date = $this->getLastUsedDate();
         if ($this->getLastUsedDate() == '') {
             $last_used_date = TTDate::getEndDayEpoch(time());
         }
         $total_time = round(TTDate::getYears($last_used_date - TTDate::getBeginDayEpoch($this->getFirstUsedDate())), 2);
         if ($total_time < 0) {
             $total_time = 0;
         }
         Debug::text(' First Used Date: ' . $this->getFirstUsedDate() . ' Last Used Date: ' . $last_used_date . ' Total Yrs: ' . $total_time, __FILE__, __LINE__, __METHOD__, 10);
         return $total_time;
     }
     return FALSE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:16,代码来源:UserSkillFactory.class.php

示例12: PayPeriodScheduleListFactory

        if ($c_obj->getStatus() != 30) {
            $ppslf = new PayPeriodScheduleListFactory();
            $ulf = new UserListFactory();
            $ulf->getByCompanyId($c_obj->getId());
            if ($ulf->getRecordCount() > 0) {
                $i = 0;
                foreach ($ulf as $u_obj) {
                    if ($u_obj->getStatus() != 10) {
                        continue;
                    }
                    Debug::text($i . '. User: ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 10);
                    //Find the pay period schedule for each user and change the timezone to that of the pay period schedule.
                    $ppslf->getByCompanyIdAndUserId($c_obj->getId(), $u_obj->getId());
                    if ($ppslf->getRecordCount() > 0) {
                        $pps_obj = $ppslf->getCurrent();
                        $pps_obj->setPayPeriodTimeZone();
                        //Insert user date row for TOMORROW.
                        $epoch = time() + (86400 + 3601);
                        //$epoch = strtotime('22-Jan-08');
                        UserDateFactory::findOrInsertUserDate($u_obj->getId(), TTDate::getBeginDayEpoch($epoch));
                    }
                    $i++;
                }
            }
        } else {
            Debug::text('Company is not ACTIVE: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
        }
    }
}
Debug::writeToLog();
Debug::Display();
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:AddUserDate.php

示例13: calcAccrualTime

 function calcAccrualTime($company_id, $accrual_policy_id, $start_date, $end_date)
 {
     $start_date = TTDate::getMiddleDayEpoch($start_date);
     $end_date = TTDate::getMiddleDayEpoch($end_date);
     $total_days = TTDate::getDays($end_date - $start_date);
     $offset = 79200;
     $apf = TTnew('AccrualPolicyFactory');
     $aplf = TTnew('AccrualPolicyListFactory');
     $aplf->getByIdAndCompanyId((int) $accrual_policy_id, $company_id);
     if ($aplf->getRecordCount() > 0) {
         foreach ($aplf as $ap_obj) {
             $aplf->StartTransaction();
             $x = 0;
             for ($i = $start_date; $i < $end_date; $i += 86400) {
                 Debug::Text('Recalculating Accruals for Date: ' . TTDate::getDate('DATE+TIME', TTDate::getBeginDayEpoch($i)), __FILE__, __LINE__, __METHOD__, 10);
                 $ap_obj->addAccrualPolicyTime(TTDate::getBeginDayEpoch($i) + 7201, $offset);
                 Debug::Text('----------------------------------', __FILE__, __LINE__, __METHOD__, 10);
                 $x++;
             }
             $aplf->CommitTransaction();
         }
     }
     return TRUE;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:24,代码来源:AccrualPolicyTest.php

示例14: ucfirst

 if ($date_type != 'last') {
     echo "Searching for Pay Period " . ucfirst($date_type) . " Date: " . TTDate::getDate('DATE', $pay_period_date) . "...\n";
 } else {
     echo "Searching for Last Pay Period...\n";
 }
 $pplf = new PayPeriodListFactory();
 $pplf->getPayPeriodsWithPayStubsByCompanyId($company_id, NULL, array('a.start_date' => 'desc'));
 if ($pplf->getRecordCount() > 0) {
     $x = 0;
     $found_pay_period = FALSE;
     foreach ($pplf as $pp_obj) {
         if ($date_type == 'start' and TTDate::getBeginDayEpoch($pp_obj->getStartDate()) == $pay_period_date) {
             $found_pay_period = TRUE;
         } elseif ($date_type == 'end' and TTDate::getBeginDayEpoch($pp_obj->getEndDate()) == $pay_period_date) {
             $found_pay_period = TRUE;
         } elseif ($date_type == 'transaction' and TTDate::getBeginDayEpoch($pp_obj->getTransactionDate()) == $pay_period_date) {
             $found_pay_period = TRUE;
         } elseif ($date_type == 'last') {
             //Last pay period
             $found_pay_period = TRUE;
         }
         if ($found_pay_period == TRUE) {
             echo "Found Pay Period: Start: " . TTDate::getDate('DATE', $pp_obj->getStartDate()) . ' End: ' . TTDate::getDate('DATE', $pp_obj->getEndDate()) . ' Transaction: ' . TTDate::getDate('DATE', $pp_obj->getTransactionDate()) . "\n";
             $pay_period_id = $pp_obj->getId();
             break;
         }
         $x++;
     }
 }
 if (isset($pay_period_id)) {
     $pslf = new PayStubListFactory();
开发者ID:alachaum,项目名称:timetrex,代码行数:31,代码来源:export_pay_stubs.php

示例15: getShiftData

 function getShiftData($user_date_id = NULL, $user_id = NULL, $epoch = NULL, $filter = NULL, $tmp_punch_control_obj = NULL)
 {
     global $profiler;
     $profiler->startTimer('PayPeriodScheduleFactory::getShiftData()');
     if (is_numeric($user_date_id) and $user_date_id > 0) {
         $user_id = $epoch = NULL;
     }
     if ($user_date_id == '' and $user_id == '' and $epoch == '') {
         return FALSE;
     }
     //Debug::text('User Date ID: '. $user_date_id .' User ID: '. $user_id .' TimeStamp: '. TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
     $new_shift_trigger_time = $this->getNewDayTriggerTime();
     $plf = new PunchListFactory();
     if ($user_date_id != '') {
         $plf->getByUserDateId($user_date_id);
     } else {
         //Get punches by time stamp.
         $punch_control_id = 0;
         if (is_object($tmp_punch_control_obj)) {
             $punch_control_id = $tmp_punch_control_obj->getId();
         }
         $plf->getShiftPunchesByUserIDAndEpoch($user_id, $epoch, $punch_control_id, $this->getMaximumShiftTime());
         unset($punch_control_id);
     }
     Debug::text('Punch Rows: ' . $plf->getRecordCount() . ' UserID: ' . $user_id . ' Date: ' . TTDate::getDate('DATE+TIME', $epoch) . '(' . $epoch . ') MaximumShiftTime: ' . $this->getMaximumShiftTime(), __FILE__, __LINE__, __METHOD__, 10);
     //Debug::Arr($punches, ' Punches: ', __FILE__, __LINE__, __METHOD__, 10);
     if ($plf->getRecordCount() > 0) {
         $shift = 0;
         $i = 0;
         $nearest_shift_id = 0;
         $nearest_punch_difference = FALSE;
         $prev_punch_obj = FALSE;
         foreach ($plf as $p_obj) {
             //Debug::text('Shift: '. $shift .' Punch ID: '. $p_obj->getID() .' Punch Control ID: '. $p_obj->getPunchControlID() .' TimeStamp: '. TTDate::getDate('DATE+TIME', $p_obj->getTimeStamp() ), __FILE__, __LINE__, __METHOD__, 10);
             //If we're editing a punch, we need to use the object passed to this function instead of the one
             //from the database.
             if ($epoch == NULL) {
                 //If user_date_id is passed without epoch, set epoch to the first punch we find.
                 $epoch = $p_obj->getTimeStamp();
             }
             if (isset($prev_punch_arr) and $p_obj->getTimeStamp() > $prev_punch_arr['time_stamp']) {
                 $shift_data[$shift]['previous_punch_key'] = $i - 1;
                 if ($shift_data[$shift]['previous_punch_key'] < 0) {
                     $shift_data[$shift]['previous_punch_key'] = NULL;
                 }
             }
             //Determine if a non-saved PunchControl object was passed, and if so, match the IDs to use that instead.
             if (is_object($tmp_punch_control_obj) and $p_obj->getPunchControlID() == $tmp_punch_control_obj->getId()) {
                 Debug::text('Passed non-saved punch control object that matches, using that instead... Using ID: ' . (int) $tmp_punch_control_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $punch_control_obj = $tmp_punch_control_obj;
             } else {
                 $punch_control_obj = $p_obj->getPunchControlObject();
             }
             //Can't use PunchControl object total_time because the record may not be saved yet when editing
             //an already existing punch.
             //When editing, simply pass the existing PunchControl object to this function so we can
             //use it instead of the one in the database perhaps?
             $total_time = $punch_control_obj->getTotalTime();
             /*
             				//We can't skip records with total_time == 0, because then when deleting one of the two
             				//punches in a pair, the remaining punch is ignored and causing punches to jump around between days in some cases.
             				if ( $total_time == 0 ) {
             					Debug::text('Total time is 0, skipping this punch control object...', __FILE__, __LINE__, __METHOD__, 10);
             					//continue;
             				}
             */
             if ($i > 0 and isset($shift_data[$shift]['last_out']) and ($p_obj->getStatus() == 10 or $p_obj->getStatus() == $prev_punch_arr['status_id'])) {
                 Debug::text('Checking for new shift...', __FILE__, __LINE__, __METHOD__, 10);
                 if ($p_obj->getTimeStamp() - $shift_data[$shift]['last_out']['time_stamp'] > $new_shift_trigger_time) {
                     $shift++;
                 }
             }
             if (!isset($shift_data[$shift]['total_time'])) {
                 $shift_data[$shift]['total_time'] = 0;
             }
             $punch_day_epoch = TTDate::getBeginDayEpoch($p_obj->getTimeStamp());
             if (!isset($shift_data[$shift]['total_time_per_day'][$punch_day_epoch])) {
                 $shift_data[$shift]['total_time_per_day'][$punch_day_epoch] = 0;
             }
             //Determine which shift is closest to the given epoch.
             $punch_difference_from_epoch = abs($epoch - $p_obj->getTimeStamp());
             if ($nearest_punch_difference === FALSE or $punch_difference_from_epoch < $nearest_punch_difference) {
                 Debug::text('Nearest Shift Determined to be: ' . $shift . ' Nearest Punch Diff: ' . (int) $nearest_punch_difference . ' Punch Diff: ' . $punch_difference_from_epoch, __FILE__, __LINE__, __METHOD__, 10);
                 $nearest_shift_id = $shift;
                 $nearest_punch_difference = $punch_difference_from_epoch;
             }
             $punch_arr = array('id' => $p_obj->getId(), 'punch_control_id' => $p_obj->getPunchControlId(), 'user_date_id' => $punch_control_obj->getUserDateID(), 'time_stamp' => $p_obj->getTimeStamp(), 'status_id' => $p_obj->getStatus(), 'type_id' => $p_obj->getType());
             $shift_data[$shift]['punches'][] = $punch_arr;
             $shift_data[$shift]['punch_control_ids'][] = $p_obj->getPunchControlId();
             if ($punch_control_obj->getUserDateID() != FALSE) {
                 $shift_data[$shift]['user_date_ids'][] = $punch_control_obj->getUserDateID();
             }
             $shift_data[$shift]['span_midnight'] = FALSE;
             if (!isset($shift_data[$shift]['first_in']) and $p_obj->getStatus() == 10) {
                 //Debug::text('First In -- Punch ID: '. $p_obj->getID() .' Punch Control ID: '. $p_obj->getPunchControlID() .' TimeStamp: '. TTDate::getDate('DATE+TIME', $p_obj->getTimeStamp() ), __FILE__, __LINE__, __METHOD__, 10);
                 $shift_data[$shift]['first_in'] = $punch_arr;
             } elseif ($p_obj->getStatus() == 20) {
                 //Debug::text('Last Out -- Punch ID: '. $p_obj->getID() .' Punch Control ID: '. $p_obj->getPunchControlID() .' TimeStamp: '. TTDate::getDate('DATE+TIME', $p_obj->getTimeStamp() ), __FILE__, __LINE__, __METHOD__, 10);
                 $shift_data[$shift]['last_out'] = $punch_arr;
                 //Debug::text('Total Time: '. $total_time, __FILE__, __LINE__, __METHOD__, 10);
//.........这里部分代码省略.........
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:101,代码来源:PayPeriodScheduleFactory.class.php


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