Ejemplo n.º 1
0
 /**
  * Generate timesheetIds for startDate , endDate and employeeIds
  *
  * @param Array $employeeIds
  * @param Object $timesheetObj
  * @return Array $timsheetIds
  */
 private function _getTimesheetIds($employeeIds, $timesheetObj)
 {
     $timsheetIds = NULL;
     $timeEventObj = new TimeEvent();
     $timeEventObj->setStartTime($timesheetObj->getStartDate());
     $timeEventObj->setEndTime($timesheetObj->getEndDate());
     $timsheetIds = $timeEventObj->fetchTimeSheetIds($employeeIds);
     if (count($timsheetIds)) {
         foreach ($timsheetIds as $key => $timeSheetId) {
             $dateFound = FALSE;
             $timeSheetObj = new Timesheet();
             $timeSheetObj->setTimesheetId($timeSheetId);
             list($tempTimeSheetObj) = $timeSheetObj->fetchTimesheets();
             $timeSheetStartDate = strtotime(date('Y-m-d', strtotime($tempTimeSheetObj->getStartDate())));
             $timeSheetEndDate = strtotime(date('Y-m-d', strtotime($tempTimeSheetObj->getEndDate())));
             for ($i = strtotime($timesheetObj->getStartDate()); $i <= strtotime($timesheetObj->getEndDate()); $i += 3600 * 24) {
                 if ($i >= $timeSheetStartDate && $i <= $timeSheetEndDate) {
                     $dateFound = TRUE;
                     break;
                 }
             }
             if (!$dateFound) {
                 unset($timsheetIds[$key]);
             }
         }
     }
     return $timsheetIds;
 }