diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 03bdedd3d4f..66f2a6b53d9 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1911,6 +1911,11 @@ class Societe extends CommonObject */ function add_commercial(User $user, $commid) { + $error=0; + + + + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; @@ -1926,6 +1931,12 @@ class Societe extends CommonObject { dol_syslog(get_class($this)."::add_commercial Erreur"); } + else { + $this->context=array('commercial_modified'=>$commid); + + $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user); + if ($result < 0) $error++; + } } } @@ -1938,6 +1949,12 @@ class Societe extends CommonObject */ function del_commercial(User $user, $commid) { + $error=0; + $this->context=array('commercial_modified'=>$commid); + + $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user); + if ($result < 0) $error++; + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux ";