public function checkWebAdminLogin(User $user) { if ($user->getType() != 'A') { return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER); } //Check User Login $userMod = new UserModel(); $userFound = $userMod->login($user); //Login Fail if (!$userFound) { return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER); } $user->setId($userFound); $ret['result'] = "success"; $ret['data']['user_id'] = $user->getId(); session_start(); $_SESSION['userId'] = $userFound; $_SESSION['userName'] = $user->getName(); $_SESSION['loginDt'] = new \DateTime(); return $ret; }
$ctr = new ClientController(); $result = $ctr->pickUpTask($params['taskId'], $params['handlerId']); } catch (SSSException $e) { $result = ErrorFactory::getError($e->getCode()); } } break; case "getTaskTypes": try { $ctr = new ClientController(); $result = $ctr->getTaskType(); } catch (SSSException $e) { $result = ErrorFactory::getError($e->getCode()); } break; case "getTasksByObservee": if (validate_input_param($params, array('observeeId'))) { try { $ctr = new ClientController(); $result = $ctr->getAllTaskByObservee($params['observeeId']); } catch (SSSException $e) { $result = ErrorFactory::getError($e->getCode()); } } break; default: $result = ErrorFactory::getError(ErrorFactory::ERR_INVALID_ACTION); break; } header('Content-Type: application/json; charset=utf-8'); echo json_encode($result);
public function exportObserveeLocationsByDate($userId, $date) { try { // print 1; $studMod = new StudentModel(); $deviceReports = $studMod->getStudentLocationsByDate($userId, $date); if ($deviceReports === FALSE) { // print 2; return ErrorFactory::getError(ErrorFactory::ERR_RECORD_NOT_FOUND); } else { // print 3; $ret['result'] = 'success'; $reportArray = DataConvertor::objectArrayToArray($deviceReports); $csvMgr = new CSVManager(); // $filename = $csvMgr->genCSV("location", $reportArray); $filename = $csvMgr->genCSV("location" . $date . ".csv", $reportArray); $ret['result'] = 'success'; $ret['data'] = $filename; return $ret; } } catch (SSSException $e) { return $e->getError(); } }
public function submitPanic($userId) { $notifiMod = new NotificationModel(); $studMod = new StudentModel(); $student = null; try { $student = $studMod->getStudent($userId); // var_dump($student); $date = new \DateTime(); $notification = new Notification(); $notification->setEventDt($date->format(DATETIME_FORMAT)); $notification->setProirity(1); $notification->setType("Panic"); $notification->setStatus("P"); $notification->setUserId($userId); $notification->setMsg($student->getName() . " call help"); $notifiMod->addNotification($notification); $result['result'] = "success"; } catch (SSSException $e) { $result = ErrorFactory::getError($e->getCode()); } return $result; }
public function getError() { return ErrorFactory::getError($this->code); }