/**
     * @param string $jobCode
     * @param string $cronExpression
     * @param int $time
     * @return Schedule
     */
    protected function generateSchedule($jobCode, $cronExpression, $time)
    {
        $schedule = $this->_scheduleFactory->create()
            ->setCronExpr($cronExpression)
            ->setJobCode($jobCode)
            ->setStatus(Schedule::STATUS_PENDING)
            ->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->timezone->scopeTimeStamp()))
            ->setScheduledAt(strftime('%Y-%m-%d %H:%M', $time));

        return $schedule;
    }
예제 #2
0
 function createSchedule($user_id, $date_stamp, $data = NULL)
 {
     $sf = new ScheduleFactory();
     $sf->setUserDateId(UserDateFactory::findOrInsertUserDate($user_id, $date_stamp));
     if (isset($data['status_id'])) {
         $sf->setStatus($data['status_id']);
     } else {
         $sf->setStatus(10);
     }
     if (isset($data['schedule_policy_id'])) {
         $sf->setSchedulePolicyID($data['schedule_policy_id']);
     }
     if (isset($data['absence_policy_id'])) {
         $sf->setAbsencePolicyID($data['absence_policy_id']);
     }
     if (isset($data['branch_id'])) {
         $sf->setBranch($data['branch_id']);
     }
     if (isset($data['department_id'])) {
         $sf->setDepartment($data['department_id']);
     }
     if (isset($data['job_id'])) {
         $sf->setJob($data['job_id']);
     }
     if (isset($data['job_item_id'])) {
         $sf->setJobItem($data['job_item_id']);
     }
     if ($data['start_time'] != '') {
         $start_time = strtotime($data['start_time'], $date_stamp);
     }
     if ($data['end_time'] != '') {
         Debug::Text('End Time: ' . $data['end_time'] . ' Date Stamp: ' . $date_stamp, __FILE__, __LINE__, __METHOD__, 10);
         $end_time = strtotime($data['end_time'], $date_stamp);
         Debug::Text('bEnd Time: ' . $data['end_time'] . ' - ' . TTDate::getDate('DATE+TIME', $data['end_time']), __FILE__, __LINE__, __METHOD__, 10);
     }
     $sf->setStartTime($start_time);
     $sf->setEndTime($end_time);
     if ($sf->isValid()) {
         $sf->setEnableReCalculateDay(FALSE);
         $insert_id = $sf->Save();
         Debug::Text('Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         return $insert_id;
     }
     Debug::Text('Failed Creating Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
예제 #3
0
    }
}
//Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
$hlf = new HierarchyListFactory();
$permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($current_company->getId(), $current_user->getId());
//Debug::Arr($permission_children_ids,'Permission Children Ids:', __FILE__, __LINE__, __METHOD__,10);
$filter_data = array();
if ($permission->Check('schedule', 'edit') == FALSE) {
    if ($permission->Check('schedule', 'edit_child')) {
        $filter_data['permission_children_ids'] = $permission_children_ids;
    }
    if ($permission->Check('schedule', 'edit_own')) {
        $filter_data['permission_children_ids'][] = $current_user->getId();
    }
}
$sf = new ScheduleFactory();
$ulf = new UserListFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        //Debug::setVerbosity(11);
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $fail_transaction = FALSE;
        if (TTDate::getDayDifference($data['start_date_stamp'], $data['end_date_stamp']) > 31) {
            Debug::Text('Date Range Exceeds 31 days, truncating', __FILE__, __LINE__, __METHOD__, 10);
            $sf->Validator->isTrue('date_stamp', FALSE, TTi18n::getText('Date range exceeds the maximum of 31 days'));
        }
        if (!(isset($filter_user_id) and is_array($filter_user_id) and count($filter_user_id) > 0)) {
            $sf->Validator->isTrue('user_id', FALSE, TTi18n::getText('Please select at least one employee'));
        }
예제 #4
0
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $hplf = new HolidayPolicyListFactory();
            $hplf->getByIdAndCompanyID($id, $current_company->getID());
            foreach ($hplf as $hp_obj) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                $data = array('id' => $hp_obj->getId(), 'name' => $hp_obj->getName(), 'type_id' => $hp_obj->getType(), 'default_schedule_status_id' => $hp_obj->getDefaultScheduleStatus(), 'minimum_employed_days' => $hp_obj->getMinimumEmployedDays(), 'minimum_worked_period_days' => $hp_obj->getMinimumWorkedPeriodDays(), 'minimum_worked_days' => $hp_obj->getMinimumWorkedDays(), 'worked_scheduled_days' => $hp_obj->getWorkedScheduledDays(), 'minimum_worked_after_period_days' => $hp_obj->getMinimumWorkedAfterPeriodDays(), 'minimum_worked_after_days' => $hp_obj->getMinimumWorkedAfterDays(), 'worked_after_scheduled_days' => $hp_obj->getWorkedAfterScheduledDays(), 'average_time_days' => $hp_obj->getAverageTimeDays(), 'average_time_worked_days' => $hp_obj->getAverageTimeWorkedDays(), 'force_over_time_policy' => $hp_obj->getForceOverTimePolicy(), 'include_over_time' => $hp_obj->getIncludeOverTime(), 'include_paid_absence_time' => $hp_obj->getIncludePaidAbsenceTime(), 'minimum_time' => $hp_obj->getMinimumTime(), 'maximum_time' => $hp_obj->getMaximumTime(), 'round_interval_policy_id' => $hp_obj->getRoundIntervalPolicyID(), 'absence_policy_id' => $hp_obj->getAbsencePolicyID(), 'recurring_holiday_ids' => $hp_obj->getRecurringHoliday(), 'created_date' => $hp_obj->getCreatedDate(), 'created_by' => $hp_obj->getCreatedBy(), 'updated_date' => $hp_obj->getUpdatedDate(), 'updated_by' => $hp_obj->getUpdatedBy(), 'deleted_date' => $hp_obj->getDeletedDate(), 'deleted_by' => $hp_obj->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            //Defaults
            $data = array('default_schedule_status_id' => 20, 'minimum_employed_days' => 30, 'minimum_worked_period_days' => 30, 'minimum_worked_days' => 15, 'minimum_worked_after_period_days' => 0, 'minimum_worked_after_days' => 0, 'average_time_days' => 30, 'force_over_time_policy' => FALSE, 'include_over_time' => FALSE, 'include_paid_absence_time' => TRUE, 'minimum_time' => 0, 'maximum_time' => 0);
        }
        $aplf = new AbsencePolicyListFactory();
        $absence_options = $aplf->getByCompanyIDArray($current_company->getId(), TRUE);
        $riplf = new RoundIntervalPolicyListFactory();
        $round_interval_options = $riplf->getByCompanyIDArray($current_company->getId(), TRUE);
        $rhlf = new RecurringHolidayListFactory();
        $recurring_holiday_options = $rhlf->getByCompanyIDArray($current_company->getId(), TRUE);
        $sf = new ScheduleFactory();
        //Select box options;
        $data['type_options'] = $hpf->getOptions('type');
        $data['schedule_status_options'] = $sf->getOptions('status');
        $data['scheduled_day_options'] = $hpf->getOptions('scheduled_day');
        $data['absence_options'] = $absence_options;
        $data['round_interval_options'] = $round_interval_options;
        $data['recurring_holiday_options'] = $recurring_holiday_options;
        $smarty->assign_by_ref('data', $data);
        break;
}
$smarty->assign_by_ref('hpf', $hpf);
$smarty->display('policy/EditHolidayPolicy.tpl');
 function getSchedule($filter_data, $start_week_day = 0, $group_schedule = FALSE)
 {
     global $current_user, $current_user_prefs;
     //Individual is one schedule per employee, or all on one schedule.
     if (!is_array($filter_data)) {
         return FALSE;
     }
     $current_epoch = time();
     //Debug::Text('Start Date: '. TTDate::getDate('DATE', $start_date) .' End Date: '. TTDate::getDate('DATE', $end_date) , __FILE__, __LINE__, __METHOD__,10);
     Debug::text(' Start Date: ' . TTDate::getDate('DATE+TIME', $filter_data['start_date']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $filter_data['end_date']) . ' Start Week Day: ' . $start_week_day, __FILE__, __LINE__, __METHOD__, 10);
     $pdf = new TTPDF('L', 'pt', 'Letter');
     $left_margin = 20;
     $top_margin = 20;
     $pdf->setMargins($left_margin, $top_margin);
     $pdf->SetAutoPageBreak(TRUE, 30);
     //$pdf->SetAutoPageBreak(FALSE);
     $pdf->SetFont('freesans', '', 10);
     $border = 0;
     $adjust_x = 0;
     $adjust_y = 0;
     if ($group_schedule == FALSE) {
         $valid_schedules = 0;
         $sf = new ScheduleFactory();
         $tmp_schedule_shifts = $sf->getScheduleArray($filter_data);
         //Re-arrange array by user_id->date
         if (is_array($tmp_schedule_shifts)) {
             foreach ($tmp_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                 foreach ($day_schedule_shifts as $day_schedule_shift) {
                     $raw_schedule_shifts[$day_schedule_shift['user_id']][$day_epoch][] = $day_schedule_shift;
                 }
             }
         }
         unset($tmp_schedule_shifts);
         //Debug::Arr($raw_schedule_shifts, 'Raw Schedule Shifts: ', __FILE__, __LINE__, __METHOD__,10);
         if (is_array($raw_schedule_shifts)) {
             foreach ($raw_schedule_shifts as $user_id => $day_schedule_shifts) {
                 foreach ($day_schedule_shifts as $day_epoch => $day_schedule_shifts) {
                     foreach ($day_schedule_shifts as $day_schedule_shift) {
                         //Debug::Arr($day_schedule_shift, 'aDay Schedule Shift: ', __FILE__, __LINE__, __METHOD__,10);
                         $tmp_schedule_shifts[$day_epoch][$day_schedule_shift['branch']][$day_schedule_shift['department']][] = $day_schedule_shift;
                         if (isset($schedule_shift_totals[$day_epoch]['total_shifts'])) {
                             $schedule_shift_totals[$day_epoch]['total_shifts']++;
                         } else {
                             $schedule_shift_totals[$day_epoch]['total_shifts'] = 1;
                         }
                         //$week_of_year = TTDate::getWeek( strtotime($day_epoch) );
                         $week_of_year = TTDate::getWeek(strtotime($day_epoch), $start_week_day);
                         if (!isset($schedule_shift_totals[$day_epoch]['labels'])) {
                             $schedule_shift_totals[$day_epoch]['labels'] = 0;
                         }
                         if ($day_schedule_shift['branch'] != '--' and !isset($schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']])) {
                             $schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']] = TRUE;
                             $schedule_shift_totals[$day_epoch]['labels']++;
                         }
                         if ($day_schedule_shift['department'] != '--' and !isset($schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']])) {
                             $schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']] = TRUE;
                             $schedule_shift_totals[$day_epoch]['labels']++;
                         }
                         if (!isset($max_week_data[$week_of_year]['shift'])) {
                             Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to 0', __FILE__, __LINE__, __METHOD__, 10);
                             $max_week_data[$week_of_year]['shift'] = 1;
                             $max_week_data[$week_of_year]['labels'] = 0;
                         }
                         if (isset($max_week_data[$week_of_year]['shift']) and $schedule_shift_totals[$day_epoch]['total_shifts'] + $schedule_shift_totals[$day_epoch]['labels'] > $max_week_data[$week_of_year]['shift'] + $max_week_data[$week_of_year]['labels']) {
                             Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to: ' . $schedule_shift_totals[$day_epoch]['total_shifts'] . ' Labels: ' . $schedule_shift_totals[$day_epoch]['labels'], __FILE__, __LINE__, __METHOD__, 10);
                             $max_week_data[$week_of_year]['shift'] = $schedule_shift_totals[$day_epoch]['total_shifts'];
                             $max_week_data[$week_of_year]['labels'] = $schedule_shift_totals[$day_epoch]['labels'];
                         }
                         //Debug::Arr($schedule_shift_totals, ' Schedule Shift Totals: ', __FILE__, __LINE__, __METHOD__,10);
                         //Debug::Arr($max_week_data, ' zMaxWeekData: ', __FILE__, __LINE__, __METHOD__,10);
                     }
                 }
                 if (isset($tmp_schedule_shifts)) {
                     //Sort Branches/Departments first
                     foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                         ksort($day_tmp_schedule_shift);
                         $tmp_schedule_shifts[$day_epoch] = $day_tmp_schedule_shift;
                         foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                             ksort($tmp_schedule_shifts[$day_epoch][$branch]);
                         }
                     }
                     //Sort each department by start time.
                     foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                         foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                             foreach ($department_schedule_shifts as $department => $department_schedule_shift) {
                                 $department_schedule_shift = Sort::multiSort($department_schedule_shift, 'start_time');
                                 $this->schedule_shifts[$day_epoch][$branch][$department] = $department_schedule_shift;
                             }
                         }
                     }
                 }
                 unset($day_tmp_schedule_shift, $department_schedule_shifts, $department_schedule_shift, $tmp_schedule_shifts, $branch, $department);
                 $calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
                 //var_dump($calendar_array);
                 if (!is_array($calendar_array) or !isset($this->schedule_shifts) or !is_array($this->schedule_shifts)) {
                     continue;
                     //Skip to next user.
                 }
                 $ulf = new UserListFactory();
                 $ulf->getByIdAndCompanyId($user_id, $current_user->getCompany());
                 if ($ulf->getRecordCount() != 1) {
                     continue;
                 } else {
                     $user_obj = $ulf->getCurrent();
                     $pdf->AddPage();
                     $pdf->setXY(670, $top_margin);
                     $pdf->SetFont('freesans', '', 10);
                     $pdf->Cell(100, 15, TTDate::getDate('DATE+TIME', $current_epoch), $border, 0, 'R');
                     $pdf->setXY($left_margin, $top_margin);
                     $pdf->SetFont('freesans', 'B', 25);
                     $pdf->Cell(0, 25, $user_obj->getFullName() . ' - ' . TTi18n::getText('Schedule'), $border, 0, 'C');
                     $pdf->Ln();
                 }
                 $pdf->SetFont('freesans', 'B', 16);
                 $pdf->Cell(0, 15, TTDate::getDate('DATE', $filter_data['start_date']) . ' - ' . TTDate::getDate('DATE', $filter_data['end_date']), $border, 0, 'C');
                 //$pdf->Ln();
                 $pdf->Ln();
                 $pdf->Ln();
                 $pdf->SetFont('freesans', '', 8);
                 $cell_width = floor(($pdf->GetPageWidth() - $left_margin * 2) / 7);
                 $cell_height = 100;
                 $i = 0;
                 $total_days = count($calendar_array) - 1;
                 $boader = 1;
                 foreach ($calendar_array as $calendar) {
                     if ($i == 0) {
                         //Calendar Header
                         $pdf->SetFont('freesans', 'B', 8);
                         $calendar_header = TTDate::getDayOfWeekArrayByStartWeekDay($start_week_day);
                         foreach ($calendar_header as $header_name) {
                             $pdf->Cell($cell_width, 15, $header_name, 1, 0, 'C');
                         }
                         $pdf->Ln();
                         unset($calendar_header, $header_name);
                     }
                     $month_name = NULL;
                     if ($i == 0 or $calendar['isNewMonth'] == TRUE) {
                         $month_name = $calendar['month_name'];
                     }
                     if ($i > 0 and $i % 7 == 0) {
                         $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day);
                         unset($week_date_stamps);
                     }
                     $pdf->SetFont('freesans', 'B', 8);
                     $pdf->Cell($cell_width / 2, 15, $month_name, 'LT', 0, 'L');
                     $pdf->Cell($cell_width / 2, 15, $calendar['day_of_month'], 'RT', 0, 'R');
                     $week_date_stamps[] = $calendar['date_stamp'];
                     $i++;
                 }
                 $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day, TRUE);
                 $valid_schedules++;
                 unset($this->schedule_shifts, $calendar_array, $week_date_stamps, $max_week_data, $day_epoch, $day_schedule_shifts, $day_schedule_shift, $schedule_shift_totals);
             }
         }
         unset($raw_schedule_shifts);
     } else {
         $valid_schedules = 1;
         $sf = new 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) {
                     //Debug::Arr($day_schedule_shift, 'bDay Schedule Shift: ', __FILE__, __LINE__, __METHOD__,10);
                     $tmp_schedule_shifts[$day_epoch][$day_schedule_shift['branch']][$day_schedule_shift['department']][] = $day_schedule_shift;
                     if (isset($schedule_shift_totals[$day_epoch]['total_shifts'])) {
                         $schedule_shift_totals[$day_epoch]['total_shifts']++;
                     } else {
                         $schedule_shift_totals[$day_epoch]['total_shifts'] = 1;
                     }
                     //$week_of_year = TTDate::getWeek( strtotime($day_epoch) );
                     $week_of_year = TTDate::getWeek(strtotime($day_epoch), $start_week_day);
                     Debug::text(' Date: ' . TTDate::getDate('DATE', strtotime($day_epoch)) . ' Week: ' . $week_of_year . ' TMP: ' . TTDate::getWeek(strtotime('20070721'), $start_week_day), __FILE__, __LINE__, __METHOD__, 10);
                     if (!isset($schedule_shift_totals[$day_epoch]['labels'])) {
                         $schedule_shift_totals[$day_epoch]['labels'] = 0;
                     }
                     if ($day_schedule_shift['branch'] != '--' and !isset($schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']])) {
                         $schedule_shift_totals[$day_epoch]['branch'][$day_schedule_shift['branch']] = TRUE;
                         $schedule_shift_totals[$day_epoch]['labels']++;
                     }
                     if ($day_schedule_shift['department'] != '--' and !isset($schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']])) {
                         $schedule_shift_totals[$day_epoch]['department'][$day_schedule_shift['branch']][$day_schedule_shift['department']] = TRUE;
                         $schedule_shift_totals[$day_epoch]['labels']++;
                     }
                     if (!isset($max_week_data[$week_of_year]['shift'])) {
                         Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to 0', __FILE__, __LINE__, __METHOD__, 10);
                         $max_week_data[$week_of_year]['shift'] = 1;
                         $max_week_data[$week_of_year]['labels'] = 0;
                     }
                     if (isset($max_week_data[$week_of_year]['shift']) and $schedule_shift_totals[$day_epoch]['total_shifts'] + $schedule_shift_totals[$day_epoch]['labels'] > $max_week_data[$week_of_year]['shift'] + $max_week_data[$week_of_year]['labels']) {
                         Debug::text('Date: ' . $day_epoch . ' Week: ' . $week_of_year . ' Setting Max Week shift to: ' . $schedule_shift_totals[$day_epoch]['total_shifts'] . ' Labels: ' . $schedule_shift_totals[$day_epoch]['labels'], __FILE__, __LINE__, __METHOD__, 10);
                         $max_week_data[$week_of_year]['shift'] = $schedule_shift_totals[$day_epoch]['total_shifts'];
                         $max_week_data[$week_of_year]['labels'] = $schedule_shift_totals[$day_epoch]['labels'];
                     }
                 }
             }
         }
         //print_r($tmp_schedule_shifts);
         //print_r($max_week_data);
         if (isset($tmp_schedule_shifts)) {
             //Sort Branches/Departments first
             foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                 ksort($day_tmp_schedule_shift);
                 $tmp_schedule_shifts[$day_epoch] = $day_tmp_schedule_shift;
                 foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                     ksort($tmp_schedule_shifts[$day_epoch][$branch]);
                 }
             }
             //Sort each department by start time.
             foreach ($tmp_schedule_shifts as $day_epoch => $day_tmp_schedule_shift) {
                 foreach ($day_tmp_schedule_shift as $branch => $department_schedule_shifts) {
                     foreach ($department_schedule_shifts as $department => $department_schedule_shift) {
                         $sort = new arr_multisort();
                         $sort->setArray($department_schedule_shift);
                         $sort->addColumn('start_time', 1);
                         $department_schedule_shift = $sort->Sort();
                         unset($sort);
                         $this->schedule_shifts[$day_epoch][$branch][$department] = $department_schedule_shift;
                     }
                 }
             }
         }
         //print_r($this->schedule_shifts);
         $calendar_array = TTDate::getCalendarArray($filter_data['start_date'], $filter_data['end_date'], $start_week_day);
         //var_dump($calendar_array);
         if (!is_array($calendar_array) or !isset($this->schedule_shifts) or !is_array($this->schedule_shifts)) {
             return FALSE;
         }
         $pdf->AddPage();
         $pdf->setXY(670, $top_margin);
         $pdf->SetFont('freesans', '', 10);
         $pdf->Cell(100, 15, TTDate::getDate('DATE+TIME', $current_epoch), $border, 0, 'R');
         $pdf->setXY($left_margin, $top_margin);
         $pdf->SetFont('freesans', 'B', 25);
         $pdf->Cell(0, 25, 'Employee Schedule', $border, 0, 'C');
         $pdf->Ln();
         $pdf->SetFont('freesans', 'B', 10);
         $pdf->Cell(0, 15, TTDate::getDate('DATE', $filter_data['start_date']) . ' - ' . TTDate::getDate('DATE', $filter_data['end_date']), $border, 0, 'C');
         $pdf->Ln();
         $pdf->Ln();
         $pdf->SetFont('freesans', '', 8);
         $cell_width = floor(($pdf->GetPageWidth() - $left_margin * 2) / 7);
         $cell_height = 100;
         $i = 0;
         $total_days = count($calendar_array) - 1;
         $boader = 1;
         foreach ($calendar_array as $calendar) {
             if ($i == 0) {
                 //Calendar Header
                 $pdf->SetFont('freesans', 'B', 8);
                 $calendar_header = TTDate::getDayOfWeekArrayByStartWeekDay($start_week_day);
                 foreach ($calendar_header as $header_name) {
                     $pdf->Cell($cell_width, 15, $header_name, 1, 0, 'C');
                 }
                 $pdf->Ln();
                 unset($calendar_header, $header_name);
             }
             $month_name = NULL;
             if ($i == 0 or $calendar['isNewMonth'] == TRUE) {
                 $month_name = $calendar['month_name'];
             }
             if ($i > 0 and $i % 7 == 0) {
                 $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day);
                 unset($week_date_stamps);
             }
             $pdf->SetFont('freesans', 'B', 8);
             $pdf->Cell($cell_width / 2, 15, $month_name, 'LT', 0, 'L');
             $pdf->Cell($cell_width / 2, 15, $calendar['day_of_month'], 'RT', 0, 'R');
             $week_date_stamps[] = $calendar['date_stamp'];
             $i++;
         }
         $this->writeWeekSchedule($pdf, $cell_width, $week_date_stamps, $max_week_data, $left_margin, $group_schedule, $start_week_day, TRUE);
     }
     if ($valid_schedules > 0) {
         $output = $pdf->Output('', 'S');
         return $output;
     }
     return FALSE;
 }
         $status_id = $h_obj->getHolidayPolicyObject()->getDefaultScheduleStatus();
         $absence_policy_id = $h_obj->getHolidayPolicyObject()->getAbsencePolicyID();
         Debug::text('Default Schedule Status: ' . $status_id, __FILE__, __LINE__, __METHOD__, 10);
     } else {
         Debug::text('User is NOT Eligible...', __FILE__, __LINE__, __METHOD__, 10);
     }
 } else {
     Debug::text('No Holidays on this day: ', __FILE__, __LINE__, __METHOD__, 10);
 }
 unset($hlf, $h_obj);
 //Debug::text('Schedule Status ID: '. $status_id, __FILE__, __LINE__, __METHOD__, 10);
 $profiler->startTimer("Add Schedule");
 //Make sure we not already added this schedule shift.
 //And that no schedule shifts overlap this one.
 //Use the isValid() function for this
 $sf = new ScheduleFactory();
 $sf->StartTransaction();
 $sf->findUserDate($user_id, $recurring_schedule_shift_start_time);
 $sf->setStatus($status_id);
 //Working
 $sf->setStartTime($recurring_schedule_shift_start_time);
 $sf->setEndTime($recurring_schedule_shift_end_time);
 $sf->setSchedulePolicyID($recurring_schedule_shift['schedule_policy_id']);
 if (isset($absence_policy_id) and $absence_policy_id != '') {
     $sf->setAbsencePolicyID($absence_policy_id);
 }
 unset($absence_policy_id);
 if ($recurring_schedule_shift['branch_id'] == -1) {
     $sf->setBranch($user_obj->getDefaultBranch());
 } else {
     $sf->setBranch($recurring_schedule_shift['branch_id']);
 if ($recurring_schedule_days !== FALSE) {
     foreach ($recurring_schedule_days as $date_stamp => $recurring_schedule_shifts) {
         Debug::text('Recurring Schedule Shift Date Stamp: ' . $date_stamp, __FILE__, __LINE__, __METHOD__, 10);
         foreach ($recurring_schedule_shifts as $recurring_schedule_shift) {
             $recurring_schedule_shift_start_time = TTDate::strtotime($recurring_schedule_shift['start_time']);
             $recurring_schedule_shift_end_time = TTDate::strtotime($recurring_schedule_shift['end_time']);
             Debug::text('(After User TimeZone)Recurring Schedule Shift Start Time: ' . TTDate::getDate('DATE+TIME', $recurring_schedule_shift_start_time) . ' End Time: ' . TTDate::getDate('DATE+TIME', $recurring_schedule_shift_end_time), __FILE__, __LINE__, __METHOD__, 10);
             //Make sure punch pairs fall within limits
             if ($recurring_schedule_shift_start_time < $current_epoch + $max_start_stop_window) {
                 Debug::text('Recurring Schedule Shift Start Time falls within Limits: ' . TTDate::getDate('DATE+TIME', $recurring_schedule_shift_start_time), __FILE__, __LINE__, __METHOD__, 10);
                 $status_id = 10;
                 //Working
                 //Make sure we not already added this schedule shift.
                 //And that no schedule shifts overlap this one.
                 //Use the isValid() function for this
                 $sf = new ScheduleFactory();
                 $sf->StartTransaction();
                 $sf->setCompany($c_obj->getID());
                 $sf->setUser($user_id);
                 //Find the date that the shift will be assigned to so we know if its a holiday or not.
                 if (is_object($sf->getPayPeriodScheduleObject())) {
                     $date_stamp = $sf->getPayPeriodScheduleObject()->getShiftAssignedDate($recurring_schedule_shift_start_time, $recurring_schedule_shift_end_time, $sf->getPayPeriodScheduleObject()->getShiftAssignedDay());
                 } else {
                     $date_stamp = $recurring_schedule_shift_start_time;
                 }
                 //Is this a holiday?
                 $hlf = new HolidayListFactory();
                 $hlf->getByPolicyGroupUserIdAndDate($user_id, TTDate::getBeginDayEpoch($date_stamp));
                 if ($hlf->getRecordCount() > 0) {
                     $h_obj = $hlf->getCurrent();
                     Debug::text('Found Holiday! Name: ' . $h_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
예제 #8
0
 $fail_transaction = FALSE;
 $sf->StartTransaction();
 //Limit it to 31 days.
 if ($data['repeat'] > 31) {
     $data['repeat'] = 31;
 }
 Debug::Text('Repeating Punch For: ' . $data['repeat'] . ' Days', __FILE__, __LINE__, __METHOD__, 10);
 for ($i = 0; $i <= (int) $data['repeat']; $i++) {
     Debug::Text('Punch Repeat: ' . $i, __FILE__, __LINE__, __METHOD__, 10);
     if ($i == 0) {
         $date_stamp = $data['date_stamp'];
     } else {
         $date_stamp = $data['date_stamp'] + 86400 * $i;
     }
     Debug::Text('Date Stamp: ' . TTDate::getDate('DATE', $date_stamp), __FILE__, __LINE__, __METHOD__, 10);
     $sf = new ScheduleFactory();
     if ($i == 0) {
         $sf->setID($data['id']);
     }
     //$sf->setUserDateId( UserDateFactory::findOrInsertUserDate($data['user_id'], $date_stamp) );
     $sf->setUserDate($data['user_id'], $date_stamp);
     $sf->setStatus($data['status_id']);
     $sf->setSchedulePolicyID($data['schedule_policy_id']);
     $sf->setAbsencePolicyID($data['absence_policy_id']);
     $sf->setBranch($data['branch_id']);
     $sf->setDepartment($data['department_id']);
     if (isset($data['job_id'])) {
         $sf->setJob($data['job_id']);
     }
     if (isset($data['job_item_id'])) {
         $sf->setJobItem($data['job_item_id']);
 function postSave()
 {
     $this->removeCache($this->getId());
     if ($this->getDeleted() == TRUE) {
         Debug::Text('UnAssign Hours from Branch: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
         //Unassign hours from this branch.
         $pcf = new PunchControlFactory();
         $udtf = new UserDateTotalFactory();
         $uf = new UserFactory();
         $sf = new StationFactory();
         $sf_b = new ScheduleFactory();
         $udf = new UserDefaultFactory();
         $rstf = new RecurringScheduleTemplateFactory();
         $query = 'update ' . $pcf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $udtf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $sf_b->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $uf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $udf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $sf->getTable() . ' set branch_id = 0 where company_id = ' . $this->getCompany() . ' AND branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $rstf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
     }
     return TRUE;
 }
     if ($filter_user_id != '') {
         $user_id = $filter_user_id;
     } else {
         $user_id = $current_user->getId();
     }
 } else {
     $user_id = $current_user->getId();
 }
 if ($filter_start_date == '' or $filter_end_date == '') {
     $start_date = $filter_start_date = TTDate::getBeginWeekEpoch(TTDate::getTime() - 86400, $current_user_prefs->getStartWeekDay());
     $end_date = $filter_end_date = TTDate::getEndWeekEpoch(TTDate::getTime() + 86400 * 28, $current_user_prefs->getStartWeekDay());
 }
 //$start_date = $filter_start_date = TTDate::getBeginWeekEpoch( $start_date, 'mon');
 //$end_date = $filter_end_date = TTDate::getEndWeekEpoch( $end_date, 'mon' );
 Debug::text(' Start Date: ' . TTDate::getDate('DATE+TIME', $start_date) . ' End Date: ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
 $sf = new ScheduleFactory();
 $default_schedule_shifts = $sf->getScheduleArray($user_id, $start_date, $end_date);
 //var_dump($default_schedule_shifts);
 $calendar_array = TTDate::getCalendarArray($start_date, $end_date, $current_user_prefs->getStartWeekDay());
 $smarty->assign_by_ref('calendar_array', $calendar_array);
 //$smarty->assign_by_ref('pay_period_locked_rows', $pay_period_locked_rows);
 $ulf = new UserListFactory();
 $user_obj = $ulf->getById($user_id)->getCurrent();
 /*
 $holiday = new Holiday();
 $holiday->GetByCountryAndProvince($user_obj->getCountry(), $user_obj->getProvince() );
 */
 $hlf = new HolidayListFactory();
 $holiday_array = $hlf->getArrayByPolicyGroupUserId($user_id, $start_date, $end_date);
 //var_dump($holiday_array);
 $smarty->assign_by_ref('holidays', $holiday_array);
예제 #11
0
 function getScheduleTotalTime($start, $end, $schedule_policy_id)
 {
     $sf = new ScheduleFactory();
     $sf->setStartTime(TTDate::parseDateTime($start));
     $sf->setEndTime(TTDate::parseDateTime($end));
     $sf->setSchedulePolicyId($schedule_policy_id);
     $sf->preSave();
     return TTDate::getTimeUnit($sf->getTotalTime());
 }
 function postSave()
 {
     if ($this->getDeleted() == TRUE) {
         Debug::Text('UnAssign Schedule Policy from Schedule/Recurring Schedules...' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
         $sf = new ScheduleFactory();
         $rstf = new RecurringScheduleTemplateFactory();
         $query = 'update ' . $sf->getTable() . ' set schedule_policy_id = 0 where schedule_policy_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $rstf->getTable() . ' set schedule_policy_id = 0 where schedule_policy_id = ' . $this->getId();
         $this->db->Execute($query);
     }
     $this->removeCache($this->getId());
     return TRUE;
 }
 function postInstall()
 {
     global $config_vars;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Update permission for new modules.
     $clf = TTnew('CompanyListFactory');
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         $i = 0;
         foreach ($clf as $c_obj) {
             if ($c_obj->getStatus() != 30) {
                 Debug::text($i . '/' . $clf->getRecordCount() . '. Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                 //Disable detailed audit logging while updating permissions, as this can create millions of records and slow the upgrade down substantially.
                 $config_vars['other']['disable_audit_log_detail'] = TRUE;
                 $config_vars['other']['disable_audit_log'] = TRUE;
                 $pclf = TTnew('PermissionControlListFactory');
                 // Update all the HR related permissions for the Standard/Business Edition (KPIs, reviews, qualifications, etc..., but *not* job vacancy or job applicants)
                 $pclf->getByCompanyID($c_obj->getID(), NULL, NULL, NULL, array('id' => 'asc'));
                 if ($pclf->getRecordCount() > 0) {
                     $pf = TTnew('PermissionFactory');
                     $preset_options = $pf->getOptions('preset');
                     $preset_level_options = $pf->getOptions('preset_level');
                     ksort($preset_options);
                     foreach ($pclf as $pc_obj) {
                         $level = $pc_obj->getLevel();
                         // 1, 10, 12, 15, 20, 25
                         if ($level >= 10) {
                             //Only process levels 10 and higher, as those are supervisors and only ones that need adjusting.
                             $old_permission_arr = $pc_obj->getPermission();
                             if (is_array($old_permission_arr)) {
                                 foreach ($preset_options as $preset => $preset_name) {
                                     // preset: 10, 18, 20, 30, 40
                                     if ($level == $preset_level_options[$preset]) {
                                         $permission_arr = $pf->getPresetPermissions($preset, array(70, 75, 80));
                                         //Module: Human Resources
                                         //Debug::Arr( $permission_arr, ' New Permissions: ', __FILE__, __LINE__, __METHOD__,10);
                                         $pc_obj->setPermission($permission_arr, $old_permission_arr);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 unset($pclf, $pf, $preset_options, $preset_level_options, $old_permission_arr, $level, $pc_obj);
                 //Re-enable audit logging after permissions were updated.
                 $config_vars['other']['disable_audit_log_detail'] = FALSE;
                 $config_vars['other']['disable_audit_log'] = FALSE;
                 //Delete duplicate OPEN shifts before todays date.
                 $sf = new ScheduleFactory();
                 $udf = new UserDateFactory();
                 $ph = array('id' => $this->db->BindDate(time()));
                 $query = 'update ' . $sf->getTable() . ' set deleted = 1 where user_date_id in ( select id from ' . $udf->getTable() . ' where user_id = 0 and date_stamp <= ? and deleted = 0 ) and created_by is NULL AND deleted = 0';
                 $this->db->Execute($query, $ph);
                 unset($query, $ph);
                 //Assign all absence policies to every policy group.
                 $aplf = TTnew('AbsencePolicyListFactory');
                 $aplf->getByCompanyId($c_obj->getId());
                 if ($aplf->getRecordCount() > 0) {
                     foreach ($aplf as $ap_obj) {
                         $ap_ids[] = $ap_obj->getId();
                     }
                 }
                 $pglf = TTnew('PolicyGroupListFactory');
                 $pglf->getByCompanyId($c_obj->getId());
                 if ($pglf->getRecordCount() > 0) {
                     foreach ($pglf as $pg_obj) {
                         if (isset($ap_ids)) {
                             $pg_obj->setAbsencePolicy($ap_ids);
                             if ($pg_obj->isValid()) {
                                 $pg_obj->Save();
                             }
                         }
                     }
                 }
                 unset($aplf, $pglf, $ap_obj, $pg_obj, $ap_ids);
             }
             $i++;
         }
     }
     return TRUE;
 }
    function getMidDayExceptionsByStartDateAndEndDateAndPayPeriodStatus($start_date, $end_date, $pay_period_status_id)
    {
        if ($start_date == '') {
            return FALSE;
        }
        if ($end_date == '') {
            return FALSE;
        }
        if ($pay_period_status_id == '') {
            return FALSE;
        }
        $epf = new ExceptionPolicyFactory();
        $ef = new ExceptionFactory();
        $epcf = new ExceptionPolicyControlFactory();
        $pgf = new PolicyGroupFactory();
        $pguf = new PolicyGroupUserFactory();
        $uf = new UserFactory();
        $cf = new CompanyFactory();
        $udf = new UserDateFactory();
        $sf = new ScheduleFactory();
        $pcf = new PunchControlFactory();
        $pf = new PunchFactory();
        $ppf = new PayPeriodFactory();
        $current_epoch = time();
        if (strncmp($this->db->databaseType, 'mysql', 5) == 0) {
            $to_timestamp_sql = 'FROM_UNIXTIME';
        } else {
            $to_timestamp_sql = 'to_timestamp';
        }
        $ph = array('current_time1' => $this->db->BindTimeStamp($current_epoch), 'current_time2' => $this->db->BindTimeStamp($current_epoch), 'current_epoch1' => $current_epoch, 'start_date' => $this->db->BindDate($start_date), 'end_date' => $this->db->BindDate($end_date));
        //Exceptions that need to be calculated in the middle of the day:
        //Definitely: In Late, Out Late, Missed CheckIn
        //Possible: Over Daily Scheduled Time, Over Weekly Scheduled Time, Over Daily Time, Over Weekly Time, Long Lunch (can't run this fast enough), Long Break (can't run this fast enough),
        //Optimize calcQuickExceptions:
        // Loop through exception policies where In Late/Out Late/Missed CheckIn are enabled.
        // Loop through ACTIVE users assigned to these exceptions policies.
        // Only find days that are scheduled AND ( NO punch after schedule start time OR NO punch after schedule end time )
        //      For Missed CheckIn they do not need to be scheduled.
        // Exclude days that already have the exceptions triggered on them (?) (What about split shifts?)
        //	- Just exclude exceptions not assigned to punch/punch_control_id, if there is more than one in the day I don't think it helps much anyways.
        //
        //Currently Over Weekly/Daily time exceptions are only triggered on a Out punch.
        $query = '	select distinct udf.*
					FROM ' . $epf->getTable() . ' as epf
					LEFT JOIN ' . $epcf->getTable() . ' as epcf ON ( epf.exception_policy_control_id = epcf.id )
					LEFT JOIN ' . $pgf->getTable() . ' as pgf ON ( epcf.id = pgf.exception_policy_control_id )
					LEFT JOIN ' . $pguf->getTable() . ' as pguf ON ( pgf.id = pguf.policy_group_id )
					LEFT JOIN ' . $uf->getTable() . ' as uf ON ( pguf.user_id = uf.id )
					LEFT JOIN ' . $cf->getTable() . ' as cf ON ( uf.company_id = cf.id )
					LEFT JOIN ' . $udf->getTable() . ' as udf ON ( uf.id = udf.user_id )
					LEFT JOIN ' . $ppf->getTable() . ' as ppf ON ( ppf.id = udf.pay_period_id )
					LEFT JOIN ' . $ef->getTable() . ' as ef ON ( udf.id = ef.user_date_id AND ef.exception_policy_id = epf.id AND ef.type_id != 5 )
					LEFT JOIN ' . $sf->getTable() . ' as sf ON ( udf.id = sf.user_date_id AND ( sf.start_time <= ? OR sf.end_time <= ? ) )
					LEFT JOIN ' . $pcf->getTable() . ' as pcf ON ( udf.id = pcf.user_date_id AND pcf.deleted = 0 )
					LEFT JOIN ' . $pf->getTable() . ' as pf ON 	(
																pcf.id = pf.punch_control_id AND pf.deleted = 0
																AND (
																		( epf.type_id = \'S4\' AND ( pf.time_stamp >= sf.start_time OR pf.time_stamp <= sf.end_time ) )
																		OR
																		( epf.type_id = \'S6\' AND ( pf.time_stamp >= sf.end_time ) )
																		OR
																		( epf.type_id = \'C1\' AND ( pf.status_id = 10 AND pf.time_stamp <= ' . $to_timestamp_sql . '(?-epf.grace) ) )
																	)
																)
					WHERE ( epf.type_id in (\'S4\',\'S6\', \'C1\') AND epf.active = 1 )
						AND ( uf.status_id = 10 AND cf.status_id != 30 )
						AND ( udf.date_stamp >= ? AND udf.date_stamp <= ? )
						AND ppf.status_id in (' . $this->getListSQL($pay_period_status_id, $ph) . ')
						AND ( ( ( epf.type_id in (\'S4\',\'S6\') AND ( sf.id IS NOT NULL AND sf.deleted = 0 ) AND pf.id IS NULL ) OR epf.type_id = \'C1\' ) AND ef.id IS NULL  )
						AND ( epf.deleted = 0 AND epcf.deleted = 0 AND pgf.deleted = 0 AND uf.deleted = 0 AND cf.deleted = 0 AND udf.deleted = 0 )
				';
        //Don't check deleted = 0 on PCF/PF tables, as we need to check IS NULL on them instead.
        //Debug::Arr($ph, 'Query: '. $query, __FILE__, __LINE__, __METHOD__, 10);
        $this->ExecuteSQL($query, $ph);
        return $this;
    }
 function setDefaultScheduleStatus($value)
 {
     $value = trim($value);
     $sf = new ScheduleFactory();
     $key = Option::getByValue($value, $sf->getOptions('status'));
     if ($key !== FALSE) {
         $value = $key;
     }
     if ($this->Validator->inArrayKey('default_schedule_status', $value, TTi18n::gettext('Incorrect Default Schedule Status'), $sf->getOptions('status'))) {
         $this->data['default_schedule_status_id'] = $value;
         return FALSE;
     }
     return FALSE;
 }
예제 #16
0
     }
 }
 unset($slf, $s_obj);
 $ulf->getByIdAndCompanyId($user_id, $current_company->getId());
 if ($ulf->getRecordCount() == 1) {
     $user_obj = $ulf->getCurrent();
     $user_generic_status_label = $user_obj->getFullName(TRUE) . ' @ ' . TTDate::getDate('DATE', $start_time) . ': ' . TTDate::getDate('TIME', $start_time) . ' - ' . TTDate::getDate('TIME', $end_time);
     if ($conflicting_shifts == TRUE) {
         $user_generic_status_label .= ' - ' . TTi18n::gettext('DELETED CONFLICTING SHIFT');
     }
 } else {
     $user_obj = NULL;
     $user_generic_status_label = 'N/A @ ' . TTDate::getDate('DATE', $start_time) . ': ' . TTDate::getDate('TIME', $start_time) . ' - ' . TTDate::getDate('TIME', $end_time);
 }
 //Re-initialize schedule factory here so we clear any errors preventing the next schedule from being inserted.
 $sf = new ScheduleFactory();
 //$sf->setUserDateId( $user_date_id  );
 $sf->setUserDate($user_id, $time_stamp);
 $sf->setStatus($data['status_id']);
 $sf->setSchedulePolicyID($data['schedule_policy_id']);
 $sf->setAbsencePolicyID($data['absence_policy_id']);
 if (isset($data['branch_id']) and $data['branch_id'] == -1) {
     $sf->setBranch($user_obj->getDefaultBranch());
 } elseif (isset($data['branch_id'])) {
     $sf->setBranch($data['branch_id']);
 }
 if (isset($data['department_id']) and $data['department_id'] == -1) {
     $sf->setDepartment($user_obj->getDefaultDepartment());
 } elseif (isset($data['department_id'])) {
     $sf->setDepartment($data['department_id']);
 }
예제 #17
0
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'] = TTDate::getEndDayEpoch($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'] = TTDate::getEndDayEpoch($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);
        $i = 0;
        $min_hour = 0;
        $max_hour = 0;
        $sf = new 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) {
                    //$day_schedule_shift['is_owner'] = $permission->isOwner( $u_obj->getCreatedBy(), $u_obj->getId() );
                    //$day_schedule_shift['is_child'] = $permission->isChild( $u_obj->getId(), $permission_children_ids );
                    $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);
                    $day_schedule_shift['span_day'] = FALSE;
                    $day_schedule_shift['span_day_split'] = TRUE;
                    //var_dump($day_schedule_shift);
                    $tmp_start_hour = TTDate::getHour($day_schedule_shift['start_time']);
                    $tmp_end_hour = TTDate::getHour($day_schedule_shift['end_time']);
                    if ($tmp_end_hour < $tmp_start_hour) {
                        $tmp_end_hour = 24;
예제 #18
0
$action = Misc::findSubmitButton('do');
Debug::Text('Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10);
switch ($action) {
    case 'print_schedule':
        //Debug::setVerbosity(11);
        Debug::Text('Print Schedule:', __FILE__, __LINE__, __METHOD__, 10);
        if (!isset($filter_data['show_days']) or isset($filter_data['show_days']) and $filter_data['show_days'] == '') {
            $filter_data['show_days'] = 4;
        }
        if (!isset($filter_data['group_schedule'])) {
            $filter_data['group_schedule'] = FALSE;
        }
        $filter_data['start_date'] = TTDate::getBeginWeekEpoch(TTDate::getBeginDayEpoch($filter_data['start_date']), $current_user_prefs->getStartWeekDay());
        Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $filter_data['start_date']), __FILE__, __LINE__, __METHOD__, 10);
        $filter_data['end_date'] = $filter_data['start_date'] + ($filter_data['show_days'] * 7 * 86400 - 3601);
        $sf = new ScheduleFactory();
        //$output = $sf->getSchedule( $current_company->getId(), $filter_user_id, $start_date, $end_date, $current_user_prefs->getStartWeekDay(), $filter_data['group_schedule'] );
        $output = $sf->getSchedule($filter_data, $current_user_prefs->getStartWeekDay(), $filter_data['group_schedule']);
        //print_r($output);
        if ($output == FALSE) {
            echo TTi18n::getText('No Schedule to print!') . "<br>\n";
        } else {
            if (Debug::getVerbosity() < 11) {
                Misc::FileDownloadHeader('schedule.pdf', 'application/pdf', strlen($output));
                echo $output;
            } else {
                Debug::Display();
            }
        }
        exit;
        break;