From 3de2b4478286c8cfacbd57a0e095f47eca81c27f Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 21 Nov 2012 17:38:28 +0100 Subject: [PATCH] Bug 9126: Do not return from Check too early. If there is no errors, it should continue instead of returning true. + move a block of code at the end of Check function. This avoid detaching and re-attaching a HTML block if there are errors. Signed-off-by: Jonathan Druart The following queries show us the issues: select count(*) from items; select * from aqorders_items where ordernumber=XX; Signed-off-by: Katrin Fischer To test: AcqCreateItem = receive UniqueItemFields = barcode 1) Create a new basket 2) Create a new order with quantity > 1 3) Close the basket and create a new invoice/shipment 4) Receive only 1 item. - Fill out the first item form with item type only. Click add. - Don't change second item form at all. - Click save. Before patch: 2 items are created on the record, both with the selected itemtype. After patch: Only 1 item is created, which is correct. Signed-off-by: Elliott Davis Seems to work as described by the test plan Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/acqui/orderreceive.tt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index da9aefea7b..84378ead7b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -18,17 +18,19 @@ } }); - var alertString; - if (total_errors==0) { - return true; - } else { - alertString = _("Form not submitted because of the following problem(s)"); + if (total_errors != 0) { + var alertString = _("Form not submitted because of the following problem(s)"); alertString += "\n------------------------------------------------------------------------------------\n"; alertString += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)"); alert(alertString); return false; } + if(check_additem('[% UniqueItemFields %]') == false){ + alert(_('Duplicate values detected. Please correct the errors and resubmit.') ); + return false; + }; + // Remove last itemblock if it is not in items_list var lastitemblock = $("#outeritemblock > div:last"); var tobedeleted = true; @@ -41,14 +43,6 @@ if(tobedeleted){ $(lastitemblock).remove(); } - - if(check_additem('[% UniqueItemFields %]') == false){ - alert(_('Duplicate values detected. Please correct the errors and resubmit.') ); - if(tobedeleted) { - $(lastitemblock).appendTo("#outeritemblock"); - } - return false; - }; [% END %] return true; -- 2.39.5