public function deleteAction($I_id)
 {
     // On vérifie si l'utilisateur connecté est bien un admin
     $this->haveAccess();
     // On appelle le modele UserMapper et on lui demande de supprimer le user qui a l'$I_id
     $O_inspectorMapper = new InspectorMapper();
     $O_inspectorMapper->delete($I_id);
     die(header('Location:/inspector/paginate'));
 }
Exemplo n.º 2
0
 public function findPerPage($A_limit)
 {
     $I_firstOfPage = $A_limit['firstOfPage'];
     $I_perPage = $A_limit['perPage'];
     $S_sql = 'SELECT id, login, operator_id, inspector_id, profile_id FROM user LIMIT ' . $I_firstOfPage . ', ' . $I_perPage;
     $O_connection = new Connection();
     if ($A_data = $O_connection->requestDb($S_sql, $A_params = null, self::CLASS_NAME)) {
         $A_users = null;
         foreach ($A_data as $key => $value) {
             $O_user = $A_data[$key];
             if (!is_null($O_user->getOperatorId())) {
                 try {
                     $O_operatorMapper = new OperatorMapper();
                     $O_operator = $O_operatorMapper->findById($O_user->getOperatorId());
                     $O_user->setOperator($O_operator);
                     $O_teamMapper = new TeamMapper();
                     $O_team = $O_teamMapper->findByOperator($O_user->getOperatorId());
                     $O_operator->setTeam($O_team);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_user->getInspectorId())) {
                 try {
                     $O_inspectorMapper = new InspectorMapper();
                     $O_inspector = $O_inspectorMapper->findById($O_user->getInspectorId());
                     $O_user->setInspector($O_inspector);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_user->getProfileId())) {
                 try {
                     $O_profileMapper = new ProfileMapper();
                     $O_profile = $O_profileMapper->findById($O_user->getProfileId());
                     $O_user->setProfile($O_profile);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             $A_users[] = $O_user;
         }
     } else {
         throw new Exception("Une erreur s'est produite");
     }
     return $A_users;
 }
Exemplo n.º 3
0
 public function findByUserPerPage($A_limit)
 {
     $I_firstOfPage = $A_limit['firstOfPage'];
     $I_perPage = $A_limit['perPage'];
     $S_sql = 'SELECT c.id, c.control_date, c.conform, c.comment, c.epi_id, c.inspector_id
           FROM check_epi AS c
           INNER JOIN epi AS e ON e.id = c.epi_id
           INNER JOIN operator AS o ON o.id = e.operator_id
           WHERE o.id = ?
           LIMIT ' . $I_firstOfPage . ', ' . $I_perPage;
     $A_params = array(Session::getSession('user')->getOperatorId());
     $O_connection = new Connection();
     if ($A_data = $O_connection->requestDb($S_sql, $A_params, self::CLASS_NAME)) {
         $A_checks = null;
         foreach ($A_data as $O_check) {
             $O_check->initControlDate();
             if (!is_null($O_check->getEpiId())) {
                 try {
                     $O_epiMapper = new EpiMapper();
                     $O_epi = $O_epiMapper->findById($O_check->getEpiId());
                     $O_check->setEpi($O_epi);
                     $O_operatorMapper = new OperatorMapper();
                     $O_operator = $O_operatorMapper->findByEpi($O_check->getEpiId());
                 } catch (Exception $e) {
                     //On récupère le message de l'exception
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_check->getInspectorId())) {
                 try {
                     $O_inspectorMapper = new InspectorMapper();
                     $O_inspector = $O_inspectorMapper->findById($O_check->getInspectorId());
                     $O_check->setInspector($O_inspector);
                 } catch (Exception $e) {
                     //On récupère le message de l'exception
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             $A_checks[] = ['check' => $O_check, 'operator' => $O_operator];
             // $A_checks[] = $O_check;
         }
         return $A_checks;
     } else {
         throw new Exception("Une erreur s'est produite");
     }
 }
Exemplo n.º 4
0
 public function createAction()
 {
     $this->isAdmin();
     if (isset($_POST['operator'])) {
         $O_operator = new Operator();
         $O_operator->setName($_POST['name']);
         $O_operator->setFirstName($_POST['firstName']);
         $O_operator->setSizeHarness($_POST['sizeHarness']);
         $O_operator->setEmail($_POST['email']);
         $O_operator->initInceptionDate();
         $O_teamMapper = new TeamMapper();
         $O_team = $O_teamMapper->findByTwoIds($_POST['staff_id'], $_POST['subgroup_id']);
         $O_operator->setTeamId($O_team->getId());
         $O_operatorMapper = new OperatorMapper();
         $I_operatorId = $O_operatorMapper->insert($O_operator);
         //die(header('Location:/user/default/'));
     }
     if (isset($_POST['inspector'])) {
         $O_inspector = new Inspector();
         $O_inspector->setName($_POST['name']);
         $O_inspector->setFirstName($_POST['firstName']);
         $O_inspector->setEmail($_POST['email']);
         $O_inspector->setSubgroupId($_POST['subgroup_id']);
         $O_inspector->initInceptionDate();
         $O_inspectorMapper = new InspectorMapper();
         $I_inspectorId = $O_inspectorMapper->insert($O_inspector);
     }
     $O_user = new User();
     $O_user->setLogin($_POST['login']);
     $O_user->setPassword($_POST['password']);
     $O_user->setProfileId($_POST['profile_id']);
     if (isset($_POST['operator'])) {
         $O_user->setOperatorId($I_operatorId);
     }
     if (isset($_POST['inspector'])) {
         $O_user->setInspectorId($I_inspectorId);
     }
     $O_userMapper = new UserMapper();
     $I_userId = $O_userMapper->insert($O_user);
 }