Example #1
0
 /**
  * @Template()
  * Sauvegarde les prévisions de marée en prenant en compte ce qui existe déjà dans la BD
  */
 public function mareeSaveAction($id)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $spots = $em->getRepository('LaPoizWindBundle:Spot')->findAll();
     $spot = $em->find('LaPoizWindBundle:Spot', $id);
     $form = $this->createForm('testGetMaree', $spots);
     if (!$spot) {
         return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "No spot find !"));
     }
     $mareeURL = $spot->getParameter()->getMareeURL();
     if (!empty($mareeURL)) {
         $prevMaree = MareeGetData::getMaree($mareeURL);
         MareeGetData::saveMaree($spot, $prevMaree, $em, new NullOutput());
     }
     $mareeDateDB = $em->getRepository('LaPoizWindBundle:MareeDate')->findLastPrev(10, $spot);
     return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Test:maree.html.twig', array('listSpot' => $spots, 'spot' => $spot, 'form' => $form->createView(), 'mareeURL' => $mareeURL, 'prevMaree' => $prevMaree, 'mareeDateDB' => $mareeDateDB));
 }
 /**
  * @Template()
  * Sauvegarde les prévisions de marée en prenant en compte ce qui existe déjà dans la BD
  * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/spot/maree/save/1
  */
 public function mareeSaveAction($id)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $spot = $em->find('LaPoizWindBundle:Spot', $id);
     if (!$spot) {
         return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "Spot not find !"));
     }
     $mareeURL = $spot->getMareeURL();
     if (!empty($mareeURL)) {
         $prevMaree = MareeGetData::getMaree($mareeURL);
         MareeGetData::saveMaree($spot, $prevMaree, $em, new NullOutput());
     }
     $mareeDateDB = $em->getRepository('LaPoizWindBundle:MareeDate')->findLastPrev(10, $spot);
     return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Spot/Ajax/Maree:mareeSaveResult.html.twig', array('mareeDateDB' => $mareeDateDB, 'spot' => $spot, 'message' => "", 'saveSuccess' => true));
 }