Fix firstname/lastname

This commit is contained in:
Laurent Destailleur 2018-08-13 01:10:51 +02:00
parent 2d571acc03
commit 21555a7435
3 changed files with 13 additions and 8 deletions

View File

@ -315,8 +315,8 @@ if ($action == 'edit') // Edit
// Firstname/Name
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
$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 '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';

View File

@ -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);

View File

@ -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"];