Esempio n. 1
0
 /**
  * For searching HSP Summary for an employee
  */
 public static function searchHspSummary($empId, $year, $saveSuccess = null)
 {
     $errorFlag = false;
     //Checking whether records exist for $year
     try {
         if (!HspSummary::recordsExist($year)) {
             switch (Config::getHspCurrentPlan()) {
                 case 1:
                     self::_saveInitialRecords($year, 1);
                     break;
                 case 2:
                     self::_saveInitialRecords($year, 2);
                     break;
                 case 3:
                     self::_saveInitialRecords($year, 3);
                     break;
                 case 4:
                     self::_saveInitialRecords($year, 1);
                     self::_saveInitialRecords($year, 3);
                     break;
                 case 5:
                     self::_saveInitialRecords($year, 2);
                     self::_saveInitialRecords($year, 3);
                     break;
                 case 6:
                     self::_saveInitialRecords($year, 1);
                     self::_saveInitialRecords($year, 2);
                     break;
             }
         }
     } catch (HspSummaryException $e) {
         if ($e->getCode() == HspSummaryException::HSP_PLAN_NOT_DEFINED) {
             $errorFlag = true;
         }
     }
     // Setting template path
     $path = "/templates/benefits/hspSummary.php";
     if ($errorFlag) {
         $error['hspNotDefinedESS'] = true;
         $template = new TemplateMerger($error, $path);
         $template->setError(true);
     } else {
         // Setting the Page No
         if (isset($_POST['pageNo'])) {
             $pageNo = $_POST['pageNo'];
         } else {
             $pageNo = 1;
         }
         // Setting records that are used in /templates/benefits/hspSummary.php
         $tmpOb[0] = "searchHspSummary";
         $tmpOb[1] = HspSummary::fetchHspSummary($year, 1, $empId);
         $tmpOb[2] = $year;
         $tmpOb[3] = $pageNo;
         $tmpOb[4] = HspSummary::recordsCount($year, Config::getHspCurrentPlan());
         if (isset($saveSuccess)) {
             $tmpOb[5] = $saveSuccess;
         } else {
             $tmpOb[5] = null;
         }
         $tmpOb[6] = EmpInfo::getEmployeeMainDetails();
         $tmpOb[7] = HspSummary::getYears();
         $template = new TemplateMerger($tmpOb, $path);
     }
     // Displaying
     $template->display();
 }
Esempio n. 2
0
 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
     }
 }
Esempio n. 3
0
 public function testRecordsExist()
 {
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"), mysql_error());
     // Add 2 records to `hs_hr_hsp_summary`
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_summary` VALUES (1, 1, 1, " . date('Y') . ", 0, 0.00, 0.00, 0.00, 0.00, 0.00)"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_summary` VALUES (2, 2, 1, " . date('Y') . ", 0, 0.00, 0.00, 0.00, 0.00, 0.00)"), mysql_error());
     $this->assertTrue(HspSummary::recordsExist(date('Y')));
     $this->assertTrue(HspSummary::recordsExist(date('Y'), 1));
     $this->assertFalse(HspSummary::recordsExist(date('Y') + 1));
     $this->assertFalse(HspSummary::recordsExist(date('Y'), 2));
     $this->assertFalse(HspSummary::recordsExist(date('Y') + 1, 2));
 }