コード例 #1
0
 /**
  * Testing for saving a timesheet for newly made timesheets
  */
 public function testSaveTimesheetWithNewTimesheet()
 {
     TestDataService::truncateTables(array('Timesheet'));
     $timesheet = new Timesheet();
     $timesheet->setState("CREATED");
     $timesheet->setEmployeeId(200);
     $timesheet->setStartDate("2011-04-07");
     $timesheet->setEndDate("2011-04-14");
     $savedNewTimesheet = $this->timesheetDao->saveTimesheet($timesheet);
     $this->assertNotNull($savedNewTimesheet->getTimesheetId());
     $this->assertEquals($savedNewTimesheet->getState(), "CREATED");
     $this->assertEquals($savedNewTimesheet->getStartDate(), "2011-04-07");
 }
コード例 #2
0
 public function createTimesheets($startDate, $employeeId)
 {
     $datesInTheCurrenTimesheetPeriod = $this->getTimesheetPeriodService()->getDefinedTimesheetPeriod($startDate);
     $timesheetStartingDate = $datesInTheCurrenTimesheetPeriod[0];
     $endDate = end($datesInTheCurrenTimesheetPeriod);
     $timesheet = $this->getTimesheetByStartDateAndEmployeeId($timesheetStartingDate, $employeeId);
     if ($timesheet == null) {
         if ($this->checkForOverlappingTimesheets($timesheetStartingDate, $endDate, $employeeId) == 0) {
             $statusValuesArray['state'] = 1;
         } else {
             $accessFlowStateMachineService = new AccessFlowStateMachineService();
             $tempNextState = $accessFlowStateMachineService->getNextState(WorkflowStateMachine::FLOW_TIME_TIMESHEET, Timesheet::STATE_INITIAL, "SYSTEM", WorkflowStateMachine::TIMESHEET_ACTION_CREATE);
             $timesheet = new Timesheet();
             $timesheet->setState($tempNextState);
             $timesheet->setStartDate($timesheetStartingDate);
             $timesheet->setEndDate($endDate);
             $timesheet->setEmployeeId($employeeId);
             $timesheet = $this->saveTimesheet($timesheet);
             $statusValuesArray['state'] = 2;
             $statusValuesArray['startDate'] = $timesheetStartingDate;
         }
     } else {
         $statusValuesArray['state'] = 3;
     }
     return $statusValuesArray;
 }