$Ens3 = array($_SESSION['enseignant']->getTel(), $_SESSION['enseignant']->getMail()); $Ens2 = array('Classe' => $_SESSION['classe'], 'Elèves' => $_SESSION['nbrEleve'], 'Accompagnateurs' => $_SESSION['nbrAccom']); $Choix1 = array('Choisi' => $_SESSION['choix1']); $Choix2 = array('Choisi' => $_SESSION['choix2']); $Choix3 = array('Choisi' => $_SESSION['choix3']); require_once ROOT . 'views/inscriptionCollegeLycee/v_Recap.php'; } catch (\Exception $e) { Main::setFlashMessage($e->getMessage(), "error"); } break; case 'valider': try { if (MEnseignant::isEnseignantExistant($_SESSION['enseignant']) == 0) { $_SESSION['enseignant']->setTypeEnseignant(2); MEnseignant::addEnseignant($_SESSION['enseignant']); $unEnseignant = MEnseignant::getEnseignantByName($_SESSION['enseignant']->getNom(), $_SESSION['enseignant']->getPrenom()); $_SESSION['enseignant']->setId($unEnseignant->getId()); } $divers = $_SESSION['divers']; if (empty($_SESSION['impo1']) && empty($_SESSION['impo2']) && empty($_SESSION['impo3'])) { $impo = '<strong><em>Vide</em></strong>'; $impo = '1 : ' . $_SESSION['impo1'] . '<br> 2 : ' . $_SESSION['impo2'] . '<br> 3 : ' . $_SESSION['impo3']; } $date = new DateTime(); $classe = implode(", ", $_SESSION['classe']); $UneInscription = new Inscription(1, $_SESSION['enseignant'], $date, $divers, $impo, $_SESSION['nbrEleve'], $_SESSION['nbrAccom'], $classe); $IdInscription = MInscription::addInscription($UneInscription); $_SESSION['Spectacle1'] = MSpectacle::getSpectacleByName($_SESSION['choix1']); $UneInscription->setId($IdInscription); $unChoix = new Choix($UneInscription, $_SESSION['Spectacle1'], 1); MChoix::addChoix($unChoix);
/** * Modifie une école * @param Ecole $ecole * @throws \Exception */ public static function editEcole(Ecole $ecole, Enseignant $directeur) { $conn = Main::bdd(); try { $conn->beginTransaction(); MEnseignant::editDirecteur($directeur); $reqPrepare = $conn->prepare("UPDATE ecole SET typeEcole = ?, nomEcole = ?, adresseEcole = ?, adresse2Ecole = ?, cpEcole = ?, villeEcole = ?, mail_dir = ? WHERE idEcole = ?"); $reqPrepare->execute(array($ecole->getType(), $ecole->getNom(), $ecole->getAdresse(), $ecole->getAdresse2(), $ecole->getCp(), $ecole->getVille(), $ecole->getMailDirecteur(), $ecole->getId())); $conn->commit(); } catch (\PDOException $e) { $conn->rollBack(); throw new \Exception("L'école " . $ecole->getId() . " n'a pas pu être modifiée. Détails : <p>" . $e->getMessage() . "</p>"); } }
} catch (\Exception $e) { Main::setFlashMessage($e->getMessage(), "error"); } break; case 'voirAjouterEcole': require_once ROOT . 'views/kiosqueadmin/schools/v_SchoolAdd.php'; break; case 'AjouterEcole': try { if (!is_numeric($_POST['nomEcole']) && is_numeric($_POST['cpEcole']) && is_numeric($_POST['telDir']) && !empty($_POST['nomEcole']) && !empty($_POST['adresseEcole']) && !empty($_POST['cpEcole']) && !empty($_POST['villeEcole']) && !empty($_POST['mailDir']) && !empty($_POST['telDir']) && !empty($_POST['nomDir'])) { $directeur = new Enseignant(1, $_POST['civDir'], $_POST['nomDir'], $_POST['prenomDir'], $_POST['mailDir'], $_POST['telDir'], 1); $ecole = new Ecole(1, $_POST['typeEcole'], $_POST['nomEcole'], $_POST['adresseEcole'], 1, $_POST['cpEcole'], $_POST['villeEcole'], $_POST['mailDir'], $directeur); $idEcole = MEcole::setEcole($ecole); $ecole->setId($idEcole); $directeur->setEcole($ecole); $idEnseignant = MEnseignant::addEnseignant($directeur); $directeur->setId($idEnseignant); $ecole->setDirecteur($directeur); MEcole::editEcole($ecole, $directeur); Main::setFlashMessage("L'école a bien été ajoutée", "valid"); echo '<script>document.location.href ="?uc=ecole"</script>'; } else { echo '<script>document.location.href ="?uc=ecole"</script>'; throw new \Exception("Impossible d'ajouter l'école (mauvais formats entrés)"); } } catch (\Exception $e) { Main::setFlashMessage($e->getMessage(), "error"); } break; case 'SupprimerEcole': try {
/** * Récupère l'inscription dont le numéro est passé en paramètre * @param int $id idInscription * @return Inscription * @throws \Exception */ public static function getInscriptionByIdInscription($id) { try { $conn = Main::bdd(); $reqPrepare = $conn->prepare("SELECT * FROM inscription WHERE idInscription = ?"); $reqPrepare->execute(array($id)); $tab = $reqPrepare->fetch(); $enseignant = MEnseignant::getEnseignantById($tab['idEns']); $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); return $inscription; } catch (\PDOException $e) { throw new \Exception("L'inscription {$id} n'existe pas."); } }