Bugzilla – Attachment 23162 Details for
Bug 6837
When AllowOnShelfHolds is OFF then holds on records with available items should not be possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix Bug 6837
0001-Bug-6837-When-AllowOnShelfHolds-is-OFF-then-holds-on.patch (text/plain), 12.37 KB, created by
Barry Cannon
on 2013-11-26 16:23:13 UTC
(
hide
)
Description:
Patch to fix Bug 6837
Filename:
MIME Type:
Creator:
Barry Cannon
Created:
2013-11-26 16:23:13 UTC
Size:
12.37 KB
patch
obsolete
>From 69b120c32682f9cd5286a9ecba77d0d7aa537bf4 Mon Sep 17 00:00:00 2001 >From: Barry Cannon <barry@oslo.ie> >Date: Tue, 26 Nov 2013 16:10:10 +0000 >Subject: [PATCH] Bug 6837 - When AllowOnShelfHolds is OFF then holds on > records with available items should not be possible > >The original "AllowOnShelfHolds" SysPref had two options: >"Allow" and "Don't Allow". When the preference was set to "Don't Allow" the system >would still allow a hold to be placed on a bib if at least one of it's items was not >on the shelf. This violated the SystemPreference. > >When this patch is implemented, and the "AllowShelfHolds" SysPref is set to "Don't Allow" >the system will not provide a "Place Hold" option to the OPAC user if ANY item is on >the shelf (in ANY location). Setting the SysPref to "Allow" will allow holds to be placed >on the bib if there is an attached item on the shelf. > >I will look to address the issues of allowing holds for items in remote branches >in a later patch. >--- > C4/Reserves.pm | 61 +++++++++++++++++++- > .../prog/en/includes/opac-detail-sidebar.inc | 10 ++-- > .../prog/en/modules/opac-results-grouped.tt | 14 +++-- > .../opac-tmpl/prog/en/modules/opac-results.tt | 10 ++-- > opac/opac-detail.pl | 7 ++- > opac/opac-reserve.pl | 18 ++++-- > opac/opac-search.pl | 12 +++- > 7 files changed, 109 insertions(+), 23 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index d1bca25..2e616b0 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -133,6 +133,7 @@ BEGIN { > &SuspendAll > > &GetReservesControlBranch >+ &PreventHoldsAnyAvailableItem > ); > @EXPORT_OK = qw( MergeHolds ); > } >@@ -788,7 +789,6 @@ If several reserves exist, the reserve with the lower priority is given. > ## the sub is only used once in the codebase. > sub GetReserveStatus { > my ($itemnumber, $biblionumber) = @_; >- > my $dbh = C4::Context->dbh; > > my ($sth, $found, $priority); >@@ -2214,6 +2214,65 @@ sub GetReservesControlBranch { > return $branchcode; > } > >+=head2 PreventHoldsAnyAvailableItem >+Checks if an item is available to have a hold placed on it. >+Specifically relates to items currently on the shelf (without a datedue). >+ >+Returns true when any item attached to the bib is on the shelf and available >+ >+=cut >+ >+sub PreventHoldsAnyAvailableItem { >+ my $biblionumber = shift; >+ my @items = GetItemsInfo( $biblionumber ); >+ my $prevent_hold = 0; >+ my $not_out = 0; >+ my $checked_out = 0; >+ my $dbh = C4::Context->dbh; >+ my $notforloan_query; >+ if (C4::Context->preference('item-level_itypes')) { >+ $notforloan_query = "SELECT itemtypes.notforloan >+ FROM items >+ JOIN itemtypes ON (itemtypes.itemtype = items.itype) >+ WHERE itemnumber = ?"; >+ } else { >+ $notforloan_query = "SELECT itemtypes.notforloan >+ FROM items >+ JOIN biblioitems USING (biblioitemnumber) >+ JOIN itemtypes USING (itemtype) >+ WHERE itemnumber = ?"; >+ } >+ my $sth = $dbh->prepare($notforloan_query); >+ >+ foreach my $item (@items) { >+ $sth->execute( $item->{itemnumber} ); >+ my $notforloan_itemtype = 0; >+ if (my ($notforloan) = $sth->fetchrow_array) { >+ $notforloan_itemtype = 1 if $notforloan; >+ } >+ >+ if ( not $item->{datedue} ) { >+ my $reserve_status = GetReserveStatus( $item->{itemnumber} ); >+ if ($item->{itemlost} >+ or ( $item->{notforloan} > 0 ) >+ or ( $item->{damaged} and not C4::Context->preference('AllowHoldsOnDamagedItems') ) >+ or $item->{wthdrawn} >+ or $notforloan_itemtype >+ or $reserve_status eq "Waiting" >+ or $reserve_status eq "Reserved") >+ { >+ next; >+ } >+ else {$prevent_hold++} >+ >+ } >+ >+ } >+ >+ return $prevent_hold; >+ >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc >index 0f16f3a..68db1dd 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-detail-sidebar.inc >@@ -2,11 +2,13 @@ > [% UNLESS ( norequests ) %] > [% IF ( opacuserlogin ) %] > [% IF ( RequestOnOpac ) %] >- [% IF ( AllowOnShelfHolds ) %] >- <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li> >- [% ELSE %] >- [% IF ( ItemsIssued ) %] >+ [% UNLESS ( PreventHoldsAnyAvailableItem ) %] >+ [% IF ( AllowOnShelfHolds ) %] > <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li> >+ [% ELSE %] >+ [% IF ( ItemsIssued ) %] >+ <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li> >+ [% END %] > [% END %] > [% END %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >index 2010cee..970d6f8 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >@@ -273,13 +273,15 @@ function highlightOn() { > [% IF ( RequestOnOpac ) %] > [% UNLESS ( GROUP_RESULT.norequests ) %] > [% IF ( opacuserlogin ) %] >- [% IF ( AllowOnShelfHolds ) %] >- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >- [% ELSE %] >- [% IF ( GROUP_RESULT.itemsissued ) %] >- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >+ [% UNLESS SEARCH_RESULT.prevent_holds %] >+ [% IF ( AllowOnShelfHolds ) %] >+ <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >+ [% ELSE %] >+ [% IF ( GROUP_RESULT.itemsissued ) %] >+ <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >+ [% END %] > [% END %] >- [% END %] >+ [% END %] > [% END %] > [% END %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 9235b2b..ac9607a 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -667,11 +667,13 @@ $(document).ready(function(){ > [% IF ( RequestOnOpac ) %] > [% UNLESS ( SEARCH_RESULT.norequests ) %] > [% IF ( opacuserlogin ) %] >- [% IF ( AllowOnShelfHolds ) %] >- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >- [% ELSE %] >- [% IF ( SEARCH_RESULT.itemsissued ) %] >+ [% UNLESS SEARCH_RESULT.prevent_holds %] >+ [% IF ( AllowOnShelfHolds ) %] > <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >+ [% ELSE %] >+ [% IF ( SEARCH_RESULT.itemsissued ) %] >+ <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--> >+ [% END %] > [% END %] > [% END %] > [% END %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 41de4fd..030c5c0 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -401,12 +401,17 @@ if ($session->param('busc')) { > } > > >+my $prevent_holds = 0; >+if ( not C4::Context->preference('AllowOnShelfHolds') ) { >+ $prevent_holds = PreventHoldsAnyAvailableItem( $biblionumber ); > >+} >+ >+$template->param( 'PreventHoldsAnyAvailableItem' => $prevent_holds ); > $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') ); > $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); > > >- > $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); > $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") ); > >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 97d136a..f4759c4 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -352,9 +352,12 @@ my $itemdata_enumchron = 0; > my $anyholdable = 0; > my $itemLevelTypes = C4::Context->preference('item-level_itypes'); > $template->param('item_level_itypes' => $itemLevelTypes); >- >+my $prevent_holds = 0; > foreach my $biblioNum (@biblionumbers) { >- >+ if ( not C4::Context->preference('AllowOnShelfHolds') ) { >+ $prevent_holds = PreventHoldsAnyAvailableItem($biblioNum) >+ } >+ > my $record = GetMarcBiblio($biblioNum); > # Init the bib item with the choices for branch pickup > my %biblioLoopIter = ( branchloop => $branchloop ); >@@ -500,11 +503,14 @@ foreach my $biblioNum (@biblionumbers) { > $policy_holdallowed = 0; > } > >- if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { >- $itemLoopIter->{available} = 1; >- $numCopiesAvailable++; >+ unless ($prevent_holds > 0 ) { >+ if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { >+ $itemLoopIter->{available} = 1; >+ $numCopiesAvailable++; >+ } > } > >+ > # FIXME: move this to a pm > my $dbh = C4::Context->dbh; > my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'"); >@@ -544,7 +550,7 @@ foreach my $biblioNum (@biblionumbers) { > push @$biblioLoop, \%biblioLoopIter; > } > >-if ( $numBibsAvailable == 0 || $anyholdable == 0) { >+if ( $numBibsAvailable == 0 || $anyholdable == 0 || $prevent_holds > 0 ) { > $template->param( none_available => 1 ); > } > >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 2854da6..4e8f80e 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -52,7 +52,7 @@ use C4::Branch; # GetBranches > use C4::SocialData; > use C4::Ratings; > use C4::External::OverDrive; >- >+use C4::Reserves; > use POSIX qw(ceil floor strftime); > use URI::Escape; > use JSON qw/decode_json encode_json/; >@@ -675,9 +675,19 @@ for (my $i=0;$i<@servers;$i++) { > my $j = 0; > foreach (@newresults) { > my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0; >+ # Check if holds are allowed >+ my $prevent_holds = 0; >+ if ( not C4::Context->preference('AllowOnShelfHolds') ) { >+ $prevent_holds = PreventHoldsAnyAvailableItem($bibnum) if $bibnum; >+ } >+ if ( $prevent_holds ) { >+ $_->{prevent_holds} =1; >+ } >+ > $pasarParams .= $bibnum . ','; > $j++; > last if ($j == $results_per_page); >+ > } > chop $pasarParams if ($pasarParams =~ /,$/); > $pasarParams .= '&total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/); >-- >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 6837
:
5285
|
22847
|
23002
|
23003
| 23162