From 0c1ba58a00f96d952214cc37b048d0954c25f3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:13:27 +0200 Subject: [PATCH 01/14] Fix: [ bug #1449 ] Trigger ORDER_CREATE ignores interception on error --- ChangeLog | 1 + htdocs/commande/class/commande.class.php | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3a10ce31ae..2031bd5ec6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ Fix: [ bug #1416 ] Supplier order does not list document models in the select bo supplier order card Fix: [ bug #1443 ] Payment conditions is erased after editing supplier invoice label or limit date for payment +Fix: [ bug #1449 ] Trigger ORDER_CREATE ignores interception on error ***** 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/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b96ea931f21..90c54a5fefe 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -795,8 +795,19 @@ class Commande extends CommonOrder // Fin appel triggers } - $this->db->commit(); - return $this->id; + if (!$error) { + $this->db->commit(); + return $this->id; + } + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } else { From 900b182f3c01218dc963b9b95bd55affffea1d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:22:31 +0200 Subject: [PATCH 02/14] Updated changelog --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2031bd5ec6b..e1649ddec66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,7 @@ Fix: [ bug #1416 ] Supplier order does not list document models in the select bo supplier order card Fix: [ bug #1443 ] Payment conditions is erased after editing supplier invoice label or limit date for payment -Fix: [ bug #1449 ] Trigger ORDER_CREATE ignores interception on error +Fix: [ bug #1449 ] Trigger ORDER_CREATE, LINEORDER_DELETE, LINEORDER_UPDATE and LINEORDER_INSERT ignore interception on error ***** ChangeLog for 3.5.3 compared to 3.5.2 ***** Fix: Error on field accountancy code for export profile of invoices. @@ -29,7 +29,7 @@ Fix: [ bug #1353 ] Email notifications, wrong URL. Fix: [ bug #1362 ] Note is not saved. Fix: tr/td balance. Fix: [ bug #1360 ] note indicator for member tab. -Fix: Nb of notes and doc not visible onto tasks. +Fix: Nb of notes and doc not visible onto task Fix: [ bug #1372 ] Margin calculation does not work in proposals. Fix: [ bug #1381 ] PHP Warning when listing stock transactions page. Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. From 6e0ecc4f780ce79066b31a9510730debaf6b2d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:22:43 +0200 Subject: [PATCH 03/14] Fixed LINEORDER_DELETE interception --- htdocs/commande/class/commande.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 90c54a5fefe..40937fc77e5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3140,6 +3140,8 @@ class OrderLine extends CommonOrderLine $error=0; + $this->db->begin(); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';"; dol_syslog("OrderLine::delete sql=".$sql); @@ -3165,7 +3167,18 @@ class OrderLine extends CommonOrderLine if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - return 1; + if (!$error) { + $this->db->commit(); + return 1; + } + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } else { From 95a58ebef8a248102d9870942b25d632fb6d9aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:23:31 +0200 Subject: [PATCH 04/14] Fixed LINEORDER_UPDATE interception --- htdocs/commande/class/commande.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 40937fc77e5..7281a013552 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3402,8 +3402,18 @@ class OrderLine extends CommonOrderLine // Fin appel triggers } - $this->db->commit(); - return 1; + if (!$error) { + $this->db->commit(); + return 1; + } + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } else { From 7ebd23153249183159b6b343b25042f002bb5cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:23:57 +0200 Subject: [PATCH 05/14] Fixed LINEORDER_INSERT interception --- htdocs/commande/class/commande.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7281a013552..3df18855769 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3294,8 +3294,18 @@ class OrderLine extends CommonOrderLine // Fin appel triggers } - $this->db->commit(); - return 1; + if (!$error) { + $this->db->commit(); + return 1; + } + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } else { From 08588e208086d6a46cdafe9094b3a5e80632d576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:31:48 +0200 Subject: [PATCH 06/14] Fixed ORDER_REOPEN trigger error message --- htdocs/commande/class/commande.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3df18855769..6a0fc61776e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -452,8 +452,13 @@ class Commande extends CommonOrder } else { - $this->db->rollback(); - return -1; + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } } From 86719bc82a7b212e4a4d24f2e540af20c0270383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:35:41 +0200 Subject: [PATCH 07/14] Fixed ORDER_CANCEL trigger error message --- htdocs/commande/class/commande.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6a0fc61776e..0b4cea677fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -584,8 +584,14 @@ class Commande extends CommonOrder else { $this->error=$mouvP->error; + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::cancel ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } $this->db->rollback(); - return -1; + return -1*$error; } } else From 16b1b0f22753d4d844eb30cd30545f4f3477a0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:39:04 +0200 Subject: [PATCH 08/14] Fixed ORDER_CLASSIFY_BILLED trigger error message --- htdocs/commande/class/commande.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0b4cea677fb..8e3e2cab64c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2226,9 +2226,14 @@ class Commande extends CommonOrder else { $this->error=$this->db->error(); - dol_syslog(get_class($this)."::classifyBilled ".$this->error, LOG_ERR); + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::classifyBilled ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } $this->db->rollback(); - return -2; + return -1*$error; } } else From f3807c754cf3784b8f6a2fc9e7da6f2075d70969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 12:44:41 +0200 Subject: [PATCH 09/14] Fixed ORDER_DELETE trigger error message --- htdocs/commande/class/commande.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8e3e2cab64c..6c7b7bb5ff3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2521,9 +2521,13 @@ class Commande extends CommonOrder else { $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } } From 5a3fc00b4c28e96d0e57f637a73ff013e16f9324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 13:32:17 +0200 Subject: [PATCH 10/14] Fix: [ bug #1450 ] Several Customer order's triggers do not report the error from the trigger handler --- htdocs/commande/class/commande.class.php | 11 +++++------ htdocs/commande/fiche.php | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6c7b7bb5ff3..199b6500184 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1792,7 +1792,7 @@ class Commande extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error=$line->error; return -1; } } @@ -2399,11 +2399,10 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->lasterror(); - $this->errors=array($this->db->lasterror()); - $this->db->rollback(); - dol_syslog(get_class($this)."::updateline Error=".$this->error, LOG_ERR); - return -1; + $this->error=$this->line->error; + + $this->db->rollback(); + return -1; } } else diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index c1a6d38a58a..666a1ea10d4 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -140,7 +140,7 @@ else if ($action == 'reopen' && $user->rights->commande->creer) } else { - $mesg='
'.$object->error.'
'; + setEventMessage($object->error, 'errors'); } } } @@ -154,9 +154,8 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->comm header('Location: index.php'); exit; } - else - { - $mesg='
'.$object->error.'
'; + else { + setEventMessage($object->error, 'errors'); } } @@ -187,7 +186,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> } else { - $mesg='
'.$object->error.'
'; + setEventMessage($object->error, 'errors'); } } @@ -445,6 +444,10 @@ else if ($action == 'add' && $user->rights->commande->creer) else if ($action == 'classifybilled' && $user->rights->commande->creer) { $ret=$object->classifyBilled(); + + if ($ret < 0) { + setEventMessage($object->error, 'errors'); + } } // Positionne ref commande client @@ -1076,7 +1079,9 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { $result = $object->cloture($user); - if ($result < 0) $mesgs=$object->errors; + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } } else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) @@ -1097,6 +1102,10 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm if (! $error) { $result = $object->cancel($idwarehouse); + + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } } } From b9801a8b3cbf1304a00ab371f95168d2d56b5ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 13:32:47 +0200 Subject: [PATCH 11/14] Missing changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index e1649ddec66..4755b61153f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ Fix: [ bug #1416 ] Supplier order does not list document models in the select bo Fix: [ bug #1443 ] Payment conditions is erased after editing supplier invoice label or limit date for payment Fix: [ bug #1449 ] Trigger ORDER_CREATE, LINEORDER_DELETE, LINEORDER_UPDATE and LINEORDER_INSERT ignore interception on error +Fix: [ bug #1450 ] Several Customer order's triggers do not report the error from the trigger handler ***** ChangeLog for 3.5.3 compared to 3.5.2 ***** Fix: Error on field accountancy code for export profile of invoices. From 0ef89e40608943b9986a2422728c25d342714680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 13:40:06 +0200 Subject: [PATCH 12/14] Corrected ORDER_CLONE trigger error message --- htdocs/commande/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 666a1ea10d4..34dcccb80b8 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -120,7 +120,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> } else { - $mesg='
'.$object->error.'
'; + setEventMessage($object->error, 'errors'); $action=''; } } From 7cb5cc550fae6d353c5f135cb08a2e5b1cb2bf6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 13:41:17 +0200 Subject: [PATCH 13/14] Didn't mean to change this entry of the changelog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4755b61153f..f77863f1de0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,7 +30,7 @@ Fix: [ bug #1353 ] Email notifications, wrong URL. Fix: [ bug #1362 ] Note is not saved. Fix: tr/td balance. Fix: [ bug #1360 ] note indicator for member tab. -Fix: Nb of notes and doc not visible onto task +Fix: Nb of notes and doc not visible onto tasks. Fix: [ bug #1372 ] Margin calculation does not work in proposals. Fix: [ bug #1381 ] PHP Warning when listing stock transactions page. Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. From ff37adf6f1e8468f7c32bc4631571f3c342ac3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 10 Jun 2014 13:47:30 +0200 Subject: [PATCH 14/14] Fix: [ bug #1451 ] Interrupted order clone through trigger, loads nonexistent order --- ChangeLog | 1 + htdocs/commande/fiche.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index f77863f1de0..8b291cf3d5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ Fix: [ bug #1443 ] Payment conditions is erased after editing supplier invoice l limit date for payment Fix: [ bug #1449 ] Trigger ORDER_CREATE, LINEORDER_DELETE, LINEORDER_UPDATE and LINEORDER_INSERT ignore interception on error Fix: [ bug #1450 ] Several Customer order's triggers do not report the error from the trigger handler +Fix: [ bug #1451 ] Interrupted order clone through trigger, loads nonexistent order ***** 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/commande/fiche.php b/htdocs/commande/fiche.php index 34dcccb80b8..6630477d740 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -112,6 +112,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> { if ($object->id > 0) { + //Because createFromClone modifies the object, we must clone it so that we can restore it later + $orig = clone $object; + $result=$object->createFromClone($socid); if ($result > 0) { @@ -121,6 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> else { setEventMessage($object->error, 'errors'); + $object = $orig; $action=''; } }