From c91c70a1315b24461036b7b13c8002122a2cf52a Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Mon, 15 Dec 2014 14:10:56 +0100
Subject: [PATCH] Bug 9743: Allow customization for making hold notes required
Content-Type: text/plain; charset=utf-8
This patch removes some unused code in the reserves template for
mandatory hold notes reasons. It adds a simpler approach: if you
define a custom routine for required hold notes, the textarea is
required under the conditions you specified.
Test plan:
[1] Without adding a routine in opac-reserve:
Place a hold on one and on more biblio numbers.
Verify that hold notes are not required in any case.
[2] Add the following simple routine to opac-reserve:
sub _reqholdnotes { 1; }
Verify that hold notes are always required now.
[3] Place a multiple hold request and check the following:
If you hide the hold notes (and leave them blank), the additional
options (incl. hold notes) should expand again for the first biblio
with required hold notes when submitting the form.
---
.../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 37 +++++++++----------
opac/opac-reserve.pl | 5 ++-
2 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
index 6558e6e..e986911 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
@@ -235,10 +235,11 @@
[% IF ( OpacHoldNotes ) %]
<li>
<div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
- <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
- <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
- <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
- <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
+ <label for="holdnotes_[% bibitemloo.biblionumber %]">Hold notes:</label>
+ [% IF bibitemloo.reqholdnotes %]
+ <span id="reqholdnotes_[% bibitemloo.biblionumber %]">Please enter additional information on the part/volume/serial issue you request:</span>
+ [% END %]
+ <textarea id="holdnotes_[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]" >[% bibitemloo.holdnotes %]</textarea>
</div>
</li>
[% END # / IF OpacHoldNotes %]
@@ -403,10 +404,6 @@
<script type="text/javascript">
// <![CDATA[
var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
- var ForceHoldNotesReasons=new Array(
- _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific item information may be helpful."),
- "*** Add a new reason above this line ***" );
- // NOTE: Do not renumber reasons; this will affect use of existing ones.
// Clear the contents of an input field
$(".clearfield").on("click",function(e){
@@ -469,15 +466,6 @@
[% END %]
[% END %]
- // Insert reasons for forced hold notes
- $(".forcenotesreason").each(function(){
- biblioNum = suffixOf($(this).attr("id"), "_");
- var j=$("#notesmandatory_"+biblioNum).val();
- if(j>0) {
- $(this).html(ForceHoldNotesReasons[j-1]);
- }
- });
-
$(".date-format").each(function(){
if($(this).hasClass("to")){ var op = "to"; }
if($(this).hasClass("from")){ var op = "from"; }
@@ -591,11 +579,23 @@
biblionumbers += biblioNum + "/";
selections += biblioNum + "/";
+ // Check required hold notes
+ if( $("#reqholdnotes_"+biblioNum).length > 0 &&
+ $("#holdnotes_"+biblioNum).val() =='' ) {
+ alert(_("Please enter hold notes"));
+ if( !$("#hold-options-"+biblioNum).is(':visible')) {
+ $("#toggle-hold-options-"+biblioNum).click();
+ }
+ badBib=biblioNum;
+ return false;
+ }
+
// If the 'specific copy' radio button is checked
if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
// Find the selected copy
var item = $(".checkitem_" + biblioNum + ":checked");
if ($(item).size() == 0) {
+ alert(MSG_NO_ITEM_SELECTED);
badBib = biblioNum;
return false;
} else {
@@ -613,8 +613,7 @@
return true;
});
- if (badBib) {
- alert(MSG_NO_ITEM_SELECTED);
+ if (badBib) { // alert has been raised already
return false;
}
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index ba778db..4ab872e 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -396,7 +396,10 @@ foreach my $biblioNum (@biblionumbers) {
$biblioLoopIter{rank} = $biblioData->{rank};
$biblioLoopIter{reservecount} = $biblioData->{reservecount};
$biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
- $biblioLoopIter{mandatorynotes}=0; #FIXME: For future use
+ $biblioLoopIter{reqholdnotes} =
+ defined &_reqholdnotes? _reqholdnotes( $record, $biblioData ): 0;
+ #This allows for local customization: if you define _reqholdnotes
+ #you can force hold notes based on your own rules.
if (!$itemLevelTypes && $biblioData->{itemtype}) {
$biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
--
1.7.7.6