示例#1
0
 public function access_ModelRoom_findByCity($ville)
 {
     include_once "models/room.php";
     $room = new Room();
     $room->setVille($ville);
     $resultat = $room->findRoomByCity();
     return $resultat;
 }
示例#2
0
 public function modifyRoom()
 {
     $msg = "";
     $room = new Room();
     if ($room->access_ModelMember_sessionExists() && $room->access_ModelMember_userAdmin()) {
         // Récupération de l'id passée en URL
         $id = $_GET['id'];
         $room->setIdSalle($id);
         $modRoom = $room->findRoom();
         if ($_POST) {
             $id_salle = $modRoom['id_salle'];
             $pays = htmlentities($_POST['pays'], ENT_QUOTES, "utf-8");
             $ville = htmlentities($_POST['ville'], ENT_QUOTES, "utf-8");
             $adresse = htmlentities($_POST['adresse'], ENT_QUOTES, "utf-8");
             $cp = htmlentities($_POST['cp'], ENT_QUOTES, "utf-8");
             $titre = htmlentities($_POST['titre'], ENT_QUOTES, "utf-8");
             $description = htmlentities($_POST['description'], ENT_QUOTES, "utf-8");
             $photo = $_FILES['photo'];
             $capacite = htmlentities($_POST['capacite'], ENT_QUOTES, "utf-8");
             $categorie = htmlentities($_POST['categorie'], ENT_QUOTES, "utf-8");
             // Instancie un nouvel objet room
             $room = new Room();
             $room->setIdSalle($id_salle);
             // Je remplis le nouvel objet avec les valeurs récupérées dans le formulaire
             $room->setPays($pays);
             $room->setVille($ville);
             $room->setAdresse($adresse);
             $room->setCP($cp);
             $room->setTitre($titre);
             $room->setDescription($description);
             $room->setPhoto($photo);
             $room->setCapacite($capacite);
             $room->setCategorie($categorie);
             $msgError = "";
             // VERIFICATIONS SI LA PHOTO EST CHANGEE
             if (!empty($_FILES['photo']['name'])) {
                 $resultArray = $room->checkPhotoReplace();
                 for ($i = 0; $i < count($resultArray); $i++) {
                     if (!$resultArray[$i]->getPassed()) {
                         $msgError .= $resultArray[$i]->getErrorMessage();
                         $msgError .= "<br/>";
                     }
                 }
             }
             if ($msgError == "") {
                 $room->replaceRoom();
                 header('location:index.php?controller=rooms&action=roomModified');
                 //                    $msg = '<p class="validation">Bravo, la salle a bien été enregistrée</p>';
                 // Appeler une autre page pour rafficher la salle modifiée ?
             } else {
                 $msg .= $msgError;
             }
         }
     } else {
         $msg .= 'Vous n\'avez pas le droit d\'accéder à cette page.<br/>';
     }
     include "views/rooms/modifyRooms.php";
 }