From 04228cca82989ccf79c116805aec09521c33471d Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 4 May 2018 12:20:29 +0200 Subject: [PATCH 1/2] NEW triggers add commercial and del commercial --- htdocs/societe/class/societe.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 32f29522268..05e15b9cb03 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1909,6 +1909,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"; @@ -1924,6 +1929,12 @@ class Societe extends CommonObject { dol_syslog(get_class($this)."::add_commercial Erreur"); } + else { + $this->commercial_modified = $commid; + + $result=$this->call_trigger('COMPANY_ADD_COMMERCIAL',$user); + if ($result < 0) $error++; + } } } @@ -1936,6 +1947,12 @@ class Societe extends CommonObject */ function del_commercial(User $user, $commid) { + $error=0; + $this->commercial_modified = $commid; + + $result=$this->call_trigger('COMPANY_DEL_COMMERCIAL',$user); + if ($result < 0) $error++; + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; From 5802eb63ecf07f5100e697cc471272429b1043db Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 7 May 2018 11:36:34 +0200 Subject: [PATCH 2/2] FIX name of trigger and use of context --- htdocs/societe/class/societe.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 05e15b9cb03..69812787b8c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1930,9 +1930,9 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::add_commercial Erreur"); } else { - $this->commercial_modified = $commid; + $this->context=array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_ADD_COMMERCIAL',$user); + $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; } } @@ -1948,9 +1948,9 @@ class Societe extends CommonObject function del_commercial(User $user, $commid) { $error=0; - $this->commercial_modified = $commid; + $this->context=array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_DEL_COMMERCIAL',$user); + $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; if ($this->id > 0 && $commid > 0)