From 304b147031cfd4d0ecc54d2dbb11366c9327ee9e Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Tue, 10 Nov 2020 14:08:12 +0100
Subject: [PATCH] FIX #15317 TIME 0:05 wording in mergeController visa/avis
 workflow

---
 .../controllers/MergeController.php            | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/app/contentManagement/controllers/MergeController.php b/src/app/contentManagement/controllers/MergeController.php
index ae91c94b91c..236011607c3 100644
--- a/src/app/contentManagement/controllers/MergeController.php
+++ b/src/app/contentManagement/controllers/MergeController.php
@@ -216,7 +216,7 @@ class MergeController
         $visas = '';
         if (!empty($args['resId'])) {
             $visaWorkflow = ListInstanceModel::get([
-                'select'    => ['item_id'],
+                'select'    => ['item_id', 'process_date', 'requested_signature'],
                 'where'     => ['difflist_type = ?', 'res_id = ?'],
                 'data'      => ['VISA_CIRCUIT', $args['resId']],
                 'orderBy'   => ['listinstance_id']
@@ -224,7 +224,12 @@ class MergeController
             foreach ($visaWorkflow as $value) {
                 $user = UserModel::getById(['id' => $value['item_id'], 'select' => ['firstname', 'lastname']]);
                 $primaryentity = UserModel::getPrimaryEntityById(['id' => $value['item_id'], 'select' => ['entities.entity_label']]);
-                $visas .= "{$user['firstname']} {$user['lastname']} ({$primaryentity['entity_label']})\n";
+
+                $mode = $value['requested_signature'] ? _SIGNATORY : _VISA_USER_MIN;
+                if (!empty($value['process_date'])) {
+                    $mode .= ', ' . TextFormatModel::formatDate($value['process_date']);
+                }
+                $visas .= "{$user['firstname']} {$user['lastname']} ({$primaryentity['entity_label']}) - {$mode}\n";
             }
         }
 
@@ -232,7 +237,7 @@ class MergeController
         $opinions = '';
         if (!empty($args['resId'])) {
             $opinionWorkflow = ListInstanceModel::get([
-                'select'    => ['item_id'],
+                'select'    => ['item_id', 'process_date'],
                 'where'     => ['difflist_type = ?', 'res_id = ?'],
                 'data'      => ['AVIS_CIRCUIT', $args['resId']],
                 'orderBy'   => ['listinstance_id']
@@ -240,7 +245,12 @@ class MergeController
             foreach ($opinionWorkflow as $value) {
                 $user = UserModel::getById(['id' => $value['item_id'], 'select' => ['firstname', 'lastname']]);
                 $primaryentity = UserModel::getPrimaryEntityById(['id' => $value['item_id'], 'select' => ['entities.entity_label']]);
-                $opinions .= "{$user['firstname']} {$user['lastname']} ({$primaryentity['entity_label']})\n";
+
+                $processDate = null;
+                if (!empty($value['process_date'])) {
+                    $processDate = ' - ' . TextFormatModel::formatDate($value['process_date']);
+                }
+                $opinions .= "{$user['firstname']} {$user['lastname']} ({$primaryentity['entity_label']}) {$processDate}\n";
             }
         }
 
-- 
GitLab