diff --git a/ChangeLog b/ChangeLog
index bb23bc6940e..6498158b912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -81,6 +81,9 @@ For users:
- Fix: [ bug #1439 ] impossible to remove a a translation (multilanguage-feature)
- New: If multilangue is enabled, mail (from propal, invoice, etc...) message is pre-defaulted in Customer language
- Fix: [ bug #1459 ] _ADD_CONTACT and _DEL_CONTACT triggers do not intercept insertion when reported an error
+- Fix: [ bug #1478 ] BILL_PAYED trigger action does not intercept failure under some circumstances
+- Fix: [ bug #1479 ] Several customer invoice triggers do not intercept trigger action
+- Fix: [ bug #1477 ] Several customer invoice triggers do not show trigger error messages
For translators:
- Update language files.
@@ -122,6 +125,7 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
***** ChangeLog for 3.5.4 compared to 3.5.3 *****
+Fix: When using option MAIN_MAIL_ALLOW_SENDMAIL_F, a mail was sent to sender.
Fix: Question about warehouse must not be done when module stock is disabled.
Fix: Option STOCK_SUPPORTS_SERVICES was not correctly implemented
(missing test at some places).
@@ -155,8 +159,12 @@ Fix: If multiprice level is used the VAT on addline is not correct
Fix: [ bug #1254 ] Error when using "Enter" on qty input box of a product (on supplier order part)
Fix: [ bug #1462, 1468, 1480, 1483, 1490, 1497] $this instead of $object
Fix: [ bug #1455 ] outstanding amount
-Fix: [ bug #1425 ]
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/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index 0fcedb8e96d..36967d56e22 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -873,7 +873,8 @@ if ($rowid)
$name = $object->getFullName($langs);
if (! empty($name))
{
- if ($object->societe) $name.=' ('.$object->societe.')';
+ if ($object->morphy == 'mor' && ! empty($object->societe)) $name=$object->societe.' ('.$name.')';
+ else if ($object->societe) $name.=' ('.$object->societe.')';
}
else
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 450e9e86762..8b37f6196c9 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -124,7 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
exit();
} else {
- $mesgs [] = $object->error;
+ setEventMessage($object->error, 'errors');
$action = '';
}
}
@@ -140,7 +140,7 @@ else if ($action == 'reopen' && $user->rights->facture->creer) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
exit();
} else {
- $mesgs [] = '
' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
}
}
}
@@ -164,7 +164,8 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php');
exit();
} else {
- $mesgs [] = '' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
+ $action='';
}
}
@@ -195,7 +196,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
exit();
}
} else {
- $mesgs [] = '' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
$action = '';
}
}
@@ -453,7 +454,8 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
- $object->set_draft($user, $idwarehouse);
+ $result=$object->set_draft($user, $idwarehouse);
+ if ($result<0) setEventMessage($object->error,'errors');
// Define output language
$outputlangs = $langs;
@@ -478,6 +480,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) {
$object->fetch($id);
$result = $object->set_paid($user);
+ if ($result<0) setEventMessage($object->error,'errors');
} // Classif "paid partialy"
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) {
$object->fetch($id);
@@ -485,6 +488,7 @@ else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->righ
$close_note = $_POST["close_note"];
if ($close_code) {
$result = $object->set_paid($user, $close_code, $close_note);
+ if ($result<0) setEventMessage($object->error,'errors');
} else {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors');
}
@@ -495,6 +499,7 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes') {
$close_note = $_POST["close_note"];
if ($close_code) {
$result = $object->set_canceled($user, $close_code, $close_note);
+ if ($result<0) setEventMessage($object->error,'errors');
} else {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors');
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index fb92a3b69e1..096fee84d6a 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1564,7 +1564,11 @@ class Facture extends CommonInvoice
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_CANCEL',$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
@@ -1808,7 +1812,6 @@ class Facture extends CommonInvoice
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
return -1;
}
}
@@ -2216,6 +2219,7 @@ class Facture extends CommonInvoice
}
else
{
+ $this->error=$this->line->error;
$this->db->rollback();
return -1;
}
@@ -2286,7 +2290,7 @@ class Facture extends CommonInvoice
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
+ $this->error=$line->error;
return -1;
}
}
@@ -3570,8 +3574,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_INSERT',$this,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $this->errors=$interface->errors;
+ if ($result < 0)
+ {
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ return -2;
}
// Fin appel triggers
}
@@ -3683,8 +3691,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_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 -2;
}
// Fin appel triggers
}
@@ -3721,8 +3733,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_DELETE',$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
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 93f5f017c44..0eea10bf510 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -221,7 +221,15 @@ class Paiement extends CommonObject
if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice. We do nothing more.");
else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
- else $result=$invoice->set_paid($user,'','');
+ else
+ {
+ $result=$invoice->set_paid($user,'','');
+ if ($result<0)
+ {
+ $this->error=$invoice->error;
+ $error++;
+ }
+ }
}
}
else
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index ed9464a14b3..c16af4c5b24 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -405,7 +405,7 @@ class CMailFile
// le return-path dans les header ne fonctionne pas avec tous les MTA
// Le passage par -f est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie.
// La variable definie pose des pb avec certains sendmail securisee (option -f refusee car dangereuse)
- $bounce .= ($bounce?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $conf->global->MAIN_MAIL_ERRORS_TO : ($this->addr_from != '' ? '-f' . $this->addr_from : '') );
+ $bounce .= ($bounce?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO,2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from,2) : '') );
}
if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender
{
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 e3257e2bda8..f0f96961b86 100644
--- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
+++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
@@ -257,10 +257,30 @@ class InterfaceDemo
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
+ elseif ($action == 'ORDER_SUPPLIER_CLONE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
+ elseif ($action == 'ORDER_SUPPLIER_DELETE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'ORDER_SUPPLIER_APPROVE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'ORDER_SUPPLIER_REFUSE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'ORDER_SUPPLIER_CANCEL')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -396,6 +416,10 @@ class InterfaceDemo
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_DELETE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'BILL_PAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
@@ -411,6 +435,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);
@@ -423,7 +469,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.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 704e06b2f3b..a70b71c7b5f 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -393,7 +393,13 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$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
}
@@ -404,9 +410,9 @@ class CommandeFournisseur extends CommonOrder
}
else
{
+ $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
$this->db->rollback();
- $this->error=$this->db->lasterror();
return -1;
}
}
@@ -666,7 +672,6 @@ class CommandeFournisseur extends CommonOrder
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
return -1;
}
}
@@ -701,6 +706,8 @@ class CommandeFournisseur extends CommonOrder
$result = 0;
if ($user->rights->fournisseur->commande->approuver)
{
+ $this->db->begin();
+
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9";
$sql .= " WHERE rowid = ".$this->id;
@@ -715,12 +722,19 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ if ($result < 0)
+ {
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ }
// Fin appel triggers
}
}
else
{
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::refuse Error -1");
$result = -1;
}
@@ -777,7 +791,6 @@ class CommandeFournisseur extends CommonOrder
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
return -1;
}
}
@@ -961,7 +974,13 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_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
}
@@ -1212,7 +1231,13 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_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
}
@@ -1280,7 +1305,13 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_SUPPLIER_DISPATCH',$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
}
@@ -1310,6 +1341,7 @@ class CommandeFournisseur extends CommonOrder
}
}
+ //TODO: Check if there is a current transaction in DB but seems not.
if ($error == 0)
{
$this->db->commit();
@@ -1333,18 +1365,15 @@ class CommandeFournisseur extends CommonOrder
*
* @param int $idline Id of line to delete
* @param int $notrigger 1=Disable call to triggers
- * @return 0 if Ok, <0 ik Ko
+ * @return >=0 if OK, <0 if KO
*/
function deleteline($idline, $notrigger=0)
{
if ($this->statut == 0)
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline;
- $resql=$this->db->query($sql);
+ $this->db->begin();
- dol_syslog(get_class($this)."::deleteline sql=".$sql);
-
- if (!$notrigger && $resql)
+ if (! $notrigger)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
@@ -1357,14 +1386,29 @@ class CommandeFournisseur extends CommonOrder
// Fin appel triggers
}
- if ($resql)
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline;
+ $resql=$this->db->query($sql);
+
+ dol_syslog(get_class($this)."::deleteline sql=".$sql);
+ if (! $resql)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+
+ if (! $error)
{
$result=$this->update_price();
+
+ $this->db->commit();
return 0;
}
else
- {
- $this->error=$this->db->error();
+ {
+ $this->db->rollback();
return -1;
}
}
@@ -1402,11 +1446,13 @@ class CommandeFournisseur extends CommonOrder
{
if ($this->db->affected_rows($resql) < 1)
{
+ $this->error=$this->db->lasterror();
$error++;
}
}
else
{
+ $this->error=$this->db->lasterror();
$error++;
}
@@ -1469,7 +1515,6 @@ class CommandeFournisseur extends CommonOrder
}
else
{
- $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -$error;
@@ -1670,7 +1715,7 @@ class CommandeFournisseur extends CommonOrder
$resql = $this->db->query($sql);
if ($resql)
{
-
+ //TODO: Add trigger for status modification
}
else
{
@@ -1794,7 +1839,13 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_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
}
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 9b523b2bc60..786d619665e 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -676,7 +676,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
}
@@ -1129,7 +1132,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
}
@@ -1219,6 +1228,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);
@@ -1254,17 +1265,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('','auto');
+ $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/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 0c975158474..07d43231005 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -939,7 +939,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
if ($error)
{
- dol_print_error($db);
+ setEventMessage($object->error, 'errors');
}
else
{
@@ -1065,6 +1065,7 @@ if ($action=="create")
print_fiche_titre($langs->trans('NewOrder'));
dol_htmloutput_mesg($mesg);
+ dol_htmloutput_events();
$societe='';
if ($socid>0)
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index fde8b63e299..e929a6b548a 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -190,6 +190,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
@@ -518,6 +522,10 @@ elseif ($action == 'update_line' && $user->rights->fournisseur->facture->creer)
{
unset($_POST['label']);
}
+ else
+ {
+ setEventMessage($object->error,'errors');
+ }
}
}
@@ -1107,6 +1115,7 @@ if ($action == 'create')
print_fiche_titre($langs->trans('NewBill'));
dol_htmloutput_mesg($mesg);
+ dol_htmloutput_events();
$societe='';
if ($_GET['socid'])
diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php
index 8e1f50782e2..05046f5ad60 100644
--- a/htdocs/holiday/month_report.php
+++ b/htdocs/holiday/month_report.php
@@ -61,8 +61,8 @@ if(empty($year)) {
}
$sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, cp.halfday";
-$sql.= " FROM llx_holiday cp";
-$sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid";
+$sql.= " FROM " . MAIN_DB_PREFIX . "holiday cp";
+$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "user u ON cp.fk_user = u.rowid";
$sql.= " WHERE cp.statut = 3"; // Approved
// TODO Use BETWEEN instead of date_format
$sql.= " AND (date_format(cp.date_debut, '%Y-%c') = '$year-$month' OR date_format(cp.date_fin, '%Y-%c') = '$year-$month')";
diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php
index eb11b91a56d..e155418226a 100644
--- a/htdocs/product/stock/lib/replenishment.lib.php
+++ b/htdocs/product/stock/lib/replenishment.lib.php
@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
function dispatched($order_id)
{
global $db;
- $sql = 'SELECT fk_product, SUM(qty) from llx_commande_fournisseur_dispatch';
+ $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch';
$sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product';
$sql .= ' ORDER by fk_product';
$resql = $db->query($sql);
@@ -44,7 +44,7 @@ function dispatched($order_id)
while($res = $db->fetch_object($resql))
$dispatched[] = $res;
}
- $sql = 'SELECT fk_product, SUM(qty) from llx_commande_fournisseurdet';
+ $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet';
$sql .= ' WHERE fk_commande = ' . $order_id . ' GROUP BY fk_product';
$sql .= ' ORDER by fk_product';
$resql = $db->query($sql);