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

(-)a/C4/Reserves.pm (-9 / +2 lines)
Lines 428-442 See CanItemBeReserved() for possible return values. Link Here
428
sub CanBookBeReserved{
428
sub CanBookBeReserved{
429
    my ($borrowernumber, $biblionumber) = @_;
429
    my ($borrowernumber, $biblionumber) = @_;
430
430
431
    # Check if borrower already has reserved the same biblio.
432
    my @reserves = GetReservesFromBorrowernumber($borrowernumber);
433
    foreach my $reserve (@reserves) {
434
        if ($reserve->{biblionumber} == $biblionumber) {
435
            return 'alreadyReserved';
436
        }
437
    }
438
439
    # Check if borrower has reached the maximum number of holds allowed
431
    # Check if borrower has reached the maximum number of holds allowed
432
    my @reserves = GetReservesFromBorrowernumber($borrowernumber);
440
    my $maxreserves = C4::Context->preference('maxreserves');
433
    my $maxreserves = C4::Context->preference('maxreserves');
441
    if ($maxreserves && scalar(@reserves) >= $maxreserves) {
434
    if ($maxreserves && scalar(@reserves) >= $maxreserves) {
442
        return 'tooManyReserves';
435
        return 'tooManyReserves';
Lines 619-625 sub CanItemBeReserved { Link Here
619
    if ( C4::Context->preference('IndependentBranches')
612
    if ( C4::Context->preference('IndependentBranches')
620
        and !C4::Context->preference('canreservefromotherbranches') )
613
        and !C4::Context->preference('canreservefromotherbranches') )
621
    {
614
    {
622
        my $itembranch = $item->{homebranch};
615
        my $itembranch = $item->homebranch;
623
        if ( $itembranch ne $borrower->{branchcode} ) {
616
        if ( $itembranch ne $borrower->{branchcode} ) {
624
            return 'cannotReserveFromOtherBranches';
617
            return 'cannotReserveFromOtherBranches';
625
        }
618
        }
(-)a/t/db_dependent/Holds.t (-3 / +2 lines)
Lines 386-395 ok( Link Here
386
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
386
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
387
);
387
);
388
388
389
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'alreadyReserved');
389
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'none_available');
390
390
391
C4::Context->set_preference('maxreserves', 1);
391
C4::Context->set_preference('maxreserves', 1);
392
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves');
392
is(CanBookBeReserved($borrowernumbers[0], $biblionumber), 'tooManyReserves');
393
393
394
C4::Context->set_preference('maxreserves', 0);
394
C4::Context->set_preference('maxreserves', 0);
395
t::lib::Mocks::mock_preference('IndependentBranches', 1);
395
t::lib::Mocks::mock_preference('IndependentBranches', 1);
396
- 

Return to bug 11999