Ejemplo n.º 1
0
 public function findHistoriqueByEtablissementAndPrestationsAndNumeroContrat(Contrat $contrat, $etablissement, $prestations = array(), $limit = 2)
 {
     $passagesHistorique = array();
     $contratsNumArchive = $this->dm->getRepository('AppBundle:Contrat')->findByNumeroArchive($contrat->getNumeroArchive());
     $contratsNumArchiveArray = array();
     foreach ($contratsNumArchive as $contratNumArchive) {
         $contratsNumArchiveArray[$contratNumArchive->getId()] = $contratNumArchive->getId();
     }
     foreach ($prestations as $prestation) {
         $passages = array();
         foreach ($contratsNumArchiveArray as $idContrat) {
             $passages = array_merge($passages, $this->findBy(array('contrat' => $idContrat, 'etablissement' => $etablissement->getId(), 'statut' => PassageManager::STATUT_REALISE, 'prestations.identifiant' => $prestation->getIdentifiant()), array('dateDebut' => 'DESC'), $limit));
             foreach ($passages as $passage) {
                 $passagesHistorique[$passage->getDateDebut()->format('YmdHi') . "_" . $passage->getId()] = $passage;
             }
         }
     }
     krsort($passagesHistorique);
     $passagesHistorique = array_slice($passagesHistorique, 0, 2);
     return $passagesHistorique;
 }
Ejemplo n.º 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;
 }