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

(-)a/C4/Reserves.pm (-18 / +14 lines)
Lines 458-488 sub CanItemBeReserved { Link Here
458
    my $holds_per_record = $rights->{holds_per_record} // 1;
458
    my $holds_per_record = $rights->{holds_per_record} // 1;
459
    my $holds_per_day    = $rights->{holds_per_day};
459
    my $holds_per_day    = $rights->{holds_per_day};
460
460
461
    my $search_params = {
462
        borrowernumber => $patron->borrowernumber,
463
        biblionumber   => $item->biblionumber,
464
    };
465
    $search_params->{found} = undef if $params->{ignore_found_holds};
466
467
    my $holds = Koha::Holds->search($search_params);
468
    if (   defined $holds_per_record && $holds_per_record ne '' ){
461
    if (   defined $holds_per_record && $holds_per_record ne '' ){
469
        if ( $holds_per_record == 0 ) {
462
        if ( $holds_per_record == 0 ) {
470
            return { status => "noReservesAllowed" };
463
            return { status => "noReservesAllowed" };
471
        }
464
        }
472
        if ( !$params->{ignore_hold_counts} && $holds->count() >= $holds_per_record ) {
465
        if ( !$params->{ignore_hold_counts} ) {
473
            return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
466
            my $search_params = {
467
                borrowernumber => $patron->borrowernumber,
468
                biblionumber   => $item->biblionumber,
469
            };
470
            $search_params->{found} = undef if $params->{ignore_found_holds};
471
            my $holds = Koha::Holds->search($search_params);
472
            return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds->count() >= $holds_per_record;
474
        }
473
        }
475
    }
474
    }
476
475
477
    my $today_holds = Koha::Holds->search({
476
    if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '')
478
        borrowernumber => $patron->borrowernumber,
479
        reservedate    => dt_from_string->date
480
    });
481
482
    if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne ''
483
        && $today_holds->count() >= $holds_per_day )
484
    {
477
    {
485
        return { status => 'tooManyReservesToday', limit => $holds_per_day };
478
        my $today_holds = Koha::Holds->search({
479
            borrowernumber => $patron->borrowernumber,
480
            reservedate    => dt_from_string->date
481
        });
482
        return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day;
486
    }
483
    }
487
484
488
    # we retrieve count
485
    # we retrieve count
489
- 

Return to bug 30085