Esempio n. 1
0
 function delEmpFormData($getArr, $postArr)
 {
     if (isset($postArr['econtactSTAT']) && $postArr['econtactSTAT'] == 'DEL') {
         $econ = new EmpEmergencyCon();
         $arr[1] = $postArr['chkecontactdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $econ->delEmpEC($arr);
     }
     if (isset($postArr['passportSTAT']) && $postArr['passportSTAT'] == 'DEL') {
         $passport = new EmpPassPort();
         $arr[1] = $postArr['chkpassportdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $passport->delEmpPP($arr);
     }
     if (isset($postArr['directDebitSTAT']) && $postArr['directDebitSTAT'] == 'DEL') {
         $directDebit = new EmpDirectDebit();
         $directDebit->delete($getArr['id'], $postArr['chkdebitdel']);
     }
     if (isset($postArr['wrkexpSTAT']) && $postArr['wrkexpSTAT'] == 'DEL') {
         $empwrkexp = new EmpWorkExp();
         $arr[1] = $postArr['chkwrkexpdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $empwrkexp->delEmpWorkExp($arr);
     }
     if (isset($postArr['licenseSTAT']) && $postArr['licenseSTAT'] == 'DEL') {
         $license = new EmpLicenses();
         $arr[1] = $postArr['chklicdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $license->delEmpLicenses($arr);
     }
     if (isset($postArr['skillSTAT']) && $postArr['skillSTAT'] == 'DEL') {
         $empskill = new EmpSkill();
         $arr[1] = $postArr['chkskilldel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $empskill->delEmpSkill($arr);
     }
     if (isset($postArr['educationSTAT']) && $postArr['educationSTAT'] == 'DEL') {
         $empeducation = new EmpEducation();
         $arr[1] = $postArr['chkedudel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $empeducation->delEmpEducation($arr);
     }
     if (isset($postArr['membershipSTAT']) && $postArr['membershipSTAT'] == 'DEL') {
         $empmem = new EmpMembership();
         $arr = $postArr['chkmemdel'];
         for ($c = 0; count($arr) > $c; $c++) {
             $frg = explode("|", $arr[$c]);
             $arrpass[1][$c] = $frg[0];
             $arrpass[2][$c] = $frg[1];
         }
         for ($c = 0; count($arr) > $c; $c++) {
             if ($arr[$c] != NULL) {
                 $arrpass[0][$c] = $getArr['id'];
             }
         }
         $empmem->delEmpMembership($arrpass);
     }
     if (isset($postArr['paymentSTAT']) && $postArr['paymentSTAT'] == 'DEL') {
         $emppayment = new EmpBasSalary();
         $arr = $postArr['chkpaydel'];
         for ($c = 0; count($arr) > $c; $c++) {
             $frg = explode("|", $arr[$c]);
             $arrpass[1][$c] = $frg[0];
             $arrpass[2][$c] = $frg[1];
         }
         for ($c = 0; count($arr) > $c; $c++) {
             if ($arr[$c] != NULL) {
                 $arrpass[0][$c] = $getArr['id'];
             }
         }
         $emppayment->delEmpBasSal($arrpass);
     }
     if (isset($postArr['reporttoSTAT']) && $postArr['reporttoSTAT'] == 'DEL') {
         $emprepto = new EmpRepTo();
         if ($postArr['delSupSub'] == 'sup') {
             $arr = $postArr['chksupdel'];
             for ($c = 0; count($arr) > $c; $c++) {
                 $frg = explode("|", $arr[$c]);
                 $arrpass[0][$c] = $frg[0];
                 $arrpass[2][$c] = $frg[1];
             }
             for ($c = 0; count($arr) > $c; $c++) {
                 if ($arr[$c] != NULL) {
                     $arrpass[1][$c] = $getArr['id'];
                 }
             }
         } elseif ($postArr['delSupSub'] == 'sub') {
             $arr = $postArr['chksubdel'];
             for ($c = 0; count($arr) > $c; $c++) {
                 $frg = explode("|", $arr[$c]);
                 $arrpass[1][$c] = $frg[0];
                 $arrpass[2][$c] = $frg[1];
             }
             for ($c = 0; count($arr) > $c; $c++) {
                 if ($arr[$c] != NULL) {
                     $arrpass[0][$c] = $getArr['id'];
                 }
             }
         }
         $emprepto->delEmpRepTo($arrpass);
     }
     if (isset($postArr['langSTAT']) && $postArr['langSTAT'] == 'DEL') {
         $emplan = new EmpLanguage();
         $arr = $postArr['chklangdel'];
         for ($c = 0; count($arr) > $c; $c++) {
             $frg = explode("|", $arr[$c]);
             $arrpass[1][$c] = $frg[0];
             $arrpass[2][$c] = $frg[1];
         }
         for ($c = 0; count($arr) > $c; $c++) {
             if ($arr[$c] != NULL) {
                 $arrpass[0][$c] = $getArr['id'];
             }
         }
         $emplan->delEmpLang($arrpass);
     }
     if (isset($postArr['dependentSTAT']) && $postArr['dependentSTAT'] == 'DEL') {
         $dep = new EmpDependents();
         $arr[1] = $postArr['chkdepdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $dep->delEmpDep($arr);
     }
     if (isset($postArr['conextSTAT']) && $postArr['conextSTAT'] == 'DEL') {
         $conext = new EmpConExt();
         $arr[1] = $postArr['chkconextdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $conext->delConExt($arr);
     }
     if (isset($postArr['empjobHistorySTAT']) && $postArr['empjobHistorySTAT'] == 'DEL') {
         // Job title history
         if (isset($postArr['chkjobtitHistory'])) {
             $jobTitleHistory = new JobTitleHistory();
             $jobTitleHistory->delete($postArr['chkjobtitHistory']);
         }
         // Sub division history
         if (isset($postArr['chksubdivisionHistory'])) {
             $empDivisionHistory = new SubDivisionHistory();
             $empDivisionHistory->delete($postArr['chksubdivisionHistory']);
         }
         // Location history
         if (isset($postArr['chklocationHistory'])) {
             $locationHistory = new LocationHistory();
             $locationHistory->delete($postArr['chklocationHistory']);
         }
     }
     if (isset($postArr['childrenSTAT']) && $postArr['childrenSTAT'] == 'DEL') {
         $chi = new EmpChildren();
         $arr[1] = $postArr['chkchidel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $chi->delEmpChi($arr);
     }
     if (isset($postArr['brchSTAT']) && $postArr['brchSTAT'] == 'DEL') {
         $bankacc = new EmpBank();
         $arr[1] = $postArr['chkbrchdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $bankacc->delEmpBank($arr);
     }
     if (isset($postArr['attSTAT']) && $postArr['attSTAT'] == 'DEL') {
         $attachment = new EmpAttach();
         $arr[1] = $postArr['chkattdel'];
         for ($c = 0; count($arr[1]) > $c; $c++) {
             if ($arr[1][$c] != NULL) {
                 $arr[0][$c] = $getArr['id'];
             }
         }
         $attachment->delEmpAtt($arr);
     }
 }
Esempio n. 2
0
 /**
  * Test delete() method
  */
 public function testDelete()
 {
     // find array of id's that are not available in database
     foreach ($this->subDivisionHistory as $hist) {
         $ids[] = $hist->getId();
     }
     $notIds = array_values(array_diff(range(1, 14), $ids));
     $before = $this->_getNumRows();
     $history = new SubDivisionHistory();
     // invalid params
     try {
         $history->delete(34);
         $this->fail("Exception not thrown");
     } catch (EmpHistoryException $e) {
         $this->assertEquals(EmpHistoryException::INVALID_PARAMETER, $e->getCode());
     }
     // invalid params
     try {
         $history->delete(array(1, 'w', 12));
         $this->fail("Exception not thrown");
     } catch (EmpHistoryException $e) {
         $this->assertEquals(EmpHistoryException::INVALID_PARAMETER, $e->getCode());
     }
     // empty array
     $res = $history->delete(array());
     $this->assertEquals(0, $res);
     $this->assertEquals($before, $this->_getNumRows());
     // no matches
     $res = $history->delete(array($notIds[1], $notIds[4]));
     $this->assertEquals(0, $res);
     $this->assertEquals($before, $this->_getNumRows());
     // one match
     $res = $history->delete(array($ids[0], $notIds[3]));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // one more the rest
     $res = $history->delete(array($ids[2]));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // rest
     $res = $history->delete(array($ids[1], $ids[3], $ids[4], $ids[5]));
     $this->assertEquals(4, $res);
     $this->assertEquals(4, $before - $this->_getNumRows());
     $this->assertEquals(0, $this->_getNumRows());
 }