function Validate()
 {
     Debug::Text('User Date ID: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
     $this->handleDayBoundary();
     if ($this->getUserDateObject() == FALSE or !is_object($this->getUserDateObject())) {
         Debug::Text('UserDateID is INVALID! ID: ' . $this->getUserDateID(), __FILE__, __LINE__, __METHOD__, 10);
         $this->Validator->isTrue('user_date', FALSE, TTi18n::gettext('Invalid User/Date. Pay Period may be locked'));
     }
     if (is_object($this->getUserDateObject()) and $this->getUserDateObject()->getPayPeriodObject()->getIsLocked() == TRUE) {
         $this->Validator->isTrue('user_date', FALSE, TTi18n::gettext('Pay Period is Currently Locked'));
     }
     if (is_object($this->getUserDateObject())) {
         //Make sure we're not conflicting with any other schedule shifts.
         $slf = new ScheduleListFactory();
         $conflicting_schedule_shift_obj = $slf->getConflictingByUserIdAndStartDateAndEndDate($this->getUserDateObject()->getUser(), $this->getStartTime(), $this->getEndTime());
         if (is_object($conflicting_schedule_shift_obj)) {
             $conflicting_schedule_shift_obj = $conflicting_schedule_shift_obj->getCurrent();
             if ($conflicting_schedule_shift_obj->isNew() === FALSE and $conflicting_schedule_shift_obj->getId() != $this->getId()) {
                 Debug::text('Conflicting Schedule Shift ID:' . $conflicting_schedule_shift_obj->getId() . ' Schedule Shift ID: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $this->Validator->isTrue('start_time', FALSE, TTi18n::gettext('Conflicting start time'));
             }
         }
     }
     return TRUE;
 }
예제 #2
0
 }
 if ($data['end_time'] != '') {
     Debug::Text('End Time: ' . $data['end_time'] . ' Date Stamp: ' . $time_stamp, __FILE__, __LINE__, __METHOD__, 10);
     $end_time = strtotime($data['end_time'], $time_stamp);
     //Debug::Text('bEnd Time: '. $data['end_time'] .' - '. TTDate::getDate('DATE+TIME',$data['end_time']) , __FILE__, __LINE__, __METHOD__,10);
 } else {
     $end_time = NULL;
 }
 //$user_date_id = UserDateFactory::findOrInsertUserDate($user_id, $time_stamp);
 Debug::Text('User ID: ' . $user_id . ' Date Stamp: ' . TTDate::getDate('DATE', $time_stamp), __FILE__, __LINE__, __METHOD__, 10);
 $conflicting_shifts = FALSE;
 if (isset($data['overwrite']) and $data['overwrite'] == 1) {
     Debug::Text('Overwriting Existing Shifts Enabled...', __FILE__, __LINE__, __METHOD__, 10);
     $slf = new ScheduleListFactory();
     //$slf->getConflictingByUserDateIdAndStartDateAndEndDate($user_date_id, $start_time, $end_time);
     $slf->getConflictingByUserIdAndStartDateAndEndDate($user_id, $start_time, $end_time);
     if ($slf->getRecordCount() > 0) {
         $conflicting_shifts = TRUE;
         Debug::Text('Found Conflicting Shift!!', __FILE__, __LINE__, __METHOD__, 10);
         //Delete shifts.
         foreach ($slf as $s_obj) {
             Debug::Text('Deleting Schedule Shift ID: ' . $s_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
             $s_obj->setDeleted(TRUE);
             if ($s_obj->isValid()) {
                 $s_obj->Save();
             }
         }
     } else {
         Debug::Text('NO Conflicting Shift found...', __FILE__, __LINE__, __METHOD__, 10);
     }
 }