Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /**
  * Récupère tous les lieux
  * @return Collection
  * @throws \Exception
  */
 public static function getLieux()
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->query("SELECT * FROM lieu");
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $lieu = new Lieu($tab['idLieu'], $tab['nomLieu'], $tab['adrLieu'], $tab['cpLieu'], $tab['villeLieu']);
             $lesSeances = MSeance::getSeancesByLieu($lieu);
             $lieu->setLesSeances($lesSeances);
             $coll->ajouter($lieu);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("Il n'y a aucun lieu");
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }
Ejemplo n.º 3
0
 public static function getChoixBySub(Inscription $inscription)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT * FROM choix WHERE idInscription = ? ORDER BY PrioriteChoix");
         $reqPrepare->execute(array($inscription->getId()));
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $spectacle = MSpectacle::getSpectacleById($tab['idSpectacle']);
             $choix = new Choix($inscription, $spectacle, $tab['prioriteChoix']);
             $coll->ajouter($choix);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception($e->getMessage());
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }
Ejemplo n.º 4
0
 /**
  * Récupère tous les enseignants
  * @return Collection
  * @throws \Exception
  */
 public static function getEnseignants()
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->query("\n                SELECT *\n                FROM enseignant ens\n                INNER JOIN ecole e ON e.idEcole = ens.idEcole");
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $directeur = new Enseignant($tab['idEns'], $tab['civEns'], $tab['nomEns'], $tab['prenomEns'], $tab['mailEns'], $tab['telEns'], $tab['TypeEnseignant']);
             $ecole = new Ecole($tab['idEcole'], $tab['typeEcole'], $tab['nomEcole'], $tab['adresseEcole'], $tab['adresse2Ecole'], $tab['cpEcole'], $tab['villeEcole'], $tab['mail_dir'], $directeur);
             $lesInscriptions = MInscription::getInscriptionByEnseignant($directeur);
             $directeur->setEcole($ecole);
             $directeur->setLesInscriptions($lesInscriptions);
             $coll->ajouter($directeur);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("Il n'y a aucun enseignant");
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 /**
  * @param int $idSaison
  * @return Collection
  * @throws \Exception
  */
 public static function getSpectaclesByIdSaison($idSaison)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT sp.idSpectacle, nomSpectacle, nbPlaceSpectacle, typeClasse, typeSpectacle, s.idSaison\n                FROM spectacle sp\n                INNER JOIN saison_spectacle ss ON ss.idSpectacle = sp.idSpectacle\n                INNER JOIN saison s ON s.idSaison = ss.idSaison\n                WHERE s.idSaison = ?");
         $reqPrepare->execute(array($idSaison));
         $tabs = $reqPrepare->fetchAll();
         Main::viewVar($tabs);
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $saison = new Saison($tab['idSaison'], $tab['nomSaison'], $tab['courante']);
             $spectacle = new Spectacle($tab['idSpectacle'], $tab['nomSpectacle'], $tab['nbPlaceSpectacle'], $tab['typeClasse'], $saison, $tab['typeSpectacle']);
             $coll->ajouter($spectacle);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("Il n'y a aucun spectacle dans la saison {$idSaison}");
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }
Ejemplo n.º 7
0
 /**
  * Récupère le planning où la séance est passée en paramètre
  * @param Seance $seance
  * @return Collection
  * @throws \Exception
  */
 public static function getPlanningBySeance(Seance $seance)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT * FROM planning WHERE idSeance = ?");
         $reqPrepare->execute(array($seance->getId()));
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $inscription = MInscription::getInscriptionByIdInscription($tab['idInscription']);
             $seance = MSeance::getSeance($tab['idSeance']);
             $planning = new Planning($seance, $inscription);
             $coll->ajouter($planning);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("La séance " . $seance->getId() . " n'est pas dans le planning");
     }
 }
Ejemplo n.º 8
0
 /**
  * Récupère les écoles avec comme type $type
  * @param int $type
  * @return Collection
  * @throws \Exception
  */
 public static function getEcoleByType($type)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT *\n                FROM ecole e\n                INNER JOIN enseignant ens ON e.idEcole = ens.idEcole\n                WHERE e.typeEcole = ?\n                AND TypeEnseignant = 1\n                ORDER BY villeEcole");
         $reqPrepare->execute(array($type));
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $directeur = new Enseignant($tab['idEns'], $tab['civEns'], $tab['nomEns'], $tab['prenomEns'], $tab['mailEns'], $tab['telEns'], $tab['TypeEnseignant']);
             $ecole = new Ecole($tab['idEcole'], $tab['typeEcole'], $tab['nomEcole'], $tab['adresseEcole'], $tab['adresse2Ecole'], $tab['cpEcole'], $tab['villeEcole'], $tab['mail_dir'], $directeur);
             $coll->ajouter($ecole);
             return $coll;
         }
     } catch (\PDOException $e) {
         throw new \Exception("Il n'y a aucune école de type {$type}");
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }
Ejemplo n.º 9
0
 /**
  * Récupère les inscriptions d'un enseignant
  * @param Enseignant $enseignant
  * @return Inscription
  * @throws \Exception
  */
 public static function getInscriptionByEnseignant(Enseignant $enseignant)
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->prepare("SELECT * FROM inscription WHERE idEns = ?");
         $reqPrepare->execute(array($enseignant->getId()));
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $inscription = new Inscription($tab['idInscription'], $enseignant, new \DateTime($tab['dateInscription']), $tab['diversInscription'], $tab['impoInscription'], $tab['nbEnfantsInscription'], $tab['nbAdultesInscription'], $tab['classe']);
             $lesChoix = MChoix::getChoixBySub($inscription);
             $inscription->setLesChoix($lesChoix);
             $coll->ajouter($inscription);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("L'enseignant " . $enseignant->getId() . " n'a aucune inscription.");
     }
 }
Ejemplo n.º 10
0
 /**
  * Récupère la saison courante
  * @return Saison
  * @throws \Exception
  */
 public static function getSaisonNonCourante()
 {
     try {
         $conn = Main::bdd();
         $reqPrepare = $conn->query("SELECT * FROM saison s WHERE courante = 0");
         $tabs = $reqPrepare->fetchAll();
         $coll = new Collection();
         foreach ($tabs as $tab) {
             $saison = new Saison($tab['idSaison'], $tab['nomSaison'], $tab['courante']);
             $lesSpectacles = MSpectacle::getSpectaclesBySaison($saison);
             $saison->setLesSpectacles($lesSpectacles);
             $coll->ajouter($saison);
         }
         return $coll;
     } catch (\PDOException $e) {
         throw new \Exception("La saison n'existe pas.");
     } catch (KeyHasUseException $ex) {
         throw new \Exception($ex->getMessage());
     }
 }