Commit 54ca171c authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Migration de l'export des ecarts heures complementaires en état de sortie pour...

Migration de l'export des ecarts heures complementaires en état de sortie pour plus de personnalisation (#45807)

(cherry picked from commit f0bdad7a)
parent ec416d25
Loading
Loading
Loading
Loading
+182 −215
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_EXPORT_PILOTAGE_ECARTS_ETATS AS
SELECT
  t3.annee_id annee_id,
CREATE
OR REPLACE FORCE VIEW V_EXPORT_PILOTAGE_ECARTS_ETATS AS
SELECT t3.annee_id                             annee_id,
       t3.annee_id || '-' || (t3.annee_id + 1) annee,
       t3.etat,
       t3.type_heures_id,
@@ -10,22 +10,17 @@ SELECT
       i.id                                    intervenant_id,
       ti.libelle                              intervenant_type,
       i.source_code                           intervenant_code,
  i.prenom || ' ' || i.nom_usuel intervenant,
       i.prenom                                prenom,
       i.nom_usuel                             nom_usuel,
       t3.hetd_payables
FROM

(
SELECT
  annee_id,
FROM (SELECT annee_id,
             etat,
             type_heures_id,
             type_heures,
             structure_id,
             intervenant_id,
  sum(hetd) hetd_payables
FROM (
  SELECT
    annee_id,
             SUM(hetd) hetd_payables
      FROM (SELECT annee_id,
                   LOWER(tvh.code) || '-' || evh.code etat,
                   10 * tvh.ordre + evh.ordre         ordre,
                   type_heures_id,
@@ -33,9 +28,7 @@ FROM (
                   structure_id,
                   intervenant_id,
                   SUM(hetd)                          hetd
  FROM (
    SELECT
      i.annee_id,
            FROM (SELECT i.annee_id,
                         fr.type_volume_horaire_id,
                         fr.etat_volume_horaire_id,
                         th.id                                     type_heures_id,
@@ -43,15 +36,13 @@ FROM (
                         COALESCE(ep.structure_id, i.structure_id) structure_id,
                         fr.intervenant_id,
                         SUM(frs.heures_compl_fi)                  hetd
    FROM
           formule_resultat_service  frs
                  FROM formule_resultat_service frs
                           JOIN formule_resultat fr ON fr.id = frs.formule_resultat_id
                           JOIN service s ON s.id = frs.service_id
                           JOIN intervenant i ON i.id = fr.intervenant_id
                           JOIN type_heures th ON th.code = 'fi'
                           LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
    GROUP BY
      i.annee_id,
                  GROUP BY i.annee_id,
                           fr.type_volume_horaire_id,
                           fr.etat_volume_horaire_id,
                           th.id, th.code,
@@ -61,8 +52,7 @@ FROM (

                  UNION ALL

    SELECT
      i.annee_id,
                  SELECT i.annee_id,
                         fr.type_volume_horaire_id,
                         fr.etat_volume_horaire_id,
                         th.id                                     type_heures_id,
@@ -70,15 +60,13 @@ FROM (
                         COALESCE(ep.structure_id, i.structure_id) structure_id,
                         fr.intervenant_id,
                         SUM(frs.heures_compl_fa)                  hetd
    FROM
           formule_resultat_service  frs
                  FROM formule_resultat_service frs
                           JOIN formule_resultat fr ON fr.id = frs.formule_resultat_id
                           JOIN service s ON s.id = frs.service_id
                           JOIN intervenant i ON i.id = fr.intervenant_id
                           JOIN type_heures th ON th.code = 'fa'
                           LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
    GROUP BY
      i.annee_id,
                  GROUP BY i.annee_id,
                           fr.type_volume_horaire_id,
                           fr.etat_volume_horaire_id,
                           th.id, th.code,
@@ -88,8 +76,7 @@ FROM (

                  UNION ALL

    SELECT
      i.annee_id,
                  SELECT i.annee_id,
                         fr.type_volume_horaire_id,
                         fr.etat_volume_horaire_id,
                         th.id                                     type_heures_id,
@@ -97,15 +84,13 @@ FROM (
                         COALESCE(ep.structure_id, i.structure_id) structure_id,
                         fr.intervenant_id,
                         SUM(frs.heures_compl_fc)                  hetd
    FROM
           formule_resultat_service  frs
                  FROM formule_resultat_service frs
                           JOIN formule_resultat fr ON fr.id = frs.formule_resultat_id
                           JOIN service s ON s.id = frs.service_id
                           JOIN intervenant i ON i.id = fr.intervenant_id
                           JOIN type_heures th ON th.code = 'fc'
                           LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
    GROUP BY
      i.annee_id,
                  GROUP BY i.annee_id,
                           fr.type_volume_horaire_id,
                           fr.etat_volume_horaire_id,
                           th.id, th.code,
@@ -115,38 +100,33 @@ FROM (

                  UNION ALL

    SELECT
      i.annee_id,
                  SELECT i.annee_id,
                         fr.type_volume_horaire_id,
                         fr.etat_volume_horaire_id,
                         th.id                              type_heures_id,
                         th.code                            type_heures,
                         sr.structure_id,
                         fr.intervenant_id,
      sum( frsr.heures_compl_referentiel ) hetd
    FROM
           formule_resultat_service_ref  frsr
                         SUM(frsr.heures_compl_referentiel) hetd
                  FROM formule_resultat_service_ref frsr
                           JOIN formule_resultat fr ON fr.id = frsr.formule_resultat_id
                           JOIN service_referentiel sr ON sr.id = frsr.service_referentiel_id
                           JOIN intervenant i ON i.id = fr.intervenant_id
                           JOIN type_heures th ON th.code = 'referentiel'
    GROUP BY
      i.annee_id,
                  GROUP BY i.annee_id,
                           fr.type_volume_horaire_id,
                           fr.etat_volume_horaire_id,
                           th.id, th.code,
                           fr.intervenant_id,
      sr.structure_id
  ) t1
                           sr.structure_id) t1
                     JOIN type_volume_horaire tvh ON tvh.id = t1.type_volume_horaire_id
                     JOIN etat_volume_horaire evh ON evh.id = t1.etat_volume_horaire_id
  GROUP BY
    annee_id, tvh.code, evh.code, tvh.ordre, evh.ordre, type_heures_id, type_heures, structure_id, intervenant_id
            GROUP BY annee_id, tvh.code, evh.code, tvh.ordre, evh.ordre, type_heures_id, type_heures, structure_id,
                     intervenant_id

            UNION ALL

  SELECT
    annee_id,
            SELECT annee_id,
                   etat,
                   ordre,
                   type_heures_id,
@@ -154,9 +134,7 @@ FROM (
                   structure_id,
                   intervenant_id,
                   SUM(hetd) hetd
  FROM (
    SELECT
      i.annee_id,
            FROM (SELECT i.annee_id,
                         'demande-mise-en-paiement'                                 etat,
                         90                                                         ordre,
                         th.id                                                      type_heures_id,
@@ -164,25 +142,23 @@ FROM (
                         COALESCE(sr.structure_id, ep.structure_id, i.structure_id) structure_id,
                         i.id                                                       intervenant_id,
                         mep.heures                                                 hetd
    FROM
                mise_en_paiement              mep
                  FROM mise_en_paiement mep
                           JOIN type_heures th ON th.id = mep.type_heures_id
                           JOIN centre_cout cc ON cc.id = mep.centre_cout_id
                           LEFT JOIN formule_resultat_service frs ON frs.id = mep.formule_res_service_id
                           LEFT JOIN formule_resultat_service_ref frsr ON frsr.id = mep.formule_res_service_ref_id
      LEFT JOIN formule_resultat               fr ON fr.id = COALESCE(frs.formule_resultat_id, frsr.formule_resultat_id)
                           LEFT JOIN formule_resultat fr
                                     ON fr.id = COALESCE(frs.formule_resultat_id, frsr.formule_resultat_id)
                           LEFT JOIN service s ON s.id = frs.service_id
                           LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
                           LEFT JOIN service_referentiel sr ON sr.id = frsr.service_referentiel_id
                           LEFT JOIN intervenant i ON i.id = fr.intervenant_id
    WHERE
      mep.histo_destruction IS NULL
                  WHERE mep.histo_destruction IS NULL
                    AND th.eligible_extraction_paie = 1

                  UNION ALL

    SELECT
      i.annee_id,
                  SELECT i.annee_id,
                         'mise-en-paiement'                                         etat,
                         91                                                         ordre,
                         th.id                                                      type_heures_id,
@@ -190,35 +166,26 @@ FROM (
                         COALESCE(sr.structure_id, ep.structure_id, i.structure_id) structure_id,
                         i.id                                                       intervenant_id,
                         mep.heures                                                 hetd
    FROM
                mise_en_paiement              mep
                  FROM mise_en_paiement mep
                           JOIN type_heures th ON th.id = mep.type_heures_id
                           JOIN centre_cout cc ON cc.id = mep.centre_cout_id
                           LEFT JOIN formule_resultat_service frs ON frs.id = mep.formule_res_service_id
                           LEFT JOIN formule_resultat_service_ref frsr ON frsr.id = mep.formule_res_service_ref_id
      LEFT JOIN formule_resultat               fr ON fr.id = COALESCE(frs.formule_resultat_id, frsr.formule_resultat_id)
                           LEFT JOIN formule_resultat fr
                                     ON fr.id = COALESCE(frs.formule_resultat_id, frsr.formule_resultat_id)
                           LEFT JOIN service s ON s.id = frs.service_id
                           LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
                           LEFT JOIN service_referentiel sr ON sr.id = frsr.service_referentiel_id
                           LEFT JOIN intervenant i ON i.id = fr.intervenant_id
    WHERE
      mep.histo_destruction IS NULL
                  WHERE mep.histo_destruction IS NULL
                    AND th.eligible_extraction_paie = 1
      AND mep.PERIODE_PAIEMENT_ID IS NOT NULL
  ) t1
  GROUP BY
    annee_id, etat, ordre, type_heures_id, type_heures, structure_id, intervenant_id
) t2
GROUP BY
  annee_id,
  etat, ordre
                    AND mep.periode_paiement_id IS NOT NULL) t1
            GROUP BY annee_id, etat, ordre, type_heures_id, type_heures, structure_id, intervenant_id) t2
      GROUP BY annee_id, etat, ordre
             , type_heures_id, type_heures
             , structure_id
             , intervenant_id
ORDER BY
  annee_id, ordre

) t3
      ORDER BY annee_id, ordre) t3
         JOIN intervenant i ON i.id = t3.intervenant_id
         JOIN statut si ON si.id = i.statut_id
         JOIN type_intervenant ti ON ti.id = si.type_intervenant_id
+51 −0
Original line number Diff line number Diff line
@@ -70,6 +70,57 @@ return [
    "CODE_ORIGINE": {
        "libelle": "Code origine"
    }
}',
    ],
    [
        'CODE'           => 'ecarts-heures-complementaire',
        'LIBELLE'        => 'Ecarts heures complémentaires',
        'PDF_TRAITEMENT' => null,
        'AUTO_BREAK'     => false,
        'REQUETE'        => 'SELECT * FROM v_export_pilotage_ecarts_etats',
        'CSV_PARAMS'     => '{
    "INTERVENANT_TYPE_ID": {
        "visible": false
    },
    "STRUCTURE_ID": {
        "visible": false
    },
    "TYPE_HEURES_ID": {
        "visible": false
    },
    "INTERVENANT_ID": {
        "visible": false
    },
    "ANNEE_ID": {
        "visible": false
    },
    "ANNEE": {
        "libelle": "Année"
    },
    "ETAT": {
        "libelle": "Etat"
    },
    "TYPE_HEURES": {
        "libelle": "Type heures"
    },
    "STRUCTURE": {
        "libelle": "Structure"
    },
     "INTERVENANT_TYPE": {
        "libelle": "Type intervenant"
    },
     "INTERVENANT_CODE": {
        "libelle": "Code intervenant"
    },
     "NOM_USUEL": {
        "libelle": "Nom"
    },
    "PRENOM": {
        "libelle": "Prénom"
    },
     "HETD_PAYABLES": {
        "libelle": "HETD payables"
    }
}',
    ],
    [
+17 −19
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

namespace Application\Controller;

use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\EtatSortieServiceAwareTrait;
use Application\Service\Traits\PilotageServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;

@@ -11,39 +13,35 @@ use UnicaenApp\View\Model\CsvModel;
 */
class PilotageController extends AbstractController
{
    use ContextServiceAwareTrait;
    use EtatSortieServiceAwareTrait;
    use PilotageServiceAwareTrait;




    public function indexAction()
    {
        return [];
    }



    public function ecartsEtatsACtion()
    {

        $csvModel = new CsvModel();
        $csvModel->setHeader([
            'Année',
            'État',
            'Type d\'heures',
            'Structure',
            'Intervenant (type)',
            'Intervenant (code)',
            'Intervenant',
            'HETD payables'
        ]);

        $data = $this->getServicePilotage()->getEcartsEtats();
        foreach ($data as $d) {
            $csvModel->addLine($d);
        //Contexte année et structure
        $annee = $this->getServiceContext()->getAnnee();
        $structure = $this->getServiceContext()->getStructure();

        $filters['ANNEE_ID'] = $annee->getId();
        if ($structure) {
            $filters['STRUCTURE_ID'] = $structure->getId();
        }
        $csvModel->setFilename('pilotage-ecarts-etats.csv');
        //On récupére l'état de sortie pour l'export des agréments
        $etatSortie = $this->getServiceEtatSortie()->getRepo()->findOneBy(['code' => 'ecarts-heures-complementaire']);
        $csvModel = $this->getServiceEtatSortie()->genererCsv($etatSortie, $filters);
        $csvModel->setFilename('ecarts-heures-complementaires-' . $annee->getId() . '.csv');


        return $csvModel;

    }
}
 No newline at end of file