Bugzilla – Attachment 125945 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.61 KB, created by
Marcel de Rooy
on 2021-10-08 09:26:12 UTC
(
hide
)
Description:
Bug 3142: Use filter_by_for_holds where holdability is calculated
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-10-08 09:26:12 UTC
Size:
8.61 KB
patch
obsolete
>From 29339e5b59203c5c41287c9dd7007ff46616fb22 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 >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Search.pm | 25 ++++++------------------- > Koha/Holds.pm | 17 ++--------------- > opac/opac-ISBDdetail.pl | 10 ++-------- > opac/opac-MARCdetail.pl | 10 +--------- > opac/opac-detail.pl | 9 +-------- > 5 files changed, 12 insertions(+), 59 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 5cf7e0ae90..0da4b3ddf0 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1781,7 +1781,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); >@@ -1852,9 +1851,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 ) >@@ -1916,18 +1912,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}; >@@ -1944,7 +1928,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)) { >@@ -2001,11 +1984,17 @@ sub searchResults { > ); > } > >+ 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; >@@ -2054,8 +2043,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 fdc492b0ce..6885b4d6bf 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -130,26 +130,13 @@ 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 }, >+ onloan => undef, > } >- ); >+ )->filter_by_for_hold(); > } > > =head3 type >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index 47fcb5e852..dada1a2744 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -167,7 +167,6 @@ $template->param( > subscriptionsnumber => $subscriptionsnumber, > ); > >-my $norequests = 1; > my $allow_onshelf_holds; > my $res = GetISBDView({ > 'record' => $record, >@@ -177,13 +176,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; >@@ -193,6 +185,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 69578be6aa..4d9b5efbf3 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -143,19 +143,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; > } >@@ -391,6 +382,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 0860aa487a..fb9247d83d 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -668,7 +668,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; >@@ -712,13 +711,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; >@@ -805,6 +797,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