/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $p1 = new Pavion(); $p2 = new Pavion(); $p3 = new Pavion(); $p4 = new Pavion(); //ajout des différents pavions $p1->setLibelle("H1"); $p2->setLibelle("H2"); $p3->setLibelle("H3"); $p4->setLibelle("H4"); //persist des données $manager->persist($p1); $manager->persist($p2); $manager->persist($p3); $manager->persist($p4); $manager->flush(); }
public function addAction(Request $request) { //création de l'objet codification $codification = new Codification(); //si nous avons une requête ajax, elle sera traité ici if ($request->isXmlHttpRequest()) { $requete = $request->request->get('requete'); if ($requete == "affichage") { //création du formulaire d'ajout d'une codification $form = $this->get('form.factory')->create(new CodificationType(), $codification); return $this->render("SMBLoyerBundle:Codification:add.html.twig", array('form' => $form->createView())); } else { if ($requete == "ajout") { $id_chambre = $request->request->get('numero'); $id_pavion = $request->request->get('pavion'); $id_etudiant = $request->request->get('id_etudiant'); $em = $this->getDoctrine()->getManager(); //on recupere la chambre correspondant à ce numero $chambre = \SMB\LoyerBundle\Entity\Chambre::getChambre($em, $id_chambre); //on recupere le pavion correspondant à ce nom $pavion = \SMB\LoyerBundle\Entity\Pavion::getPavion($em, $id_pavion); //on recupere l'etudiant correspondant à $id_etudiant $etudiant = \SMB\LoyerBundle\Entity\Etudiant::getEtudiant($em, $id_etudiant); //on recupère le registre courant $session = $request->getSession(); $id_registre = $session->get('id_registre_courant'); $registre = \SMB\LoyerBundle\Entity\Registre::getRegistre($em, $id_registre); if ($registre == null) { throw new \Exception("Il n'existe pas de registre correspondant à l'id " . $id_registre); } $codification->setRegistre($registre); $codification->setChambre($chambre); $codification->setPavion($pavion); $codification->setEtudiant($etudiant); $em->persist($codification); $em->flush(); //on envoie les informatons de l'étudiant return $this->render("SMBLoyerBundle:Etudiant:view.html.twig", array('etudiant' => $etudiant, 'codifier' => true, 'codification' => $codification, 'listPaiements' => $codification->getPaiements())); } } } else { throw new Exception("Pas de Requete envoyée!", 1); } }
public function deleteAction($id, Request $request) { //si nous avons une requête ajax, elle sera traité ici if ($request->isXmlHttpRequest()) { //on recupère la liste des pavions à supprimer $listPavions = json_decode($request->request->get('listPavions')); $nbre = $request->request->get('nbre'); for ($i = 0; $i < $nbre; $i++) { $ident = $listPavions[$i]; $this->getDoctrine()->getManager()->getRepository("SMBLoyerBundle:Pavion")->supprimer_pavion($ident); } //on retourne la liste de tous les pavions $listPavion = Pavion::listPavions($this); return $this->render("SMBLoyerBundle:Pavion:index.html.twig", array('listPavions' => $listPavion)); } else { throw new \Exception("Pas de requête!", 1); } }
/** * Set pavion * * @param \SMB\LoyerBundle\Entity\Pavion $pavion * @return Codification */ public function setPavion(\SMB\LoyerBundle\Entity\Pavion $pavion) { $this->pavion = $pavion; $pavion->addCodification($this); return $this; }