From de159d569a5de6fae34e47154b3ced92e3e8a547 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Feb 2014 16:40:25 +0100 Subject: [PATCH] Fix: Missing transactions --- htdocs/product/stock/replenish.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 887a23ac0bc..081603a3103 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -81,7 +81,10 @@ if ($action == 'order' && isset($_POST['valid'])) $linecount = GETPOST('linecount', 'int'); $box = 0; unset($_POST['linecount']); - if ($linecount > 0) { + if ($linecount > 0) + { + $db->begin(); + $suppliers = array(); for ($i = 0; $i < $linecount; $i++) { @@ -154,13 +157,22 @@ if ($action == 'order' && isset($_POST['valid'])) } $i++; } - if (!$fail && $id) { + + if (! $fail && $id) + { + $db->commit(); + setEventMessage($langs->trans('OrderCreated'), 'mesgs'); header('Location: replenishorders.php'); exit; } + else + { + $db->rollback(); + } } - if ($box == 0) { + if ($box == 0) + { setEventMessage($langs->trans('SelectProductWithNotNullQty'), 'warnings'); } }