public function getSaisonContingent(Hotel $hotel, $date) { $saison = $hotel->getSaisonPromotionByDate($date, true); if ($saison->getType() == 4) { return $saison; } else { return null; } }
public function GenererAction(Hotel $hotel) { $em = $this->getDoctrine()->getManager(); $session = $this->getRequest()->getSession(); $data = array(); $form = $this->createFormBuilder()->add('libelle', 'text')->add('type', 'choice', array('choices' => array('1' => 'Saison', '2' => 'Promotion', '4' => 'Contingent', '3' => 'Amicales'), 'required' => TRUE, 'empty_value' => 'Type de saison', 'empty_data' => NULL))->add('saisons', 'entity', array('class' => 'BackHotelTunisieBundle:Saison', 'query_builder' => function (EntityRepository $er) use($hotel) { return $er->createQueryBuilder('s')->where('s.hotel = :id')->setParameter('id', $hotel->getId())->orderBy('s.id', 'desc'); }, 'property' => 'contratLibelle', 'required' => FALSE, 'empty_value' => 'Saison de base', 'empty_data' => NULL))->add('contrats', 'entity', array('class' => 'BackHotelTunisieBundle:Contrat', 'query_builder' => function (EntityRepository $er) use($hotel) { return $er->createQueryBuilder('c')->where('c.hotel = :id')->setParameter('id', $hotel->getId())->orderBy('c.id', 'desc'); }, 'required' => TRUE, 'attr' => array('required' => TRUE)))->getForm(); $request = $this->getRequest(); if ($request->isMethod("POST")) { $form->submit($request); $data = $form->getData(); if ($data['saisons'] == NULL) { $Saison = $hotel->getSaisonBase(); } else { $Saison = $data['saisons']; } $newSaison = clone $Saison; $newSaison->setContrat($data['contrats']); $newSaison->setHotelBase(NULL); $newSaison->setHotel($hotel); $newSaison->setLibelle($data['libelle']); $newSaison->setType($data['type']); $newSaison->setCreated(new \DateTime()); $em->persist($newSaison); foreach ($Saison->getArrangements() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } foreach ($Saison->getAutresReductions() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } foreach ($Saison->getAutresSupplements() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } foreach ($Saison->getChambres() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } foreach ($Saison->getSuppChambres() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } foreach ($Saison->getVues() as $entity) { $newEntity = clone $entity; $em->persist($newEntity->setSaison($newSaison)); } $em->flush(); $session->getFlashBag()->add('success', " Votre saison a été générer avec succées "); return $this->redirect($this->generateUrl("PeriodeSaison", array('id' => $newSaison->getId()))); } return $this->render('BackHotelTunisieBundle:Saisons:generer.html.twig', array('hotel' => $hotel, 'form' => $form->createView())); }
public function deleteAutreReducAction(Hotel $hotel, SaisonAutreReduc $saisonAutreReduc) { $em = $this->getDoctrine()->getManager(); $session = $this->getRequest()->getSession(); $em->remove($saisonAutreReduc); $em->flush(); $session->getFlashBag()->add('success', "La réduction a été supprimée avec succées"); return $this->redirect($this->generateUrl("saison_autres_reduc", array('id' => $hotel->getId()))); }
public function hotelChambreAction(Hotel $hotel) { $em = $this->getDoctrine()->getManager(); $session = $this->getRequest()->getSession(); foreach ($hotel->getChambres() as $ch) { $verif = $em->getRepository("BackHotelTunisieBundle:HotelChambre")->findBy(array('hotel' => $hotel, 'chambre' => $ch)); if (count($verif) == 0) { $hotelChambre = new HotelChambre(); $hotelChambre->setChambre($ch); $hotel->addHotelChambre($hotelChambre); } } $form = $this->createForm(new HotelChambresType(), $hotel); if ($this->getRequest()->isMethod("POST")) { $form->submit($this->getRequest()); if ($form->isValid()) { $hotel = $form->getData(); foreach ($hotel->getHotelChambres() as $hotelChambre) { $em->persist($hotelChambre->setHotel($hotel)); } $em->persist($hotel); $em->flush(); $session->getFlashBag()->add('success', " Vos chambres ont été modifié avec succées "); return $this->redirect($this->generateUrl("chambre_hotel", array('id' => $hotel->getId()))); } } return $this->render('BackHotelTunisieBundle:Hotels:chambres.html.twig', array('hotel' => $hotel, 'form' => $form->createView())); }