@@ -, +, @@ --- opac/opac-reserve.pl | 51 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) --- a/opac/opac-reserve.pl +++ a/opac/opac-reserve.pl @@ -43,7 +43,7 @@ use Koha::Checkouts; use Koha::Libraries; use Koha::Patrons; use Date::Calc qw/Today Date_to_Days/; -use List::MoreUtils qw/uniq/; +use List::MoreUtils qw/uniq any/; my $maxreserves = C4::Context->preference("maxreserves"); @@ -586,6 +586,12 @@ foreach my $biblioNum (@biblionumbers) { push @{$biblioLoopIter{itemLoop}}, $itemLoopIter; } + $biblioLoopIter{itemLoop} = [ + filter_items({ + items => $biblioLoopIter{itemLoop}, + patron => $patron, + }) + ]; $template->param( itemdata_enumchron => $itemdata_enumchron, itemdata_ccode => $itemdata_ccode, @@ -676,3 +682,46 @@ if ( } output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; + +sub filter_items { + my ( $params ) = @_; + my @all_items = @{$params->{items}}; + my $patron = $params->{patron}; + my @hiddenitems; + my $patron_category = + ( C4::Context->preference('OpacHiddenItemsExceptions') && $patron ) + ? $patron->categorycode + : undef; + + if ( scalar @all_items >= 1 ) { + push @hiddenitems, + GetHiddenItemnumbers( { items => \@all_items, borcat => $patron_category } ); + + return () if scalar @hiddenitems == scalar @all_items; + } + + my @items; + # Are there items to hide? + my $hideitems; + + # Hide items + if ( C4::Context->preference('hidelostitems') || @hiddenitems ) { + for my $itm (@all_items) { + if ( C4::Context->preference('hidelostitems') ) { + push @items, $itm + unless $itm->{itemlost} + or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; + } + else { + push @items, $itm + unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; + } + } + } + # Or not + else { + @items = @all_items; + } + return @items; +} + --