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

(-)a/Koha/Items.pm (-5 / +5 lines)
Lines 37-53 Koha::Items - Koha Item object set class Link Here
37
37
38
=cut
38
=cut
39
39
40
=head3 filter_by_for_loan
40
=head3 filter_by_for_hold
41
41
42
    my $filtered_items = $items->filter_by_for_loan;
42
    my $filtered_items = $items->filter_by_for_hold;
43
43
44
Return the items of the set that are loanable
44
Return the items of the set that are holdable
45
45
46
=cut
46
=cut
47
47
48
sub filter_by_for_loan {
48
sub filter_by_for_hold {
49
    my ($self) = @_;
49
    my ($self) = @_;
50
    return $self->search( { notforloan => [ 0, undef ] } );
50
    return $self->search( { notforloan => { '<' => 1 } } ); # items with negative or zero notforloan value are holdable
51
}
51
}
52
52
53
=head3 filter_by_visible_in_opac
53
=head3 filter_by_visible_in_opac
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-2 / +1 lines)
Lines 166-174 CAN_user_serials_create_subscription ) %] Link Here
166
    <div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
166
    <div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
167
167
168
[% IF ( CAN_user_reserveforothers ) %]
168
[% IF ( CAN_user_reserveforothers ) %]
169
    [%# biblio.items.filter_by_for_loan.count %]
170
    [% SET items = biblio.items %]
169
    [% SET items = biblio.items %]
171
    [% IF Context.Scalar(Context.Scalar(items, "filter_by_for_loan"), "count") %]
170
    [% IF Context.Scalar(Context.Scalar(items, "filter_by_for_hold"), "count") %]
172
        [% IF ( holdfor ) %]
171
        [% IF ( holdfor ) %]
173
            <div class="btn-group">
172
            <div class="btn-group">
174
                <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
173
                <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
(-)a/t/db_dependent/Koha/Items.t (-6 / +7 lines)
Lines 1470-1484 subtest 'can_be_transferred' => sub { Link Here
1470
       'We get the same result also if we pass the from-library parameter.');
1470
       'We get the same result also if we pass the from-library parameter.');
1471
};
1471
};
1472
1472
1473
subtest 'filter_by_for_loan' => sub {
1473
subtest 'filter_by_for_hold' => sub {
1474
    plan tests => 3;
1474
    plan tests => 4;
1475
1475
1476
    my $biblio = $builder->build_sample_biblio;
1476
    my $biblio = $builder->build_sample_biblio;
1477
    is( $biblio->items->filter_by_for_loan->count, 0, 'no item yet' );
1477
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
1478
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } );
1478
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } );
1479
    is( $biblio->items->filter_by_for_loan->count, 0, 'no item for loan' );
1479
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item for hold' );
1480
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } );
1480
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } );
1481
    is( $biblio->items->filter_by_for_loan->count, 1, '1 item for loan' );
1481
    is( $biblio->items->filter_by_for_hold->count, 1, '1 item for hold' );
1482
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } );
1483
    is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' );
1482
1484
1483
    $biblio->delete;
1485
    $biblio->delete;
1484
};
1486
};
1485
- 

Return to bug 28286