/**
  * Mail
  */
 public function mailAction($id)
 {
     $manager = $this->container->get('jlm_commerce.quote_manager');
     $manager->secure('ROLE_USER');
     $entity = $manager->getEntity($id);
     $manager->assertState($entity, array(1, 2, 3, 4, 5));
     $mail = new Mail();
     $mail->setSubject('Devis n°' . $entity->getNumber());
     $mail->setFrom('*****@*****.**');
     $mail->setBody($manager->renderView('JLMCommerceBundle:Quote:email.txt.twig', array('entity' => $entity)));
     $mail->setSignature($manager->renderView('JLMCommerceBundle:QuoteVariant:emailsignature.txt.twig', array('name' => $entity->getFollowerCp())));
     if ($entity->getContact()) {
         if ($entity->getContact()->getPerson()) {
             if ($entity->getContact()->getPerson()->getEmail()) {
                 $mail->setTo($entity->getContact()->getPerson()->getEmail());
             }
         }
     }
     $form = $manager->getFormFactory()->create(new MailType(), $mail);
     return $manager->renderResponse('JLMCommerceBundle:Quote:mail.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
 /**
  * Mail
  * @Template()
  */
 public function mailAction($id)
 {
     $manager = $this->container->get('jlm_commerce.quotevariant_manager');
     $manager->secure('ROLE_USER');
     $entity = $manager->getEntity($id);
     $manager->assertState($entity, array(QuoteVariant::STATE_READY, QuoteVariant::STATE_PRINTED, QuoteVariant::STATE_SENDED, QuoteVariant::STATE_RECEIPT, QuoteVariant::STATE_GIVEN));
     $mail = new Mail();
     $mail->setSubject('Devis n°' . $entity->getNumber());
     $mail->setFrom('*****@*****.**');
     $mail->setBody($this->renderView('JLMCommerceBundle:QuoteVariant:email.txt.twig', array('intro' => $entity->getIntro(), 'door' => $entity->getQuote()->getDoorCp())));
     $mail->setSignature($this->renderView('JLMCommerceBundle:QuoteVariant:emailsignature.txt.twig', array('name' => $entity->getQuote()->getFollowerCp())));
     if ($entity->getQuote()->getContact()) {
         if ($entity->getQuote()->getContact()->getPerson()) {
             if ($entity->getQuote()->getContact()->getPerson()->getEmail()) {
                 $mail->setTo($entity->getQuote()->getContact()->getPerson()->getEmail());
             }
         }
     }
     $form = $this->createForm(new MailType(), $mail);
     return array('entity' => $entity, 'form' => $form->createView());
 }