From 21555a7435858c46e4b5b72de536058789936bab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 01:10:51 +0200 Subject: [PATCH 1/2] Fix firstname/lastname --- htdocs/admin/ihm.php | 4 ++-- htdocs/core/class/html.form.class.php | 15 ++++++++++----- .../societe/canvas/actions_card_common.class.php | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 03f3d364cca..a9bf5313789 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -315,8 +315,8 @@ if ($action == 'edit') // Edit // Firstname/Name print ''.$langs->trans("FirstnameNamePosition").''; - $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); - print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); + $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); + print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); print ''; print ' '; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5c7091ba6e3..bd7feb9414d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1530,9 +1530,12 @@ class Form if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql.= " AND u.statut <> 0"; if (! empty($morefilter)) $sql.=" ".$morefilter; - if(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)){ + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname + { $sql.= " ORDER BY u.firstname ASC"; - }else{ + } + else + { $sql.= " ORDER BY u.lastname ASC"; } @@ -1579,9 +1582,11 @@ class Form $out.= '>'; } - $fullNameMode = 0; //Lastname + firstname - if(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)){ - $fullNameMode = 1; //firstname + lastname + // $fullNameMode is 0=Lastname+Firstname (MAIN_FIRSTNAME_NAME_POSITION=1), 1=Firstname+Lastname (MAIN_FIRSTNAME_NAME_POSITION=0) + $fullNameMode = 0; + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) + { + $fullNameMode = 1; //Firstname+lastname } $out.= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 452a9cc6a61..a0980563996 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -121,7 +121,7 @@ abstract class ActionsCardCommon { $this->object->particulier = GETPOST("private"); - $this->object->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["firstname"].' '.$_POST["lastname"]):trim($_POST["lastname"].' '.$_POST["firstname"]); + $this->object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('lastname','alpha')); $this->object->civility_id = $_POST["civility_id"]; // Add non official properties $this->object->name_bis = $_POST["lastname"]; From 7cd24c389db208d52b10363fba0192d51442417a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 01:21:23 +0200 Subject: [PATCH 2/2] Fix firstname/lastname --- test/phpunit/AdherentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index a2f4f64aba5..7f3455ce37a 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -317,7 +317,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 1; // Force setup for firstname then lastname + $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__';