Bugzilla – Attachment 17720 Details for
Bug 9743
Allow customization for making hold notes required
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9743: Mandatory opac hold notes under specified conditions
Bug-9743-Mandatory-opac-hold-notes-under-specified.patch (text/plain), 11.10 KB, created by
Marcel de Rooy
on 2013-04-26 14:56:37 UTC
(
hide
)
Description:
Bug 9743: Mandatory opac hold notes under specified conditions
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-04-26 14:56:37 UTC
Size:
11.10 KB
patch
obsolete
>From 9f071486bec7a31bd09e9abaa965ac2cf86c8e3f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 28 Feb 2013 15:26:55 +0100 >Subject: [PATCH] Bug 9743: Mandatory opac hold notes under specified > conditions >Content-Type: text/plain; charset=utf-8 > >Description: >Adds a new preference OPACMandatoryHoldNotes controlling when hold notes are >mandatory for opac users placing a hold. >In this initial implementation four reasons for a mandatory hold are added: >1) MARC21 300$a contains a reference to multiple volumes/parts >2) Biblio has one item (used in combination with 1) >3) UNIMARC 200$a contains the word test (for testing purposes only) >4) MARC21 leader pos 7 is collection >A new file is added to describe the use of this pref. The opac preferences form >shows a link to that file. > >Test plan: >1) Enable OPACShowHoldNotes. >2) Enter 1&2,4 into OPACMandatoryHoldNotes (for MARC21 testing). For UNIMARC, >you could use 3. >3) Change two biblios: one with leader 7==c and one with 1 item and 300a==2 v. >For UNIMARC, you could add the word test to 200$a. >4) Place a hold in opac on these two books separately. Just verify if the hold >notes display the reason for mandatory notes. Do not place the holds. Test if >you can place a hold if the notes are empty. You should not be allowed to do so. >5) Enable DisplayMultiPlaceHold. Place hold on both books simultaneously. Verify >if you see both reasons for mandatory notes. Place the holds. Check them in >staff. >--- > C4/Reserves.pm | 71 ++++++++++++++++++++ > .../prog/en/modules/admin/mandatory-hold-notes.tt | 18 +++++ > .../prog/en/modules/admin/preferences/opac.pref | 4 + > .../opac-tmpl/prog/en/modules/opac-reserve.tt | 25 ++++++- > opac/opac-reserve.pl | 2 +- > 5 files changed, 116 insertions(+), 4 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index c8b0cdd..a20b922 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -2168,6 +2168,77 @@ sub ReserveSlip { > ); > } > >+=head2 GetMandatoryNoteReason >+ >+ my $reason= GetMandatoryNoteReason( $biblionumber, $marcrecord ) >+ >+ Returns an integer representing the reason for a mandatory holds note. >+ Returns zero if the note is not mandatory or OPACShowHoldNotes is disabled. >+ >+ The reasons are listed in the opac-reserve template. >+ >+=cut >+ >+sub GetMandatoryNoteReason { >+ my ($biblionumber, $marcrecord) = @_; >+ >+ my $mandatoryReasons= C4::Context->preference('OPACMandatoryHoldNotes'); >+ my $shownotes= C4::Context->preference('OPACShowHoldNotes'); >+ return 0 if !$mandatoryReasons || !$shownotes; >+ >+ my ($res,$first); >+ my @subexpr= split ',',$mandatoryReasons; >+ #contains a list of numbered reasons in the form of 1,3&4,2,5&4,6 >+ #meaning check 1, or 3 and 4, or 2, or 5 and 4, or 6 .. >+ #for a combined check 3&4, the firstmentioned reason (3) is returned >+ foreach my $expr (@subexpr) { >+ my @checks= split '&', $expr; >+ $first=0; >+ foreach my $check (@checks) { >+ next if $check!~/(\d+)/; >+ $first=$1 if !$first; >+ $res= _CheckReason($biblionumber, $marcrecord, $1); >+ last if !$res; >+ } >+ return $first if $res; >+ } >+ return 0; #nothing found to justify a mandatory note >+} >+ >+sub _CheckReason { >+#Returns false if the condition is not met or an error occurred >+ my ($biblionumber, $marcrecord, $check)= @_; >+ >+ if($check==1) { #MARC21: 300a contains ref to multiple parts/volumes >+ if(my $f=$marcrecord->field('300') ) { >+ if($f->subfield('a') && $f->subfield('a')=~ /(\d+)\s*(v\.|vol|dl|delen|bd|tle|parts|pts|t\.|tome)/i) { >+ #FIXME: Actually a cataloging language dependent test >+ return 1 if $1>1; >+ } >+ } >+ } >+ elsif($check==2) { #Number of items==1 >+ my $sql="select count(*) from items where biblionumber=?"; >+ my $dbh= C4::Context->dbh; >+ my @c=$dbh->selectrow_array($sql,undef,($biblionumber)); >+ return 1 if @c && $c[0]==1; >+ #if @c does not have rows, something went very wrong: return false >+ } >+ elsif($check==3) { #Added for UNIMARC testing: Title contains test >+ if(my $f=$marcrecord->field('200') ) { >+ if($f->subfield('a')) { >+ return 1 if $f->subfield('a')=~/test/i; >+ } >+ } >+ } >+ elsif($check==4) { #MARC21: Leader pos 07 equals c (collection) >+ if(my $ldr=$marcrecord->leader) { >+ return 1 if substr($ldr,7,1) eq 'c'; >+ } >+ } >+ return 0; >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt >new file mode 100644 >index 0000000..568ef83 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt >@@ -0,0 +1,18 @@ >+The following reasons can be used: >+ >+1) MARC21 300$a contains a term indicating multiple volumes or parts (like v. or vol or pts). >+2) The biblio record only has one item. This reason is only meant for use in combination with another reason like number 1. >+3) UNIMARC 200$a contains the word 'test'. Added for test purposes. >+4) MARC21 leader position 7 contains c for collection. >+ >+How do you specify the reasons you want to use? >+Just add them in your preferred order between commas in preference OPACMandatoryHoldNotes. >+When you want to include an additional subcondition like number 2, use an expression like 1&2 indicating that you check for 1 AND 2. >+So, as an example, you could write 4,1&2,3 meaning check reason 4 first, then check on 1 and 2, and finally check 3. >+ >+For developers: How do you add a mandatory hold notes reason? >+1) Pick the next free number from opac-reserves.tt: add an entry to the ForceHoldNotesReasons array. >+2) Add your new reason to this documentation file: koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt. >+3) Add the code for this reason to sub _CheckReason in Reserves.pm. >+4) Submit a patch! >+5) Edit pref OPACMandatoryHoldNotes and add the new number. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 81824e4..949508a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -510,6 +510,10 @@ OPAC: > no: "Don't allow" > yes: Allow > - opac users to share private lists with other patrons. This feature is not active yet but will be released soon >+ - >+ - You can specify which conditions make hold notes mandatory. This pref is only active when OPACShowHoldNotes is enabled. For more information, click <a href="/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt" target="_blank">here</a>. >+ - pref: OPACMandatoryHoldNotes >+ type: textarea > > Privacy: > - >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >index ebb9bbf..ae0fe83 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt >@@ -4,9 +4,13 @@ > <script type="text/javascript"> > // <![CDATA[ > var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection."); >+ var MSG_EMPTY_MAND_NOTE = _("Please enter mandatory hold notes."); > var ForceHoldNotesReasons=new Array( >- _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."), >- "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones. >+ _("This title consists of multiple volumes/parts. Please indicate which part you need. Looking at the specific copy information may be helpful."), // R 1 >+ "This title has one item.", // R 2 (meant only for combining with R 1; no translation) >+ "UNIMARC test: Title contains 'test'.", // R 3 (unimarc testing; no translation) >+ _("This title represents a collection. Please indicate which part you need."), // R 4 (MARC21 leader: collection) >+ "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones. Add the _() for translation! > > function prefixOf (s, tok) { > var index = s.indexOf(tok); >@@ -137,11 +141,20 @@ > > // Find the items with the 'Hold' box checked > var badBib = null; >+ var emptyMandNote=0; > $(".confirmjs:checked").each(function() { > var biblioNum = $(this).val(); > biblionumbers += biblioNum + "/"; > selections += biblioNum + "/"; > >+ // Check mandatory notes >+ if($("#notesmandatory_"+biblioNum).val()>0) { >+ if($.trim($("#notes_"+biblioNum).val())==='') { >+ emptyMandNote= biblioNum; >+ return false; >+ } >+ } >+ > // If the 'specific copy' radio button is checked > if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) { > // Find the selected copy >@@ -168,6 +181,12 @@ > alert(MSG_NO_COPY_SELECTED); > return false; > } >+ else if(emptyMandNote>0) { >+ alert(MSG_EMPTY_MAND_NOTE); >+ $(".notesrow").hide(); >+ $("#notesrow_"+emptyMandNote).show(); >+ return false; >+ } > > $("#selections").val(selections); > $("#biblionumbers").val(biblionumbers); >@@ -449,7 +468,7 @@ > <td colspan="[% itemtable_colspan %]"> > <label for="holdnotes">Hold notes:</label> > <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span> >- <textarea name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea> >+ <textarea id="notes_[% bibitemloo.biblionumber %]" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea> > <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/> > </td> > </tr> >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 91526ed..960791c 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -373,7 +373,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{mandatorynotes}= C4::Reserves::GetMandatoryNoteReason($biblioNum, $record); #zero means that note is not mandatory > > if (!$itemLevelTypes && $biblioData->{itemtype}) { > $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description}; >-- >1.7.7.6
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 9743
:
15842
|
15843
|
15910
|
17720
|
17721
|
17722
|
19561
|
19562
|
19563
|
21233
|
21236
|
21240
|
21741
|
21742
|
21743
|
21744
|
34422
|
34526