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

(-)a/C4/Reserves.pm (-3 / +23 lines)
Lines 320-325 See CanItemBeReserved() for possible return values. Link Here
320
320
321
sub CanBookBeReserved{
321
sub CanBookBeReserved{
322
    my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_;
322
    my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_;
323
    my $patron = Koha::Patrons->find( $borrowernumber );
324
    my $borrower = $patron->unblessed;
323
325
324
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
326
    # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
325
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
327
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
Lines 335-343 sub CanBookBeReserved{ Link Here
335
    }
337
    }
336
338
337
    my $canReserve = { status => '' };
339
    my $canReserve = { status => '' };
340
    my ($rights,$item);
341
338
    foreach my $itemnumber (@itemnumbers) {
342
    foreach my $itemnumber (@itemnumbers) {
339
        $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params );
343
        $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params );
344
        return { status => 'recordHoldNotAllowed' } if $canReserve->{rights}->{opacitemholds} eq 'F';
340
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
345
        return { status => 'OK' } if $canReserve->{status} eq 'OK';
346
        return { status => 'OK' } if $canReserve->{status} eq 'recordHoldsOnly';
341
    }
347
    }
342
    return $canReserve;
348
    return $canReserve;
343
}
349
}
Lines 442-451 sub CanItemBeReserved { Link Here
442
        categorycode => $borrower->{'categorycode'},
448
        categorycode => $borrower->{'categorycode'},
443
        itemtype     => $item->effective_itemtype,
449
        itemtype     => $item->effective_itemtype,
444
        branchcode   => $branchcode,
450
        branchcode   => $branchcode,
445
        rules        => ['holds_per_record','holds_per_day']
451
        rules        => ['holds_per_record','holds_per_day','opacitemholds']
446
    });
452
    });
447
    my $holds_per_record = $rights->{holds_per_record} // 1;
453
    my $holds_per_record = $rights->{holds_per_record} // 1;
448
    my $holds_per_day    = $rights->{holds_per_day};
454
    my $holds_per_day    = $rights->{holds_per_day};
455
    my $opacitemholds    = $rights->{opacitemholds} // 'Y';
449
456
450
    my $search_params = {
457
    my $search_params = {
451
        borrowernumber => $borrowernumber,
458
        borrowernumber => $borrowernumber,
Lines 454-459 sub CanItemBeReserved { Link Here
454
    $search_params->{found} = undef if $params->{ignore_found_holds};
461
    $search_params->{found} = undef if $params->{ignore_found_holds};
455
462
456
    my $holds = Koha::Holds->search($search_params);
463
    my $holds = Koha::Holds->search($search_params);
464
465
    $item = Koha::Items->find( $itemnumber );
466
467
    $holds = Koha::Holds->search(
468
        {
469
            borrowernumber => $borrowernumber,
470
            biblionumber   => $item->biblionumber,
471
        }
472
    );
473
457
    if (   defined $holds_per_record && $holds_per_record ne ''
474
    if (   defined $holds_per_record && $holds_per_record ne ''
458
        && $holds->count() >= $holds_per_record ) {
475
        && $holds->count() >= $holds_per_record ) {
459
        return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
476
        return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
Lines 574-580 sub CanItemBeReserved { Link Here
574
        }
591
        }
575
    }
592
    }
576
593
577
    return { status => 'OK' };
594
    if ( $opacitemholds eq "N" ) {
595
        return { status => "recordHoldsOnly", right => $rights };
596
    }
597
598
    return { status => 'OK', rights => $rights };
578
}
599
}
579
600
580
=head2 CanReserveBeCanceledFromOpac
601
=head2 CanReserveBeCanceledFromOpac
581
- 

Return to bug 25408