From b47e6e452072244f1973904e49cdebaba84bbc1e Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Thu, 28 Jul 2016 15:58:45 +0200 Subject: [PATCH] FIX #5544 Disabled Contact still appear in lists to send emails --- htdocs/societe/class/societe.class.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e9b77836d3c..9f48f7c0541 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1936,12 +1936,24 @@ class Societe extends CommonObject { global $langs; - $contact_emails = $this->contact_property_array('email'); + $contact_emails = $this->contact_property_array('email',1); if ($this->email && $addthirdparty) { - if (empty($this->name)) $this->name=$this->nom; - // TODO: Tester si email non deja present dans tableau contact - $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + $exist = 0; + foreach($contact_emails as $contacts){ + if($exist ===0){ + $contacts = str_replace('>','',$contacts); + $contacts = explode ('<',$contacts); + if($contacts[1]===$this->email){ + $exist = 1; + } + } + } + if($exist ===0){ + if (empty($this->name)) $this->name=$this->nom; + $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + } + } return $contact_emails; }