/** * 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())); }
/** * Réécrire les lignes DQE * * @param Avenant $avenant * */ private function defineDqe(Avenant $avenant) { $em = $this->getDoctrine()->getManager(); $avenantPrecedent = $em->getRepository("LaisoArmBundle:Avenant")->findOneBy(array('marche' => $avenant->getMarche(), 'libelle' => $em->getRepository("LaisoArmBundle:LibelleAvenant")->findOneBy(array('numero' => $avenant->getLibelle()->getNumero() - 1))->getId())); foreach ($avenantPrecedent->getLignes() as $ligne) { $ligneDqe = new LigneDQE(); $ligneDqe->setQuantite($ligne->getQuantite()); $ligneDqe->setPrix($ligne->getprix()); $ligneDqe->setAvenant($avenant); $em->persist($ligneDqe); $em->flush(); } }