From 9b2f186e8e4eab1ed19fbdd241e59be9ae625ece Mon Sep 17 00:00:00 2001 From: Christophe Croullebois Date: Mon, 13 Aug 2012 17:09:30 +0200 Subject: [PATCH 1/1] (MT #9956) Lack of control on mandatory in orderreveive.tt Just add a check in Jscript when the form is submited --- .../prog/en/modules/acqui/orderreceive.tt | 22 ++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 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 821dcd3..a7e6cba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -8,6 +8,28 @@ function Check(form) { [% IF (AcqCreateItemReceiving) %] // Remove last itemblock if it is not in items_list + var total_errors=0; + $("input[name='mandatory'],select[name='mandatory']").each(function(i){ + if($(this).val() == 1){ + var mandatory_field = $("input[name='field_value'],select[name='field_value']").eq(i); + if(mandatory_field.val() == ''){ + mandatory_field.css("background-color","#FFFFCC"); + total_errors++; + } + } + }); + + var alertString2; + if (total_errors==0) { + return true; + } else { + alertString2 = _("Form not submitted because of the following problem(s)"); + alertString2 += "\n------------------------------------------------------------------------------------\n"; + alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)"); + alert(alertString2); + return false; + } + var lastitemblock = $("#outeritemblock > div:last"); var tobedeleted = true; var listitems = $("#items_list tr"); -- 1.7.0.4