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()); }