From e8d2236fb703d8b39872c8a0b18624f32dcabc32 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 in the template may turn into a required field, otherwise it will not. 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. --- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 22 +++++-------------- opac/opac-reserve.pl | 5 +++- 2 files changed, 10 insertions(+), 17 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..2d38508 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -236,9 +236,12 @@ <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 %]"/> + [% IF bibitemloo.reqholdnotes %] + <span>Please enter additional information on the part/volume/serial issue you request:</span> + <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]" required >[% bibitemloo.holdnotes %]</textarea> + [% ELSE %] + <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea> + [% END %] </div> </li> [% END # / IF OpacHoldNotes %] @@ -403,10 +406,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 +468,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"; } 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