From e21e4dbf1172586c0a96cb764ebe5d6490d46590 Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 24 Jun 2014 11:49:53 +0200 Subject: [PATCH] - FIX #1482 #1484 #1486 - Add missing triggers in interface_90 --- ChangeLog | 3 +++ .../interface_90_all_Demo.class.php-NORUN | 24 ++++++++++++++++- .../fourn/class/fournisseur.facture.class.php | 26 ++++++++++++++++--- htdocs/fourn/facture/fiche.php | 9 +++++++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40cdcd42252..14a411fa23d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,9 @@ Fix: [ bug #1455 ] outstanding amount Fix: [ bug #1425 ] LINEBILL_SUPPLIER_DELETE failure trigger leads to an endless loop Fix: [ bug #1460 ] Several supplier order triggers do not show error messages Fix: [ bug #1461 ] LINEORDER_SUPPLIER_CREATE does not intercept supplier order line insertion +Fix: [ bug #1484 ] BILL_SUPPLIER_PAYED trigger action does not intercept failure under some circumstances +Fix: [ bug #1482 ] Several supplier invoice triggers do not show trigger error messages +Fix: [ bug #1486 ] LINEBILL_SUPPLIER_CREATE and LINEBILL_SUPPLIER_UPDATE triggers do not intercept trigger action ***** ChangeLog for 3.5.3 compared to 3.5.2 ***** Fix: Error on field accountancy code for export profile of invoices. diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 9ab71904ac3..e7892582e08 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -431,6 +431,28 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + + //Supplier Bill + elseif ($action == 'BILL_SUPPLIER_CREATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'BILL_SUPPLIER_DELETE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'BILL_SUPPLIER_PAYED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'BILL_SUPPLIER_UNPAYED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'BILL_SUPPLIER_VALIDATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'LINEBILL_SUPPLIER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -443,7 +465,7 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } - + // Payments elseif ($action == 'PAYMENT_CUSTOMER_CREATE') { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6f9d132a477..6e0e8732410 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -651,7 +651,10 @@ class FactureFournisseur extends CommonInvoice $interface=new Interfaces($this->db); $result=$interface->run_triggers('BILL_SUPPLIER_DELETE',$this,$user,$langs,$conf); if ($result < 0) { - $error++; $this->errors=$interface->errors; + $error++; + $this->errors=$interface->errors; + $this->db->rollback(); + return -1; } // Fin appel triggers } @@ -1103,7 +1106,13 @@ class FactureFournisseur extends CommonInvoice include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers('LINEBILL_SUPPLIER_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + if ($result < 0) + { + $error++; + $this->errors=$interface->errors; + $this->db->rollback(); + return -1; + } // Fin appel triggers } @@ -1193,6 +1202,8 @@ class FactureFournisseur extends CommonInvoice $product_type = $type; } + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql.= " description ='".$this->db->escape($desc)."'"; $sql.= ", pu_ht = ".price2num($pu_ht); @@ -1228,17 +1239,26 @@ class FactureFournisseur extends CommonInvoice include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers('LINEBILL_SUPPLIER_UPDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + if ($result < 0) + { + $error++; + $this->errors=$interface->errors; + $this->db->rollback(); + return -1; + } // Fin appel triggers } // Update total price into invoice record $result=$this->update_price(); + $this->db->commit(); + return $result; } else { + $this->db->rollback(); $this->error=$this->db->lasterror(); dol_syslog(get_class($this)."::updateline error=".$this->error, LOG_ERR); return -1; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index d0bc7e5dfa4..f8b991969e1 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -188,6 +188,10 @@ elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournis { $object->fetch($id); $result=$object->set_paid($user); + if ($result<0) + { + setEventMessage($object->error,'errors'); + } } // Set supplier ref @@ -524,6 +528,10 @@ elseif ($action == 'update_line' && $user->rights->fournisseur->facture->creer) { unset($_POST['label']); } + else + { + setEventMessage($object->error,'errors'); + } } } @@ -1074,6 +1082,7 @@ if ($action == 'create') print_fiche_titre($langs->trans('NewBill')); dol_htmloutput_mesg($mesg); + dol_htmloutput_events(); $societe=''; if ($_GET['socid'])