From 7ed4fafc895b5029d249931b90113a4bc254a60d Mon Sep 17 00:00:00 2001
From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr>
Date: Wed, 27 Nov 2024 14:17:33 +0100
Subject: [PATCH] Ajout de colonne dans l'export des inscriptions

---
 module/Application/view/layout/layout.phtml               | 2 +-
 .../src/Formation/Controller/ExportController.php         | 6 ++++--
 .../Formation/Service/Inscription/InscriptionService.php  | 3 +++
 .../view/formation/export/extraction-inscription.phtml    | 8 ++++++--
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/module/Application/view/layout/layout.phtml b/module/Application/view/layout/layout.phtml
index 9919086e..9aa87c6f 100644
--- a/module/Application/view/layout/layout.phtml
+++ b/module/Application/view/layout/layout.phtml
@@ -134,7 +134,7 @@ echo $this->doctype();
         border: 1px solid grey;
         position: fixed;
         bottom : 120px;
-        right : 100px;
+        right : 50px;
         background: white;
         z-index:1050 !important;
     }
diff --git a/module/Formation/src/Formation/Controller/ExportController.php b/module/Formation/src/Formation/Controller/ExportController.php
index 1cc7a89b..b1c4aa3d 100644
--- a/module/Formation/src/Formation/Controller/ExportController.php
+++ b/module/Formation/src/Formation/Controller/ExportController.php
@@ -45,7 +45,7 @@ class ExportController extends AbstractActionController {
         } else { $inscriptions = null; }
 
         if ($csv) {
-            $headers = ["stagiaire", "affectation", "action de formation", "domaines", "période", "Au plan de formation"];
+            $headers = ["stagiaire_id", "stagiaire", "affectation", "action de formation", "domaines", "début", "fin", "Au plan de formation"];
             $records = [];
             foreach ($inscriptions as $inscription) {
                 $stagiaire = $inscription->getIndividu();
@@ -59,11 +59,13 @@ class ExportController extends AbstractActionController {
                 $action = $session->getFormation();
                 $domaines = array_map(function (Domaine $domaine) {return $domaine->getLibelle();}, $action->getDomaines());
                 $records[] = [
+                    "stagiaire_id" => $stagiaire->getId(),
                     "stagiaire" => $stagiaire->getDenomination(false),
                     "affectation" => $affecation,
                     "action de formation" => $action->getLibelle(),
                     "domaines" => implode("\n",$domaines),
-                    "période" => $session->getPeriode(),
+                    "debut" => $session->getDebut(true)?$session->getDebut(true)->format("d/m/Y"):"",
+                    "fin" => $session->getFin(true)?$session->getFin(true)->format("d/m/Y"):"",
                     "Au plan de formation" => (!empty($session->getDemandesExternes())) ? "Hors plan de formation":"Dans le plan de formation",
                 ];
             }
diff --git a/module/Formation/src/Formation/Service/Inscription/InscriptionService.php b/module/Formation/src/Formation/Service/Inscription/InscriptionService.php
index 56ac2fd8..ffec255e 100644
--- a/module/Formation/src/Formation/Service/Inscription/InscriptionService.php
+++ b/module/Formation/src/Formation/Service/Inscription/InscriptionService.php
@@ -275,6 +275,9 @@ class InscriptionService
         return $result;
     }
 
+    /**
+     * @return Inscription[]
+     */
     public function getInscriptionsWithFiltre(array $params)
     {
         $qb = $this->createQueryBuilder()->orderBy('inscription.histoCreation', 'asc');
diff --git a/module/Formation/view/formation/export/extraction-inscription.phtml b/module/Formation/view/formation/export/extraction-inscription.phtml
index 8bf9cbce..f9322661 100644
--- a/module/Formation/view/formation/export/extraction-inscription.phtml
+++ b/module/Formation/view/formation/export/extraction-inscription.phtml
@@ -130,12 +130,14 @@ $this->headTitle("Extraction d'inscription");
     <table class="table table-condensed" id="inscriptions">
         <thead>
         <tr>
+            <th> Id </th>
             <th> Stagiaire </th>
             <th> Affectation </th>
     <!--        <th> État de l'inscription</th>-->
             <th> Action de formation </th>
             <th> Domaine </th>
-            <th> Période </th>
+            <th> Début </th>
+            <th> Fin </th>
     <!--        <th> État de la sesion</th>-->
     <!--        <th> Liste </th>-->
             <th> Au plan de formation</th>
@@ -155,6 +157,7 @@ $this->headTitle("Extraction d'inscription");
                 $action = $session->getFormation();
             ?>
             <tr>
+                <td> <?php echo $stagiaire->getId(); ?> </td>
                 <td data-order="<?php echo $stagiaire->getDenomination(false); ?>">
                     <?php echo $stagiaire->getDenomination(); ?>
                 </td>
@@ -171,7 +174,8 @@ $this->headTitle("Extraction d'inscription");
                         <?php endforeach; ?>
                     <?php endif; ?>
                 </td>
-                <td> <?php echo $session->getPeriode(); ?> </td>
+                <td> <?php echo ($session->getDebut(true))?->format('d/m/Y'); ?> </td>
+                <td> <?php echo ($session->getFin(true))?->format('d/m/Y'); ?> </td>
     <!--            <td> --><?php //echo $this->etatinstance($session->getEtatActif()); ?><!--</td>-->
     <!--            <td> --><?php //echo $inscription->getListe(); ?><!-- </td>-->
                 <td>
-- 
GitLab