From 35debd06fbfd550eb36f3c56ad4a56a452ff37fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Dec 2018 01:28:36 +0100 Subject: [PATCH] List of events show user firstname by default --- htdocs/core/class/commonobject.class.php | 6 +++--- htdocs/core/class/html.formactions.class.php | 2 +- htdocs/core/lib/company.lib.php | 11 ++++++----- htdocs/core/lib/functions.lib.php | 10 +++++++--- htdocs/user/class/user.class.php | 4 ++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index afee4c1fcdd..5b66617a7f3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -462,7 +462,7 @@ abstract class CommonObject * * @param Translate $langs Language object for translation of civility (used only if option is 1) * @param int $option 0=No option, 1=Add civility - * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname * @param int $maxlen Maximum length * @return string String with full name */ @@ -4208,7 +4208,7 @@ abstract class CommonObject $line->fetch_product(); $productstatic = $line->product; } - + $this->tpl['label'].= $productstatic->getNomUrl(1); $this->tpl['label'].= ' - '.(! empty($line->label)?$line->label:$line->product_label); // Dates @@ -4225,7 +4225,7 @@ abstract class CommonObject }else { $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); } - + // Dates if ($line->product_type == 1 && ($date_start || $date_end)) { diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 066c2a25a23..9dbf8b9ae47 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -249,7 +249,7 @@ class FormActions if (! empty($action->userownerid)) { $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched - print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } print ''; // Type diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 20c4b4f5a90..bd6d03dc542 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1330,10 +1330,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Facture') $sql.= ", o.ref"; - else $sql.= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; @@ -1634,8 +1635,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= //$out.=$userstatic->getLoginUrl(1); if ($histo[$key]['userid'] > 0) { - $userstatic->fetch($histo[$key]['userid']); - $out.=$userstatic->getNomUrl(-1); + $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched + $out.=$userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } $out.=''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 336881ce97d..c8c5937aaad 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6274,7 +6274,7 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='', $wit * * @param string $firstname Firstname * @param string $lastname Lastname - * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname * @return string Firstname + lastname or Lastname + firstname */ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) @@ -6284,15 +6284,19 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) $ret=''; // If order not defined, we use the setup if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?1:0); - if ($nameorder && ((string) $nameorder != '2')) + if ($nameorder && $nameorder != 2 && $nameorder != 3) { $ret.=$firstname; if ($firstname && $lastname) $ret.=' '; $ret.=$lastname; } - else if ($nameorder == 2) + else if ($nameorder == 2 || $nameorder == 3) { $ret.=$firstname; + if (empty($ret) && $nameorder == 3) + { + $ret.=$lastname; + } } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 217211dde4e..f198a6d99a1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2243,7 +2243,7 @@ class User extends CommonObject * @param integer $notooltip 1=Disable tooltip on picto and name * @param int $maxlen Max length of visible user name * @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user - * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login + * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'firstelselast'=Show firstname or lastname if not defined, 'login'=Show login * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL @@ -2360,7 +2360,7 @@ class User extends CommonObject { if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen); - else $result.=$this->getFullName($langs,'',($mode == 'firstname' ? 2 : -1),$maxlen); + else $result.=$this->getFullName($langs,'',($mode == 'firstelselast' ? 3 : ($mode == 'firstname' ? 2 : -1)),$maxlen); if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; } $result.=(($option == 'nolink')?'':$linkend);