public static function processAccountChanges($csv, $CID, $UID) { include_once $_SERVER['DOCUMENT_ROOT'] . "/bossflex/DB/Models/Deposit.php"; include_once $_SERVER['DOCUMENT_ROOT'] . "/bossflex/DB/Models/Ledger.php"; foreach ($csv as $accountChange) { $EID = $accountChange[0]; $payrollDate = strtotime($accountChange[1]); $payrollDate = date('Y-m-d H:i:s', $payrollDate); $withheldAmount = $accountChange[2]; $employee = Employee::getEmployee($EID, $CID); if ($employee) { $deposit = Deposit::depositAmt($employee->getAccountNum(), $UID, $withheldAmount, $payrollDate); Ledger::addDeposit($deposit); } } }
$v = $_SESSION['v']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $PhoneNum = $_POST['PhoneNum']; $EID = $_POST['EID']; $CID = $_POST['CID']; if (!isset($Fname) || !isset($Lname) || !isset($PhoneNum) || !isset($EID)) { header('Location:https://' . $_SESSION['redir'] . "?result=1&u=" . $u . "&v=" . $v); } if ($CID == 1) { include "DB/Models/BossFlexEmployee.php"; /** @var BossFlexEmployee $emp */ $emp = BossFlexEmployee::getEmployeeByBFID($EID); if ($emp->getBFID() == $EID && $emp->getFname() == $Fname && $emp->getLname() == $Lname && $emp->getPhoneNum() == $PhoneNum) { $_SESSION['NewUser'] = serialize($emp); $_SESSION['BossFlex'] = true; header('Location:Register.php'); } else { header('Location:https://' . $_SESSION['redir'] . "?result=2&u=" . $u . "&v=" . $v); } } else { include "DB/Models/Employee.php"; /** @var Employee $emp */ $emp = Employee::getEmployee($EID, $CID); if ($emp->getEID() == $EID && $emp->getFname() == $Fname && $emp->getLname() == $Lname && $emp->getPhoneNum() == $PhoneNum) { $_SESSION['NewUser'] = serialize($emp); header('Location:Register.php'); } else { header('Location:https://' . $_SESSION['redir'] . "?result=2&u=" . $u . "&v=" . $v); } }
public function index() { if (Input::has("json_data")) { $json_data = Input::get("json_data"); $data = json_decode($json_data); try { $login = $data->login; $method = $data->method; $section = $data->section; $where = $data->where; $detail_data = $data->data; if (User::getLogin($login) != "[]") { if ($method == "login") { $arr = array("method" => $method, "section" => "user", "data" => $login); return json_encode($arr); } if ($method == "get") { if ($section == "employee") { if ($where == "") { $arr = array("method" => $method, "section" => $section, "data" => Employee::all()); return json_encode($arr); } else { $arr = array("method" => $method, "section" => $section, "data" => Employee::getEmployee($where)); return json_encode($arr); } } } if ($method == "append") { if ($section == "employee") { if (Employee::checkEmployee($detail_data->eid) == "") { Employee::appendEmployee($detail_data); $arr = array("method" => $method, "section" => $section, "data" => "Success"); return json_encode($arr); } else { $arr = array("method" => $method, "section" => $section, "data" => "Fail, Duplicate EID"); return json_encode($arr); } } } if ($method == "update") { if ($section == "employee") { if (Employee::checkEmployee($detail_data->eid) != "") { Employee::updateEmployee($detail_data); $arr = array("method" => $method, "section" => $section, "data" => "Success"); return json_encode($arr); } else { $arr = array("method" => $method, "section" => $section, "data" => "Fail, Wrong EID"); return json_encode($arr); } } } if ($method == "remove") { if ($section == "employee") { try { foreach ($where as $value) { Employee::removeEmployee($value); } $arr = array("method" => $method, "section" => $section, "data" => "Success"); return json_encode($arr); } catch (Exception $e) { return "Error: Can't remove, Employee is using!"; } } } } else { return "Error: Login fail!"; } } catch (Exception $e) { return "Error: JsonData is not correct!" . $e; } } else { return "Error: JsonData not found!"; } }