[Koha-patches] [PATCH 1/1] Bug 8637: Lack of control on mandatory in orderreveive.tt
Christophe Croullebois
christophe.croullebois at biblibre.com
Thu Aug 16 14:54:50 CEST 2012
Just add a check in Jscript when the form is submited, the same as in additem.tt
On Owen's suggestion I have added the red color and 'Required', the same as in additem.
---
.../prog/en/modules/acqui/orderreceive.tt | 22 ++++++++++++++++++++
.../prog/en/modules/services/itemrecorddisplay.tt | 16 ++++++--------
2 files changed, 28 insertions(+), 10 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..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;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt
index 6790b3d..78a5ab2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt
@@ -2,22 +2,18 @@
[% FOREACH iteminfo IN iteminformation %]
<li>
<div class="subfield_line" style="[% iteminfo.hidden %];" id="subfield[% iteminfo.serialid %][% iteminfo.countitems %][% iteminfo.subfield %][% iteminfo.random %]">
- <label>
- [% iteminfo.subfield %] -
- [% IF ( iteminfo.mandatory ) %]
- <b>
- [% END %]
- [% iteminfo.marc_lib %]
- [% IF ( iteminfo.mandatory ) %]
- *</b>
- [% END %]
- </label>
+ [% IF (iteminfo.mandatory) %]
+ <label style="color : #C00;">[% iteminfo.subfield %] - [% iteminfo.marc_lib %]</label>
+ [% ELSE %]
+ <label>[% iteminfo.subfield %] - [% iteminfo.marc_lib %]</label>
+ [% END %]
[% iteminfo.marc_value %]
<input type="hidden" name="itemid" value="1" />
<input type="hidden" name="kohafield" value="[% iteminfo.kohafield %]" />
<input type="hidden" name="tag" value="[% iteminfo.tag %]" />
<input type="hidden" name="subfield" value="[% iteminfo.subfield %]" />
<input type="hidden" name="mandatory" value="[% iteminfo.mandatory %]" />
+ [% IF (iteminfo.mandatory) %] <span style="font-style : italic; color : #C00;">Required</span>[% END %]
</div>
</li>
[% END %]
--
1.7.9.5
More information about the Koha-patches
mailing list