Fix: Phone not saved when using web service

This commit is contained in:
Laurent Destailleur 2012-07-12 14:36:08 +02:00
parent f7eebc0502
commit bea1a50e2c

View File

@ -69,7 +69,8 @@ class Societe extends CommonObject
var $country_code; var $country_code;
var $country; var $country;
var $tel; var $tel; // deprecated
var $phone;
var $fax; var $fax;
var $email; var $email;
var $url; var $url;
@ -399,10 +400,11 @@ class Societe extends CommonObject
$this->state_id=trim($this->state_id); $this->state_id=trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id; $this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id;
$this->pays_id = $this->country_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->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("/\s/","",$this->fax);
$this->fax = preg_replace("/\./","",$this->fax); $this->fax = preg_replace("/\./","",$this->fax);
$this->email = trim($this->email); $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_departement = '" . ($this->state_id?$this->state_id:'0') ."'";
$sql .= ",fk_pays = '" . ($this->country_id?$this->country_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 .= ",fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
$sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null"); $sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null");
$sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null");
@ -639,7 +641,7 @@ class Societe extends CommonObject
$sql .= ', s.status'; $sql .= ', s.status';
$sql .= ', s.price_level'; $sql .= ', s.price_level';
$sql .= ', s.tms as date_update'; $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.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.capital, s.tva_intra';
$sql .= ', s.fk_typent as typent_id'; $sql .= ', s.fk_typent as typent_id';
@ -724,8 +726,8 @@ class Societe extends CommonObject
$this->email = $obj->email; $this->email = $obj->email;
$this->url = $obj->url; $this->url = $obj->url;
$this->tel = $obj->tel; // TODO obsolete $this->tel = $obj->phone; // TODO obsolete
$this->phone = $obj->tel; $this->phone = $obj->phone;
$this->fax = $obj->fax; $this->fax = $obj->fax;
$this->parent = $obj->parent; $this->parent = $obj->parent;
@ -1420,12 +1422,14 @@ class Societe extends CommonObject
{ {
global $langs; global $langs;
if (empty($this->phone) && ! empty($this->tel)) $this->phone=$this->tel;
$contact_phone = $this->contact_property_array('mobile'); $contact_phone = $this->contact_property_array('mobile');
if ($this->tel) if ($this->phone)
{ {
if (empty($this->name)) $this->name=$this->nom; if (empty($this->name)) $this->name=$this->nom;
// TODO: Tester si tel non deja present dans tableau contact // 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; return $contact_phone;
} }
@ -2264,7 +2268,8 @@ class Societe extends CommonObject
$this->country_code=$member->country_code; $this->country_code=$member->country_code;
$this->pays_id=$member->country_id; // TODO obsolete $this->pays_id=$member->country_id; // TODO obsolete
$this->country_id=$member->country_id; $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->email=$member->email;
$this->client = 1; // A member is a customer by default $this->client = 1; // A member is a customer by default