From 013b8a61ec9c9dc6a3ca524d65d629af22d22a85 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 29 Mar 2019 12:11:50 +0100 Subject: [PATCH 1/3] ADD cilivity label in fetch contact / API --- htdocs/contact/class/contact.class.php | 30 +++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 73f27f8ec1c..714a57b6a03 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Marcos GarcĂ­a @@ -81,6 +81,7 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; + public $civility_label; public $address; public $zip; public $town; @@ -717,12 +718,14 @@ class Contact extends CommonObject $sql.= " c.import_key,"; $sql.= " c.datec as date_creation, c.tms as date_modification,"; $sql.= " co.label as country, co.code as country_code,"; + $sql.= " ci.label as civility,"; $sql.= " d.nom as state, d.code_departement as state_code,"; $sql.= " u.rowid as user_id, u.login as user_login,"; $sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_civility as ci ON c.civility = ci.code"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if ($id) $sql.= " WHERE c.rowid = ". $id; @@ -749,9 +752,10 @@ class Contact extends CommonObject $this->ref = $obj->rowid; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; - $this->civility_code = $obj->civility_id; + $this->civility_code = $obj->civility_code; + $this->civility = $obj->civility; $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; + $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; @@ -764,29 +768,29 @@ class Contact extends CommonObject $this->departement_code = $obj->state_code; // deprecated $this->state_code = $obj->state_code; $this->departement = $obj->state; // deprecated - $this->state = $obj->state; + $this->state = $obj->state; $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->socid = $obj->fk_soc; + $this->socid = $obj->fk_soc; $this->socname = $obj->socname; - $this->poste = $obj->poste; + $this->poste = $obj->poste; $this->statut = $obj->statut; - $this->phone_pro = trim($obj->phone); + $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); $this->phone_perso = trim($obj->phone_perso); $this->phone_mobile = trim($obj->phone_mobile); - $this->email = $obj->email; + $this->email = $obj->email; $this->jabberid = $obj->jabberid; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; - $this->photo = $obj->photo; + $this->skype = $obj->skype; + $this->twitter = $obj->twitter; + $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; + $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; From 1f017d4d0680afb3ae56ccf5d94db68c7a8b5ddf Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 11 Apr 2019 17:03:07 +0200 Subject: [PATCH 2/3] Update contact.class.php --- htdocs/contact/class/contact.class.php | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 714a57b6a03..601b29201b8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -81,7 +81,7 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; - public $civility_label; + public $civility; public $address; public $zip; public $town; @@ -204,7 +204,7 @@ class Contact extends CommonObject public function create($user) { global $conf, $langs; - + $error=0; $now=dol_now(); @@ -224,9 +224,9 @@ class Contact extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql.= " datec"; $sql.= ", fk_soc"; - $sql.= ", lastname"; - $sql.= ", firstname"; - $sql.= ", fk_user_creat"; + $sql.= ", lastname"; + $sql.= ", firstname"; + $sql.= ", fk_user_creat"; $sql.= ", priv"; $sql.= ", statut"; $sql.= ", canvas"; @@ -238,14 +238,14 @@ class Contact extends CommonObject if ($this->socid > 0) $sql.= " ".$this->db->escape($this->socid).","; else $sql.= "null,"; $sql.= "'".$this->db->escape($this->lastname)."',"; - $sql.= "'".$this->db->escape($this->firstname)."',"; - $sql.= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"null").","; + $sql.= "'".$this->db->escape($this->firstname)."',"; + $sql.= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"null").","; $sql.= " ".$this->db->escape($this->priv).","; $sql.= " ".$this->db->escape($this->statut).","; - $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; - $sql.= " ".$this->db->escape($this->entity).","; - $sql.= "'".$this->db->escape($this->ref_ext)."',"; - $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; + $sql.= " ".$this->db->escape($this->entity).","; + $sql.= "'".$this->db->escape($this->ref_ext)."',"; + $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -697,6 +697,8 @@ class Contact extends CommonObject { global $langs; + $langs->load("dict"); + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); if (empty($id) && empty($ref_ext)) @@ -718,14 +720,12 @@ class Contact extends CommonObject $sql.= " c.import_key,"; $sql.= " c.datec as date_creation, c.tms as date_modification,"; $sql.= " co.label as country, co.code as country_code,"; - $sql.= " ci.label as civility,"; $sql.= " d.nom as state, d.code_departement as state_code,"; $sql.= " u.rowid as user_id, u.login as user_login,"; $sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_civility as ci ON c.civility = ci.code"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if ($id) $sql.= " WHERE c.rowid = ". $id; @@ -752,8 +752,8 @@ class Contact extends CommonObject $this->ref = $obj->rowid; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; - $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility; + $this->civility_code = $obj->civility_id; + $this->civility = $langs->trans("Civility".$obj->civility_id); $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address; From 42b1ab10d12bc030120d889e6379b8f674454404 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 11 Apr 2019 17:04:40 +0200 Subject: [PATCH 3/3] Update contact.class.php --- htdocs/contact/class/contact.class.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 601b29201b8..757bedee433 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -224,9 +224,9 @@ class Contact extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql.= " datec"; $sql.= ", fk_soc"; - $sql.= ", lastname"; - $sql.= ", firstname"; - $sql.= ", fk_user_creat"; + $sql.= ", lastname"; + $sql.= ", firstname"; + $sql.= ", fk_user_creat"; $sql.= ", priv"; $sql.= ", statut"; $sql.= ", canvas"; @@ -238,14 +238,14 @@ class Contact extends CommonObject if ($this->socid > 0) $sql.= " ".$this->db->escape($this->socid).","; else $sql.= "null,"; $sql.= "'".$this->db->escape($this->lastname)."',"; - $sql.= "'".$this->db->escape($this->firstname)."',"; - $sql.= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"null").","; + $sql.= "'".$this->db->escape($this->firstname)."',"; + $sql.= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"null").","; $sql.= " ".$this->db->escape($this->priv).","; $sql.= " ".$this->db->escape($this->statut).","; - $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; - $sql.= " ".$this->db->escape($this->entity).","; - $sql.= "'".$this->db->escape($this->ref_ext)."',"; - $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; + $sql.= " ".$this->db->escape($this->entity).","; + $sql.= "'".$this->db->escape($this->ref_ext)."',"; + $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -696,8 +696,8 @@ class Contact extends CommonObject public function fetch($id, $user = null, $ref_ext = '', $email = '') { global $langs; - - $langs->load("dict"); + + $langs->load("dict"); dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); @@ -753,7 +753,7 @@ class Contact extends CommonObject $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_id; $this->civility_code = $obj->civility_id; - $this->civility = $langs->trans("Civility".$obj->civility_id); + $this->civility = $langs->trans("Civility".$obj->civility_id); $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address;