Bugzilla – Attachment 122287 Details for
Bug 3142
Standardize how OPAC and staff determine requestability
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3142: Use filter_by_for_holds where holdability is calculated
Bug-3142-Use-filterbyforholds-where-holdability-is.patch (text/plain), 8.58 KB, created by
Jonathan Druart
on 2021-06-22 13:57:18 UTC
(
hide
)
Description:
Bug 3142: Use filter_by_for_holds where holdability is calculated
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-06-22 13:57:18 UTC
Size:
8.58 KB
patch
obsolete
>From 0023d0897ade76289de6415158075f5681854fe8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 22 Jun 2021 15:49:45 +0200 >Subject: [PATCH] Bug 3142: Use filter_by_for_holds where holdability is > calculated > >--- > C4/Search.pm | 25 ++++++------------------- > Koha/Holds.pm | 16 +--------------- > opac/opac-ISBDdetail.pl | 10 ++-------- > opac/opac-MARCdetail.pl | 10 +--------- > opac/opac-detail.pl | 9 +-------- > 5 files changed, 11 insertions(+), 59 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index b0ebedcb577..b2999a9ea7d 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1803,7 +1803,6 @@ sub searchResults { > my $itembinding_count = 0; > my $itemdamaged_count = 0; > my $item_in_transit_count = 0; >- my $can_place_holds = 0; > my $item_onhold_count = 0; > my $notforloan_count = 0; > my $items_count = scalar(@fields); >@@ -1874,9 +1873,6 @@ sub searchResults { > $onloan_items->{$key}->{longoverdue}++; > $longoverdue_count++; > } >- else { # can place holds as long as item isn't lost >- $can_place_holds = 1; >- } > } > > # items not on loan, but still unavailable ( lost, withdrawn, damaged ) >@@ -1938,18 +1934,6 @@ sub searchResults { > $item_onhold_count++ if $reservestatus eq 'Waiting'; > $item->{status} = ($item->{withdrawn}//q{}) . "-" . ($item->{itemlost}//q{}) . "-" . ($item->{damaged}//q{}) . "-" . ($item->{notforloan}//q{}); > >- # can place a hold on a item if >- # not lost nor withdrawn >- # not damaged unless AllowHoldsOnDamagedItems is true >- # item is either for loan or on order (notforloan < 0) >- $can_place_holds = 1 >- if ( >- !$item->{itemlost} >- && !$item->{withdrawn} >- && ( !$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems') ) >- && ( !$item->{notforloan} || $item->{notforloan} < 0 ) >- ); >- > $other_count++; > > my $key = $prefix . $item->{status}; >@@ -1966,7 +1950,6 @@ sub searchResults { > } > # item is available > else { >- $can_place_holds = 1; > $available_count++; > $available_items->{$prefix}->{count}++ if $item->{$hbranch}; > foreach (qw(branchname itemcallnumber description)) { >@@ -2009,11 +1992,17 @@ sub searchResults { > $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables); > } > >+ my $biblio_object = Koha::Biblios->find( $oldbiblio->{biblionumber} ); >+ $oldbiblio->{biblio_object} = $biblio_object; >+ >+ my $can_place_holds = 1; > # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either > if (!C4::Context->preference("item-level_itypes")) { > if ($itemtype && $itemtype->{notforloan}) { > $can_place_holds = 0; > } >+ } else { >+ $can_place_holds = $biblio_object->items->filter_by_for_hold()->count; > } > $oldbiblio->{norequests} = 1 unless $can_place_holds; > $oldbiblio->{items_count} = $items_count; >@@ -2062,8 +2051,6 @@ sub searchResults { > $oldbiblio->{'alternateholdings_count'} = $alternateholdingscount; > } > >- $oldbiblio->{biblio_object} = Koha::Biblios->find( $oldbiblio->{biblionumber} ); >- > push( @newresults, $oldbiblio ); > } > >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >index 296f99cb0a1..ef042787b01 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -131,26 +131,12 @@ sub get_items_that_can_fill { > } > ); > >- my @hold_not_allowed_itypes = Koha::CirculationRules->search( >- { >- rule_name => 'holdallowed', >- branchcode => undef, >- categorycode => undef, >- rule_value => 'not_allowed', >- } >- )->get_column('itemtype'); >- > return Koha::Items->search( > { > biblionumber => { in => \@biblionumbers }, >- itemlost => 0, >- withdrawn => 0, >- notforloan => 0, >- onloan => undef, > itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, >- itype => { -not_in => \@hold_not_allowed_itypes }, > } >- ); >+ )->filter_by_for_hold(); > } > > =head3 type >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index 9f3bb869e24..52c29a0743d 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -155,7 +155,6 @@ $template->param( > subscriptionsnumber => $subscriptionsnumber, > ); > >-my $norequests = 1; > my $allow_onshelf_holds; > my $res = GetISBDView({ > 'record' => $record, >@@ -165,13 +164,6 @@ my $res = GetISBDView({ > > my $items = $biblio->items; > while ( my $item = $items->next ) { >- $norequests = 0 >- if $norequests >- && !$item->withdrawn >- && !$item->itemlost >- && ($item->notforloan < 0 || not $item->notforloan ) >- && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan >- && $item->itemnumber; > > $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; >@@ -181,6 +173,8 @@ if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_item > $template->param( ReservableItems => 1 ); > } > >+my $norequests = ! $items->filter_by_for_hold->count; >+ > $template->param( > RequestOnOpac => C4::Context->preference("RequestOnOpac"), > norequests => $norequests, >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index 0dac97d4b48..f86ca0e5994 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -137,19 +137,10 @@ $template->param( > ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. > $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; > >-my $norequests = 1; > my $allow_onshelf_holds; > my $items = $biblio->items; > > while ( my $item = $items->next ) { >- $norequests = 0 >- if $norequests >- && !$item->withdrawn >- && !$item->itemlost >- && ($item->notforloan < 0 || not $item->notforloan ) >- && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan >- && $item->itemnumber; >- > $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; > } >@@ -385,6 +376,7 @@ if( C4::Context->preference('ArticleRequests') ) { > $template->param( artreqpossible => $artreqpossible ); > } > >+my $norequests = ! $biblio->items->filter_by_for_hold->count; > $template->param( > item_loop => \@item_loop, > item_header_loop => \@item_header_loop, >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 1b7f98f64db..72d0f732a08 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -674,7 +674,6 @@ if ( $show_holds_count || $show_priority) { > } > $template->param( show_priority => $has_hold ) ; > >-my $norequests = 1; > my %itemfields; > my (@itemloop, @otheritemloop); > my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; >@@ -718,13 +717,6 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > my $item = Koha::Items->find( $itm->{itemnumber} ); > $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; > $itm->{priority} = $priority{ $itm->{itemnumber} }; >- $norequests = 0 >- if $norequests >- && !$itm->{'withdrawn'} >- && !$itm->{'itemlost'} >- && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'}) >- && !$itemtypes->{$itm->{'itype'}}->{notforloan} >- && $itm->{'itemnumber'}; > > $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; >@@ -828,6 +820,7 @@ if( C4::Context->preference('ArticleRequests') ) { > $template->param( artreqpossible => $artreqpossible ); > } > >+my $norequests = ! $biblio->items->filter_by_for_hold->count; > $template->param( > MARCNOTES => $marcnotesarray, > norequests => $norequests, >-- >2.20.1
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 3142
:
122284
|
122285
|
122286
|
122287
|
122314
|
122315
|
122316
|
122317
|
125727
|
125728
|
125729
|
125730
|
125732
|
125733
|
125734
|
125942
|
125943
|
125944
|
125945
|
125946
|
125947
|
125948
|
125949
|
125950
|
125951
|
125956
|
125967
|
125968
|
125969
|
125970
|
125971
|
125972
|
125973
|
125974
|
125975
|
125976
|
125977