public static function parseSaveData($postArr) { $hspArr = array(); for ($i = 0; $i < count($postArr['txtHspId']); $i++) { $tmpHsp = new Hsp(); if (!empty($postArr['txtHspId'][$i])) { $tmpHsp->setId($postArr['txtHspId'][$i]); } $tmpHsp->setEmployeeId($postArr['txtEmployeeId'][$i]); $tmpHsp->setHspValue($postArr['txtHspValue'][$i]); $tmpHsp->setEditedStatus($postArr['editedStatus'][$i]); if (isset($postArr['txtAmountPerDay'][$i])) { if ($postArr['txtAmountPerDay'][$i] != $postArr['initialAmountPerDay'][$i]) { $tmpHsp->setEditedStatus(1); } $tmpHsp->setAmountPerDay($postArr['txtAmountPerDay'][$i]); } $editedStatus = $tmpHsp->getEditedStatus(); if (isset($postArr['payDays'][$i]) && $editedStatus == 0) { $amountPerDay = ($postArr['txtHspValue'][$i] - $postArr['txtTotalAcrued'][$i]) / $postArr['payDays'][$i]; $tmpHsp->setAmountPerDay($amountPerDay); } else { if (isset($postArr['txtAmountPerDay'][$i])) { $tmpHsp->setAmountPerDay($postArr['txtAmountPerDay'][$i]); } } $tmpHsp->setTotalAcrued($postArr['txtTotalAcrued'][$i]); $hspArr[] = $tmpHsp; } return $hspArr; }
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()); }