@@ -, +, @@ CanItemBeReserved - Check if borrower has reached the maximum number of holds allowed (syspref maxreserves) ---------- 1 hold for a borrower than 1 hold for a borrower identical than before the patch. --- C4/Reserves.pm | 29 +++++++++++++++++++++++++++++ reserve/request.pl | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -324,7 +324,17 @@ sub CanBookBeReserved{ return { status =>'alreadypossession' }; } + my $patron = Koha::Patrons->find($borrowernumber); + my $holds = $patron->holds; + + # Check if borrower has reached the maximum number of holds allowed + my $maxreserves = C4::Context->preference('maxreserves'); + if ($maxreserves && $holds->count >= $maxreserves) { + return { status => 'tooManyReserves' }; + } + my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); + #get items linked via host records my @hostitems = get_hostitemnumbers_of($biblionumber); if (@hostitems){ @@ -359,6 +369,7 @@ sub CanBookBeReserved{ { status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode { status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. + { status => alreadyReserved }, if the borrower has already reserved this item. =cut @@ -392,10 +403,18 @@ sub CanItemBeReserved { return { status =>'itemAlreadyOnHold' } if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); +<<<<<<< HEAD # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') && C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { return { status =>'alreadypossession' }; +======= + # Check if borrower has reached the maximum number of holds allowed + my $maxreserves = C4::Context->preference('maxreserves'); + my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); + if ($maxreserves && $holds->count >= $maxreserves) { + return { status => 'tooManyReserves', limit => $maxreserves }; +>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved } my $controlbranch = C4::Context->preference('ReservesControlBranch'); @@ -432,6 +451,7 @@ sub CanItemBeReserved { $ruleitemtype = undef; } +<<<<<<< HEAD my $search_params = { borrowernumber => $borrowernumber, biblionumber => $item->biblionumber, @@ -441,6 +461,15 @@ sub CanItemBeReserved { my $holds = Koha::Holds->search($search_params); if ( defined $holds_per_record && $holds_per_record ne '' && $holds->count() >= $holds_per_record ) { +======= + $holds = Koha::Holds->search( + { + borrowernumber => $borrowernumber, + biblionumber => $item->biblionumber, + } + ); + if ( $holds->count() >= $holds_per_record ) { +>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; } --- a/reserve/request.pl +++ a/reserve/request.pl @@ -310,7 +310,9 @@ foreach my $biblionumber (@biblionumbers) { $exceeded_holds_per_record = 1; $biblioloopiter{ $canReserve->{status} } = 1; } - elsif ( $canReserve->{status} eq 'ageRestricted' ) { + elsif ( grep { $canReserve->{status} eq $_ } + (qw(ageRestricted alreadyReserved none_available)) ) + { $template->param( $canReserve->{status} => 1 ); $biblioloopiter{ $canReserve->{status} } = 1; } --