/**
  * Creates a new Transmitter entity.
  *
  * @Route("/create/{id}", name="transmitter_create")
  * @Method("POST")
  * @Template()
  */
 public function createAction(Request $request, Attribution $attribution)
 {
     $entity = new Transmitter();
     $form = $this->createForm(new TransmitterType($attribution->getSite()->getId()), $entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         // On met à jour la page de base
         return new JsonResponse(array());
     }
     return array('entity' => $entity, 'form' => $form->createView());
 }
 /**
  * Creates a new Series entity.
  *
  * @Route("/create/{id}", name="transmitter_series_create")
  * @Method("POST")
  * @Template()
  */
 public function createAction(Request $request, Attribution $attribution)
 {
     $entity = new Series();
     $form = $this->createForm(new SeriesType($attribution->getSite()->getId()), $entity);
     $form->add('submit', 'submit', array('label' => 'Enregistrer'));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $transmitters = $entity->getTransmitters();
         foreach ($transmitters as $transmitter) {
             $em->persist($transmitter);
         }
         $em->flush();
         // On met à jour la page de base
         return new JsonResponse(array());
     }
     return array('entity' => $entity, 'form' => $form->createView());
 }
 /**
  * Generate bill
  *
  * @Route("/{id}/bill", name="transmitter_attribution_bill")
  */
 public function billAction(Attribution $entity)
 {
     $em = $this->getDoctrine()->getManager();
     if ($entity->getBill() !== null) {
         return $this->redirect($this->generateUrl('bill_edit', array('id' => $entity->getBill()->getId())));
     }
     // @todo trouver un autre solution que le codage brut
     $options = array('port' => $em->getRepository('JLMProductBundle:Product')->find(134), 'earlyPayment' => (string) $em->getRepository('JLMCommerceBundle:EarlyPaymentModel')->find(1), 'penalty' => (string) $em->getRepository('JLMCommerceBundle:PenaltyModel')->find(1), 'property' => (string) $em->getRepository('JLMCommerceBundle:PropertyModel')->find(1));
     $bill = BillFactory::create(new AttributionBillBuilder($entity, $em->getRepository('JLMCommerceBundle:VAT')->find(1)->getRate(), $options));
     $em->persist($bill);
     $entity->setBill($bill);
     $em->persist($entity);
     $em->flush();
     return $this->redirect($this->generateUrl('bill_edit', array('id' => $bill->getId())));
 }