[Koha-patches] [PATCH] Bug 5446 Item creation in Acquisition module doesn't control mandatory field

Frédéric Demians f.demians at tamil.fr
Fri Nov 26 08:22:45 CET 2010


Add some JS validing form, so saving an order is blocked if any item mandatory
field is empty.
---
 .../prog/en/modules/acqui/neworderempty.tmpl       |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
index e53c7da..85ccb6f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
@@ -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) {
-- 
1.7.3.2



More information about the Koha-patches mailing list