/**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("rucher", options={"mapping": {"rucher_id" : "id"}})  
  */
 public function addAction(Rucher $rucher, Request $request)
 {
     if (!$this->getUser()->canDisplayExploitation($rucher->getExploitation())) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $emplacement = new Emplacement($rucher);
     if ($rucher->getNumerotation()) {
         $form = $this->createForm(new EmplacementType(), $emplacement);
         if ($form->handleRequest($request)->isValid()) {
             return $this->saveEmplacement($emplacement);
         }
         return $this->render('KGBeekeepingManagementBundle:Emplacement:add.html.twig', array('form' => $form->createView(), 'rucher' => $rucher));
     } else {
         return $this->saveEmplacement($emplacement);
     }
 }
Ejemplo n.º 2
0
 private function getArrayOfEntities(\KG\BeekeepingManagementBundle\Entity\Rucher $rucher)
 {
     $repo = $this->em->getRepository('KGBeekeepingManagementBundle:Ruche');
     return $repo->getRucheByRucher($rucher->getId());
 }
Ejemplo n.º 3
0
 /**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("tache", options={"mapping": {"tache_id" : "id"}})  
  * @ParamConverter("rucher", options={"mapping": {"rucher_id" : "id"}})  
  */
 public function duplicateAction(Request $request, Tache $tache, Rucher $rucher)
 {
     if (!$this->getUser()->canDisplayExploitation($tache->getColonie()->getRuche()->getRucher()->getExploitation()) || !$this->getUser()->canDisplayExploitation($rucher->getExploitation()) || !$rucher->hasRuche()) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $form = $this->createForm(new DupliquerTacheType($this->getDoctrine()->getManager()), $rucher);
     if ($form->handleRequest($request)->isValid()) {
         $em = $this->getDoctrine()->getManager();
         foreach ($form['ruches']->getData() as $ruche) {
             $tacheCopy = new Tache($ruche->getColonie());
             $tacheCopy->setDate($tache->getDate());
             $tacheCopy->setDescription($tache->getDescription());
             $tacheCopy->setResume($tache->getResume());
             $tacheCopy->setPriorite($tache->getPriorite());
             $em->persist($tacheCopy);
         }
         $em->flush();
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Tâche dupliquée avec succès');
         return $this->redirect($this->generateUrl('kg_beekeeping_management_view_rucher', array('rucher_id' => $rucher->getId())));
     }
     return $this->render('KGBeekeepingManagementBundle:Tache:duplicate.html.twig', array('form' => $form->createView(), 'rucher' => $rucher, 'tache' => $tache));
 }
Ejemplo n.º 4
0
 /**
  * Set rucher
  *
  * @param \KG\BeekeepingManagementBundle\Entity\Rucher $rucher
  * @return Ruche
  */
 public function setRucher(\KG\BeekeepingManagementBundle\Entity\Rucher $rucher)
 {
     $this->rucher = $rucher;
     $rucher->addRuche($this);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("rucher", options={"mapping": {"rucher_id" : "id"}}) 
  */
 public function updateAction(Rucher $rucher, Request $request)
 {
     if (!$this->getUser()->canDisplayExploitation($rucher->getExploitation())) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $form = $this->createForm(new RucherType(), $rucher);
     if ($form->handleRequest($request)->isValid()) {
         $rucher->updateEmplacements();
         $em = $this->getDoctrine()->getManager();
         $em->persist($rucher);
         $em->flush();
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Rucher mis à jour avec succès');
         return $this->redirect($this->generateUrl('kg_beekeeping_management_view_rucher', array('rucher_id' => $rucher->getId())));
     }
     return $this->render('KGBeekeepingManagementBundle:Rucher:update.html.twig', array('form' => $form->createView(), 'rucher' => $rucher));
 }