/** * @Security("has_role('ROLE_USER')") * @ParamConverter("ruche", options={"mapping": {"ruche_id" : "id"}}) */ public function viewAction(Ruche $ruche) { if (!$this->getUser()->canDisplayExploitation($ruche->getRucher()->getExploitation())) { throw new NotFoundHttpException('Page inexistante.'); } $taches = $this->getDoctrine()->getRepository('KGBeekeepingManagementBundle:Tache')->getListByColonie($ruche->getColonie())->getResult(); $chart = $this->get('app.chart'); return $this->render('KGBeekeepingManagementBundle:Ruche:view.html.twig', array('ruche' => $ruche, 'taches' => $taches, 'getPoidsParVisite' => $chart->getChartPoidsParVisite($ruche))); }
private function getPoidsParVisite(Ruche $ruche) { $visites = $ruche->getColonie()->getVisites(); $tabVisites = array(); foreach ($visites as $visite) { $tabVisites[] = array('Date' => $visite->getDate(), 'Poids' => 0 + $visite->getPoids()); } // Obtient une liste de colonnes foreach ($tabVisites as $key => $row) { $date[$key] = $row['Date']; } if ($tabVisites) { array_multisort($date, SORT_ASC, $tabVisites); } return $tabVisites; }