From 613d6cd1ce27495b1f0ee16182920d039b6b2207 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 8 Oct 2021 12:03:41 +0200 Subject: [PATCH] Bug 3142: Handle biblio level item type Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart (cherry picked from commit 1aa70c9bb6d20034a53e981741bc1848641209f2) Signed-off-by: Andrew Fuerste-Henry --- Koha/Items.pm | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 9c46ef936e..03522740b1 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -62,15 +62,31 @@ sub filter_by_for_hold { )->get_column('itemtype'); push @hold_not_allowed_itypes, Koha::ItemTypes->search({ notforloan => 1 })->get_column('itemtype'); - return $self->search( - { - itemlost => 0, - withdrawn => 0, - notforloan => { '<=' => 0 }, # items with negative or zero notforloan value are holdable - ( C4::Context->preference('AllowHoldsOnDamagedItems' ) ? () : ( damaged => 0 ) ), - itype => { -not_in => \@hold_not_allowed_itypes }, - } - ); + my $params = { + itemlost => 0, + withdrawn => 0, + notforloan => { '<=' => 0 }, # items with negative or zero notforloan value are holdable + ( C4::Context->preference('AllowHoldsOnDamagedItems')? (): ( damaged => 0 ) ), + }; + + if ( C4::Context->preference("item-level_itypes") ) { + return $self->search( + { + %$params, + itype => { -not_in => \@hold_not_allowed_itypes }, + } + ); + } else { + return $self->search( + { + %$params, + 'biblioitem.itemtype' => { -not_in => \@hold_not_allowed_itypes }, + }, + { + join => 'biblioitem', + } + ); + } } =head3 filter_by_visible_in_opac -- 2.39.5