Fix in select of user when firstname and lastname is empty

This commit is contained in:
Laurent Destailleur 2020-11-10 15:03:35 +01:00
parent 6536208a14
commit 29f0a9b784
3 changed files with 34 additions and 9 deletions

View File

@ -1726,6 +1726,7 @@ class Form
$fullNameMode = 1; //Firstname+lastname
}
$labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
if (empty($obj->firstname) && empty($obj->lastname)) $labeltoshow .= $obj->login;
// Complete name with more info
$moreinfo = '';

View File

@ -430,7 +430,7 @@ class FormOther
if ($showempty) $out .= '<option value="0">&nbsp;</option>';
// Get list of users allowed to be viewed
$sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login";
$sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as status, u.login, u.photo, u.gender, u.entity, u.admin";
$sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
@ -455,7 +455,7 @@ class FormOther
if (empty($user->rights->user->user->lire) && $user->socid)
{
$sql_usr .= " UNION ";
$sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login";
$sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin";
$sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
@ -480,14 +480,37 @@ class FormOther
$resql_usr = $this->db->query($sql_usr);
if ($resql_usr)
{
$userstatic = new User($this->db);
$showstatus = 1;
while ($obj_usr = $this->db->fetch_object($resql_usr))
{
$userstatic->id = $obj_usr->rowid;
$userstatic->lastname = $obj_usr->lastname;
$userstatic->firstname = $obj_usr->firstname;
$userstatic->photo = $obj_usr->photo;
$userstatic->statut = $obj_usr->status;
$userstatic->entity = $obj_usr->entity;
$userstatic->admin = $obj_usr->admin;
$labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) $labeltoshow = $obj_usr->login;
$out .= '<option value="'.$obj_usr->rowid.'"';
if ($obj_usr->rowid == $selected) $out .= ' selected';
$out .= ' data-html="';
$outhtml = '';
if (!empty($obj_usr->photo))
{
$outhtml .= $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' ';
}
if ($showstatus >= 0 && $obj_usr->status == 0) $outhtml .= '<strike class="opacitymediumxxx">';
$outhtml .= $labeltoshow;
if ($showstatus >= 0 && $obj_usr->status == 0) $outhtml .= '</strike>';
$out .= dol_escape_htmltag($outhtml);
$out .= '">';
$out .= '>';
$out .= dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
$out .= $labeltoshow;
// Complete name with more info
$moreinfo = 0;
if (!empty($conf->global->MAIN_SHOW_LOGIN))
@ -497,12 +520,12 @@ class FormOther
}
if ($showstatus >= 0)
{
if ($obj_usr->statut == 1 && $showstatus == 1)
if ($obj_usr->status == 1 && $showstatus == 1)
{
$out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
$moreinfo++;
}
if ($obj_usr->statut == 0)
if ($obj_usr->status == 0)
{
$out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
$moreinfo++;

View File

@ -7,7 +7,7 @@
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com>
* Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -505,7 +505,8 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
// If the user can view user other than himself
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': ';
$includeonly = 'hierarchyme';
//$includeonly = 'hierarchyme';
$includeonly = '';
if (empty($user->rights->user->user->lire)) $includeonly = array($user->id);
$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200');
$moreforfilter .= '</div>';