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 4f80fae42c..72c1140b60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -1337,6 +1337,23 @@ }); $('.modal-save').click(function() { + + //We need to validate the item forms here - if one is opened with missing subfields at + //confirm, it would be submitted without this + var _alertString= _("Form not submitted because of the following problem(s)")+"\n"; + _alertString +="-------------------------------------------------------------------\n\n"; + var empty_mandatory_fields = 0; + $('div[id^="itemblock"]').each(function(){ + var item_form = $(this); + var empty_item_mandatory = CheckMandatorySubfields(item_form); + empty_mandatory_fields += empty_item_mandatory; + }); + if (empty_mandatory_fields > 0) { + _alertString +="\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields); + alert(_alertString); + return false; + } + var saved_rows = save_row(); if(Object.keys(saved_rows).length) $('.save').prop('disabled', false); $("#order_edit").modal('hide'); diff --git a/koha-tmpl/intranet-tmpl/prog/js/additem.js b/koha-tmpl/intranet-tmpl/prog/js/additem.js index 35ee4e2995..b3045c656e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/additem.js +++ b/koha-tmpl/intranet-tmpl/prog/js/additem.js @@ -1,7 +1,21 @@ /* global __ */ /* exported addItem checkCount showItem deleteItemBlock clearItemBlock check_additem */ function addItem( node, unique_item_fields ) { - var index = $(node).closest("div").attr('id'); + var item_form = $(node).closest("div"); + var index = item_form.attr("id"); + + //We need to verify the item form before saving + var empty_item_mandatory = CheckMandatorySubfields(item_form); + if (empty_item_mandatory > 0) { + var _alertString= _("Form not submitted because of the following problem(s)")+"\n"; + + _alertString +="-------------------------------------------------------------------\n\n"; + _alertString += + "\n- " + _("%s item mandatory fields empty").format(empty_item_mandatory); + alert(_alertString); + return false; + } + var current_qty = parseInt($("#quantity").val()); var max_qty; if($("#quantity_to_receive").length != 0){