From 20b6d3828e90a5af12eb9650c401515a27919902 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Oct 2020 13:27:39 +0200 Subject: [PATCH] NEW Show image of user in the combo select of users --- htdocs/admin/mails_templates.php | 7 +++---- htdocs/core/class/html.form.class.php | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 27438e78dea..9ff86260c4b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -640,7 +640,7 @@ if ($resql) print ''; } elseif ($value == 'fk_user') { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth150'); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth150'); print ''; } elseif ($value == 'topic') { print ''; @@ -959,9 +959,8 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($fieldlist[$field] == 'fk_user') { print ''; - if ($user->admin) - { - print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, '', null, 0, 0, 1, '', 0, '', 'maxwidth200'); + if ($user->admin) { + print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth200'); } else { if ($context == 'add') // I am not admin and we show the add form { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index be7fde5d874..266a6e2fd9a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1646,7 +1646,7 @@ class Form $outarray = array(); // Forge request to select users - $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; + $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo"; if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { $sql .= ", e.label"; @@ -1710,6 +1710,10 @@ class Form $userstatic->id = $obj->rowid; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->statut = $obj->status; + $userstatic->entity = $obj->entity; + $userstatic->admin = $obj->admin; $disableline = ''; if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext : '1'); @@ -1732,11 +1736,11 @@ class Form } if ($showstatus >= 0) { - if ($obj->statut == 1 && $showstatus == 1) + if ($obj->status == 1 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled'); } - if ($obj->statut == 0 && $showstatus == 1) + if ($obj->status == 0 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled'); } @@ -1762,10 +1766,17 @@ class Form if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) { $out .= ' selected'; } - if ($showstatus >= 0 && $obj->statut == 0) { - $out .= ' data-html="'.dol_escape_htmltag(''.$labeltoshow.'').'"'; + $out .= ' data-html="'; + $outhtml = ''; + if (!empty($obj->photo)) + { + $outhtml .= $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' '; } - $out .= '>'; + if ($showstatus >= 0 && $obj->status == 0) $outhtml .= ''; + $outhtml .= $labeltoshow; + if ($showstatus >= 0 && $obj->status == 0) $outhtml .= ''; + $out .= dol_escape_htmltag($outhtml); + $out .= '">'; $out .= $labeltoshow; $out .= '';