View | Details | Raw Unified | Return to bug 15448
Collapse All | Expand All

(-)a/opac/opac-reserve.pl (-2 / +50 lines)
Lines 43-49 use Koha::Checkouts; Link Here
43
use Koha::Libraries;
43
use Koha::Libraries;
44
use Koha::Patrons;
44
use Koha::Patrons;
45
use Date::Calc qw/Today Date_to_Days/;
45
use Date::Calc qw/Today Date_to_Days/;
46
use List::MoreUtils qw/uniq/;
46
use List::MoreUtils qw/uniq any/;
47
47
48
my $maxreserves = C4::Context->preference("maxreserves");
48
my $maxreserves = C4::Context->preference("maxreserves");
49
49
Lines 586-591 foreach my $biblioNum (@biblionumbers) { Link Here
586
586
587
        push @{$biblioLoopIter{itemLoop}}, $itemLoopIter;
587
        push @{$biblioLoopIter{itemLoop}}, $itemLoopIter;
588
    }
588
    }
589
    $biblioLoopIter{itemLoop} = [
590
        filter_items({
591
            items => $biblioLoopIter{itemLoop},
592
            patron => $patron,
593
        })
594
    ];
589
    $template->param(
595
    $template->param(
590
        itemdata_enumchron => $itemdata_enumchron,
596
        itemdata_enumchron => $itemdata_enumchron,
591
        itemdata_ccode     => $itemdata_ccode,
597
        itemdata_ccode     => $itemdata_ccode,
Lines 676-678 if ( Link Here
676
}
682
}
677
683
678
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
684
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
679
- 
685
686
sub filter_items {
687
    my ( $params ) = @_;
688
    my @all_items = @{$params->{items}};
689
    my $patron = $params->{patron};
690
    my @hiddenitems;
691
    my $patron_category =
692
      ( C4::Context->preference('OpacHiddenItemsExceptions') && $patron )
693
      ? $patron->categorycode
694
      : undef;
695
696
    if ( scalar @all_items >= 1 ) {
697
        push @hiddenitems,
698
          GetHiddenItemnumbers( { items => \@all_items, borcat => $patron_category } );
699
700
        return () if scalar @hiddenitems == scalar @all_items;
701
    }
702
703
    my @items;
704
    # Are there items to hide?
705
    my $hideitems;
706
707
    # Hide items
708
    if ( C4::Context->preference('hidelostitems') || @hiddenitems ) {
709
        for my $itm (@all_items) {
710
            if ( C4::Context->preference('hidelostitems') ) {
711
                push @items, $itm
712
                  unless $itm->{itemlost}
713
                  or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
714
            }
715
            else {
716
                push @items, $itm
717
                  unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
718
            }
719
        }
720
    }
721
    # Or not
722
    else {
723
        @items = @all_items;
724
    }
725
    return @items;
726
}
727

Return to bug 15448