public function ajouterAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $form = $this->get('form.factory')->createNamedBuilder('formulaire_creation_acteur')->add('typeActeur', EntityType::class, array('class' => 'AMAPBundle:TypeActeur', 'choice_label' => 'libelle'))->add('nom', TextType::class)->add('prenom', TextType::class)->add('dateNaissance', DateType::class, array('input' => 'datetime', 'years' => range(1900, date('Y'))))->add('numRue', TextType::class)->add('typeVoie', TextType::class)->add('nomVoie', TextType::class)->add('ville', TextType::class)->add('cp', TextType::class)->add('amap', EntityType::class, array('class' => 'AMAPBundle:Amap', 'choice_label' => 'libelle'))->add('ajouter', SubmitType::class, array('label' => 'Créer acteur'))->getForm();
     $form2 = $this->get('form.factory')->createNamedBuilder('formulaire_creation_type_acteur')->add('libelle', TextType::class)->add('ajouter', SubmitType::class, array('label' => 'Créer type acteur'))->getForm();
     if ($form->handleRequest($request)->isSubmitted() || $form2->handleRequest($request)->isSubmitted()) {
         if ($form->get('ajouter')->isClicked()) {
             $data = $form->getData();
             $acteur = new Acteur();
             $acteur->setTypeActeur($data['typeActeur']);
             $acteur->setNom($data['nom']);
             $acteur->setPrenom($data['prenom']);
             $acteur->setDateNaissance($data['dateNaissance']);
             $adresse = new Adresse();
             $adresse->setNumRue($data['numRue']);
             $adresse->setTypeVoie($data['typeVoie']);
             $adresse->setNomVoie($data['nomVoie']);
             $adresse->setville($data['ville']);
             $adresse->setCp($data['cp']);
             $acteur->setAdresse($adresse);
             $acteur->setAmap($data['amap']);
             $em->persist($adresse);
             $em->persist($acteur);
             $em->flush();
             //return $this->redirect($this->generateUrl('amap_panier_ajouter'));
         }
         if ($form2->get('ajouter')->isClicked()) {
             $data2 = $form2->getData();
             $typeActeur = new TypeActeur();
             $typeActeur->setLibelle($data2['libelle']);
             $em->persist($typeActeur);
             $em->flush();
         }
     }
     $session = $request->getSession();
     $listacteur = $em->getRepository('AMAPBundle:Acteur')->findBy(array('amap' => $session->get('amap')));
     $typeProd = $em->getRepository('AMAPBundle:TypeActeur')->findBy(array('libelle' => "Producteur"));
     $typeAd = $em->getRepository('AMAPBundle:TypeActeur')->findBy(array('libelle' => "Consommateur"));
     $listProd = $em->getRepository('AMAPBundle:Acteur')->findBy(array('amap' => $session->get('amap'), 'typeActeur' => $typeProd));
     $listAd = $em->getRepository('AMAPBundle:Acteur')->findBy(array('amap' => $session->get('amap'), 'typeActeur' => $typeAd));
     return $this->render('AMAPBundle:Acteur:index.html.twig', array('form' => $form->createView(), 'form2' => $form2->createView(), 'page_courante' => 'acteur', 'listacteur' => $listacteur, 'listProd' => $listProd, 'listAd' => $listAd));
 }
 public function creerEntrepotAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $form = $this->get('form.factory')->createNamedBuilder('formulaire_entrepot')->add('libelle', TextType::class)->add('numRue', TextType::class)->add('typeVoie', TextType::class)->add('nomVoie', TextType::class)->add('ville', TextType::class)->add('cp', TextType::class)->add('amap', EntityType::class, array('class' => 'AMAPBundle:Amap', 'choice_label' => 'libelle'))->add('creer', SubmitType::class, array('label' => 'Créer un entrepot'))->getForm();
     if ($form->handleRequest($request)->isSubmitted()) {
         if ($form->get('creer')->isClicked()) {
             $data = $form->getData();
             $entrepot = new Entrepot();
             $entrepot->setLibelle($data['libelle']);
             $entrepot->setAmap($data['amap']);
             $adresse = new Adresse();
             $adresse->setNumRue($data['numRue']);
             $adresse->setTypeVoie($data['typeVoie']);
             $adresse->setNomVoie($data['nomVoie']);
             $adresse->setville($data['ville']);
             $adresse->setCp($data['cp']);
             $entrepot->setAdresse($adresse);
             $em->persist($adresse);
             $em->persist($entrepot);
             $em->flush();
         }
     }
     return $this->render('AMAPBundle:Admin/Entrepot:creerEntrepot.html.twig', array('page_courante' => 'AdminEntrepot', 'onglet_courant' => 'creerEntrepotAction', 'form' => $form->createView()));
 }