Beispiel #1
0
 public static function getChoixByIns($idInscription)
 {
     $conn = Main::bdd();
     try {
         $reqPrepare = $conn->prepare("SELECT *,c.prioriteChoix as Priorite FROM seance as s\n                INNER JOIN spectacle as spec ON spec.idSpectacle = s.idSpectacle\n                INNER JOIN choix as c ON c.idSpectacle = spec.idSpectacle\n                WHERE c.idInscription = ?\n                ORDER BY Priorite");
         $reqPrepare->execute(array($idInscription));
         return $reqPrepare;
     } catch (\PDOException $e) {
         throw new \Exception($e->getMessage());
     }
 }
Beispiel #2
0
 /**
  * Récupère tous les utilisateurs
  * @return Collection Utilisateurs
  * @throws \Exception
  */
 public static function getUsers()
 {
     $conn = Main::bdd();
     $reqPrepare = $conn->query("SELECT * FROM admin");
     $tabs = $reqPrepare->fetchAll();
     $coll = new Collection();
     foreach ($tabs as $tab) {
         $utilisateur = new Utilisateur($tab['code_user'], $tab['login'], $tab['password']);
         $coll->ajouter($utilisateur);
     }
     return $coll;
 }
Beispiel #3
0
 public static function getSeanceByIns($idInscription)
 {
     $conn = Main::bdd();
     $lesSeances = new Collection();
     try {
         $reqPrepare = $conn->prepare("SELECT choix.idInscription, spectacle.idSpectacle, seance.idSeance, seance.idLieu, seance.date_heure, choix.prioriteChoix\n            FROM choix\n            INNER JOIN spectacle ON choix.idSpectacle = spectacle.idSpectacle\n            INNER JOIN seance ON seance.idSeance = spectacle.idSpectacle\n\n            WHERE choix.idInscription = ?\n            ORDER BY choix.prioriteChoix");
         $reqPrepare->execute(array($idInscription));
         $tabs = $reqPrepare->fetchAll();
         foreach ($tabs as $tab) {
             $spectacle = MSpectacle::getSpectacleById($tab['idSpectacle']);
             $inscription = MInscription::getInscriptionByIdInscription($idInscription);
             $lieu = MLieu::getLieuById($tab['idLieu']);
             $seance = new Seance($tab['idSeance'], $spectacle, new \DateTime($tab['date_heure']), $lieu);
             $choix = MChoix::getChoixBySub($inscription);
             $lesSeances->ajouter($seance);
         }
     } catch (\PDOException $e) {
         throw new \Exception($e->getMessage());
     }
     return $lesSeances;
 }
Beispiel #4
0
 /**
  * Supprime un spectacle
  * @param Spectacle $spectacle
  * @throws \Exception
  */
 public static function rmSpectacle(Spectacle $spectacle)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         MSaison::rmSaisonSpectacle($spectacle);
         foreach ($spectacle->getLesSeances()->getCollection() as $seance) {
             MPlanning::rmPlanningbySeance($seance);
         }
         MSeance::rmSeancesSpec($spectacle);
         $reqPrepare = $conn->prepare("DELETE FROM spectacle WHERE idSpectacle = ?");
         $reqPrepare->execute(array($spectacle->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("Le spectacle " . $spectacle->getId() . " n'a pas pu être supprimé. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }
Beispiel #5
0
 /**
  * Ajoute la séance et l'inscription au planning
  * @param Planning $unPlanning
  * @throws \Exception
  */
 public static function addUnPlanning(Planning $unPlanning)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("INSERT INTO planning (idSeance, idInscription) VALUES (?,?)");
         $reqPrepare->execute(array($unPlanning->getSeance()->getId(), $unPlanning->getInscription()->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("L'ajout du planning a échoué. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }
Beispiel #6
0
 /**
  * Supprime un enseignant et ses inscriptions en cascade
  * @param Enseignant $enseignant
  * @throws \Exception
  */
 public static function rmEnseignant(Enseignant $enseignant)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         foreach ($enseignant->getLesInscriptions()->getCollection() as $inscription) {
             $reqPrepare = $conn->prepare("DELETE FROM choix WHERE idInscription = ?");
             $reqPrepare->execute(array($inscription->getId()));
         }
         $reqPrepare = $conn->prepare("DELETE FROM inscription WHERE idEns = ?");
         $reqPrepare->execute(array($enseignant->getId()));
         $reqPrepare = $conn->prepare("DELETE FROM enseignant WHERE idEns = ?");
         $reqPrepare->execute(array($enseignant->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("L'enseignant " . $enseignant->getId() . " n'a pas pu être supprimé. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }
Beispiel #7
0
 /**
  * Modifie un lieu
  * @param Lieu $lieu
  * @throws \Exception
  */
 public static function editLieu(Lieu $lieu)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("UPDATE lieu SET nomLieu = ?, adrLieu = ?, cpLieu = ?, villeLieu = ? WHERE idLieu = ?");
         $reqPrepare->execute(array($lieu->getNom(), $lieu->getAdresse(), $lieu->getCp(), $lieu->getVille(), $lieu->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("Le lieu " . $lieu->getId() . " n'a pas pu être modifié. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }
Beispiel #8
0
 /**
  * Supprime une école et ses enseignant en cascade
  * @param Ecole $ecole
  * @throws \Exception
  */
 public static function rmEcole(Ecole $ecole)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("DELETE FROM enseignant WHERE idEcole = ?");
         $reqPrepare->execute(array($ecole->getId()));
         $reqPrepare = $conn->prepare("DELETE FROM ecole WHERE idEcole = ?");
         $reqPrepare->execute(array($ecole->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("L'école " . $ecole->getId() . " n'a pas pu être supprimée. Détails : <p>" . $e->getMessage() . "</p>");
     }
 }
Beispiel #9
0
 public static function validerInscription(Inscription $inscription)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("UPDATE inscription SET validationInscription = 1 WHERE idInscription = ?");
         $reqPrepare->execute(array($inscription->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception("l'inscription n° " . $inscription->getId() . " n'a pas été valider.");
     }
 }
Beispiel #10
0
 public static function rmSaisonSpectacle(Spectacle $spectacle)
 {
     $conn = Main::bdd();
     try {
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare("DELETE FROM saison_spectacle WHERE idSpectacle = ?");
         $reqPrepare->execute(array($spectacle->getId()));
         $conn->commit();
     } catch (\PDOException $e) {
         $conn->rollBack();
         throw new \Exception($e->getMessage());
     }
 }