/**
  *
  * @param sfForm $form
  * @return boolean 
  */
 public function applyMoreThanAllowedForADay(LeaveParameterObject $leaveAssignmentData)
 {
     $fromTime = date('H:i:s', strtotime($leaveAssignmentData->getFromTime()));
     $toTime = date('H:i:s', strtotime($leaveAssignmentData->getToTime()));
     $totalDuration = 0;
     if ($leaveAssignmentData->getFromDate() == $leaveAssignmentData->getToDate()) {
         $totalDuration = $this->getLeaveRequestService()->getTotalLeaveDuration($leaveAssignmentData->getEmployeeNumber(), $leaveAssignmentData->getFromDate());
     }
     if ($totalDuration + $leaveAssignmentData->getLeaveTotalTime() > $this->getWorkShiftDurationForEmployee($leaveAssignmentData->getEmployeeNumber())) {
         $dateRange = new DateRange();
         $dateRange->setFromDate($leaveAssignmentData->getFromDate());
         $dateRange->setToDate($leaveAssignmentData->getToDate());
         $searchParameters['dateRange'] = $dateRange;
         $searchParameters['employeeFilter'] = $leaveAssignmentData->getEmployeeNumber();
         $parameter = new ParameterObject($searchParameters);
         $leaveRequests = $this->getLeaveRequestService()->searchLeaveRequests($parameter);
         if (count($leaveRequests['list']) > 0) {
             foreach ($leaveRequests['list'] as $leaveRequest) {
                 $this->overlapLeaves[] = $leaveRequest->getLeave();
             }
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  *
  * @param sfForm $form
  * @return boolean 
  */
 public function applyMoreThanAllowedForADay(LeaveParameterObject $leaveAssignmentData)
 {
     //        $fromTime = date('H:i:s', strtotime($leaveAssignmentData->getFromTime()));
     //        $toTime = date('H:i:s', strtotime($leaveAssignmentData->getToTime()));
     $totalDuration = 0;
     $empNumber = $leaveAssignmentData->getEmployeeNumber();
     $fromDate = $leaveAssignmentData->getFromDate();
     $toDate = $leaveAssignmentData->getToDate();
     $logger = $this->getLogger();
     if ($fromDate == $toDate) {
         $totalDuration = $this->getLeaveRequestService()->getTotalLeaveDuration($empNumber, $fromDate);
         $workShiftLength = $this->getWorkShiftDurationForEmployee($empNumber);
         $totalLeaveTime = $leaveAssignmentData->getLeaveTotalTime();
         if ($logger->isDebugEnabled()) {
             $logger->debug("fromDate={$fromDate}, toDate={$toDate}, totalDuration={$totalDuration}, " . "workShiftLength={$workShiftLength}, totalLeaveTime={$totalLeaveTime}");
         }
         // We only show workshift exceeded warning for partial leave days (length < workshift)
         if ($totalDuration + $totalLeaveTime > $workShiftLength) {
             if ($logger->isDebugEnabled()) {
                 $logger->debug('Workshift length exceeded!');
             }
             $dateRange = new DateRange();
             $dateRange->setFromDate($fromDate);
             $dateRange->setToDate($fromDate);
             $searchParameters['dateRange'] = $dateRange;
             $searchParameters['employeeFilter'] = $empNumber;
             $parameter = new ParameterObject($searchParameters);
             $leaveRequests = $this->getLeaveRequestService()->searchLeaveRequests($parameter);
             if (count($leaveRequests['list']) > 0) {
                 $overlapLeave = array();
                 foreach ($leaveRequests['list'] as $leaveRequest) {
                     $overlapLeave = $leaveRequest->getLeave();
                 }
                 $this->setOverlapLeave($overlapLeave);
             }
             return true;
         }
     }
     return false;
 }