From e418e10df07c2b20b32913be4154b72d97164cd5 Mon Sep 17 00:00:00 2001 From: "geoffrey.girard" Date: Fri, 17 Jan 2014 09:45:57 +0100 Subject: [PATCH 1/3] Add new doActions hook on supplier prices page --- htdocs/product/fournisseurs.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index e98ce39bfe9..cd5f69ba95d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -72,6 +72,10 @@ if (! $sortorder) $sortorder="ASC"; /* * Actions */ + +$parameters=array('socid'=>$socid, 'id_prod'=>$id); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); if ($action == 'remove_pf') { @@ -385,6 +389,12 @@ if ($id || $ref) print ''; print ''; } + + if (is_object($hookmanager)) + { + $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$product->id); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); + } print ''; From 872979001684ce714472fcb4f59771666bde5683 Mon Sep 17 00:00:00 2001 From: "geoffrey.girard" Date: Fri, 17 Jan 2014 10:38:18 +0100 Subject: [PATCH 2/3] Add trigger on update product buyprice --- htdocs/fourn/class/fournisseur.product.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 10bbd8b270b..1f622103b09 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -201,6 +201,16 @@ class ProductFournisseur extends Product if ($resql) { $this->db->commit(); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('UPDATE_BUYPRICE',$this,$user,$langs,$conf); + if ($result < 0) + { + $error++; $this->errors=$interface->errors; + } + return 0; } else From 7f59def98bb01c6dffa57442ce9a560083d6b1ca Mon Sep 17 00:00:00 2001 From: "geoffrey.girard" Date: Wed, 22 Jan 2014 10:44:23 +0100 Subject: [PATCH 3/3] Correction trigger on update product buyprice --- htdocs/fourn/class/fournisseur.product.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 1f622103b09..a54b2bc2ce5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -199,9 +199,7 @@ class ProductFournisseur extends Product dol_syslog(get_class($this).'::update_buyprice sql='.$sql); $resql = $this->db->query($sql); if ($resql) - { - $this->db->commit(); - + { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); @@ -211,7 +209,16 @@ class ProductFournisseur extends Product $error++; $this->errors=$interface->errors; } - return 0; + if (empty($error)) + { + $this->db->commit(); + return 0; + } + else + { + $this->db->rollback(); + return 1; + } } else {