Bugzilla – Attachment 49085 Details for
Bug 15545
Remove remainders of unfinished reqholdnotes functionality
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15545: Optionally require notes when placing a hold
Bug-15545-Optionally-require-notes-when-placing-a-.patch (text/plain), 9.19 KB, created by
Marcel de Rooy
on 2016-03-14 07:49:59 UTC
(
hide
)
Description:
Bug 15545: Optionally require notes when placing a hold
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-03-14 07:49:59 UTC
Size:
9.19 KB
patch
obsolete
>From 789f9f80ddef661f60c6c2ba7db6714a569af3e2 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 15545: Optionally require notes when placing a hold >Content-Type: text/plain; charset=utf-8 > >This report adds three cases where you could want to require a note when >placing a hold. Each of these cases may be enabled separately via the >system preference HoldNoteReasons. (The hold note itself is triggered >by OpacHoldNotes.) > >These three cases are: >[1] serial indication in the leader (called LEADER_SERIAL) >[2] collection indication in the leader (LEADER_COLLECTION) >[3] MARC 300$a contains an indication of multiple parts/volumes, as > identified by a regular expression (MARC300A_PARTS). > >The new sub IsHoldNoteRequired in Reserves.pm handles these cases. And will >be easily extensible. >Also this patch removes some unused code in the reserves template for >mandatory hold notes reasons. > >Test plan: >[1] Enable OpacHoldNotes. Set HoldNoteReasons to LEADER_SERIAL. >[2] In OPAC, place a hold on a serial record (with correct leader). > Verify that the hold notes are required. >[3] Set HoldNoteReasons to MARC300A_PARTS. > Verify that the hold notes are no longer required for the record in > the preceding step. (This actually depends on your 300$a..) > Cancel the hold you placed. >[4] Add "2 vols" to MARC 300$a in the same record. > Try to place the hold again. The hold notes should be required again. >[5] Place a multiple hold request with the same record and another one. > Click Place Hold while more-options is collapsed (blank notes). > Is the correct hold note made visible? >--- > C4/Reserves.pm | 44 +++++++++++++++++++- > .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 36 ++++++++-------- > opac/opac-reserve.pl | 2 +- > 3 files changed, 61 insertions(+), 21 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index e0d616b..4befc57 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -142,7 +142,7 @@ BEGIN { > > IsItemOnHoldAndFound > ); >- @EXPORT_OK = qw( MergeHolds ); >+ @EXPORT_OK = qw( MergeHolds IsHoldNoteRequired ); > } > > =head2 AddReserve >@@ -2450,6 +2450,48 @@ sub IsItemOnHoldAndFound { > return $found; > } > >+=head2 IsHoldNoteRequired >+ >+ my $boolean = IsHoldNoteRequired( $marc ); >+ >+ Checks if a hold note is required for a given record. >+ Triggered by the pref HoldNoteReasons. >+ This pref may contain a list of reason codes to be checked. >+ So, it could look like: LEADER_SERIAL|MARC300A_PARTS >+ >+ This routine returns true if the note is required, undef otherwise. >+ >+=cut >+ >+sub IsHoldNoteRequired { >+ my ( $marcrecord ) = @_; >+ return if !$marcrecord || !C4::Context->preference( 'OPACHoldNotes' ); >+ my $reasons = uc C4::Context->preference( 'HoldNoteReasons' ); >+ return if !$reasons; >+ my $ldr = $marcrecord->leader; >+ >+ # check LEADER_SERIAL >+ if( $reasons =~ /LEADER_SERIAL/ && substr($ldr,7,1) eq 's' ) { >+ return 1; >+ } >+ # check LEADER_COLLECTION >+ if( $reasons =~ /LEADER_COLLECTION/ && substr($ldr,7,1) eq 'c' ) { >+ return 1; >+ } >+ # check MARC300A_PARTS >+ if( $reasons =~ /MARC300A_PARTS/ && >+ ( my @fld = $marcrecord->field('300') )) { >+ my $re = qr/(\d+)\s*(v\.|vol|dl|delen|band|bd|tle|parts|pts|t\.|tome)/i; >+ foreach my $f ( @fld ) { >+ next if !$f->subfield('a'); >+ # Check for something like 3 parts or 22 volumes in 300$a >+ return 1 if $f->subfield('a') =~ /$re/ && $1 > 1; >+ } >+ } >+ # next reason comes here.. >+ return; >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >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 516ada5..f3a77d4 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >@@ -251,10 +251,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 about the requested item:</span> >+ [% END %] >+ <textarea id="holdnotes_[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]" >[% bibitemloo.holdnotes %]</textarea> > </div> > </li> > [% END # / IF OpacHoldNotes %] >@@ -406,10 +407,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,17 +466,11 @@ > $("#reqspecific_[% bibitemloo.biblionumber %]").click(); > $("#copiesrow_[% bibitemloo.biblionumber %]").show(); > [% END %] >+ [% IF bibitemloo.reqholdnotes %] >+ $("#holdnotes_[% bibitemloo.biblionumber %]").attr( 'required', true ); >+ [% 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"; } >@@ -589,11 +580,19 @@ > biblionumbers += biblioNum + "/"; > selections += biblioNum + "/"; > >+ // If required hold note is empty, make it visible >+ if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) { >+ if( !$("#hold-options-"+biblioNum).is(':visible')) { >+ $("#toggle-hold-options-"+biblioNum).click(); >+ } >+ } >+ > // 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 { >@@ -611,8 +610,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 0f753d8..b7941c1 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -408,7 +408,7 @@ 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} = C4::Reserves::IsHoldNoteRequired( $record ); > > if (!$itemLevelTypes && $biblioData->{itemtype}) { > $biblioLoopIter{translated_description} = $itemTypes->{$biblioData->{itemtype}}{translated_description}; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15545
:
46687
|
46688
|
46689
|
49084
|
49085
|
49086
|
51832
|
51833
|
51834
|
53546
|
53547
|
59252
|
59253
|
139947
|
140960