From 444a3328c602ae3ba3bf96fd8cad3e2509911212 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jul 2013 14:45:55 +0200 Subject: [PATCH] New: More options to select status of users into select user list. --- ChangeLog | 1 + htdocs/core/class/html.form.class.php | 40 ++++++++++++++++------ htdocs/core/class/html.formother.class.php | 26 +++++++++++--- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43f9e3c6859..72a5c386d30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: +- New: More options to select status of users into select user list. - New: [ task #862 ] Add ODT on shipments - New: [ task #149 ] Add # of notes and attachments in tabs - New: Can edit customer ref at eny time. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 60ac2cf0571..2b540f3aabd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1080,7 +1080,7 @@ class Form * @param array $enableonly Array list of users id to be enabled. All other must be disabled * @param int $force_entity 0 or Id of environment to force * @param int $maxlength Maximum length of string into list (0=no limit) - * @param int $showstatus Show user status into label + * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @return string HTML select string */ function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0) @@ -1166,20 +1166,40 @@ class Form } $out.= $userstatic->getFullName($langs, 0, 0, $maxlength); - if ($showstatus) + // Complete name with more info + $moreinfo=0; + if (! empty($conf->global->MAIN_SHOW_LOGIN)) { - if ($obj->statut == 1) $out.=" (".$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4').")"; - else $out.=" (".$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5').")"; + $out.= ($moreinfo?' - ':' (').$obj->login; + $moreinfo++; + } + if ($showstatus >= 0) + { + if ($obj->statut == 1 && $showstatus == 1) + { + $out.=($moreinfo?' - ':' (').$langs->trans('Enabled'); + $moreinfo++; + } + if ($obj->statut == 0) + { + $out.=($moreinfo?' - ':' (').$langs->trans('Disabled'); + $moreinfo++; + } } - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { - if ($obj->admin && ! $obj->entity) $out.=" (".$langs->trans("AllEntities").")"; - else $out.=" (".$obj->label.")"; + if ($obj->admin && ! $obj->entity) + { + $out.=($moreinfo?' - ':' (').$langs->trans("AllEntities"); + $moreinfo++; + } + else + { + $out.=($moreinfo?' - ':' (').$obj->label; + $moreinfo++; + } } - - //if ($obj->admin) $out.= ' *'; - if (! empty($conf->global->MAIN_SHOW_LOGIN)) $out.= ' ('.$obj->login.')'; + $out.=($moreinfo?')':''); $out.= ''; $i++; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index bc1eefcce3b..1694e7f32de 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -347,7 +347,7 @@ class FormOther * @param string $selected Preselected value * @param string $htmlname Name of combo list (example: 'search_sale') * @param User $user Object user - * @param int $showstatus Show user status into label + * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @return string Html combo list code */ function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0) @@ -386,12 +386,28 @@ class FormOther if ($obj_usr->rowid == $selected) $moreforfilter.=' selected="selected"'; $moreforfilter.='>'; - $moreforfilter.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->name)." (".$obj_usr->login.')'; - if ($showstatus) + $moreforfilter.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->name); + // Complete name with more info + $moreinfo=0; + if (! empty($conf->global->MAIN_SHOW_LOGIN)) { - if ($obj_usr->statut == 1) $moreforfilter.=" ". img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - else $moreforfilter.=" ". img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + $out.=($moreinfo?' - ':' (').$obj->login; + $moreinfo++; + } + if ($showstatus >= 0) + { + if ($obj_usr->statut == 1 && $showstatus == 1) + { + $moreforfilter.=($moreinfo?' - ':' (').$langs->trans('Enabled'); + $moreinfo++; + } + if ($obj_usr->statut == 0) + { + $moreforfilter.=($moreinfo?' - ':' (').$langs->trans('Disabled'); + $moreinfo++; + } } + $moreforfilter.=($moreinfo?')':''); $moreforfilter.=''; } $this->db->free($resql_usr);