/**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("colonie", options={"mapping": {"colonie_id" : "id"}})  
  */
 public function viewAllAction(Colonie $colonie)
 {
     if (!$this->getUser()->canDisplayExploitation($colonie->getRuche()->getRucher()->getExploitation())) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     return $this->render('KGBeekeepingManagementBundle:Recolte:viewAll.html.twig', array('colonie' => $colonie));
 }
 /**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("colonie", options={"mapping": {"colonie_id" : "id"}})  
  */
 public function addAction(Colonie $colonie, Request $request)
 {
     if (!$this->getUser()->canDisplayExploitation($colonie->getRuche()->getRucher()->getExploitation()) || !$colonie->canHaveNewTranshumance()) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $transhumance = new Transhumance($colonie);
     $form = $this->createForm(new TranshumanceType(), $transhumance);
     if ($form->handleRequest($request)->isValid()) {
         $transhumance->getColonie()->getRuche()->setEmplacement($transhumance->getEmplacementto());
         $em = $this->getDoctrine()->getManager();
         $em->persist($transhumance);
         $em->flush();
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Transhumance créée avec succès');
         return $this->redirect($this->generateUrl('kg_beekeeping_management_view_ruche', array('ruche_id' => $transhumance->getColonie()->getRuche()->getId())));
     }
     return $this->render('KGBeekeepingManagementBundle:Transhumance:add.html.twig', array('form' => $form->createView(), 'colonie' => $colonie));
 }
Beispiel #3
0
 /**
  * Constructor
  */
 public function __construct(Colonie $colonie)
 {
     $this->colonie = $colonie;
     $this->setNbcouvain($colonie->getRuche()->getCorps()->getNbcouvain());
     $this->setNbnourriture($colonie->getRuche()->getCorps()->getNbnourriture());
     if (!$colonie->getVisites()->isEmpty()) {
         $lastVisite = $colonie->getVisites()->last();
         $this->setActivite($lastVisite->getActivite());
         $this->setEtat($lastVisite->getEtat());
         $this->setAgressivite($lastVisite->getAgressivite());
         $this->setPoids($lastVisite->getPoids());
     }
     $this->setDate(new \DateTime());
     $this->hausses = new \Doctrine\Common\Collections\ArrayCollection();
     $this->taches = new \Doctrine\Common\Collections\ArrayCollection();
     foreach ($colonie->getRuche()->getHausses() as $hausse) {
         $this->addHauss(new HausseVisite($this, $hausse->getNbplein(), $hausse->getNbcadres()));
     }
 }
 /**
  * Constructor
  */
 public function __construct(Colonie $colonie)
 {
     $this->colonie = $colonie;
     $this->emplacementfrom = $colonie->getRuche()->getEmplacement();
     $this->rucherfrom = $colonie->getRuche()->getRucher();
 }
 /**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("colonie", options={"mapping": {"colonie_id" : "id"}})  
  */
 public function tuerAction(Colonie $colonie, Request $request)
 {
     if (!$this->getUser()->canDisplayExploitation($colonie->getRuche()->getRucher()->getExploitation()) || !$colonie->canBeTuee()) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $form = $this->createForm(new CauseType(), $colonie);
     if ($form->handleRequest($request)->isValid()) {
         $colonie->setMorte(true);
         $colonie->getRuche()->getEmplacement()->setRuche();
         $colonie->getRuche()->setEmplacement();
         $em = $this->getDoctrine()->getManager();
         $em->persist($colonie);
         $em->flush();
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('La mort de la colonie a bien été enregistrée');
         return $this->redirect($this->generateUrl('kg_beekeeping_management_view_ruche', array('ruche_id' => $colonie->getRuche()->getId())));
     }
     return $this->render('KGBeekeepingManagementBundle:Colonie:tuer.html.twig', array('form' => $form->createView(), 'colonie' => $colonie));
 }