Example #1
0
 public function autreChambreAction(Saison $saison)
 {
     $em = $this->getDoctrine()->getManager();
     $session = $this->getRequest()->getSession();
     $request = $this->getRequest();
     $hotel = $saison->getHotel();
     foreach ($hotel->getChambres() as $ch) {
         $verif = $em->getRepository("BackHotelTunisieBundle:SaisonSuppChambre")->findBy(array('saison' => $saison, 'chambre' => $ch));
         if (count($verif) == 0 && $ch->getType() == 0) {
             $saisonSuppChambres = new SaisonSuppChambre();
             $saisonSuppChambres->setChambre($ch);
             $saison->addSuppChambre($saisonSuppChambres);
         }
     }
     $form = $this->createForm(new SaisonSType(), $saison);
     if ($request->isMethod("POST")) {
         $form->bind($request);
         if ($form->isValid()) {
             $saison = $form->getData();
             foreach ($saison->getSuppChambres() as $chambres) {
                 $em->persist($chambres->setSaison($saison));
             }
             $em->flush();
             $session->getFlashBag()->add('success', " Votre saison de base a été modifié avec succées ");
             return $this->redirect($this->generateUrl("AutreChambreSaison", array('id' => $saison->getId())));
         }
     }
     return $this->render('BackHotelTunisieBundle:Saisons:autre_chambre.html.twig', array('saison' => $saison, 'hotel' => $hotel, 'form' => $form->createView()));
 }