From 2fa0f90ae5a29a3573eed28e4ec0515ccb514489 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Sun, 12 Nov 2017 14:26:52 +0100
Subject: [PATCH] FEAT #6134 add confirm box + fix display sign by/visa by in
 visa workflow

---
 .../class/class_modules_tools_Abstract.php    | 26 ++++++++++++++-----
 modules/visa/interrupt_visa.php               |  5 ++--
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php
index dc62fcb250f..6a24993ff3d 100755
--- a/modules/visa/class/class_modules_tools_Abstract.php
+++ b/modules/visa/class/class_modules_tools_Abstract.php
@@ -602,13 +602,19 @@ abstract class visa_Abstract extends Database
                                 $disabled = '';
                                 $link_vis = 'arrow-right ';
                                 $del_vis = '<div class="delete_visa"></div>';
-                                if($info_userVis['user_id'] <> $_SESSION['user']['UserId']){
-                                    $info_vised = '<p style="color:red;">'._VISA_USER_COU_DESC.' '.$info_userVis['firstname'].' '.$info_userVis['lastname'].'</p>';
+	                            if($info_userVis['requested_signature'] && $info_userVis['user_id'] <> $_SESSION['user']['UserId']){
+	                                $info_vised = '<p style="color:red;">'._SIGN_USER_COU_DESC.' '.$info_userVis['firstname'].' '.$info_userVis['lastname'].'</p>';
 									$dropZone = '';
-								}else{
-                                    $info_vised = '<p style="font-weight:normal;">'._VISA_USER_COU.'</p>';
+	                            }else if($info_userVis['requested_signature'] && $info_userVis['user_id'] == $_SESSION['user']['UserId']){
+	                                $info_vised = '<p style="font-weight:normal;">'._SIGN_USER_COU.'</p>';
+									$dropZone = '';
+	                            }else if(!$info_userVis['requested_signature'] && $info_userVis['user_id'] <> $_SESSION['user']['UserId']){
+	                                $info_vised = '<p style="color:red;">'._VISA_USER_COU_DESC.' '.$info_userVis['firstname'].' '.$info_userVis['lastname'].'</p>';
+									$dropZone = '';
+	                            }else {
+	                                $info_vised = '<p style="font-weight:normal;">'._VISA_USER_COU.'</p>';
 									$dropZone = '';
-                                }
+	                            }
 								if($core->test_service('modify_visa_in_signatureBook', 'visa', false)){
 									$modif = 'true';
 									$dropZone = '<i class="fa fa-exchange fa-2x fa-rotate-90" aria-hidden="true" title="'._DRAG_N_DROP_CHANGE_ORDER.'" style="cursor: pointer"></i>';
@@ -730,12 +736,18 @@ abstract class visa_Abstract extends Database
                             $disabled = '';
                             $del_vis = '';
                             $link_vis = 'arrow-right ';
-                            if($info_userSign['user_id'] <> $_SESSION['user']['UserId']){
+                            if($info_userSign['requested_signature'] && $info_userSign['user_id'] <> $_SESSION['user']['UserId']){
 								$dropZone = '';
                                 $info_vised = '<p style="color:red;">'._SIGN_USER_COU_DESC.' '.$info_userSign['firstname'].' '.$info_userSign['lastname'].'</p>';
-                            }else{
+                            }else if($info_userSign['requested_signature'] && $info_userSign['user_id'] == $_SESSION['user']['UserId']){
 								$dropZone = '';
                                 $info_vised = '<p style="font-weight:normal;">'._SIGN_USER_COU.'</p>';
+                            }else if(!$info_userSign['requested_signature'] && $info_userSign['user_id'] <> $_SESSION['user']['UserId']){
+								$dropZone = '';
+                                $info_vised = '<p style="color:red;">'._VISA_USER_COU_DESC.' '.$info_userSign['firstname'].' '.$info_userSign['lastname'].'</p>';
+                            }else {
+								$dropZone = '';
+                                $info_vised = '<p style="font-weight:normal;">'._VISA_USER_COU.'</p>';
                             }
 							if($core->test_service('modify_visa_in_signatureBook', 'visa', false)){
 								$modif = 'true';
diff --git a/modules/visa/interrupt_visa.php b/modules/visa/interrupt_visa.php
index d0f6d6d40b4..d2d72334f81 100755
--- a/modules/visa/interrupt_visa.php
+++ b/modules/visa/interrupt_visa.php
@@ -13,11 +13,10 @@ require_once 'modules/visa/class/class_modules_tools.php';
 $visa = new visa();
 
 if ($visa->currentUserSignRequired($_SESSION['doc_id']) == 'true') {
-    $confirm = true;
     $label_action .=" ("._NO_USER_SIGNED_DOC.")";
-} else {
-    $confirm = false;
 }
+
+$confirm = true;
 $etapes = ['empty_error'];
 
 function manage_empty_error($arr_id, $history, $id_action, $label_action, $status)
-- 
GitLab