示例#1
0
 function updateEmpJobInfo()
 {
     $arrRecordsList[0] = "'" . $this->getEmpId() . "'";
     $arrRecordsList[1] = $this->getEmpStatus() != '0' ? "'" . $this->getEmpStatus() . "'" : 'null';
     $arrRecordsList[2] = $this->getEmpJobTitle() != '0' ? "'" . $this->getEmpJobTitle() . "'" : 'null';
     $arrRecordsList[3] = $this->getEmpEEOCat() != '0' ? "'" . $this->getEmpEEOCat() . "'" : 'null';
     $arrRecordsList[4] = $this->getEmpLocation() != '' ? "'" . $this->getEmpLocation() . "'" : 'null';
     $arrRecordsList[5] = $this->getEmpJoinedDate();
     // Quotes removed to accept null values
     $arrRecordsList[6] = $this->getEmpTerminatedDate();
     $arrRecordsList[7] = $this->getEmpTerminationRes() != '' ? "'" . $this->getEmpTerminationRes() . "'" : 'null';
     $tableName = 'HS_HR_EMPLOYEE';
     $arrFieldList[0] = 'EMP_NUMBER';
     $arrFieldList[1] = 'EMP_STATUS';
     $arrFieldList[2] = 'JOB_TITLE_CODE';
     $arrFieldList[3] = 'EEO_CAT_CODE';
     $arrFieldList[4] = 'WORK_STATION';
     $arrFieldList[5] = 'JOINED_DATE';
     $arrFieldList[6] = 'TERMINATED_DATE';
     $arrFieldList[7] = 'TERMINATION_REASON';
     $sql_builder = new SQLQBuilder();
     $sql_builder->table_name = $tableName;
     $sql_builder->flg_update = 'true';
     $sql_builder->arr_update = $arrFieldList;
     $sql_builder->arr_updateRecList = $arrRecordsList;
     $sqlQString = $sql_builder->addUpdateRecord1();
     $dbConnection = new DMLFunctions();
     $message2 = $dbConnection->executeQuery($sqlQString);
     //Calling the addData() function
     // Update job history
     if ($message2) {
         $empJobTitleHistory = new JobTitleHistory();
         if (!empty($this->empJobTitle)) {
             $empJobTitleHistory->updateHistory($this->getEmpId(), $this->empJobTitle);
         }
         $empDivisionHistory = new SubDivisionHistory();
         if (!empty($this->empLocation)) {
             $empDivisionHistory->updateHistory($this->getEmpId(), $this->empLocation);
         }
     }
     return $message2;
 }
示例#2
0
 /**
  * Test case for updateHistory().
  */
 public function testUpdateHistory()
 {
     $history = new JobTitleHistory();
     // invalid emp number
     try {
         $history->updateHistory('ab1', 'JOB003');
         $this->fail("Exception expected");
     } catch (EmpHistoryException $e) {
         $this->assertEquals(EmpHistoryException::INVALID_PARAMETER, $e->getCode());
     }
     // invalid job title code
     try {
         $history->updateHistory(11, 'JOBA003');
         $this->fail("Exception expected");
     } catch (EmpHistoryException $e) {
         $this->assertEquals(EmpHistoryException::INVALID_PARAMETER, $e->getCode());
     }
     // No change
     $this->assertEquals(1, $this->_getNumRows("emp_number = 12 AND code = 'JOB003' AND end_date IS NULL"));
     $before = $this->_getNumRows();
     $result = $history->updateHistory(12, 'JOB003');
     $this->assertFalse($result);
     $this->assertEquals($before, $this->_getNumRows());
     $this->assertEquals(1, $this->_getNumRows("emp_number = 12 AND code = 'JOB003' AND end_date IS NULL"));
     // Employee with 2 current items, verify exception thrown
     $this->_runQuery('UPDATE hs_hr_emp_jobtitle_history SET end_date = null WHERE id=' . $this->jobtitleHistory[3]->getId());
     try {
         $result = $history->updateHistory(11, 'JOB001');
         $this->fail('Exception expected');
     } catch (EmpHistoryException $e) {
         $this->assertEquals(EmpHistoryException::MULTIPLE_CURRENT_ITEMS_NOT_ALLOWED, $e->getCode());
     }
     // Change job title
     $result = $history->updateHistory(12, 'JOB001');
     $this->assertTrue($result);
     $this->assertEquals($before + 1, $this->_getNumRows());
     $this->assertEquals(0, $this->_getNumRows("emp_number = 12 AND code = 'JOB002' AND end_date IS NULL"));
     $this->assertEquals(1, $this->_getNumRows("emp_number = 12 AND code = 'JOB001' AND end_date IS NULL"));
     // validate end date of old job correctly set
     $result = $this->_getMatchingRows('id = ' . $this->jobtitleHistory[6]->getId());
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
     $this->assertNotNull($result[0]['end_date']);
     // Verify the end time is correct
     $endDate = $result[0]['end_date'];
     $this->assertTrue(time() - strtotime($endDate) < 30);
     // Verify name is current
     $this->assertEquals('Programmer', $result[0]['name']);
     // validate start date of new job correctly set
     $result = $this->_getMatchingRows("emp_number = 12 AND code = 'JOB001' AND end_date IS NULL");
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
     $this->assertNotNull($result[0]['start_date']);
     // Verify the start time is correct
     $startDate = $result[0]['start_date'];
     $this->assertTrue(time() - strtotime($startDate) < 30);
     // Verify name is current
     $this->assertEquals('Manager', $result[0]['name']);
     // Update history for employee with no current history items.
     $this->_runQuery('DELETE from hs_hr_emp_jobtitle_history');
     $this->assertEquals(0, $this->_getNumRows());
     $result = $history->updateHistory(12, 'JOB003');
     $this->assertTrue($result);
     $this->assertEquals(1, $this->_getNumRows());
     $this->assertEquals(1, $this->_getNumRows("emp_number = 12 AND code = 'JOB003' AND end_date IS NULL"));
 }