Esempio n. 1
0
 /**
  * Generate a reaseau params.
  *
  * @param Request $request        	
  * @param Reseau $reseau        	
  * @param Version $version        	
  * @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function generateParamsAction(Request $request, Reseau $reseau, Version $version)
 {
     $paramService = $this->get("param_service");
     $version = $reseau->getVersions()->last();
     $form = $this->createForm('DocBundle\\Form\\VersionType', $version);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         ini_set('max_execution_time', 0);
         $version->setUser($this->getUser()->getUsername());
         $reseauParamsDir = $this->container->getParameter('generation_dir') . '/' . $reseau->getCode();
         $em = $this->getDoctrine()->getManager();
         $parametrages = $em->getRepository('DocBundle:ArchiveParam')->getArchivesByVersion($version);
         $paramService->generateArchives($version, $parametrages, $reseauParamsDir);
         return $this->redirectToRoute('reseau_show_parametrage', ['id' => $reseau->getId()]);
     }
     return new JsonResponse(array('statut' => 'Vous devez passer par le formulaire de génération'));
 }
Esempio n. 2
0
 /**
  * Generate a reaseau params.
  *
  * @param Reseau $reseau        	
  * @param Version $version        	
  * @param unknown $parametrages        	
  * @param string $reseauParamsDir        	
  */
 public function generateParams(Reseau $reseau, Version $version, $parametrages, $reseauParamsDir)
 {
     $block = 1;
     $range = 20;
     $fs = new Filesystem();
     if ($fs->exists($reseauParamsDir)) {
         try {
             $fs->remove($reseauParamsDir);
         } catch (IOException $e) {
             echo "Imposible de supprimer le repertoire " + $reseauParamsDir + " raison :" + $e->getMessage();
         }
     }
     ini_set('max_execution_time', 0);
     while ($block < count($parametrages)) {
         $parametrages = $this->em->getRepository('DocBundle:Parametrage')->getParametrageByReseau($reseau->getId(), $block, $range);
         foreach ($parametrages as $param) {
             try {
                 $contratDir = $reseauParamsDir . '/' . $param->getContrat();
                 $fs->mkdir($contratDir);
                 file_put_contents($contratDir . '/' . $param->getLastPdfSource()->getTitle(), $param->getLastPdfSource()->getFile());
                 $collectiviteFileName = $contratDir . '/' . str_replace('.pdf', '.collectivites', $param->getLastPdfSource()->getTitle());
                 $this->generateCollectiviteFile($param, $version, $version->getMessage(), $collectiviteFileName);
             } catch (IOException $e) {
                 echo 'Une erreur est survenue lors de la création du repertoire ' . $e->getPath();
             }
             $archive = new ArchiveParam();
             $pdf = $param->getLastPdfSource();
             $pdf->setCurrent(0);
             $archive->addPdfSource($pdf);
             $archive->setParametrage($param);
             $archive->setAction("Génération");
             $version->addArchive($archive);
             $archive->addVersion($version);
             $version->setEncours('0');
             $reseau->addVersion($version);
             $this->em->persist($reseau);
             $this->em->flush();
             $archive = null;
         }
         $block = $block + 1;
     }
     ini_set('max_execution_time', 60);
 }
Esempio n. 3
0
 /**
  * Creates a form to delete a Parametrage entity.
  *
  * @param Reseau $parametrage The Parametrage entity
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Reseau $reseau)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('reseau_delete', array('id' => $reseau->getId())))->setMethod('DELETE')->getForm();
 }
Esempio n. 4
0
 /**
  * @return array
  */
 public function getClosedByReseau(Reseau $reseau)
 {
     $qb = $this->createQueryBuilder('v');
     $qb->join('v.reseau', 'res')->addSelect('res')->where('v.enCours = 0')->andWhere('res.id = :id')->setParameter('id', $reseau->getId());
     return $qb->getQuery()->getResult();
 }