Esempio n. 1
0
 public function sendMailHotel(Reservation $reservation)
 {
     $agence = $this->em->getRepository('BackAdministrationBundle:Agence')->find(1);
     $user = $this->container->get('security.context')->getToken()->getUser();
     if (!is_null($reservation->getHotel()->getEmail())) {
         $message = \Swift_Message::newInstance()->setSubject('Nouvelle Réservation de la par ' . $agence->getNom())->setFrom($user->getEmail())->setTo($reservation->getHotel()->getEmail())->setCc($user->getEmail());
         $emails = $this->em->getRepository('BackAdministrationBundle:Email')->findByProduit('SHT');
         foreach ($emails as $email) {
             $message->addCc($email->getEmail());
         }
         $message->setContentType("text/html");
         $message->setCharset("utf-8");
         $message->setBody($this->templating->render('BackAdministrationBundle:mails:notifierHotel.html.twig', array('reservation' => $reservation)));
         return $this->mailer->send($message);
     }
     return false;
 }
 public function notifierAction(Reservation $reservation)
 {
     $em = $this->getDoctrine()->getManager();
     $session = $this->getRequest()->getSession();
     if (!$reservation->getHotel()->isValideEmail1() && !$reservation->getHotel()->isValideEmail2()) {
         $session->getFlashBag()->add('info', $reservation->getHotel()->getLibelle() . " n' a pas un email valide <a target='_blank' href='" . $this->generateUrl('modif_hotel', array('id' => $reservation->getHotel()->getId())) . "' >Modifier cet hôtel</a>");
     } else {
         if ($this->container->get('mailerservice')->sendMailHotel($reservation)) {
             $reservation->setHotelNotifier(TRUE);
             $em->persist($reservation);
             $em->flush();
             $session->getFlashBag()->add('success', $reservation->getHotel()->getLibelle() . " a été notifiée avec succès ");
         }
     }
     return $this->redirect($this->generateUrl('liste_reservations'));
 }
Esempio n. 3
0
 public function generateSessionReservation(Reservation $reservation)
 {
     $tab = array();
     $tab['hotel'] = $reservation->getHotel()->getId();
     $tab['client'] = $reservation->getClient()->getId();
     $tab['dateDebut'] = $reservation->getDateDebut()->format('Y-m-d');
     $tab['dateFin'] = $reservation->getDateFin()->format('Y-m-d');
     $tab['nuitees'] = $reservation->getNuitees();
     return $tab;
 }