function addData($postArr, $index, $object)
 {
     switch ($index) {
         case 'EMP':
             $empinfo = new EmpInfo();
             $empinfo = $object['EmpInfo'];
             $res = $empinfo->addEmpMain();
             /* Get padded empID since most classes expect the empId to
              * be left padded with zeros.
              */
             $id = $empinfo->getPaddedEmpId();
             if (isset($object['EmpPhoto']) && $res) {
                 $empphoto = $object['EmpPhoto'];
                 $empphoto->setEmpId($empinfo->getEmpId());
                 $empphoto->addEmpPic();
             }
             break;
     }
     if ($res) {
         // For adding a new record to `hs_hr_hsp_summary` table.
         if (HspSummary::recordsExist(date('Y'))) {
             HspSummary::saveInitialSummaryForOneEmployee($empinfo->getEmpId());
         }
         $showMsg = "Addition%Successful!";
         //If $message is 1 setting up the
         $reqcode = $index;
         header("Location: ./CentralController.php?reqcode=EMP&id={$id}&capturemode=updatemode");
     } else {
         $errCode = mysql_errno();
         switch ($errCode) {
             case 1062:
                 $showMsg = "DUPLICATE_EMPCODE_FAILURE";
                 break;
             default:
                 $showMsg = "ADD_FAILURE";
                 break;
         }
         $reqcode = $index;
         header("Location: ./CentralController.php?message={$showMsg}&capturemode=addmode&reqcode={$reqcode}");
         //if Adding Data to DB not succeed set msg with showMsg
     }
 }
Exemple #2
0
 public function testSaveInitialSummaryForOneEmployee2()
 {
     // Four records for employee-1 are added at setup
     HspSummary::saveInitialSummaryForOneEmployee(2);
     $result = mysql_query("SELECT `hsp_plan_id`, `hsp_plan_year` FROM `hs_hr_hsp_summary` WHERE `employee_id` = '2'");
     $k = 0;
     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
         $actual[$k][0] = $row[0];
         $actual[$k][1] = $row[1];
         $k++;
     }
     $expected[0][0] = 1;
     $expected[0][1] = date('Y');
     $expected[1][0] = 3;
     $expected[1][1] = date('Y');
     $expected[2][0] = 1;
     $expected[2][1] = date('Y') + 1;
     $expected[3][0] = 3;
     $expected[3][1] = date('Y') + 1;
     for ($i = 0; $i < 4; $i++) {
         $this->assertEquals($expected[$i][0], $actual[$i][0]);
         $this->assertEquals($expected[$i][1], $actual[$i][1]);
     }
 }