예제 #1
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()));
 }
예제 #2
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()));
 }
예제 #3
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));
 }