From 0ec7f7d8fc333b53b16f7015504fc3d24fbeecc8 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Wed, 4 Mar 2020 14:26:11 +0100
Subject: [PATCH] FEAT #13217 TIME 0:05 Fix items

---
 src/app/entity/controllers/ListTemplateController.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/app/entity/controllers/ListTemplateController.php b/src/app/entity/controllers/ListTemplateController.php
index 5f0e644b8cb..011c8397a09 100755
--- a/src/app/entity/controllers/ListTemplateController.php
+++ b/src/app/entity/controllers/ListTemplateController.php
@@ -327,11 +327,11 @@ class ListTemplateController
                     $listTemplateItems[$itemKey]['labelToDisplay'] = "{$user['firstname']} {$user['lastname']}";
                     $listTemplateItems[$itemKey]['descriptionToDisplay'] = UserModel::getPrimaryEntityById(['id' => $value['item_id'], 'select' => ['entity_label']])['entity_label'];
 
-                    $listTemplateItems[$key]['hasPrivilege'] = true;
+                    $listTemplateItems[$itemKey]['hasPrivilege'] = true;
                     if ($listTemplate['type'] == 'visaCircuit' && !PrivilegeController::hasPrivilege(['privilegeId' => 'visa_documents', 'userId' => $value['item_id']]) && !PrivilegeController::hasPrivilege(['privilegeId' => 'sign_document', 'userId' => $value['item_id']])) {
-                        $listTemplateItems[$key]['hasPrivilege'] = false;
+                        $listTemplateItems[$itemKey]['hasPrivilege'] = false;
                     } elseif ($listTemplate['type'] == 'opinionCircuit' && !PrivilegeController::hasPrivilege(['privilegeId' => 'avis_documents', 'userId' => $value['item_id']])) {
-                        $listTemplateItems[$key]['hasPrivilege'] = false;
+                        $listTemplateItems[$itemKey]['hasPrivilege'] = false;
                     }
 
                     $externalId = json_decode($user['external_id'], true);
@@ -343,6 +343,7 @@ class ListTemplateController
                     }
                 }
             }
+            $listTemplates[$key]['items'] = array_values($listTemplateItems);
         }
 
         return $response->withJson(['listTemplates' => $listTemplates]);
@@ -601,6 +602,7 @@ class ListTemplateController
                 $listTemplateItems[$key]['hasPrivilege'] = false;
             }
         }
+        $circuit['items'] = array_values($listTemplateItems);
 
         return $response->withJson(['circuit' => $circuit]);
     }
-- 
GitLab