function getBreakPolicyObject($break_policy_id)
 {
     if ($break_policy_id == '') {
         return FALSE;
     }
     Debug::Text('Client Contact ID: ' . $break_policy_id . ' Client ID: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
     if (isset($this->break_policy_obj[$break_policy_id]) and is_object($this->break_policy_obj[$break_policy_id])) {
         return $this->break_policy_obj[$break_policy_id];
     } else {
         $bplf = new BreakPolicyListFactory();
         $bplf->getById($break_policy_id);
         if ($bplf->getRecordCount() > 0) {
             $this->break_policy_obj[$break_policy_id] = $bplf->getCurrent();
             return $this->break_policy_obj[$break_policy_id];
         }
         return FALSE;
     }
 }
예제 #2
0
 function inBreakPolicyWindow($current_epoch, $previous_epoch)
 {
     Debug::Text(' Checking if we are in break policy window/punch time... Current: ' . TTDate::getDate('DATe+TIME', $current_epoch) . ' Previous: ' . TTDate::getDate('DATe+TIME', $previous_epoch), __FILE__, __LINE__, __METHOD__, 10);
     if ($current_epoch == '') {
         return FALSE;
     }
     if ($previous_epoch == '') {
         return FALSE;
     }
     if (is_object($this->getScheduleObject()) and is_object($this->getScheduleObject()->getSchedulePolicyObject()) and is_array($this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicy())) {
         Debug::Text(' Found Schedule Break Policies...', __FILE__, __LINE__, __METHOD__, 10);
         $bp_ids = $this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicy();
         foreach ($bp_ids as $bp_id) {
             $bp_objs[] = $this->getScheduleObject()->getSchedulePolicyObject()->getBreakPolicyObject($bp_id);
         }
         unset($bp_ids);
         $start_epoch = $this->getScheduleObject()->getStartTime();
     } else {
         //Make sure prev punch is a Break Out Punch
         //Check NON-scheduled break policies
         $bplf = new BreakPolicyListFactory();
         $bplf->getByPolicyGroupUserId($this->getUser());
         if ($bplf->getRecordCount() > 0) {
             $bp_objs[] = $bplf->getCurrent();
             //FIXME: Start time should be the shift start time, not the previous punch start time.
             $start_epoch = $previous_epoch;
             Debug::Text(' Found NON Schedule Break Policy...', __FILE__, __LINE__, __METHOD__, 10);
         } else {
             Debug::Text(' DID NOT Find NON Schedule Break Policy...', __FILE__, __LINE__, __METHOD__, 10);
         }
         unset($mplf);
     }
     if (isset($bp_objs) and is_array($bp_objs)) {
         foreach ($bp_objs as $bp_obj) {
             if ($bp_obj->getAutoDetectType() == 10) {
                 //Meal window
                 Debug::Text(' Auto Detect Type: Break Window...', __FILE__, __LINE__, __METHOD__, 10);
                 if ($current_epoch >= $start_epoch + $bp_obj->getStartWindow() and $current_epoch <= $start_epoch + $bp_obj->getStartWindow() + $bp_obj->getWindowLength()) {
                     Debug::Text(' aPunch is in break policy (ID:' . $bp_obj->getId() . ') window!', __FILE__, __LINE__, __METHOD__, 10);
                     return TRUE;
                 }
             } else {
                 //Punch time.
                 Debug::Text(' Auto Detect Type: Punch Time...', __FILE__, __LINE__, __METHOD__, 10);
                 if ($current_epoch - $previous_epoch >= $bp_obj->getMinimumPunchTime() and $current_epoch - $previous_epoch <= $bp_obj->getMaximumPunchTime()) {
                     Debug::Text(' bPunch is in break policy (ID:' . $bp_obj->getId() . ') window!', __FILE__, __LINE__, __METHOD__, 10);
                     return TRUE;
                 }
             }
         }
     } else {
         Debug::Text(' Unable to find break policy object...', __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
 function getBreakPolicyObject()
 {
     if (is_object($this->break_policy_obj)) {
         return $this->break_policy_obj;
     } else {
         $bplf = new BreakPolicyListFactory();
         $bplf->getById($this->getBreakPolicyID());
         if ($bplf->getRecordCount() > 0) {
             $this->break_policy_obj = $bplf->getCurrent();
             return $this->break_policy_obj;
         }
         return FALSE;
     }
 }