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']);
 }
 Debug::text('Department ID: ' . $recurring_schedule_shift['department_id'] . ' Default Department ID: ' . $user_obj->getDefaultDepartment(), __FILE__, __LINE__, __METHOD__, 10);
 if ($recurring_schedule_shift['department_id'] == -1) {
     $sf->setDepartment($user_obj->getDefaultDepartment());
 } else {
     $sf->setDepartment($recurring_schedule_shift['department_id']);
 }
 if (isset($recurring_schedule_shift['job_id'])) {
     $sf->setJob($recurring_schedule_shift['job_id']);
Exemplo n.º 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;
 }
Exemplo n.º 3
0
     $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']);
 }
 if (isset($data['job_id'])) {
     $sf->setJob($data['job_id']);
 }
 if (isset($data['job_item_id'])) {
     $sf->setJobItem($data['job_item_id']);