From ca8c1adf55dc1f3ded447626064e9815d8856306 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Wed, 21 Oct 2015 10:07:53 +0200 Subject: [PATCH] Add trigger "SUPPLIER_PRODUCT_BUYPRICE_DELETE" for frounisseur.product remove_product_fournisseur_price() --- .../fourn/class/fournisseur.product.class.php | 19 ++++++++++++++++--- htdocs/product/fournisseurs.php | 9 +++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 490b5cf1ea3..346f69a4cef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -121,7 +121,7 @@ class ProductFournisseur extends Product */ function remove_product_fournisseur_price($rowid) { - global $conf; + global $conf, $user; $this->db->begin(); @@ -132,8 +132,21 @@ class ProductFournisseur extends Product $resql = $this->db->query($sql); if ($resql) { - $this->db->commit(); - return 1; + // Call trigger + $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + + if (empty($error)) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } else { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 72f8ed2b0b2..526b67b123c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -95,9 +95,14 @@ if (empty($reshook)) { if ($rowid) { - $result=$object->remove_product_fournisseur_price($rowid); $action = ''; - setEventMessage($langs->trans("PriceRemoved")); + $result=$product->remove_product_fournisseur_price($rowid); + if($result > 0){ + setEventMessage($langs->trans("PriceRemoved")); + }else{ + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + } } }