示例#1
0
 /**
  * @Route("/contrat/{id}/suppression", name="contrat_suppression")
  * @ParamConverter("contrat", class="AppBundle:Contrat")
  */
 public function suppressionAction(Request $request, Contrat $contrat)
 {
     $dm = $this->get('doctrine_mongodb')->getManager();
     if (!$contrat->isModifiable()) {
         throw $this->createNotFoundException();
     }
     $societeId = $contrat->getSociete()->getId();
     foreach ($contrat->getContratPassages() as $contratPassages) {
         foreach ($contratPassages->getPassages() as $passage) {
             $dm->remove($passage);
         }
     }
     $dm->remove($contrat);
     $dm->flush();
     return $this->redirectToRoute('contrats_societe', array('id' => $societeId));
 }
示例#2
0
 public function getPassagesByNumeroArchiveContrat(Contrat $contrat, $reverse = false)
 {
     $contratsByNumero = $this->getRepository()->findByNumeroArchive($contrat->getNumeroArchive());
     $passagesByNumero = array();
     foreach ($contratsByNumero as $contrat) {
         foreach ($contrat->getContratPassages() as $contratPassages) {
             $idEtb = $contratPassages->getEtablissement()->getId();
             if (!array_key_exists($idEtb, $passagesByNumero)) {
                 $passagesByNumero[$idEtb] = array();
             }
             foreach ($contratPassages->getPassages() as $passage) {
                 $passagesByNumero[$idEtb][$passage->getDatePrevision()->format('Ymd')] = $passage;
             }
         }
     }
     foreach ($passagesByNumero as $idEtb => $passagesByNumeroAndEtb) {
         $passages = $passagesByNumeroAndEtb;
         if ($reverse) {
             krsort($passages);
         } else {
             ksort($passages);
         }
         $passagesByNumero[$idEtb] = $passages;
     }
     return $passagesByNumero;
 }