From 0ec8be56051a78f54d54c2d899a4892a10de3e8e Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Thu, 5 Nov 2020 18:04:37 +0100
Subject: [PATCH] FEAT #14949 TIME 1:00 Fix list template with invalid users

---
 src/app/entity/controllers/ListTemplateController.php | 2 +-
 src/frontend/app/visa/visa-workflow.component.ts      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/app/entity/controllers/ListTemplateController.php b/src/app/entity/controllers/ListTemplateController.php
index d1f1f788e6b..f4ec8e0e3dc 100755
--- a/src/app/entity/controllers/ListTemplateController.php
+++ b/src/app/entity/controllers/ListTemplateController.php
@@ -665,7 +665,7 @@ class ListTemplateController
             }
             if ($item['type'] == 'user') {
                 $user = UserModel::getById(['id' => $item['id'], 'select' => ['status']]);
-                if ($user == 'SPD' || $user == 'DEL') {
+                if (empty($user) || $user['status'] == 'SPD' || $user['status'] == 'DEL') {
                     return ['errors' => 'Item user is not valid'];
                 }
             }
diff --git a/src/frontend/app/visa/visa-workflow.component.ts b/src/frontend/app/visa/visa-workflow.component.ts
index e827332d988..380837d70bd 100644
--- a/src/frontend/app/visa/visa-workflow.component.ts
+++ b/src/frontend/app/visa/visa-workflow.component.ts
@@ -535,7 +535,7 @@ export class VisaWorkflowComponent implements OnInit {
     }
 
     isValidWorkflow() {
-        if ((this.visaWorkflow.items.filter((item: any) => item.requested_signature).length > 0 && this.visaWorkflow.items.filter((item: any) => (!item.hasPrivilege || !item.isValid) && item.process_date === null).length === 0) && this.visaWorkflow.items.length > 0) {
+        if ((this.visaWorkflow.items.filter((item: any) => item.requested_signature).length > 0 && this.visaWorkflow.items.filter((item: any) => (!item.hasPrivilege || !item.isValid) && (item.process_date === null || this.functions.empty(item.process_date))).length === 0) && this.visaWorkflow.items.length > 0) {
             return true;
         } else {
             return false;
@@ -547,7 +547,7 @@ export class VisaWorkflowComponent implements OnInit {
             return this.translate.instant('lang.signUserRequired');
         } else if (this.visaWorkflow.items.filter((item: any) => !item.hasPrivilege).length > 0) {
             return this.translate.instant('lang.mustDeleteUsersWithNoPrivileges');
-        } else if (this.visaWorkflow.items.filter((item: any) => !item.isValid && item.process_date === null).length > 0) {
+        } else if (this.visaWorkflow.items.filter((item: any) => !item.isValid && (item.process_date === null || this.functions.empty(item.process_date))).length > 0) {
             return this.translate.instant('lang.mustDeleteInvalidUsers');
         }
     }
-- 
GitLab