Bug 5446 Item creation in Acquisition module doesn't control mandatory field
authorf.demians at tamil.fr <(frederic@tamil.fr)>
Fri, 26 Nov 2010 07:22:45 +0000 (08:22 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Sat, 11 Dec 2010 18:50:27 +0000 (07:50 +1300)
Add some JS validing form, so saving an order is blocked if any item mandatory
field is empty.

Signed-off-by: Koustubha Kale <kmkale@anantcorp.com>
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl

index e53c7da..85ccb6f 100644 (file)
@@ -36,7 +36,20 @@ function Check(ff) {
 
     if (totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
         ok=1;
-        _alertString += "\n- " + "Order total (" + ff.total.value + ") exceeds budget available ("+actTotal+")";
+        _alertString += "\n- " + _("Order total (") + ff.total.value +
+            _(") exceeds budget available (") + actTotal+")";
+    }
+
+    var empty_item_mandatory = 0;
+    for (i = 0; i < ff.field_value.length; i++) {
+        if (ff.field_value[i].value.length == 0 && ff.mandatory[i].value == 1) {
+            empty_item_mandatory++;
+        }
+    }
+    if (empty_item_mandatory > 0) {
+        ok = 1;
+        _alertString +=
+            "\n- " + empty_item_mandatory + _(" item mandatory fields empty");
     }
 
 if (ok) {