From d76617af9529e1d07612accc94f232d5a7d98e1a Mon Sep 17 00:00:00 2001
From: Quentin RIBAC <quentin.ribac@xelians.fr>
Date: Thu, 18 Nov 2021 12:23:00 +0100
Subject: [PATCH] FEAT #14839 TIME 0:20 move multigest UID from history to
 technical informations

---
 .../multigest/controllers/MultigestController.php        | 3 +--
 src/app/resource/controllers/ResController.php           | 6 +++++-
 .../technical-information.component.ts                   | 9 +++++++++
 src/lang/lang-en.json                                    | 6 +++++-
 src/lang/lang-fr.json                                    | 6 +++++-
 5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/app/external/multigest/controllers/MultigestController.php b/src/app/external/multigest/controllers/MultigestController.php
index fc07e0197bb..aca70557642 100644
--- a/src/app/external/multigest/controllers/MultigestController.php
+++ b/src/app/external/multigest/controllers/MultigestController.php
@@ -788,8 +788,7 @@ class MultigestController
             AttachmentModel::update(['set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], 'data' => [$attachment['res_id']]]);
         }
 
-        $message = " (envoyé avec l’UID MultiGest {$multigestUIDs['document']})";
-        return ['history' => $message];
+        return true;
     }
 
     public static function getResourceField(array $document, string $field, array $rawContacts) {
diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php
index b7e8420dd96..ce9d113794e 100755
--- a/src/app/resource/controllers/ResController.php
+++ b/src/app/resource/controllers/ResController.php
@@ -119,7 +119,7 @@ class ResController extends ResourceControlController
 
         $queryParams = $request->getQueryParams();
 
-        $select = ['model_id', 'category_id', 'priority', 'status', 'subject', 'alt_identifier', 'process_limit_date', 'closing_date', 'creation_date', 'modification_date', 'integrations', 'retention_frozen', 'binding'];
+        $select = ['model_id', 'category_id', 'priority', 'status', 'subject', 'alt_identifier', 'process_limit_date', 'closing_date', 'creation_date', 'modification_date', 'integrations', 'retention_frozen', 'binding', 'external_id'];
         if (empty($queryParams['light'])) {
             $select = array_merge($select, ['type_id', 'typist', 'destination', 'initiator', 'confidentiality', 'doc_date', 'admission_date', 'departure_date', 'barcode', 'custom_fields']);
         }
@@ -257,6 +257,10 @@ class ResController extends ResourceControlController
             $formattedData['registeredMail_deposit_id']   = $registeredMail['deposit_id'];
         }
 
+        if (PrivilegeController::hasPrivilege(['privilegeId' => 'view_technical_infos', 'userId' => $GLOBALS['id']])) {
+            $formattedData['externalId'] = json_decode($document['external_id'], true);
+        }
+
         return $response->withJson($formattedData);
     }
 
diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.ts b/src/frontend/app/indexation/technical-information/technical-information.component.ts
index 6a1e8f6e2a3..0f1080224ce 100644
--- a/src/frontend/app/indexation/technical-information/technical-information.component.ts
+++ b/src/frontend/app/indexation/technical-information/technical-information.component.ts
@@ -113,6 +113,15 @@ export class TechnicalInformationComponent implements OnInit {
                         };
                     }
                 });
+                Object.keys(data.externalId).forEach(key => {
+                    if (this.functions.empty(this.techData[key])) {
+                        this.techData[key] = {
+                            label: key,
+                            value: data.externalId[key],
+                            icon: 'fa fa-key'
+                        };
+                    }
+                });
             }),
             catchError((err: any) => {
                 this.notify.handleSoftErrors(err);
diff --git a/src/lang/lang-en.json b/src/lang/lang-en.json
index af6f1606543..3435cd48544 100644
--- a/src/lang/lang-en.json
+++ b/src/lang/lang-en.json
@@ -2562,5 +2562,9 @@
     "documentHasNoChrono": "This document has no chrono identifier",
     "documentNotFoundOnDocserver": "Document not found on document server",
     "docserverDocumentNotReadable": "Document could not be read from document server",
-    "soapClientCreationError": "Error while initiating SOAP client"
+    "soapClientCreationError": "Error while initiating SOAP client",
+    "mailevaSendingId": "Maileva sending identifier",
+    "signatureBookId": "ID in external signature book",
+    "m2m": "M2M identifier",
+    "multigestId": "Multigest Unique Identifier (UID)"
 }
diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json
index af7db35a754..5caefd63eed 100644
--- a/src/lang/lang-fr.json
+++ b/src/lang/lang-fr.json
@@ -2567,5 +2567,9 @@
     "documentHasNoChrono": "Ce courrier n’a pas de numéro chrono",
     "documentNotFoundOnDocserver": "Fichier introuvable dans l’espace de stockage",
     "docserverDocumentNotReadable": "Fichier illisible sur l’espace de stockage",
-    "soapClientCreationError": "Erreur de lancement de la communication SOAP"
+    "soapClientCreationError": "Erreur de lancement de la communication SOAP",
+    "mailevaSendingId": "Identifiant d’envoi Maileva",
+    "m2m": "Identifiant M2M",
+    "signatureBookId": "Identifiant dans le parapheur externe",
+    "multigestId": "Identifiant unique (UID) Multigest"
 }
-- 
GitLab