diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ba7cd546d54..f57c329d5a1 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -204,6 +204,7 @@ if (empty($reshook)) { } if (!$error) { + $object->civility_code = GETPOST("civility_code", 'aZ09'); $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); $object->login = GETPOST("login", 'alphanohtml'); @@ -366,6 +367,7 @@ if (empty($reshook)) { $db->begin(); + $object->civility_code = GETPOST("civility_code", 'aZ09'); $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); $object->login = GETPOST("login", 'alphanohtml'); @@ -789,6 +791,11 @@ if ($action == 'create' || $action == 'adduserldap') print '
| '; + print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09') : $object->civility_code, 'civility_code'); + print ' | |||
| '.$langs->trans("Lastname").' | '; @@ -2037,6 +2044,11 @@ if ($action == 'create' || $action == 'adduserldap') print '|||
| '; + print $formcompany->select_civility( GETPOSTISSET( "civility_code" ) ? GETPOST( "civility_code" , 'aZ09' ) : $object->civility_code , 'civility_code' ); + print ' | |||
| '.$langs->trans("Lastname").' | '; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3288571d2a7..be1cd4514e3 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -74,6 +74,7 @@ class User extends CommonObject public $ldap_sid; public $search_sid; public $employee; + public $civility_code; /** * @var string gender @@ -400,7 +401,7 @@ class User extends CommonObject $login = trim($login); // Get user - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job,"; + $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.civility as civility_code, u.birth, u.email, u.personal_email, u.job,"; $sql .= " u.socialnetworks,"; $sql .= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,"; $sql .= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; @@ -470,6 +471,7 @@ class User extends CommonObject $this->ref_ext = $obj->ref_ext; $this->ldap_sid = $obj->ldap_sid; + $this->civility_code = $obj->civility_code; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; @@ -1293,6 +1295,8 @@ class User extends CommonObject // Clean parameters $this->setUpperOrLowerCase(); + + $this->civility_code = trim($this->civility_code); $this->login = trim($this->login); if (!isset($this->entity)) { $this->entity = $conf->entity; // If not defined, we use default value @@ -1419,6 +1423,7 @@ class User extends CommonObject // Define parameters $this->admin = 0; + $this->civility_code = $contact->civility_code; $this->lastname = $contact->lastname; $this->firstname = $contact->firstname; $this->gender = $contact->gender; @@ -1447,6 +1452,7 @@ class User extends CommonObject if ($result > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql .= " SET fk_socpeople=".$contact->id; + $sql .= ", civility=".$contact->civility_code; if ($contact->socid) { $sql .= ", fk_soc=".$contact->socid; } @@ -1497,6 +1503,7 @@ class User extends CommonObject // Set properties on new user $this->admin = 0; + $this->civility_code = $member->civility_id; $this->lastname = $member->lastname; $this->firstname = $member->firstname; $this->gender = $member->gender; @@ -1632,6 +1639,7 @@ class User extends CommonObject dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember.", nosyncmemberpass=".$nosyncmemberpass); // Clean parameters + $this->civility_code = trim($this->civility_code); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); $this->employee = $this->employee ? $this->employee : 0; @@ -1686,7 +1694,8 @@ class User extends CommonObject // Update datas $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; - $sql .= " lastname = '".$this->db->escape($this->lastname)."'"; + $sql .= " civility = '".$this->db->escape($this->civility_code)."'"; + $sql .= ", lastname = '".$this->db->escape($this->lastname)."'"; $sql .= ", firstname = '".$this->db->escape($this->firstname)."'"; $sql .= ", employee = ".(int) $this->employee; $sql .= ", login = '".$this->db->escape($this->login)."'"; @@ -1788,6 +1797,7 @@ class User extends CommonObject $result = $adh->fetch($this->fk_member); if ($result > 0) { + $adh->civility_code = $this->civility_code; $adh->firstname = $this->firstname; $adh->lastname = $this->lastname; $adh->login = $this->login; @@ -1838,6 +1848,7 @@ class User extends CommonObject $result = $tmpobj->fetch($this->contact_id); if ($result >= 0) { + $tmpobj->civility_code = $this->civility_code; $tmpobj->firstname = $this->firstname; $tmpobj->lastname = $this->lastname; $tmpobj->login = $this->login;|||