/** * 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(); }
public function testGetYears() { $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 (2, 1, 1, " . (date('Y') - 2) . ", 1, 0.00, 0.00, 0.00, 0.00, 0.00)"), mysql_error()); $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_summary` VALUES (3, 1, 1, " . (date('Y') + 5) . ", 1, 0.00, 0.00, 0.00, 0.00, 0.00)"), mysql_error()); $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_summary` VALUES (6, 1, 1, " . (date('Y') + 2) . ", 1, 0.00, 0.00, 0.00, 0.00, 0.00)"), mysql_error()); $year = (int) date('Y'); $expected = array($year - 2, $year - 1, $year, $year + 1, $year + 2, $year + 5); $result = HspSummary::getYears(); $this->assertEquals($expected, $result); }