Example #1
0
 public function testSetTimePeriodSet()
 {
     Config::setTimePeriodSet('Yes');
     $result = mysql_query("SELECT `value` FROM `hs_hr_config` WHERE `key` = 'timesheet_period_set'");
     $row = mysql_fetch_array($result, MYSQL_NUM);
     $value = $row[0];
     $this->assertEquals('Yes', $value);
     Config::setTimePeriodSet('No');
     $result = mysql_query("SELECT `value` FROM `hs_hr_config` WHERE `key` = 'timesheet_period_set'");
     $row = mysql_fetch_array($result, MYSQL_NUM);
     $value = $row[0];
     $this->assertEquals('No', $value);
     try {
         Config::setTimePeriodSet('ABC');
         $this->fail('Invalid arguments are allowed. Did not throw an exception');
     } catch (Exception $e) {
         $this->assertEquals("Given value for TimeSheetPeriodSet should be 'Yes' or 'No'", $e->getMessage());
     }
 }
Example #2
0
 public function saveWorkWeek()
 {
     $timesheetSubmissionPeriod = $this->getObjTime();
     $timesheetSubmissionPeriod->setFrequency(TimesheetSubmissionPeriod::TIMESHEET_SUBMISSION_PERIOD_FREQUENCY_WEEK);
     try {
         $res = $timesheetSubmissionPeriod->saveTimesheetSubmissionPeriod();
     } catch (TimesheetSubmissionPeriodException $err) {
         $_GET['message'] = 'EXCEPTION_THROWN_WARNING';
         $this->redirect($_GET['message'], "?timecode=Time&action=Work_Week_Edit_View");
     }
     if ($res) {
         $_GET['message'] = 'UPDATE_SUCCESS';
         Config::setTimePeriodSet('Yes');
     } else {
         $_GET['message'] = 'UPDATE_FAILURE';
     }
     $this->redirect($_GET['message'], "?timecode=Time&action=Work_Week_Edit_View");
 }