[Koha-patches] [PATCH 1/1] Bug 8637: Lack of control on mandatory in orderreveive.tt

Christophe Croullebois christophe.croullebois at biblibre.com
Tue Aug 14 11:46:11 CEST 2012


Just add a check in Jscript when the form is submited, the same as in additem.tt
---
 .../prog/en/modules/acqui/orderreceive.tt          |   22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)

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..50b7fcb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
@@ -7,6 +7,28 @@
 //<![CDATA[
     function Check(form) {
         [% IF (AcqCreateItemReceiving) %]
+            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;
+            }
+
             // Remove last itemblock if it is not in items_list
             var lastitemblock = $("#outeritemblock > div:last");
             var tobedeleted = true;
-- 
1.7.9.5



More information about the Koha-patches mailing list