From e3922a23f136e565acdca0506973341ac647a8a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Apr 2008 12:47:23 +0000 Subject: [PATCH] Fix: Duplicate automatic contact add when adding a third party. --- htdocs/contact.class.php | 4 ++-- htdocs/soc.php | 6 +++--- htdocs/societe.class.php | 30 ++---------------------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 25c06a7d8bf..f12f8acd914 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -159,8 +159,8 @@ class Contact extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; - if ($this->socid > 0) $sql .= " fk_soc='".addslashes($this->socid)."',"; - if ($this->socid == -1) $sql .= " fk_soc=null,"; + if ($this->socid > 0) $sql .= " fk_soc='".addslashes($this->socid)."',"; + if ($this->socid == -1) $sql .= " fk_soc=null,"; $sql .= " civilite='".addslashes($this->civilite_id)."'"; $sql .= ", name='".addslashes($this->name)."'"; $sql .= ", firstname='".addslashes($this->firstname)."'"; diff --git a/htdocs/soc.php b/htdocs/soc.php index 73b190f9d05..41367e49af2 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -158,9 +158,9 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $contact=new Contact($db); $contact->civilite_id = $soc->civilite_id; - $contact->name=$soc->name; - $contact->firstname=$soc->firstname; - $contact->address=$soc->address; + $contact->name=$soc->nom_particulier; + $contact->firstname=$soc->prenom; + $contact->address=$soc->adresse; $contact->cp=$soc->cp; $contact->ville=$soc->ville; $contact->fk_pays=$soc->fk_pays; diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 1415b459b53..6282ebf7866 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -421,34 +421,8 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - - //Si c'est un particulier on cr�e la fiche contact - if ($this->particulier == 1) - { - require_once (DOL_DOCUMENT_ROOT."/contact.class.php"); - $contact = new Contact($this->db); - - $contact->socid = $id; - $contact->name = $this->nom_particulier; - $contact->firstname = $this->prenom; - //$contact->civilite_id = $_POST["civilite_id"]; - //$contact->poste = $_POST["poste"]; - $contact->address = $this->adresse; - $contact->cp = $this->cp; - $contact->ville = $this->ville; - $contact->fk_pays = $this->pays_id; - $contact->email = $this->email; - $contact->phone_pro = $this->tel; - //$contact->phone_perso = $_POST["phone_perso"]; - //$contact->phone_mobile = $_POST["phone_mobile"]; - $contact->fax = $this->fax; - - $id = $contact->create($user); - } - - - // si le fournisseur est classe on l'ajoute - $this->AddFournisseurInCategory($this->fournisseur_categorie); + // Si le fournisseur est classe on l'ajoute + $this->AddFournisseurInCategory($this->fournisseur_categorie); if ($call_trigger) {