From bea1a50e2cc0bff6e93b4b37a45b3ae1f4acc375 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Jul 2012 14:36:08 +0200 Subject: [PATCH] Fix: Phone not saved when using web service --- htdocs/societe/class/societe.class.php | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 530faae72c7..300f2dfb8bf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -69,7 +69,8 @@ class Societe extends CommonObject var $country_code; var $country; - var $tel; + var $tel; // deprecated + var $phone; var $fax; var $email; var $url; @@ -399,10 +400,11 @@ class Societe extends CommonObject $this->state_id=trim($this->state_id); $this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id; $this->pays_id = $this->country_id; - $this->tel = trim($this->tel); + $this->phone = trim($this->phone?$this->phone:$this->tel); + $this->phone = preg_replace("/\s/","",$this->phone); + $this->phone = preg_replace("/\./","",$this->phone); + $this->tel = $this->phone; $this->fax = trim($this->fax); - $this->tel = preg_replace("/\s/","",$this->tel); - $this->tel = preg_replace("/\./","",$this->tel); $this->fax = preg_replace("/\s/","",$this->fax); $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); @@ -475,7 +477,7 @@ class Societe extends CommonObject $sql .= ",fk_departement = '" . ($this->state_id?$this->state_id:'0') ."'"; $sql .= ",fk_pays = '" . ($this->country_id?$this->country_id:'0') ."'"; - $sql .= ",tel = ".($this->tel?"'".$this->db->escape($this->tel)."'":"null"); + $sql .= ",tel = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql .= ",fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); $sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null"); $sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); @@ -639,7 +641,7 @@ class Societe extends CommonObject $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_update'; - $sql .= ', s.tel, s.fax, s.email, s.url, s.cp as zip, s.ville as town, s.note, s.client, s.fournisseur'; + $sql .= ', s.tel as phone, s.fax, s.email, s.url, s.cp as zip, s.ville as town, s.note, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; $sql .= ', s.fk_typent as typent_id'; @@ -724,8 +726,8 @@ class Societe extends CommonObject $this->email = $obj->email; $this->url = $obj->url; - $this->tel = $obj->tel; // TODO obsolete - $this->phone = $obj->tel; + $this->tel = $obj->phone; // TODO obsolete + $this->phone = $obj->phone; $this->fax = $obj->fax; $this->parent = $obj->parent; @@ -1420,12 +1422,14 @@ class Societe extends CommonObject { global $langs; + if (empty($this->phone) && ! empty($this->tel)) $this->phone=$this->tel; + $contact_phone = $this->contact_property_array('mobile'); - if ($this->tel) + if ($this->phone) { if (empty($this->name)) $this->name=$this->nom; // TODO: Tester si tel non deja present dans tableau contact - $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->tel.">"; + $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; } return $contact_phone; } @@ -2264,7 +2268,8 @@ class Societe extends CommonObject $this->country_code=$member->country_code; $this->pays_id=$member->country_id; // TODO obsolete $this->country_id=$member->country_id; - $this->tel=$member->phone; // Prof phone + $this->tel=$member->phone; // deprecated + $this->phone=$member->phone; // Prof phone $this->email=$member->email; $this->client = 1; // A member is a customer by default