/**
  * Finds and displays a InterventionPlanned entity.
  *
  * @Template()
  * @Secure(roles="ROLE_USER")
  */
 public function emailAction(Fixing $entity, $step)
 {
     $request = $this->getRequest();
     $steps = array('taken' => 'JLM\\DailyBundle\\Builder\\Email\\FixingTakenMailBuilder', 'distributed' => 'JLM\\DailyBundle\\Builder\\Email\\FixingDistributedMailBuilder', 'onsite' => 'JLM\\DailyBundle\\Builder\\Email\\FixingOnSiteMailBuilder', 'end' => 'JLM\\DailyBundle\\Builder\\Email\\FixingEndMailBuilder', 'report' => 'JLM\\DailyBundle\\Builder\\Email\\FixingReportMailBuilder');
     $class = array_key_exists($step, $steps) ? $steps[$step] : null;
     if (null === $class) {
         throw new NotFoundHttpException('Page inexistante');
     }
     $mail = MailFactory::create(new $class($entity));
     $editForm = $this->createForm(new MailType(), $mail);
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         $this->get('mailer')->send(MailFactory::create(new MailSwiftMailBuilder($editForm->getData())));
         $this->get('event_dispatcher')->dispatch(JLMModelEvents::DOOR_SENDMAIL, new DoorEvent($entity->getDoor(), $request));
         return $this->redirect($this->generateUrl('fixing_show', array('id' => $entity->getId())));
     }
     return array('entity' => $entity, 'form' => $editForm->createView(), 'step' => $step);
 }
 /**
  * Email de relance facture
  */
 public function boostemailAction($id)
 {
     // @todo Passer par un service de formPopulate et créer un controller unique dans CoreBundle
     $manager = $this->container->get('jlm_commerce.bill_manager');
     $manager->secure('ROLE_USER');
     $entity = $manager->getEntity($id);
     $request = $manager->getRequest();
     $site = $entity->getSiteObject();
     $builder = $site === null ? new BillBoostMailBuilder($entity) : new BillBoostBusinessMailBuilder($site);
     $mail = MailFactory::create($builder);
     $editForm = $this->container->get('form.factory')->create(new \JLM\CoreBundle\Form\Type\MailType(), $mail);
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         $this->container->get('mailer')->send(MailFactory::create(new MailSwiftMailBuilder($editForm->getData())));
         $this->container->get('event_dispatcher')->dispatch(JLMCommerceEvents::BILL_BOOST_SENDMAIL, new BillEvent($entity, $request));
         return $manager->redirectReferer();
     }
     return $manager->renderResponse('JLMCommerceBundle:Bill:boostemail.html.twig', array('entity' => $entity, 'form' => $editForm->createView()));
 }
 /**
  * Email de confirmation d'accord de devis
  */
 public function emailAction($id)
 {
     // @todo Passer par un service de formPopulate et créer un controller unique dans CoreBundle
     $manager = $this->container->get('jlm_commerce.quotevariant_manager');
     $manager->secure('ROLE_USER');
     $entity = $manager->getEntity($id);
     $request = $manager->getRequest();
     $mail = MailFactory::create(new QuoteVariantConfirmGivenMailBuilder($entity));
     $editForm = $this->createForm(new \JLM\CoreBundle\Form\Type\MailType(), $mail);
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         $this->get('mailer')->send(MailFactory::create(new MailSwiftMailBuilder($editForm->getData())));
         //$this->get('event_dispatcher')->dispatch(JLMModelEvents::DOOR_SENDMAIL, new DoorEvent($entity->getDoor(), $request));
         return $this->redirect($this->generateUrl('quote_show', array('id' => $entity->getQuote()->getId())));
     }
     return $manager->renderResponse('JLMCommerceBundle:QuoteVariant:email.html.twig', array('entity' => $entity, 'form' => $editForm->createView()));
 }
 public function sendGivenConfirmMail(QuoteVariantEvent $event)
 {
     $mail = MailFactory::create(new QuoteVariantConfirmGivenMailBuilder($event->getQuoteVariant()));
     $swift = MailFactory::create(new MailSwiftMailBuilder($mail));
     $this->mailer->send($swift);
 }