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

(-)a/C4/Reserves.pm (-8 / +1 lines)
Lines 291-306 See CanItemBeReserved() for possible return values. Link Here
291
sub CanBookBeReserved{
291
sub CanBookBeReserved{
292
    my ($borrowernumber, $biblionumber) = @_;
292
    my ($borrowernumber, $biblionumber) = @_;
293
293
294
    # Check if borrower already has reserved the same biblio.
294
    # Check if borrower has reached the maximum number of holds allowed
295
    my $patron = Koha::Patrons->find($borrowernumber);
295
    my $patron = Koha::Patrons->find($borrowernumber);
296
    my $holds = $patron->holds;
296
    my $holds = $patron->holds;
297
    while (my $hold = $holds->next) {
298
        if ($hold->biblionumber == $biblionumber) {
299
            return 'alreadyReserved';
300
        }
301
    }
302
303
    # Check if borrower has reached the maximum number of holds allowed
304
    my $maxreserves = C4::Context->preference('maxreserves');
297
    my $maxreserves = C4::Context->preference('maxreserves');
305
    if ($maxreserves && $holds->count >= $maxreserves) {
298
    if ($maxreserves && $holds->count >= $maxreserves) {
306
        return 'tooManyReserves';
299
        return 'tooManyReserves';
(-)a/t/db_dependent/Holds.t (-2 / +1 lines)
Lines 403-409 is( Link Here
403
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'OK');
403
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'OK');
404
404
405
C4::Context->set_preference('maxreserves', 1);
405
C4::Context->set_preference('maxreserves', 1);
406
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves');
406
is(CanBookBeReserved($borrowernumbers[0], $biblionumber), 'tooManyReserves');
407
407
408
C4::Context->set_preference('maxreserves', 0);
408
C4::Context->set_preference('maxreserves', 0);
409
t::lib::Mocks::mock_preference('IndependentBranches', 1);
409
t::lib::Mocks::mock_preference('IndependentBranches', 1);
410
- 

Return to bug 11999