Esempio n. 1
0
 /**
  * test method getProjectActivityTime()
  */
 public function testGetProjectActivityTimeWithMultipleActivities()
 {
     $report = new ProjectReport();
     // QA - Employee 1
     $this->_addEvent(1, 1, "QA", "2007-07-05  09:25", 70);
     $this->_addEvent(1, 1, "QA", "2007-07-07  08:12", 33);
     // 33 min
     $this->_addEvent(1, 1, "QA", "2007-07-10  09:25", 8 * 60 + 30);
     // 510 min
     // QA - Employee 2
     $this->_addEvent(1, 2, "QA", "2007-07-05  09:25", 70);
     // 70 min
     $this->_addEvent(1, 2, "QA", "2007-07-12  11:25", 4 * 60 + 10);
     // 250 min
     $this->_addEvent(1, 2, "QA", "2007-07-11  06:25", 4 * 60 + 10);
     // 250 min
     // QA Events for different project
     $this->_addEvent(2, 1, "QA", "2007-07-05  07:25", 8 * 60 + 10);
     // 490 min
     $this->_addEvent(2, 2, "QA", "2007-07-05  09:25", 5 * 60);
     // 300 min
     // Programming - Employee 1
     $this->_addEvent(1, 1, "Programming", "2007-07-05  09:25", 80);
     $this->_addEvent(1, 1, "Programming", "2007-07-07  08:12", 70);
     $this->_addEvent(1, 1, "Programming", "2007-07-10  09:25", 210);
     // Programming - Employee 2
     $this->_addEvent(1, 2, "Programming", "2007-07-05  09:25", 230);
     $this->_addEvent(1, 2, "Programming", "2007-07-12  11:25", 450);
     $this->_addEvent(1, 2, "Programming", "2007-07-11  06:25", 900);
     // Programming for different project
     $this->_addEvent(2, 1, "Programming", "2007-07-05  05:25", 800);
     $this->_addEvent(2, 2, "Programming", "2007-07-12  15:25", 450);
     // Event spanning more than one day
     $this->_addEvent(1, 1, "Programming", "2007-07-19 18:00", 600);
     $this->_addEvent(1, 2, "Programming", "2007-07-18 21:25", 500);
     // Deleted activity for project 2
     $this->_addEvent(2, 1, "Deleted Activity", "2007-07-10  09:25", 400);
     $this->_addEvent(2, 2, "Deleted Activity", "2007-07-11  09:25", 300);
     // Check project 2 time
     $results = $report->getProjectActivityTime(2, "2007-07-05", "2007-07-25");
     $res = $this->_verifyActivityTime($results, 2, array("Programming", "QA", "Support", "Deleted Activity"), array(1250, 790, 0, 700));
     $this->assertTrue($res);
     // Check project 1 time
     $results = $report->getProjectActivityTime(1, "2007-07-05", "2007-07-25");
     $res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(3040, 1183, 0));
     $this->assertTrue($res);
     // Project 1 time for day with spanning events.
     $results = $report->getProjectActivityTime(1, "2007-07-19", "2007-07-19");
     $res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(360 + 345, 0, 0));
     $this->assertTrue($res);
     // Project 1 time from 07-10
     $results = $report->getProjectActivityTime(1, "2007-07-10", "2007-07-30");
     $res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(2660, 1010, 0));
     $this->assertTrue($res);
 }
Esempio n. 2
0
 /**
  * View project report
  */
 public function viewProjectReport()
 {
     $path = "/templates/time/projectReport.php";
     $timeEventObj = $this->objTime[0];
     $startDate = $this->objTime[1];
     $endDate = $this->objTime[2];
     $projectId = $timeEventObj->getProjectId();
     if (!$this->authorizeObj->isAdmin() && !$this->authorizeObj->isProjectAdminOf($projectId)) {
         $this->redirect('UNAUTHORIZED_FAILURE');
     }
     $projectObj = new Projects();
     $project = $projectObj->fetchProject($projectId);
     if (empty($project)) {
         $this->redirect('PROJECT_NOT_FOUND_FAILURE', '?timecode=Time&action=Project_Report_Define');
     }
     $report = new ProjectReport();
     $activityTimeArray = $report->getProjectActivityTime($projectId, $startDate, $endDate);
     $dataArr[0] = $project;
     $dataArr[1] = $startDate;
     $dataArr[2] = $endDate;
     $dataArr[3] = $activityTimeArray;
     $template = new TemplateMerger($dataArr, $path);
     $template->display();
 }