From 1e4d8ec104f8b0da10fdf5e1a395e3ba15795d45 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 18 Nov 2015 06:34:08 +0100 Subject: [PATCH] New: HRM #3699 Add address informations in user card --- htdocs/user/card.php | 75 +++++++++++++++++++++++++++++++- htdocs/user/class/user.class.php | 35 +++++++++++++-- 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ffd2f878adf..f92b9e6b1b2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -183,6 +184,11 @@ if (empty($reshook)) { $object->api_key = GETPOST("api_key", 'alpha'); $object->gender = GETPOST("gender", 'alpha'); $object->admin = GETPOST("admin", 'alpha'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); $object->office_phone = GETPOST("office_phone", 'alpha'); $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); @@ -315,7 +321,12 @@ if (empty($reshook)) { $object->pass = GETPOST("password"); $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin - $object->office_phone = GETPOST("office_phone", 'alpha'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); + $object->office_phone = GETPOST("office_phone", 'alpha'); $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype"); @@ -578,6 +589,7 @@ if (empty($reshook)) { $form = new Form($db); $formother=new FormOther($db); +$formcompany = new FormCompany($db); llxHeader('',$langs->trans("UserCard")); @@ -865,6 +877,37 @@ if (($action == 'create') || ($action == 'adduserldap')) print $form->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2); print ''; + // Address + print ''.fieldLabel('Address','address').''; + print ''; + + // Zip + print ''.fieldLabel('Zip','zipcode').''; + print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'),6); + print ''; + + // Town + print ''.fieldLabel('Town','town').''; + print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id')); + print ''; + + // Country + print ''.fieldLabel('Country','selectcountry_id').''; + print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print ''; + + // State + if (empty($conf->global->USER_DISABLE_STATE)) + { + print ''.fieldLabel('State','state_id').''; + if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code); + else print $countrynotdefined; + print ''; + } + // Tel print ''.$langs->trans("PhonePro").''; print ''; @@ -1919,6 +1962,36 @@ else } print ''; + // Address + print ''.fieldLabel('Address','address').''; + print ''; + + // Zip + print ''.fieldLabel('Zip','zipcode').''; + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print ''; + + // Town + print ''.fieldLabel('Town','town').''; + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print ''; + + // Country + print ''.fieldLabel('Country','selectcounty_id').''; + print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print ''; + + // State + if (empty($conf->global->USER_DISABLE_STATE)) + { + print ''.fieldLabel('State','state_id').''; + print $formcompany->select_state($object->state_id,$object->country_code); + print ''; + } + // Tel pro print "".''.$langs->trans("PhonePro").''; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f16af2ee72d..2d52d11a588 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -52,6 +52,12 @@ class User extends CommonObject var $skype; var $job; var $signature; + var $address; + var $zip; + var $town; + var $state_id; + var $state_code; + var $state; var $office_phone; var $office_fax; var $user_mobile; @@ -156,13 +162,14 @@ class User extends CommonObject */ function fetch($id='', $login='',$sid='',$loadpersonalconf=1, $entity=-1) { - global $conf, $user; + global $langs, $conf, $user; // Clean parameters $login=trim($login); // Get user $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; + $sql.= " u.address, u.zip, u.town, u.fk_state, u.fk_country as country_id,"; $sql.= " u.admin, u.login, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,"; $sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,"; @@ -180,8 +187,12 @@ class User extends CommonObject $sql.= " u.salaryextra,"; $sql.= " u.weeklyhours,"; $sql.= " u.color,"; - $sql.= " u.ref_int, u.ref_ext"; + $sql.= " u.ref_int, u.ref_ext,"; + $sql.= " c.code as country_code, c.label as country,"; + $sql.= " d.code_departement as state_code, d.nom as state"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON u.fk_state = d.rowid"; if ($entity < 0) { @@ -238,6 +249,19 @@ class User extends CommonObject $this->pass = $obj->pass; $this->pass_temp = $obj->pass_temp; $this->api_key = $obj->api_key; + + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; + + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_id?$obj->country_code:''; + $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + + $this->state_id = $obj->fk_departement; + $this->state_code = $obj->state_code; + $this->state = ($obj->state!='-'?$obj->state:''); + $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; @@ -960,7 +984,7 @@ class User extends CommonObject $error=0; - // Positionne parametres + // Define parameters $this->admin = 0; $this->lastname = $contact->lastname; $this->firstname = $contact->firstname; @@ -1165,6 +1189,11 @@ class User extends CommonObject $this->gender = trim($this->gender); $this->pass = trim($this->pass); $this->api_key = trim($this->api_key); + $this->address = $this->address?trim($this->address):trim($this->address); + $this->zip = $this->zip?trim($this->zip):trim($this->zip); + $this->town = $this->town?trim($this->town):trim($this->town); + $this->state_id = trim($this->state_id); + $this->country_id = ($this->country_id > 0)?$this->country_id:0; $this->office_phone = trim($this->office_phone); $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile);