From 688073dc18b49d836341c8b2f549a5990faae026 Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Wed, 15 Mar 2017 10:31:45 +0100 Subject: [PATCH] Create a trigger for company create RIB Since there no 'trigger' executed when we create a RIB for a company (COMPANY_CREATE, COMPANY_MODIFY, COMPANY_DELETE not executed), I purpose a new one COMPANY_RIB_CREATE. If this PR is qualified i will purpose COMPANY_RIB_MODIFY and COMPANY_RIB_DELETE too. tks --- .../class/companybankaccount.class.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 7d1afae725d..d59bedd03af 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -69,8 +69,8 @@ class CompanyBankAccount extends Account */ function create(User $user = null, $notrigger=0) { - $now=dol_now(); - + $now = dol_now(); + $error = 0; // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1"; $result = $this->db->query($sql); @@ -89,7 +89,21 @@ class CompanyBankAccount extends Account if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - return 1; + + // Call trigger + $result=$this->call_trigger('COMPANY_RIB_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + + if(! $error ) + { + return 1; + } + else + { + return 0; + } + } } else