/**
  * Creates a new Lotissement entity.
  *
  *
  */
 public function createAction(Request $request)
 {
     $this->verifyAccess();
     $em = $this->getDoctrine()->getManager();
     $entity = new Lotissement();
     $marche = new Marche();
     $avenant = new Avenant();
     $libelleZero = $em->getRepository("LaisoArmBundle:LibelleAvenant")->findOneByNumero(0);
     $avenant->setLibelle($libelleZero);
     $avenant->setMarche($marche);
     $avenant->setMotif("Marché initial");
     $avenant->setDelai($entity->getDelai());
     $entity->setValide(false);
     $entity->setPuValide(false);
     $avenant->setValide(false);
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($entity);
         $avenant->setDelai($entity->getDelai());
         $marche->setLotissement($entity);
         $marche->setEntrepriseAssujettie(false);
         $em->persist($marche);
         $em->persist($avenant);
         $em->flush();
         return $this->redirect($this->generateUrl('dao_show', array('id' => $entity->getId())));
     }
     return $this->render('LaisoArmBundle:Lotissement:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
Beispiel #2
0
 /**
  * Displays a form to create a new Avenant entity.
  *
  */
 public function newAction(Request $request, $marcheId)
 {
     $this->verifyAccess();
     $entity = new Avenant();
     $avenants = $this->getDoctrine()->getRepository("LaisoArmBundle:Avenant")->findBy(array('marche' => $marcheId));
     $delai = 0;
     $numero = 0;
     foreach ($avenants as $avenant) {
         $delai = $avenant->getDelai();
         $numero++;
     }
     $entity->setDelai($delai);
     $libelle = $this->getDoctrine()->getRepository("LaisoArmBundle:LibelleAvenant")->findOneByNumero($numero);
     $entity->setLibelle($libelle);
     $entity->setMarche($this->getDoctrine()->getRepository('LaisoArmBundle:Marche')->find($marcheId));
     $form = $this->createCreateForm($entity, $marcheId);
     if ($request->isXmlHttpRequest()) {
         return $this->render('LaisoArmBundle:Avenant/includes:new_avenant.html.twig', array('entity' => $entity, 'form' => $form->createView()));
     }
     return $this->render('LaisoArmBundle:Avenant:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }