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

(-)a/C4/Reserves.pm (-1 / +11 lines)
Lines 1080-1085 item-level hold request. An item is available if Link Here
1080
* it is not lost AND
1080
* it is not lost AND
1081
* it is not damaged AND
1081
* it is not damaged AND
1082
* it is not withdrawn AND
1082
* it is not withdrawn AND
1083
* a waiting or in transit reserve is placed on
1083
* does not have a not for loan value > 0
1084
* does not have a not for loan value > 0
1084
1085
1085
Need to check the issuingrules onshelfholds column,
1086
Need to check the issuingrules onshelfholds column,
Lines 1144-1150 sub IsAvailableForItemLevelRequest { Link Here
1144
        return $any_available ? 0 : 1;
1145
        return $any_available ? 0 : 1;
1145
    }
1146
    }
1146
1147
1147
    return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
1148
    if ($item->{onloan}) {
1149
        return 1;
1150
    }
1151
1152
    if ( Koha::Holds->search({itemnumber => $item->{itemnumber},
1153
                              found => ['W', 'T']})->count ) {
1154
        return 1;
1155
    }
1156
1157
    return 0;
1148
}
1158
}
1149
1159
1150
=head2 OnShelfHoldsAllowed
1160
=head2 OnShelfHoldsAllowed
(-)a/Koha/Biblio.pm (+18 lines)
Lines 318-323 sub subscriptions { Link Here
318
    return $self->{_subscriptions};
318
    return $self->{_subscriptions};
319
}
319
}
320
320
321
=head3 hasItemswaitingOrInTransit
322
323
=cut
324
325
sub hasItemswaitingOrInTransit {
326
    my ( $self ) = @_;
327
328
    if ( Koha::Holds->search({ biblionumber => $self->id,
329
                               found => ['W', 'T'] })->count ) {
330
        return 1;
331
    }
332
333
    foreach my $item ( $self->items ) {
334
        return 1 if $item->get_transfer;
335
    }
336
337
    return 0;
338
}
321
339
322
=head3 type
340
=head3 type
323
341
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +1 lines)
Lines 3-9 Link Here
3
    [% UNLESS ( norequests ) %]
3
    [% UNLESS ( norequests ) %]
4
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
4
        [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
5
            [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
5
            [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
6
                [% IF ( AllowOnShelfHolds OR ItemsIssued ) %]
6
                [% IF ( ReservableItems ) %]
7
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblio.biblionumber %]">Place hold</a></li>
7
                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblio.biblionumber %]">Place hold</a></li>
8
                [% END %]
8
                [% END %]
9
            [% END %]
9
            [% END %]
(-)a/opac/opac-detail.pl (-5 / +8 lines)
Lines 460-468 if ($session->param('busc')) { Link Here
460
}
460
}
461
}
461
}
462
462
463
463
$template->param(
464
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
464
    OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
465
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
465
);
466
466
467
# adding items linked via host biblios
467
# adding items linked via host biblios
468
468
Lines 652-664 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { Link Here
652
    };
652
    };
653
}
653
}
654
654
655
my $allow_onshelf_holds;
655
if ( not $viewallitems and @items > $max_items_to_display ) {
656
if ( not $viewallitems and @items > $max_items_to_display ) {
656
    $template->param(
657
    $template->param(
657
        too_many_items => 1,
658
        too_many_items => 1,
658
        items_count => scalar( @items ),
659
        items_count => scalar( @items ),
659
    );
660
    );
660
} else {
661
} else {
661
  my $allow_onshelf_holds;
662
  my $patron = Koha::Patrons->find( $borrowernumber );
662
  my $patron = Koha::Patrons->find( $borrowernumber );
663
  for my $itm (@items) {
663
  for my $itm (@items) {
664
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
664
    $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
Lines 717-725 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
717
        push @itemloop, $itm;
717
        push @itemloop, $itm;
718
    }
718
    }
719
  }
719
  }
720
  $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
721
}
720
}
722
721
722
my $itemsWaitingOrInTransit = Koha::Biblios->find($biblionumber)->hasItemswaitingOrInTransit || 0;
723
my $itemsIssued = CountItemsIssued( $biblionumber );
724
$template->param( 'ReservableItems' => $itemsWaitingOrInTransit || $itemsIssued || $allow_onshelf_holds );
725
723
# Display only one tab if one items list is empty
726
# Display only one tab if one items list is empty
724
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
727
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
725
    $template->param(SeparateHoldings => 0);
728
    $template->param(SeparateHoldings => 0);
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-1 / +48 lines)
Lines 7-13 use C4::Items; Link Here
7
use C4::Circulation;
7
use C4::Circulation;
8
use Koha::IssuingRule;
8
use Koha::IssuingRule;
9
9
10
use Test::More tests => 5;
10
use Test::More tests => 7;
11
11
12
use t::lib::TestBuilder;
12
use t::lib::TestBuilder;
13
use t::lib::Mocks;
13
use t::lib::Mocks;
Lines 213-217 AddReturn( $item1->{barcode} ); Link Here
213
    };
213
    };
214
}
214
}
215
215
216
my $biblio = $builder->build({
217
    source => 'Biblio',
218
});
219
220
my $item3 = $builder->build({
221
    source => 'Item',
222
    value => {
223
        biblionumber => $biblio->{biblionumber},
224
        itemlost     => 0,
225
        notforloan   => 0,
226
        withdrawn    => 0,
227
        damaged      => 0,
228
        onloan       => 0
229
    }
230
});
231
232
my $hold = $builder->build({
233
    source => 'Reserve',
234
    value =>{
235
        itemnumber => $item3->{itemnumber},
236
        found => 'T'
237
    }
238
});
239
240
$dbh->do("DELETE FROM issuingrules");
241
$rule = Koha::IssuingRule->new(
242
    {
243
        categorycode => '*',
244
        itemtype     => '*',
245
        branchcode   => '*',
246
        maxissueqty  => 99,
247
        issuelength  => 7,
248
        lengthunit   => 8,
249
        reservesallowed => 99,
250
        onshelfholds => 0,
251
    }
252
);
253
$rule->store();
254
255
$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
256
is( $is, 1, "Item can be held, items in transit are not available" );
257
258
Koha::Holds->find($hold->{reserve_id})->found('F')->store;
259
260
$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
261
is( $is, 0, "Item is neither waiting nor in transit." );
262
216
# Cleanup
263
# Cleanup
217
$schema->storage->txn_rollback;
264
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Biblios.t (-2 / +41 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
23
24
use C4::Reserves;
24
use C4::Reserves;
25
25
Lines 80-84 subtest 'subscriptions' => sub { Link Here
80
    is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
80
    is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
81
};
81
};
82
82
83
subtest 'waiting_or_in_transit' => sub {
84
    plan tests => 4;
85
    my $biblio = $builder->build( { source => 'Biblio' } );
86
    my $item = $builder->build({
87
        source => 'Item',
88
        value => {
89
            biblionumber => $biblio->{biblionumber}
90
        }
91
    });
92
    my $reserve = $builder->build({
93
        source => 'Reserve',
94
        value => {
95
            biblionumber => $biblio->{biblionumber},
96
            found => undef
97
        }
98
    });
99
100
    $reserve = Koha::Holds->find($reserve->{reserve_id});
101
    $biblio = Koha::Biblios->find($biblio->{biblionumber});
102
103
    is($biblio->hasItemswaitingOrInTransit, 0, 'Item is neither waiting nor in transit');
104
105
    $reserve->found('W')->store;
106
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item is waiting');
107
108
    $reserve->found('T')->store;
109
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item is in transit');
110
111
    my $transfer = $builder->build({
112
        source => 'Branchtransfer',
113
        value => {
114
            itemnumber => $item->{itemnumber},
115
            datearrived => undef
116
        }
117
    });
118
    my $t = Koha::Database->new()->schema()->resultset( 'Branchtransfer' )->find($transfer->{branchtransfer_id});
119
    $reserve->found(undef)->store;
120
    is($biblio->hasItemswaitingOrInTransit, 1, 'Item has transfer');
121
};
122
83
$schema->storage->txn_rollback;
123
$schema->storage->txn_rollback;
84
124
85
- 

Return to bug 4319