Exemple #1
0
session_start();
if (!defined('ROOT_PATH')) {
    define('ROOT_PATH', $_SESSION['path']);
}
require_once ROOT_PATH . '/lib/models/benefits/Hsp.php';
require_once ROOT_PATH . '/lib/models/benefits/mail/HspMailNotification.php';
try {
    $hspSummaryId = $_GET['hspSummaryId'];
    $newHspStatus = $_GET['newHspStatus'];
    $empId = $_GET['empId'];
    $hsp = new Hsp();
    $hsp->setEmployeeId($empId);
    $hsp->setSummaryId($hspSummaryId);
    $hsp->setHspPlanStatus($newHspStatus);
    $hspMailNotification = new HspMailNotification();
    if (Hsp::updateStatus($hspSummaryId, $newHspStatus)) {
        switch ($newHspStatus) {
            case Hsp::HSP_STATUS_HALTED:
                $hspMailNotification->sendHspPlanHaltedByHRAdminNotification($hsp);
                break;
            case Hsp::HSP_STATUS_ACTIVE:
                break;
            case Hsp::HSP_STATUS_ESS_HALTED:
                $hspMailNotification->sendHspPlanHaltedByHRAdminOnRequestNotification($hsp);
                break;
            case Hsp::HSP_STATUS_PENDING_HALT:
                $hspMailNotification->sendHspPlanHaltRequestedByESSNotification($hsp);
                break;
        }
        echo 'done:' . $newHspStatus;
    } else {
Exemple #2
0
 public function testUpdateStatus()
 {
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"), mysql_error());
     $this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL, '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, NULL, '')"));
     $this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (2, '002', 'Kalum', 'Kumara', '', 'Kal', 0, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL, '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, NULL, '')"));
     // For employee1
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(1, 1, 1, '" . date('Y') . "', 1, 1500, 50, 50, 0, 22)"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(2, 2, 1, '" . date('Y') . "', 1, 2500, 75, 75, 0, 0)"), mysql_error());
     $this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '" . (date('Y') - 1) . "-12-31' WHERE `key` = 'hsp_Used_last_updated'"));
     Hsp::updateStatus(1, 0);
     $result = mysql_query("SELECT `hsp_plan_status` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");
     $resultArray = mysql_fetch_array($result);
     $this->assertEquals($resultArray[0], 0);
     // should be 0 (Halted)
     Hsp::updateStatus(1, 1);
     $result = mysql_query("SELECT `hsp_plan_status` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");
     $resultArray = mysql_fetch_array($result);
     $this->assertEquals($resultArray[0], 1);
     // should be 1 (Active)
 }