public function saveTimeEvent() { $timeEvent = $this->getObjTime(); if ($timeEvent == null) { $this->redirect('INVALID_TIME_FAILURE', "?timecode=Time&action=Show_Punch_Time"); } $timeEvent->resolveTimesheet(); /* Check whether the timesheet is an approved or rejected one: Begins */ $timesheetId = $timeEvent->getTimesheetId(); if (Timesheet::checkTimesheetStatus($timesheetId, Timesheet::TIMESHEET_STATUS_APPROVED)) { $_GET['message'] = 'APPROVED_TIMESHEET_FAILURE'; $this->redirect($_GET['message'], "?timecode=Time&action=Time_Event_Home"); return; } /* Check whether the timesheet is an approved or rejected one: Ends */ try { if ($timeEvent->getTimeEventId() == null) { $res = $timeEvent->addTimeEvent(); } else { $res = $timeEvent->editTimeEvent(); } } catch (TimeEventException $e) { switch ($e->getCode()) { case TimeEventException::OVERLAPPING_TIME_PERIOD: $_GET['message'] = 'OVERLAPPING_TIME_PERIOD_FAILURE'; break; default: $_GET['message'] = 'UNKNOWN_ERROR_FAILURE'; break; } } if (isset($res)) { if ($res) { $_GET['message'] = 'UPDATE_SUCCESS'; } else { $_GET['message'] = 'UPDATE_FAILURE'; } } $this->redirect($_GET['message'], "?timecode=Time&action=Time_Event_Home"); return $res; }
public function testCheckTimesheetStatus() { $statusResult = Timesheet::checkTimesheetStatus(12, Timesheet::TIMESHEET_STATUS_APPROVED); $this->assertTrue($statusResult); $statusResult = Timesheet::checkTimesheetStatus(13, Timesheet::TIMESHEET_STATUS_REJECTED); $this->assertTrue($statusResult); $statusResult = Timesheet::checkTimesheetStatus(10, Timesheet::TIMESHEET_STATUS_REJECTED); $this->assertFalse($statusResult); }