public static function haltHspPlan($id, $year, $employee = false) { try { $hsp = Hsp::getHsp($id); } catch (Exception $e) { $hsp = new Hsp(); } $backAction = 'Hsp_Summary'; if ($employee) { $backAction = 'Hsp_Summary_Employee'; if ($hsp->getEmployeeId() != $_SESSION['empID'] && $_SESSION['isAdmin'] != 'Yes') { self::redirect('UNAUTHORIZED_FAILURE', '?benefitcode=Benefits&action=' . $backAction . '&year=' . $year . '&employeeId=' . $hsp->getEmployeeId()); } } if ($hsp->getHalted() == 1 || $hsp->getTerminated() == 1) { self::redirect('HALT_FAILURE', '?benefitcode=Benefits&action=' . $backAction . '&year=' . $year . '&employeeId=' . $hsp->getEmployeeId()); } $hsp->setHalted(1); $hsp->setHaltedDate(date('Y-m-d')); $hspSummary = new HspSummary(); $empId = $hsp->getEmployeeId(); $totalUsed = $hspRecordArr[0]['total_used']; $totalAccrued = $hspRecordArr[0]['total_acrued']; if ($totalUsed < $totalAccrued) { $hsp->setHspValue($totalAccrued); } else { $hsp->setHspValue($totalUsed); } try { $hsp->save(); } catch (Exception $e) { } try { $hspMailNotification = new HspMailNotification(); if ($_SESSION['isAdmin'] == 'Yes') { $hspMailNotification->sendHspPlanHaltedByHRAdminNotification($hsp); } else { $hspMailNotification->sendHspPlanHaltedByESSNotification($hsp); } } catch (Exception $e) { } $msg = 'HALT_SUCCESS'; self::redirect($msg, '?benefitcode=Benefits&action=' . $backAction . '&year=' . $year . '&employeeId=' . $hsp->getEmployeeId()); }
} 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 { echo 'fail:Error while changing the new HSP status'; } } catch (Exception $e) {