public function testIsUnfinishedTimesheet()
 {
     $this->assertTrue(TimeEvent::isUnfinishedTimesheet(10));
     $this->assertFalse(TimeEvent::isUnfinishedTimesheet(11));
 }
Ejemplo n.º 2
0
 public function approveTimesheet()
 {
     $timesheetObj = $this->objTime;
     /* For checking unfinished timesheets */
     if (TimeEvent::isUnfinishedTimesheet($timesheetObj->getTimesheetId())) {
         $_GET['message'] = 'UNFINISHED_TIMESHEET_FAILURE';
         $this->_redirectToTimesheet($timesheetObj->getTimesheetId(), $_GET['message']);
         return false;
     }
     $timesheets = $timesheetObj->fetchTimesheets();
     if (isset($timesheets) && isset($timesheets[0])) {
         $timesheet = $timesheets[0];
     } else {
         $this->redirect('NO_TIMESHEET_FAILURE', '?timecode=Time&action=View_Timesheet');
     }
     $roles = array(authorize::AUTHORIZE_ROLE_ADMIN, authorize::AUTHORIZE_ROLE_SUPERVISOR);
     $role = $this->authorizeObj->firstRole($roles);
     if (!$role || $role == authorize::AUTHORIZE_ROLE_SUPERVISOR && !$this->authorizeObj->isTheSupervisor($timesheet->getEmployeeId())) {
         $this->redirect('UNAUTHORIZED_FAILURE');
     }
     $timesheet->setComment($timesheetObj->getComment());
     $res = $timesheet->approveTimesheet();
     if ($res) {
         $_GET['message'] = 'APPROVE_SUCCESS';
     } else {
         $_GET['message'] = 'APPROVE_FAILURE';
     }
     $this->_redirectToTimesheet($timesheet->getTimesheetId(), $_GET['message']);
     return $res;
 }