Пример #1
0
 /**
  * Build the object with fetched records
  *
  * @access private
  * @return TimeEvent[] array of time events
  */
 private function _buildObjArr($result)
 {
     $objArr = null;
     while ($row = mysql_fetch_assoc($result)) {
         $tmpEventArr = new TimeEvent();
         $tmpEventArr->setTimeEventId($row[self::TIME_EVENT_DB_FIELD_TIME_EVENT_ID]);
         $tmpEventArr->setProjectId($row[self::TIME_EVENT_DB_FIELD_PROJECT_ID]);
         $tmpEventArr->setActivityId($row[self::TIME_EVENT_DB_FIELD_ACTIVITY_ID]);
         $tmpEventArr->setEmployeeId($row[self::TIME_EVENT_DB_FIELD_EMPLOYEE_ID]);
         $tmpEventArr->setTimesheetId($row[self::TIME_EVENT_DB_FIELD_TIMESHEET_ID]);
         if (!empty($row[self::TIME_EVENT_DB_FIELD_START_TIME])) {
             $tmpEventArr->setStartTime(date('Y-m-d H:i', strtotime($row[self::TIME_EVENT_DB_FIELD_START_TIME])));
         }
         if (!empty($row[self::TIME_EVENT_DB_FIELD_END_TIME])) {
             $tmpEventArr->setEndTime(date('Y-m-d H:i', strtotime($row[self::TIME_EVENT_DB_FIELD_END_TIME])));
         }
         $tmpEventArr->setReportedDate(date('Y-m-d', strtotime($row[self::TIME_EVENT_DB_FIELD_REPORTED_DATE])));
         $tmpEventArr->setDuration($row[self::TIME_EVENT_DB_FIELD_DURATION]);
         $tmpEventArr->setDescription($row[self::TIME_EVENT_DB_FIELD_DESCRIPTION]);
         $objArr[] = $tmpEventArr;
     }
     return $objArr;
 }
Пример #2
0
 /**
  * Constructs and returns time event with given parameters
  */
 private function _getTimeEvent($timeEventId, $projectId, $employeeId, $timesheetId, $startTime, $endTime, $reportedDate, $duration, $description, $activityId = 1)
 {
     $timeEvent = new TimeEvent();
     $timeEvent->setTimeEventId($timeEventId);
     $timeEvent->setActivityId($activityId);
     $timeEvent->setProjectId($projectId);
     $timeEvent->setEmployeeId($employeeId);
     $timeEvent->setTimesheetId($timesheetId);
     $timeEvent->setStartTime($startTime);
     $timeEvent->setEndTime($endTime);
     $timeEvent->setReportedDate($reportedDate);
     $timeEvent->setDuration($duration);
     $timeEvent->setDescription($description);
     return $timeEvent;
 }
 public function parseSingleEvent($postArr)
 {
     $tmpObj = new TimeEvent();
     $tmpObj->setProjectId($postArr['cmbProject']);
     $tmpObj->setActivityId($postArr['cmbActivity']);
     if (!empty($postArr['txtStartTime'])) {
         $tmpObj->setStartTime(LocaleUtil::getInstance()->convertToStandardDateTimeFormat($postArr['txtStartTime']));
     }
     if (!empty($postArr['txtEndTime'])) {
         $tmpObj->setEndTime(LocaleUtil::getInstance()->convertToStandardDateTimeFormat($postArr['txtEndTime']));
     }
     $tmpObj->setReportedDate(LocaleUtil::getInstance()->convertToStandardDateFormat($postArr['txtReportedDate']));
     if (isset($postArr['txtDuration']) && !empty($postArr['txtDuration'])) {
         $tmpObj->setDuration(trim($postArr['txtDuration']) * 3600);
     } else {
         if (isset($postArr['txtStartTime']) && isset($postArr['txtEndTime'])) {
             $startTime = strtotime($tmpObj->getStartTime());
             $endTime = strtotime($tmpObj->getEndTime());
             if ($endTime > $startTime) {
                 $tmpObj->setDuration($endTime - $startTime);
             } else {
                 $tmpObj->setDuration(0);
             }
         }
     }
     $tmpObj->setDescription(stripslashes($postArr['txtDescription']));
     if (isset($postArr['txtTimeEventId'])) {
         $tmpObj->setTimeEventId($postArr['txtTimeEventId']);
     }
     $tmpObj->setEmployeeId($_SESSION['empID']);
     return $tmpObj;
 }
Пример #4
0
 /**
  * Parse time events and generate the information for timesheets
  *
  * @param Timesheet timesheet
  */
 private function _generateTimesheet($timesheet)
 {
     $timeEventObj = new TimeEvent();
     $timeEventObj->setTimesheetId($timesheet->getTimesheetId());
     $timeEventObj->setEmployeeId($timesheet->getEmployeeId());
     $timeEventObj->setStartTime($timesheet->getStartDate());
     $timeEventObj->setEndTime($timesheet->getEndDate());
     $timeEvents = $timeEventObj->fetchTimeEvents();
     $durationArr = null;
     $dailySum = null;
     $activitySum = null;
     $totalTime = 0;
     for ($i = 0; $i < count($timeEvents); $i++) {
         $projectId = $timeEvents[$i]->getProjectId();
         $activityId = $timeEvents[$i]->getActivityId();
         if ($timeEvents[$i]->getStartTime() != null) {
             $expenseDate = strtotime(date('Y-m-d', strtotime($timeEvents[$i]->getStartTime())));
         } else {
             $expenseDate = strtotime(date('Y-m-d', strtotime($timeEvents[$i]->getReportedDate())));
         }
         if (!isset($durationArr[$projectId][$activityId][$expenseDate])) {
             $durationArr[$projectId][$activityId][$expenseDate] = 0;
         }
         if (!isset($dailySum[$expenseDate])) {
             $dailySum[$expenseDate] = 0;
         }
         if (!isset($activitySum[$projectId][$activityId])) {
             $activitySum[$projectId][$activityId] = 0;
         }
         $durationArr[$projectId][$activityId][$expenseDate] += $timeEvents[$i]->getDuration();
         $dailySum[$expenseDate] += $timeEvents[$i]->getDuration();
         $activitySum[$projectId][$activityId] += $timeEvents[$i]->getDuration();
         $totalTime += $timeEvents[$i]->getDuration();
     }
     return array($durationArr, $dailySum, $activitySum, $totalTime);
 }