Esempio n. 1
0
 /**
  * @param Version $version
  * @param int $page
  * @param int $maxPerPage
  * @return array
  */
 public function getArchivesByVersion(Version $version, $page = 1, $maxPerPage = 20)
 {
     $qb = $this->createQueryBuilder('ar');
     $qb->join('ar.versions', 'v')->addSelect('v')->where('v.id = :id')->setParameter('id', $version->getId());
     $qb->setFirstResult(($page - 1) * $maxPerPage)->setMaxResults($maxPerPage);
     return new Paginator($qb, true);
 }
Esempio n. 2
0
 /**
  * Displays a form to edit an existing ArchiveParam entity.
  *
  * @param Request $request        	
  * @param ArchiveParam $archiveParam        	
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editAction(Request $request, ArchiveParam $archiveParam)
 {
     $deleteForm = $this->createDeleteForm($archiveParam);
     $editForm = $this->createForm('DocBundle\\Form\\ArchiveParamType', $archiveParam);
     $editForm->handleRequest($request);
     if ($editForm->isSubmitted() && $editForm->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $newArchive = $archiveParam->hydrateNewArchive();
         if ($archiveParam->getCurrentPdf()->getFile() !== null) {
             $pdf = new Pdf();
             $pdf->setCurrent(0);
             $stream = fopen($archiveParam->getCurrentPdf()->getFile(), 'rb');
             $pdf->setFile(stream_get_contents($stream));
             $pdf->setTitle($archiveParam->generateFileName('.pdf'));
             $pdf->addArchive($newArchive);
             $newArchive->addPdfSource($pdf);
         }
         $currentVersion = $archiveParam->getVersions()->last();
         $numero = $currentVersion->getNumero() + 0.1;
         $currentVersion->removeArchive($archiveParam);
         // $archives = $currentVersion->getArchives();
         $version = new Version();
         $version->setNumero($numero);
         // $version->addGroupArchives($archives);
         $version->setReseau($currentVersion->getReseau());
         $version->setEnCours(0);
         $version->addArchive($newArchive);
         $newArchive->addVersion($version);
         $em->persist($version);
         $em->flush();
         return $this->redirectToRoute('archiveparam_edit', array('id' => $archiveParam->getId()));
     }
     return $this->render('@Doc/archiveparam/edit.html.twig', array('archiveParam' => $archiveParam, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView()));
 }
Esempio n. 3
0
 /**
  * 
  * @param Request $request
  * 
  * Creates a new Reseau entity.
  */
 public function newAction(Request $request)
 {
     $reseau = new Reseau();
     $form = $this->createForm('DocBundle\\Form\\ReseauType', $reseau);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $versioin = new Version();
         $versioin->setReseau($reseau);
         $versioin->setNumero('0');
         $versioin->setEnCours('1');
         $em->persist($versioin);
         $em->flush();
         return $this->redirectToRoute('reseau_show', array('id' => $reseau->getId()));
     }
     return $this->render('DocBundle:reseau:new.html.twig', array('reseau' => $reseau, 'form' => $form->createView()));
 }
Esempio n. 4
0
 /**
  *
  * @param Parametrage $parametrage        	
  * @param Version $version        	
  * @param unknown $commentaire        	
  * @param unknown $path        	
  */
 protected function generateCollectiviteFile($parametrage, Version $version, $commentaire, $path)
 {
     $now = new DateTime();
     $now->format('d/m/Y H:i:s');
     $content = "#CREE AUTOMATIQUEMENT LE " . $now->format('d/m/Y H:i:s');
     $content .= "\n#Utilisateur : " . $version->getUser();
     // . "( " . $version->getUser ()->getEmail () . ")";
     $content .= "\n# Version V" . $version->getNumero();
     $content .= "\n# {$commentaire}";
     $content .= "\n#----------------------------- ";
     $content .= "\nLIBELLE=" . $parametrage->getLibelle();
     $content .= "\nORDRE=" . $parametrage->getOrdre();
     $content .= "\nPARTENAIRE=";
     $content .= in_array($parametrage->getPartenaires(), array('*', 'tous', 'Tous')) ? '*' : $parametrage->getPartenaires();
     $content .= "\nCOLLECTIVITES=";
     $content .= in_array($parametrage->getCollectivites(), array('*', 'toutes', 'Toutes')) ? '*' : $parametrage->getCollectivites();
     file_put_contents($path, $content);
 }
Esempio n. 5
0
 /**
  *
  * @param Version $version        	
  * @param unknown $actionPath        	
  * @param unknown $method        	
  */
 private function createVersionForm(Version $version, $actionPath, $method)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl($actionPath, array('id' => $version->getId())))->setMethod($method)->getForm();
 }
Esempio n. 6
0
 /**
  * Deletes a Parametrage entity.
  * 
  * @param Request $request
  * @param Parametrage $parametrage
  */
 public function deleteAction(Request $request, Parametrage $parametrage)
 {
     // TODO: Make version appear as "en cours" on delete confirmed
     $em = $this->getDoctrine()->getManager();
     if ($parametrage == null) {
         throw $this->createNotFoundException("Le réseau  " . $parametrage . getId() . " n'existe pas.");
     }
     if ($request->isMethod('GET')) {
         if ($parametrage->getDeleting()) {
             $currentVersion = $parametrage->getReseau()->getVersions()->last();
             $version = new Version();
             if (!$currentVersion->getEnCours()) {
                 $version->setEnCours('1');
                 $version->setNumero($currentVersion->getNumero() + 1);
                 $version->setReseau($parametrage->getReseau());
                 $parametrage->getReseau()->addVersion($version);
             } else {
                 $version = $currentVersion;
             }
             // On compose à nouveau les liasses qui contienent ce document
             // TODO: à mettre dans une fonction preUpdate (event doctrine)
             $ls = $parametrage->getMeElementOfLiasses();
             foreach ($ls as $param) {
                 $param->removeMyComponent($parametrage);
                 $parametrage->removeMeElementOfLiasse($param);
                 $pdf = $this->composerLiasse($param);
                 $pdf->setCurrent(1);
                 $param->addPdfSource($pdf);
                 $pdf->setParametrage($param);
             }
             $id = $parametrage->getId();
             $em->remove($parametrage);
             $em->flush();
             return new JsonResponse(array('id' => $id, 'status' => 'deleted', 'version' => $version->getNumero()));
         }
         $parametrage->setDeleting(1);
         $em->persist($parametrage);
         $em->flush();
         return new JsonResponse(array('id' => $parametrage->getId(), 'status' => 'marked'));
     }
     return $this->render('DocBundle:parametrage:show.html.twig', array('parametrage' => $parametrage));
 }