From d304abaf00a6ea6b60cb804056e7f5a431750a74 Mon Sep 17 00:00:00 2001
From: Alex Orluc <alex.orluc@maarch.org>
Date: Tue, 17 May 2016 14:31:58 +0000
Subject: [PATCH] FEAT #3907 change order by entity instead of group

---
 .../class/class_modules_tools_Abstract.php    | 43 +++++++++++++++++--
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/visa/trunk/class/class_modules_tools_Abstract.php b/visa/trunk/class/class_modules_tools_Abstract.php
index c5e16f876c5..c7cf4c121d7 100644
--- a/visa/trunk/class/class_modules_tools_Abstract.php
+++ b/visa/trunk/class/class_modules_tools_Abstract.php
@@ -597,7 +597,24 @@ abstract class visa_Abstract extends Database
 								$str .= '<select id="conseiller_'.$seq.'" name="conseiller_'.$seq.'" '.$disabled.'>';
 								$str .= '<option value="" >Sélectionnez un utilisateur</option>';
 								
-								$tab_usergroups = $this->getGroupVis();
+								$tab_userentities = $this->getEntityVis();
+								/** CUSTOM CABPM **/
+								foreach ($tab_userentities as $key => $value) {
+									$str .= '<optgroup label="'.$tab_userentities[$key]['entity_id'].'">';
+									$tab_users = $this->getUsersVis($tab_usergroups[$key]['group_id']);
+									foreach($tab_users as $user){
+										if($tab_userentities[$key]['entity_id'] == $user['entity_id']){
+											$selected = " ";
+											if ($user['id'] == $step['user_id'])
+												$selected = " selected";
+											$str .= '<option value="'.$user['id'].'" '.$selected.'>'.$user['lastname'].', '.$user['firstname'].'</option>';
+										}
+										
+									}
+									$str .= '</optgroup>';
+								}
+
+								/*$tab_usergroups = $this->getGroupVis();
 								foreach ($tab_usergroups as $key => $value) {
 									$str .= '<optgroup label="'.$tab_usergroups[$key]['group_desc'].'">';
 									$tab_users = $this->getUsersVis($tab_usergroups[$key]['group_id']);
@@ -610,7 +627,7 @@ abstract class visa_Abstract extends Database
 									}
 									$str .= '</optgroup>';
 								}
-								$str .= '</select>';
+								$str .= '</select>';*/
 
 								$str .= "<span id=\"signatory_" . $seq . "\">";
 								if (empty($circuit['sign']['users']) && $seq == count ($circuit['visa']['users'])-1)
@@ -696,7 +713,25 @@ abstract class visa_Abstract extends Database
 							$str .= '<span id="rank_' . $seq . '">'.$actual_sign.' <span class="nbResZero" style="font-weight:bold;opacity:0.5;">'. ($seq + 1) . '</span> </span>';
 							$str .= '<select id="conseiller_'.$seq.'" name="conseiller_'.$seq.'" '.$disabled.'>';
 							$str .= '<option value="" >Sélectionnez un utilisateur</option>';
-							$tab_usergroups = $this->getGroupVis();
+							
+
+							$tab_userentities = $this->getEntityVis();
+							/** CUSTOM CABPM **/
+							foreach ($tab_userentities as $key => $value) {
+								$str .= '<optgroup label="'.$tab_userentities[$key]['entity_id'].'">';
+								$tab_users = $this->getUsersVis($tab_usergroups[$key]['group_id']);
+								foreach($tab_users as $user){
+									if($tab_userentities[$key]['entity_id'] == $user['entity_id']){
+										$selected = " ";
+										if ($user['id'] == $circuit['sign']['users'][0]['user_id'])
+											$selected = " selected";
+										$str .= '<option value="'.$user['id'].'" '.$selected.'>'.$user['lastname'].', '.$user['firstname'].'</option>';
+									}
+									
+								}
+								$str .= '</optgroup>';
+							}
+							/*$tab_usergroups = $this->getGroupVis();
 							foreach ($tab_usergroups as $key => $value) {
 								$str .= '<optgroup label="'.$tab_usergroups[$key]['group_desc'].'">';
 								$tab_users = $this->getUsersVis($tab_usergroups[$key]['group_id']);
@@ -707,7 +742,7 @@ abstract class visa_Abstract extends Database
 									$str .= '<option value="'.$user['id'].'" '.$selected.'>'.$user['lastname'].', '.$user['firstname'].'</option>';
 								}
 								$str .= '</optgroup>';
-							}
+							}*/
 							$str .= '</select>';
 
 							$str .= '<span id="signatory_' . $seq . '"><i title="Signataire" style="color : #fdd16c" class="fa fa-certificate fa-lg fa-fw"></i></span></td>';
-- 
GitLab