/** * Supprime les séances du spectacle $spectacle * @param Spectacle $spectacle * @throws \Exception */ public static function rmSeancesSpec(Spectacle $spectacle) { $conn = Main::bdd(); try { $conn->beginTransaction(); foreach ($spectacle->getLesSeances()->getCollection() as $seance) { $reqPrepare = $conn->prepare("DELETE FROM planning WHERE idSeance = ?"); $reqPrepare->execute(array($seance->getId())); } $reqPrepare = $conn->prepare("DELETE FROM seance WHERE idSpectacle = ?"); $reqPrepare->execute(array($spectacle->getId())); $conn->commit(); return true; } catch (\PDOException $e) { $conn->rollBack(); throw new \Exception("Les séances du spectacle " . $spectacle->getId() . " n'ont pas pu être supprimées. Détails : <p>" . $e->getMessage() . "</p>"); return false; } }
/** * Récupère la jauge restante par séance * @param Spectacle $spectacle * @return Collection * @throws \Exception */ public static function getJaugeRestanteJeunePublicBySpec(Spectacle $spectacle) { try { $conn = Main::bdd(); $reqPrepare = $conn->prepare("SELECT *, SUM(i.nbAdultesInscription + i.nbEnfantsInscription) as jaugeUtilise, SUM(i.nbAdultesInscription) as nbAdultes, SUM(i.nbEnfantsInscription) as nbEnfants, spec.nbPlaceSpectacle as jaugeMax, (spec.nbPlaceSpectacle - SUM((i.nbAdultesInscription + i.nbEnfantsInscription))) as jaugeRestante FROM planning as p\n\t\t\t\tINNER JOIN inscription as i ON i.idInscription = p.idInscription\n\t\t\t\tINNER JOIN seance as s ON s.idSeance = p.idSeance\n\t\t\t\tINNER JOIN spectacle as spec ON spec.idSpectacle = s.idSpectacle\n\t\t\t\tWHERE i.validationInscription = 1 and spec.typeSpectacle = 1 and s.idSpectacle = ?\n\t\t\t\tGROUP BY s.idSeance"); $reqPrepare->execute(array($spectacle->getId())); $tabs = $reqPrepare->fetchAll(); $coll = new Collection(); foreach ($tabs as $tab) { $seance = MSeance::getSeance($tab['idSeance']); $jauge = new Jauge($tab['jaugeUtilise'], $tab['jaugeRestante'], $tab['nbEnfants'], $tab['nbAdultes'], $tab['jaugeMax'], $seance); $coll->ajouter($jauge); } return $coll; } catch (\PDOException $e) { throw new \Exception($e->getMessage()); } catch (KeyHasUseException $ex) { throw new \Exception($ex->getMessage()); } }
/** * Ajoute un spectacle * @param Spectacle $spectacle * @throws \Exception */ public static function addSpectacle(Spectacle $spectacle) { $conn = Main::bdd(); try { $conn->beginTransaction(); $reqPrepare = $conn->prepare("INSERT INTO spectacle (nomSpectacle, nbPlaceSpectacle, typeClasse, typeSpectacle) VALUES (?,?,?,?)"); $reqPrepare->execute(array($spectacle->getNom(), $spectacle->getNbPlace(), $spectacle->getTypeClasse(), $spectacle->getTypeSpectacle())); $conn->commit(); } catch (\PDOException $e) { $conn->rollBack(); throw new \Exception("L'ajout du spectacle " . $spectacle->getId() . " a échoué. Détails : <p>" . $e->getMessage() . "</p>"); } }
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()); } }