Loading module/Formule/src/Model/FormuleDetailsExtractor.php +191 −26 Changes for module/Formule/src/Model/FormuleDetailsExtractor.php: 191 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Formule\Entity\FormuleServiceIntervenant; use Formule\Model\Arrondisseur\Ligne; use Formule\Model\Arrondisseur\Valeur; use Formule\Service\FormuleServiceAwareTrait; use Intervenant\Entity\Db\Intervenant; use Laminas\Hydrator\ExtractionInterface; class FormuleDetailsExtractor implements ExtractionInterface Loading @@ -16,6 +17,7 @@ class FormuleDetailsExtractor implements ExtractionInterface private FormuleServiceIntervenant $fres; private Formule $formule; private Ligne $trace; private Intervenant $intervenantEntity; private array $iParams = []; private array $vhParams = []; Loading @@ -41,12 +43,15 @@ class FormuleDetailsExtractor implements ExtractionInterface } $this->trace = $this->fres->getArrondisseurTrace(); $this->intervenantEntity = $this->getServiceFormule()->getEntityManager()->find(Intervenant::class, $this->fres->getIntervenantId()); // Préparations $this->prepareTypesHetd(); $this->prepareIntervenant(); $this->prepareParams(); $this->prepareServices(); $this->prepareVolumesHoraires(); // Forge du résultat et envoi Loading @@ -60,19 +65,6 @@ class FormuleDetailsExtractor implements ExtractionInterface ]; return $result; /* Travail sur les volumes horaires */ $vhs = $formuleServiceIntervenant->getVolumesHoraires(); foreach ($vhs as $vh) { $serviceId = $vh->getService() ? 'e' . $vh->getService() : 'r' . $vh->getServiceReferentiel(); $volumeHoraireId = $vh->getVolumeHoraire() ? 'e' . $vh->getVolumeHoraire() : 'r' . $vh->getVolumeHoraireReferentiel(); $services[$serviceId]['volumesHoraires'][$volumeHoraireId] = [ 'id' => $vh->getVolumeHoraire() ?? $vh->getVolumeHoraireReferentiel(), ]; } } Loading Loading @@ -107,6 +99,15 @@ class FormuleDetailsExtractor implements ExtractionInterface private function prepareIntervenant(): void { $structure = $this->intervenantEntity->getStructure(); if ($structure) { $structure = [ 'id' => $structure->getId(), 'code' => $structure->getCode(), 'libelle' => $structure->getLibelleCourt(), ]; } $this->intervenant = [ 'id' => $this->fres->getIntervenantId(), 'anneeId' => $this->fres->getAnnee()->getId(), Loading @@ -117,7 +118,7 @@ class FormuleDetailsExtractor implements ExtractionInterface 'code' => $this->fres->getTypeIntervenant()->getCode(), 'libelle' => $this->fres->getTypeIntervenant()->getLibelle(), ], // structure 'structure' => $structure, 'heuresServiceStatutaire' => $this->fres->getHeuresServiceStatutaire(), 'heuresServiceModifie' => $this->fres->getHeuresServiceModifie(), 'depassementServiceDuSansHC' => $this->fres->isDepassementServiceDuSansHC(), Loading Loading @@ -160,9 +161,7 @@ class FormuleDetailsExtractor implements ExtractionInterface $this->services[$sname] = [ 'type' => str_starts_with($sname, 'e') ? 'enseignement' : 'referentiel', 'id' => substr($sname, 1), 'libelle' => $sname, 'volumesHoraires' => [], 'heures' => [], 'hetd' => [], ]; foreach ($this->typesHetd as $typeHetd) { Loading @@ -173,29 +172,70 @@ class FormuleDetailsExtractor implements ExtractionInterface if (!empty($eIds)) { $sql = " SELECT s.id, CASE WHEN ep.id IS NULL THEN etab.libelle || CASE WHEN s.description IS NULL THEN '' ELSE ' => ' || s.description END ELSE '[' || e.code || '] ' || e.libelle || ' => [' || ep.code || '] ' || ep.libelle END libelle s.id id, str.id structure_id, str.libelle_court structure_libelle, etab.id etablissement_id, etab.libelle etablissement_libelle, s.description description, e.id etape_id, e.code etape_code, e.libelle etape_libelle, ep.id ep_id, ep.code ep_code, ep.libelle ep_libelle, ep.taux_fi taux_fi, ep.taux_fa taux_fa, ep.taux_fc taux_fc FROM service s JOIN etablissement etab ON etab.id = s.etablissement_id LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id LEFT JOIN etape e ON e.id = ep.etape_id LEFT JOIN structure str ON str.id = ep.structure_id WHERE s.id IN (" . implode(',', $eIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $this->services['e' . $data['ID']]['libelle'] = $data['LIBELLE']; $sdata = [ 'id' => (int)$data['ID'], 'structure' => $data['STRUCTURE_ID'] ? [ 'id' => (int)$data['STRUCTURE_ID'], 'libelle' => $data['STRUCTURE_LIBELLE'], ] : null, 'etablissement' => [ 'id' => (int)$data['ETABLISSEMENT_ID'], 'libelle' => $data['ETABLISSEMENT_LIBELLE'], ], 'description' => $data['DESCRIPTION'], 'etape' => $data['ETAPE_ID'] ? [ 'id' => (int)$data['ETAPE_ID'], 'code' => $data['ETAPE_CODE'], 'libelle' => $data['ETAPE_LIBELLE'], ] : null, 'elementPedagogique' => $data['EP_ID'] ? [ 'id' => (int)$data['EP_ID'], 'code' => $data['EP_CODE'], 'libelle' => $data['EP_LIBELLE'], ] : null, 'tauxFi' => (float)$data['TAUX_FI'], 'tauxFa' => (float)$data['TAUX_FI'], 'tauxFc' => (float)$data['TAUX_FI'], ]; $this->services['e' . $data['ID']] = array_merge($this->services['e' . $data['ID']], $sdata); } } if (!empty($rIds)) { $sql = " SELECT sr.id, str.libelle_court || ' - ' || fr.libelle_court || CASE WHEN sr.commentaires IS NULL THEN '' ELSE ' ' || sr.commentaires END libelle sr.id id, str.id structure_id, str.libelle_court structure_libelle, fr.id fonction_id, fr.code fonction_code, fr.libelle_court fonction_libelle, sr.commentaires description FROM service_referentiel sr JOIN structure str ON str.id = sr.structure_id Loading @@ -204,7 +244,132 @@ class FormuleDetailsExtractor implements ExtractionInterface sr.id IN (" . implode(',', $rIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $this->services['r' . $data['ID']]['libelle'] = $data['LIBELLE']; $sdata = [ 'id' => (int)$data['ID'], 'structure' => [ 'id' => (int)$data['STRUCTURE_ID'], 'libelle' => $data['STRUCTURE_LIBELLE'], ], 'fonction' => [ 'id' => (int)$data['FONCTION_ID'], 'code' => $data['FONCTION_CODE'], 'libelle' => $data['FONCTION_LIBELLE'], ], 'description' => $data['DESCRIPTION'], ]; $this->services['r' . $data['ID']] = array_merge($this->services['r' . $data['ID']], $sdata); } } } private function prepareVolumesHoraires(): void { $eIds = []; $rIds = []; foreach ($this->trace->getSubs() as $sname => $service) { foreach ($service->getSubs() as $vh) { if ($vh->getVolumeHoraire()->getVolumeHoraire()) { $sId = 'e' . $vh->getVolumeHoraire()->getService(); $vhId = 'e' . $vh->getVolumeHoraire()->getVolumeHoraire(); $eIds[] = $vh->getVolumeHoraire()->getVolumeHoraire(); } else { $sId = 'r' . $vh->getVolumeHoraire()->getServiceReferentiel(); $vhId = 'r' . $vh->getVolumeHoraire()->getVolumeHoraireReferentiel(); $rIds[] = $vh->getVolumeHoraire()->getVolumeHoraireReferentiel(); } $this->services[$sId]['volumesHoraires'][$vhId] = [ 'type' => str_starts_with($vhId, 'e') ? 'enseignement' : 'referentiel', 'id' => substr($vhId, 1), ]; foreach ($this->typesHetd as $typeHetd) { $valeur = $service->getValeur($typeHetd); $this->services[$sId]['volumesHoraires'][$vhId]['hetd'][$typeHetd] = $this->valeurToJson($valeur); } } } if (!empty($eIds)) { $sql = " SELECT vh.service_id service_id, vh.id id, vh.heures heures, vh.horaire_debut horaire_debut, vh.horaire_fin horaire_fin, p.id periode_id, p.code periode_code, p.libelle_court periode_libelle, ti.id type_intervention_id, ti.code type_intervention_id, ti.libelle type_intervention_id, mnp.id motif_non_paiement_id, mnp.code motif_non_paiement_code, mnp.libelle_court motif_non_paiement_code FROM volume_horaire vh JOIN periode p ON p.id = vh.periode_id JOIN type_intervention ti ON ti.id = vh.type_intervention_id LEFT JOIN motif_non_paiement mnp ON mnp.id = vh.motif_non_paiement_id WHERE vh.id IN (" . implode(',', $eIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $sdata = [ 'id' => (int)$data['ID'], 'heures' => (float)$data['HEURES'], 'horaireDebut' => $data['HORAIRE_DEBUT'], 'horaireFin' => $data['HORAIRE_FIN'], 'periode' => [ 'id' => (int)$data['PERIODE_ID'], 'code' => $data['PERIODE_CODE'], 'libelle' => $data['PERIODE_LIBELLE'], ], 'typeIntervention' => [ 'id' => (int)$data['TYPE_INTERVENTION_ID'], 'code' => $data['TYPE_INTERVENTION_CODE'], 'libelle' => $data['TYPE_INTERVENTION_LIBELLE'], ], 'motifNonPaiement' => [ 'id' => (int)$data['MOTIF_NON_PAIEMENT_ID'], 'code' => $data['MOTIF_NON_PAIEMENT_CODE'], 'libelle' => $data['MOTIF_NON_PAIEMENT_LIBELLE'], ], ]; $vhId = 'e' . $data['ID']; $sId = 'e' . $data['SERVICE_ID']; $this->services[$sId]['volumesHoraires'][$vhId] = array_merge($this->services[$sId]['volumesHoraires'][$vhId], $sdata); } } if (!empty($rIds)) { $sql = " SELECT sr.id service_referentiel_id, vhr.id id, vhr.heures heures, mnp.id motif_non_paiement_id, mnp.code motif_non_paiement_code, mnp.libelle_court motif_non_paiement_code FROM volume_horaire_ref vhr JOIN service_referentiel sr ON sr.id = vhr.service_referentiel_id LEFT JOIN motif_non_paiement mnp ON mnp.id = sr.motif_non_paiement_id WHERE vhr.id IN (" . implode(',', $rIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $sdata = [ 'id' => (int)$data['ID'], 'heures' => (float)$data['HEURES'], 'motifNonPaiement' => [ 'id' => (int)$data['MOTIF_NON_PAIEMENT_ID'], 'code' => $data['MOTIF_NON_PAIEMENT_CODE'], 'libelle' => $data['MOTIF_NON_PAIEMENT_LIBELLE'], ], ]; $vhId = 'r' . $data['ID']; $sId = 'r' . $data['SERVICE_REFERENTIEL_ID']; $this->services[$sId]['volumesHoraires'][$vhId] = array_merge($this->services[$sId]['volumesHoraires'][$vhId], $sdata); } } } Loading Loading
module/Formule/src/Model/FormuleDetailsExtractor.php +191 −26 Changes for module/Formule/src/Model/FormuleDetailsExtractor.php: 191 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Formule\Entity\FormuleServiceIntervenant; use Formule\Model\Arrondisseur\Ligne; use Formule\Model\Arrondisseur\Valeur; use Formule\Service\FormuleServiceAwareTrait; use Intervenant\Entity\Db\Intervenant; use Laminas\Hydrator\ExtractionInterface; class FormuleDetailsExtractor implements ExtractionInterface Loading @@ -16,6 +17,7 @@ class FormuleDetailsExtractor implements ExtractionInterface private FormuleServiceIntervenant $fres; private Formule $formule; private Ligne $trace; private Intervenant $intervenantEntity; private array $iParams = []; private array $vhParams = []; Loading @@ -41,12 +43,15 @@ class FormuleDetailsExtractor implements ExtractionInterface } $this->trace = $this->fres->getArrondisseurTrace(); $this->intervenantEntity = $this->getServiceFormule()->getEntityManager()->find(Intervenant::class, $this->fres->getIntervenantId()); // Préparations $this->prepareTypesHetd(); $this->prepareIntervenant(); $this->prepareParams(); $this->prepareServices(); $this->prepareVolumesHoraires(); // Forge du résultat et envoi Loading @@ -60,19 +65,6 @@ class FormuleDetailsExtractor implements ExtractionInterface ]; return $result; /* Travail sur les volumes horaires */ $vhs = $formuleServiceIntervenant->getVolumesHoraires(); foreach ($vhs as $vh) { $serviceId = $vh->getService() ? 'e' . $vh->getService() : 'r' . $vh->getServiceReferentiel(); $volumeHoraireId = $vh->getVolumeHoraire() ? 'e' . $vh->getVolumeHoraire() : 'r' . $vh->getVolumeHoraireReferentiel(); $services[$serviceId]['volumesHoraires'][$volumeHoraireId] = [ 'id' => $vh->getVolumeHoraire() ?? $vh->getVolumeHoraireReferentiel(), ]; } } Loading Loading @@ -107,6 +99,15 @@ class FormuleDetailsExtractor implements ExtractionInterface private function prepareIntervenant(): void { $structure = $this->intervenantEntity->getStructure(); if ($structure) { $structure = [ 'id' => $structure->getId(), 'code' => $structure->getCode(), 'libelle' => $structure->getLibelleCourt(), ]; } $this->intervenant = [ 'id' => $this->fres->getIntervenantId(), 'anneeId' => $this->fres->getAnnee()->getId(), Loading @@ -117,7 +118,7 @@ class FormuleDetailsExtractor implements ExtractionInterface 'code' => $this->fres->getTypeIntervenant()->getCode(), 'libelle' => $this->fres->getTypeIntervenant()->getLibelle(), ], // structure 'structure' => $structure, 'heuresServiceStatutaire' => $this->fres->getHeuresServiceStatutaire(), 'heuresServiceModifie' => $this->fres->getHeuresServiceModifie(), 'depassementServiceDuSansHC' => $this->fres->isDepassementServiceDuSansHC(), Loading Loading @@ -160,9 +161,7 @@ class FormuleDetailsExtractor implements ExtractionInterface $this->services[$sname] = [ 'type' => str_starts_with($sname, 'e') ? 'enseignement' : 'referentiel', 'id' => substr($sname, 1), 'libelle' => $sname, 'volumesHoraires' => [], 'heures' => [], 'hetd' => [], ]; foreach ($this->typesHetd as $typeHetd) { Loading @@ -173,29 +172,70 @@ class FormuleDetailsExtractor implements ExtractionInterface if (!empty($eIds)) { $sql = " SELECT s.id, CASE WHEN ep.id IS NULL THEN etab.libelle || CASE WHEN s.description IS NULL THEN '' ELSE ' => ' || s.description END ELSE '[' || e.code || '] ' || e.libelle || ' => [' || ep.code || '] ' || ep.libelle END libelle s.id id, str.id structure_id, str.libelle_court structure_libelle, etab.id etablissement_id, etab.libelle etablissement_libelle, s.description description, e.id etape_id, e.code etape_code, e.libelle etape_libelle, ep.id ep_id, ep.code ep_code, ep.libelle ep_libelle, ep.taux_fi taux_fi, ep.taux_fa taux_fa, ep.taux_fc taux_fc FROM service s JOIN etablissement etab ON etab.id = s.etablissement_id LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id LEFT JOIN etape e ON e.id = ep.etape_id LEFT JOIN structure str ON str.id = ep.structure_id WHERE s.id IN (" . implode(',', $eIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $this->services['e' . $data['ID']]['libelle'] = $data['LIBELLE']; $sdata = [ 'id' => (int)$data['ID'], 'structure' => $data['STRUCTURE_ID'] ? [ 'id' => (int)$data['STRUCTURE_ID'], 'libelle' => $data['STRUCTURE_LIBELLE'], ] : null, 'etablissement' => [ 'id' => (int)$data['ETABLISSEMENT_ID'], 'libelle' => $data['ETABLISSEMENT_LIBELLE'], ], 'description' => $data['DESCRIPTION'], 'etape' => $data['ETAPE_ID'] ? [ 'id' => (int)$data['ETAPE_ID'], 'code' => $data['ETAPE_CODE'], 'libelle' => $data['ETAPE_LIBELLE'], ] : null, 'elementPedagogique' => $data['EP_ID'] ? [ 'id' => (int)$data['EP_ID'], 'code' => $data['EP_CODE'], 'libelle' => $data['EP_LIBELLE'], ] : null, 'tauxFi' => (float)$data['TAUX_FI'], 'tauxFa' => (float)$data['TAUX_FI'], 'tauxFc' => (float)$data['TAUX_FI'], ]; $this->services['e' . $data['ID']] = array_merge($this->services['e' . $data['ID']], $sdata); } } if (!empty($rIds)) { $sql = " SELECT sr.id, str.libelle_court || ' - ' || fr.libelle_court || CASE WHEN sr.commentaires IS NULL THEN '' ELSE ' ' || sr.commentaires END libelle sr.id id, str.id structure_id, str.libelle_court structure_libelle, fr.id fonction_id, fr.code fonction_code, fr.libelle_court fonction_libelle, sr.commentaires description FROM service_referentiel sr JOIN structure str ON str.id = sr.structure_id Loading @@ -204,7 +244,132 @@ class FormuleDetailsExtractor implements ExtractionInterface sr.id IN (" . implode(',', $rIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $this->services['r' . $data['ID']]['libelle'] = $data['LIBELLE']; $sdata = [ 'id' => (int)$data['ID'], 'structure' => [ 'id' => (int)$data['STRUCTURE_ID'], 'libelle' => $data['STRUCTURE_LIBELLE'], ], 'fonction' => [ 'id' => (int)$data['FONCTION_ID'], 'code' => $data['FONCTION_CODE'], 'libelle' => $data['FONCTION_LIBELLE'], ], 'description' => $data['DESCRIPTION'], ]; $this->services['r' . $data['ID']] = array_merge($this->services['r' . $data['ID']], $sdata); } } } private function prepareVolumesHoraires(): void { $eIds = []; $rIds = []; foreach ($this->trace->getSubs() as $sname => $service) { foreach ($service->getSubs() as $vh) { if ($vh->getVolumeHoraire()->getVolumeHoraire()) { $sId = 'e' . $vh->getVolumeHoraire()->getService(); $vhId = 'e' . $vh->getVolumeHoraire()->getVolumeHoraire(); $eIds[] = $vh->getVolumeHoraire()->getVolumeHoraire(); } else { $sId = 'r' . $vh->getVolumeHoraire()->getServiceReferentiel(); $vhId = 'r' . $vh->getVolumeHoraire()->getVolumeHoraireReferentiel(); $rIds[] = $vh->getVolumeHoraire()->getVolumeHoraireReferentiel(); } $this->services[$sId]['volumesHoraires'][$vhId] = [ 'type' => str_starts_with($vhId, 'e') ? 'enseignement' : 'referentiel', 'id' => substr($vhId, 1), ]; foreach ($this->typesHetd as $typeHetd) { $valeur = $service->getValeur($typeHetd); $this->services[$sId]['volumesHoraires'][$vhId]['hetd'][$typeHetd] = $this->valeurToJson($valeur); } } } if (!empty($eIds)) { $sql = " SELECT vh.service_id service_id, vh.id id, vh.heures heures, vh.horaire_debut horaire_debut, vh.horaire_fin horaire_fin, p.id periode_id, p.code periode_code, p.libelle_court periode_libelle, ti.id type_intervention_id, ti.code type_intervention_id, ti.libelle type_intervention_id, mnp.id motif_non_paiement_id, mnp.code motif_non_paiement_code, mnp.libelle_court motif_non_paiement_code FROM volume_horaire vh JOIN periode p ON p.id = vh.periode_id JOIN type_intervention ti ON ti.id = vh.type_intervention_id LEFT JOIN motif_non_paiement mnp ON mnp.id = vh.motif_non_paiement_id WHERE vh.id IN (" . implode(',', $eIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $sdata = [ 'id' => (int)$data['ID'], 'heures' => (float)$data['HEURES'], 'horaireDebut' => $data['HORAIRE_DEBUT'], 'horaireFin' => $data['HORAIRE_FIN'], 'periode' => [ 'id' => (int)$data['PERIODE_ID'], 'code' => $data['PERIODE_CODE'], 'libelle' => $data['PERIODE_LIBELLE'], ], 'typeIntervention' => [ 'id' => (int)$data['TYPE_INTERVENTION_ID'], 'code' => $data['TYPE_INTERVENTION_CODE'], 'libelle' => $data['TYPE_INTERVENTION_LIBELLE'], ], 'motifNonPaiement' => [ 'id' => (int)$data['MOTIF_NON_PAIEMENT_ID'], 'code' => $data['MOTIF_NON_PAIEMENT_CODE'], 'libelle' => $data['MOTIF_NON_PAIEMENT_LIBELLE'], ], ]; $vhId = 'e' . $data['ID']; $sId = 'e' . $data['SERVICE_ID']; $this->services[$sId]['volumesHoraires'][$vhId] = array_merge($this->services[$sId]['volumesHoraires'][$vhId], $sdata); } } if (!empty($rIds)) { $sql = " SELECT sr.id service_referentiel_id, vhr.id id, vhr.heures heures, mnp.id motif_non_paiement_id, mnp.code motif_non_paiement_code, mnp.libelle_court motif_non_paiement_code FROM volume_horaire_ref vhr JOIN service_referentiel sr ON sr.id = vhr.service_referentiel_id LEFT JOIN motif_non_paiement mnp ON mnp.id = sr.motif_non_paiement_id WHERE vhr.id IN (" . implode(',', $rIds) . ")"; $query = $this->getServiceFormule()->getEntityManager()->getConnection()->executeQuery($sql); while ($data = $query->fetchAssociative()) { $sdata = [ 'id' => (int)$data['ID'], 'heures' => (float)$data['HEURES'], 'motifNonPaiement' => [ 'id' => (int)$data['MOTIF_NON_PAIEMENT_ID'], 'code' => $data['MOTIF_NON_PAIEMENT_CODE'], 'libelle' => $data['MOTIF_NON_PAIEMENT_LIBELLE'], ], ]; $vhId = 'r' . $data['ID']; $sId = 'r' . $data['SERVICE_REFERENTIEL_ID']; $this->services[$sId]['volumesHoraires'][$vhId] = array_merge($this->services[$sId]['volumesHoraires'][$vhId], $sdata); } } } Loading