Ejemplo n.º 1
0
 /**
  * Checks that the attributes of the activity object and the database row match.
  *
  * @param ProjectActivity $activity
  * @param array           $row
  */
 private function _checkRow($activity, $row)
 {
     $this->assertEquals($activity->getName(), $row['name'], "Activity name not correct");
     $this->assertEquals($activity->getProjectId(), $row['project_id'], "Project id wrong");
     $this->assertEquals($activity->getId(), $row['activity_id'], "Activity id wrong");
     $this->assertEquals($activity->isDeleted(), (bool) $row['deleted'], "Deleted value wrong");
 }
 public function editTimesheetGrid($messageType = null, $message = null, $showComments = 'No')
 {
     $timesheet = $this->objTime;
     /* Setting Grid array: Begins */
     $timeEventObj = new TimeEvent();
     $timeEventObj->setTimesheetId($timesheet->getTimesheetId());
     $timeEventObj->setEmployeeId($timesheet->getEmployeeId());
     $timeEventObj->setStartTime($timesheet->getStartDate());
     $timeEventObj->setEndTime($timesheet->getEndDate());
     $timeEvents = $timeEventObj->fetchTimeEvents();
     $eventsCount = count($timeEvents);
     $grid = array();
     $activityObj = new ProjectActivity();
     if ($eventsCount > 0) {
         for ($i = 0; $i < $eventsCount; $i++) {
             $projectId = $timeEvents[$i]->getProjectId();
             $activityId = $timeEvents[$i]->getActivityId();
             $gridKey = $timeEvents[$i]->getEmployeeId() . '-' . $projectId . '-' . $activityId;
             $dateKey = strtotime($timeEvents[$i]->getReportedDate());
             if (!isset($grid[$gridKey])) {
                 $activityObj->setId($activityId);
                 $activityObj->fetch();
                 $projectObj = new Projects();
                 $projectObj->setProjectId($projectId);
                 $projectObj->fetch();
                 $grid[$gridKey]['projectId'] = $projectId;
                 // TODO: Remove this and use project object in the template
                 $grid[$gridKey]['projectObj'] = $projectObj;
                 $grid[$gridKey]['activityId'] = $activityId;
                 // TODO: Remove this and use activity object in the template
                 $grid[$gridKey]['activityName'] = $activityObj->getName();
                 $grid[$gridKey]['isActivityDeleted'] = $activityObj->isDeleted();
                 $grid[$gridKey]['activityList'] = $activityObj->getActivityList($projectId);
             }
             $grid[$gridKey][$dateKey]['duration'] = round($timeEvents[$i]->getDuration() / 3600, 2);
             $grid[$gridKey][$dateKey]['eventId'] = $timeEvents[$i]->getTimeEventId();
             $grid[$gridKey][$dateKey]['comment'] = $timeEvents[$i]->getDescription();
         }
         $records['grid'] = $grid;
     } else {
         $records['grid'] = null;
     }
     /* Setting Grid array: Ends */
     /* Setting Projects List: Begins */
     $projectObj = new Projects();
     $projectObj->setDeleted(Projects::PROJECT_NOT_DELETED);
     $projects = $projectObj->fetchProjects(false);
     $projectsCount = count($projects);
     if ($projectsCount > 0) {
         for ($i = 0; $i < $projectsCount; $i++) {
             $projectId = $projects[$i]->getProjectId();
             $projectsList[$i]['name'] = $projects[$i]->retrieveCustomerName($projectId) . ' - ' . $projects[$i]->getProjectName();
             $projectsList[$i]['id'] = $projectId;
             $projectsList[$i]['deleted'] = $projects[$i]->getDeleted();
         }
         $records['projectsList'] = $projectsList;
     } else {
         $records['projectsList'] = null;
     }
     /* Setting Projects List: Ends */
     $records['employeeId'] = $timesheet->getEmployeeId();
     $records['timesheetId'] = $timesheet->getTimesheetId();
     $records['timesheetPeriodId'] = $timesheet->getTimesheetPeriodId();
     $records['startDateStamp'] = strtotime($timesheet->getStartDate());
     $records['endDateStamp'] = strtotime($timesheet->getEndDate());
     if (isset($messageType)) {
         $records['messageType'] = $messageType;
         $records['message'] = $message;
     }
     $records['showComments'] = $showComments;
     $path = '/templates/time/editTimesheetGrid.php';
     $template = new TemplateMerger($records, $path);
     $template->display();
 }