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

(-)a/Koha/Items.pm (-3 / +30 lines)
Lines 33-43 Koha::Items - Koha Item object set class Link Here
33
33
34
=head1 API
34
=head1 API
35
35
36
=head2 Class Methods
36
=head2 Class methods
37
37
38
=cut
38
=cut
39
39
40
=head3 type
40
=head3 filter_by_visible_in_opac
41
42
    my $filered_items = $items->filter_by_visible_in_opac({ rules => $rules });
43
44
Returns a new resultset, containing those items that are not expected to be hidden in OPAC.
45
If no I<rules> are passed, it returns the whole resultset, with the only caveat that the
46
I<hidelostitems> system preference is honoured.
47
48
=cut
49
50
sub filter_by_visible_in_opac {
51
    my ($self, $params) = @_;
52
53
    my $rules = $params->{rules} // {};
54
55
    my $search_params;
56
    foreach my $field (keys %$rules){
57
        $search_params->{$field}->{'-not_in'} = $rules->{$field};
58
    }
59
60
    $search_params->{itemlost}->{'<='} = 0
61
        if C4::Context->preference('hidelostitems');
62
63
    return $self->search( $search_params );
64
}
65
66
=head2 Internal methods
67
68
=head3 _type
41
69
42
=cut
70
=cut
43
71
44
- 

Return to bug 24254