Commit 3ee75d6d authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Migration de l'export des agrements en état de sortie pour le rendre...

Migration de l'export des agrements en état de sortie pour le rendre paramétrable par les établissements.
parent ca0d60b2
Loading
Loading
Loading
Loading
+6 −8
Changes for data/ddl/view/V_AGREMENT_EXPORT_CSV.sql: 6 added lines, 8 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_AGREMENT_EXPORT_CSV AS
CREATE
OR REPLACE FORCE VIEW V_AGREMENT_EXPORT_CSV AS
  WITH heures_s AS (
  SELECT
    i.id                                      intervenant_id,
@@ -26,14 +27,13 @@ WITH heures_s AS (
    ep.structure_id,
    i.structure_id
)
SELECT
SELECT a.libelle                                                 annee,
       a.id                                                      annee_id,
       i.id                                                      intervenant_id,
       s2.id                                                     intervenant_structure_id,
       s2.libelle_court                                          intervenant_structure_libelle,
       s.id                                                      structure_id,

  a.libelle                                                                   annee,
       s.libelle_court                                           structure_libelle,
       i.code                                                    intervenant_code,
       i.nom_usuel                                               intervenant_nom_usuel,
@@ -56,15 +56,13 @@ SELECT
       COALESCE(heures_s.total, fr.total)                        hetd_total,




       tagr.libelle                                              type_agrement,
       CASE WHEN agr.id IS NULL THEN 0 ELSE 1 END                agree,
       CASE WHEN agr.id IS NULL THEN 'En attente' ELSE 'Oui' END agree_txt,
       agr.date_decision                                         date_decision,
       u.display_name                                            modificateur,
       agr.histo_modification                                    date_modification
FROM
            tbl_agrement             ta
FROM tbl_agrement ta
         JOIN intervenant i ON i.id = ta.intervenant_id
         JOIN statut si ON si.id = i.statut_id
         JOIN annee a ON a.id = ta.annee_id
@@ -84,4 +82,4 @@ FROM
    AND fr.etat_volume_horaire_id = evh.id

         LEFT JOIN heures_s ON heures_s.intervenant_id = i.id
                                       AND heures_s.structure_id = s.id
 No newline at end of file
    AND heures_s.structure_id = s.id;
 No newline at end of file
+32 −0
Changes for data/etats_sortie.php: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -55,6 +55,38 @@ return [
    "LIBELLE": {
        "libelle": "Libellé"
    }
}',
    ],
    [
        'CODE'           => 'export-agrement',
        'LIBELLE'        => 'Export Agrément',
        'PDF_TRAITEMENT' => null,
        'AUTO_BREAK'     => false,
        'REQUETE'        => 'SELECT * FROM v_agrement_export_csv',
        'CSV_PARAMS'     => '{
    "ANNEE_ID"            : { "visible": false },
    "INTERVENANT_ID"            : { "visible": false },
    "INTERVENANT_STRUCTURE_ID"            : { "visible": false },
    "STRUCTURE_ID"            : { "visible": false },
    "AGREE"            : { "visible": false },
    "ANNEE": { "libelle": "Année"},
    "INTERVENANT_CODE": { "libelle": "Code intervenant"},
    "STRUCTURE_LIBELLE": {"libelle": "Structure hiérarchique"},
    "INTERVENANT_STRUCTURE_LIBELLE": {"libelle": "Structure d\'affectation"},
    "INTERVENANT_NOM_USUEL": {"libelle": "Nom usuel"},
    "INTERVENANT_NOM_PATRONYMIQUE": {"libelle": "Nom patronymique"},
    "INTERVENANT_PRENOM": {"libelle": "Prénom"},
    "INTERVENANT_STATUT_LIBELLE": {"libelle": "Statut"},
    "DISCIPLINE": {"libelle": "Discipline"},
    "HETD_FI": {"libelle": "HETD (FI)", "type": "float"},
    "HETD_FA": {"libelle": "HETD (FA)","type": "float"},
    "HETD_FC": {"libelle": "HETD (FC)","type": "float"},
    "HETD_TOTAL": {"libelle": "HETD (Total)","type": "float"},
    "TYPE_AGREMENT": {"libelle": "Type d\'agrément"},
    "AGREE_TXT": {"libelle": "Agréé"},
    "DATE_DECISION": {"libelle": "Date de décision"},
    "MODIFICATEUR": {"libelle": "Modificateur"},
    "DATE_MODIFICATION": {"libelle": "Date de modification"}
}',
    ],
    [
+12 −14
Changes for module/Application/src/Controller/AgrementController.php: 12 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Application\Form\Agrement\Traits\SaisieAwareTrait;
use Application\Provider\Privilege\Privileges;
use Application\Service\AgrementService;
use Application\Service\Traits\AgrementServiceAwareTrait;
use Application\Service\Traits\EtatSortieServiceAwareTrait;
use Application\Service\Traits\IntervenantServiceAwareTrait;
use Application\Service\Traits\ServiceServiceAwareTrait;
use Application\Service\Traits\StructureServiceAwareTrait;
@@ -36,6 +37,7 @@ class AgrementController extends AbstractController
    use SaisieAwareTrait;
    use StructureServiceAwareTrait;
    use WorkflowServiceAwareTrait;
    use EtatSortieServiceAwareTrait;


    /**
@@ -53,7 +55,6 @@ class AgrementController extends AbstractController
    }



    /**
     * Page de menu des agréments
     */
@@ -63,7 +64,6 @@ class AgrementController extends AbstractController
    }



    /**
     * Détails d'un agrément.
     *
@@ -77,7 +77,6 @@ class AgrementController extends AbstractController
    }



    /**
     * Liste des agréments d'un type donné, concernant un intervenant.
     */
@@ -139,7 +138,6 @@ class AgrementController extends AbstractController
    }



    public function saisirAction()
    {
        $this->initFilters();
@@ -163,7 +161,6 @@ class AgrementController extends AbstractController
    }



    public function saisirLotAction()
    {
        $typeAgrement = $this->getEvent()->getParam('typeAgrement');
@@ -264,7 +261,6 @@ class AgrementController extends AbstractController
    }



    public function supprimerAction()
    {
        /** @var Agrement $agrement */
@@ -281,24 +277,26 @@ class AgrementController extends AbstractController
    }



    public function exportCsvAction()
    {
        //Contexte année et structure
        $annee = $this->getServiceContext()->getAnnee();
        $role  = $this->getServiceContext()->getSelectedIdentityRole();
        $structure = $this->getServiceContext()->getStructure();

        $data = $this->getServiceAgrement()->getExportCsvData($annee, $role->getStructure());
        $filters['ANNEE_ID'] = $annee->getId();
        if ($structure) {
            $filters['STRUCTURE_ID'] = $structure->getId();
        }
        //On récupére l'état de sortie pour l'export des agréments
        $etatSortie = $this->getServiceEtatSortie()->getRepo()->findOneBy(['code' => 'export-agrement']);
        $csvModel = $this->getServiceEtatSortie()->genererCsv($etatSortie, $filters);
        $csvModel->setFilename('export-agrement.csv');

        $csvModel = new CsvModel();
        $csvModel->setHeader($data['head']);
        $csvModel->addLines($data['data']);
        $csvModel->setFilename('agrements-' . $annee . '.csv');

        return $csvModel;
    }



    private function updateTableauxBord(Intervenant $intervenant)
    {
        //@alecourtes : Récupérer les intervenants avec le même code car l'agrement peut être valide