From 81a6137e9ffec0aca45be604eb0c53815f27952c Mon Sep 17 00:00:00 2001
From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr>
Date: Mon, 5 Dec 2022 14:47:01 +0100
Subject: [PATCH] Type de correspondance OK

---
 documentation/release/3.1.0.md                         |  5 +++--
 .../Entity/Db/MacroContent/AgentMacroTrait.php         |  7 ++++++-
 .../Entity/Db/MacroContent/FichePosteMacroTrait.php    |  2 +-
 .../Application/View/Helper/partial/agent-grade.phtml  |  6 ++----
 .../view/application/agent/partial/tutorat.phtml       | 10 ++++++++--
 .../Carriere/View/Helper/partial/correspondance.phtml  |  2 +-
 6 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/documentation/release/3.1.0.md b/documentation/release/3.1.0.md
index 550940919..9bc89ae59 100644
--- a/documentation/release/3.1.0.md
+++ b/documentation/release/3.1.0.md
@@ -6,11 +6,12 @@
 **Changements**
 
 * Ajout des types de correspondance
-* 
+* Ajout d'un viewhelper pour l'affichage des correspondances
+* Remplacement pour affichage du type en plus de la correspondance
 
 **Modifications de la base de donnée**
 
-Afin de modéliser les différents types de correspondances il est nécessaire de proposer dans la source de données des données ressamblant à la vue suivante (V_CORRESPONDANCE_TYPE).
+Afin de modéliser les différents types de correspondances, il est nécessaire de proposer dans la source de données des données ressamblant à la vue suivante (V_CORRESPONDANCE_TYPE).
 Ces données seront importées et référencées dans les correspondances.
 
 | column        | type          | contrainte |
diff --git a/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php b/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php
index d6161ab53..ff6de5954 100644
--- a/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php
+++ b/module/Application/src/Application/Entity/Db/MacroContent/AgentMacroTrait.php
@@ -124,7 +124,12 @@ trait AgentMacroTrait
         foreach ($grades as $grade) {
 //            $texte .= "<li>";
             $grade_libelle = $grade->getCorps()->getLibelleLong();
-            $grade_bap = ($grade->getBap() !== null)?$grade->getBap()->getCategorie():"";
+            $correspondance = $grade->getBap();
+            if ($correspondance) {
+                $grade_bap = $correspondance->getType()->getLibelleCourt(). " " .$correspondance->getLibelleCourt();
+            } else {
+                $grade_bap = "";
+            }
             $texte .= $grade_libelle . " ". $grade_bap;
             $texte .= " (";
             if($grade->estFini()) {
diff --git a/module/Application/src/Application/Entity/Db/MacroContent/FichePosteMacroTrait.php b/module/Application/src/Application/Entity/Db/MacroContent/FichePosteMacroTrait.php
index 899846558..c7dfb6480 100644
--- a/module/Application/src/Application/Entity/Db/MacroContent/FichePosteMacroTrait.php
+++ b/module/Application/src/Application/Entity/Db/MacroContent/FichePosteMacroTrait.php
@@ -392,7 +392,7 @@ trait FichePosteMacroTrait {
         if ($metier === null) return $texte;
         if ($metier->getCategorie())            $texte .= "Catégorie : " . $metier->getCategorie()->getCode() . "<br/>";
         if (true /**$metier->getNiveau()**/)    $texte .= "Corps : " . "Lien manquant" . "<br/>";
-        if (true /**$metier->getBap()**/)       $texte .= "BAP : " . "Lien manquant" . "<br/>";
+        if (true /**$metier->getBap()**/)       $texte .= "Correspondance : " . "Lien manquant" . "<br/>";
         return $texte;
     }
 
diff --git a/module/Application/src/Application/View/Helper/partial/agent-grade.phtml b/module/Application/src/Application/View/Helper/partial/agent-grade.phtml
index bb6002a5a..976d187dd 100644
--- a/module/Application/src/Application/View/Helper/partial/agent-grade.phtml
+++ b/module/Application/src/Application/View/Helper/partial/agent-grade.phtml
@@ -63,7 +63,7 @@ $displayCorrespondance = (isset($options['correspondance']) and $options['corres
     <?php endif; ?>
 
     <?php if ($displayCorrespondance) : ?>
-        <?php echo $grade->getBap()->getCategorie(); ?>
+        <?php echo $this->correspondance($grade->getBap()); ?>
     <?php endif; ?>
 
     <?php if ($displayTemoin) : ?>
@@ -95,9 +95,7 @@ $displayCorrespondance = (isset($options['correspondance']) and $options['corres
             <dt class="col-md-3"> Correspondance</dt>
             <dd class="col-md-9">
                 <?php if ($grade->getBap()) : ?>
-                    BAP
-                    <?php echo $grade->getBap()->getCategorie(); ?> -
-                    <?php echo $grade->getBap()->getLibelleLong(); ?>
+                    <?php echo $this->correspondance($grade->getBap()); ?>
                 <?php else : ?>
                     Non renseignée
                 <?php endif; ?>
diff --git a/module/Application/view/application/agent/partial/tutorat.phtml b/module/Application/view/application/agent/partial/tutorat.phtml
index 1316124c4..0648ad048 100644
--- a/module/Application/view/application/agent/partial/tutorat.phtml
+++ b/module/Application/view/application/agent/partial/tutorat.phtml
@@ -135,7 +135,7 @@ $canDetruirePPP     = $canAjouterPPP;
     <thead>
     <tr>
         <th> Agent </th>
-        <th> BAP </th>
+        <th> Correspondance </th>
         <th> Corps </th>
         <th> Période </th>
         <th> Compléments </th>
@@ -148,7 +148,13 @@ $canDetruirePPP     = $canAjouterPPP;
     <?php foreach ($accompagnements as $accompagnement) : ?>
         <tr <?php if ($accompagnement->estHistorise()) echo " class='historise' "; ?>>
             <td> <?php echo $accompagnement->getCible()->getDenomination(); ?> </td>
-            <td> <?php echo ($accompagnement->getBap())?$accompagnement->getBap()->getLibelleCourt():"Aucun"; ?> </td>
+            <td>
+                <?php if ($accompagnement->getBap()) : ?>
+                    <?php echo $this->correspondance($accompagnement->getBap()); ?>
+                <?php else : ?>
+                    Aucun
+                <?php endif; ?>
+            </td>>
             <td> <?php echo ($accompagnement->getCorps())?$accompagnement->getCorps()->getLibelleCourt():"Aucun"; ?> </td>
             <td>
                 <?php echo $accompagnement->getDateDebutToString(); ?>
diff --git a/module/Carriere/src/Carriere/View/Helper/partial/correspondance.phtml b/module/Carriere/src/Carriere/View/Helper/partial/correspondance.phtml
index c24b2ad39..82c6c96e2 100644
--- a/module/Carriere/src/Carriere/View/Helper/partial/correspondance.phtml
+++ b/module/Carriere/src/Carriere/View/Helper/partial/correspondance.phtml
@@ -26,7 +26,7 @@ use Carriere\Entity\Db\Correspondance;
     <?php endif; ?>
     -
     <span title="<?php echo $correspondance->getLibelleLong(); ?>">
-        <?php echo $correspondance->getCategorie(); ?>
+        <?php echo $correspondance->getLibelleCourt(); ?>
     </span>
 <?php endif; ?>
 
-- 
GitLab