|
Lines 318-324
See CanItemBeReserved() for possible return values.
Link Here
|
| 318 |
sub CanBookBeReserved{ |
318 |
sub CanBookBeReserved{ |
| 319 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
319 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
| 320 |
|
320 |
|
|
|
321 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 322 |
my $holds = $patron->holds; |
| 323 |
|
| 324 |
# Check if borrower has reached the maximum number of holds allowed |
| 325 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 326 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 327 |
return { status => 'tooManyReserves' }; |
| 328 |
} |
| 329 |
|
| 321 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
330 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
|
|
331 |
|
| 322 |
#get items linked via host records |
332 |
#get items linked via host records |
| 323 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
333 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
| 324 |
if (@hostitems){ |
334 |
if (@hostitems){ |
|
Lines 353-358
sub CanBookBeReserved{
Link Here
|
| 353 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
363 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
| 354 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
364 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
| 355 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
365 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
|
|
366 |
{ status => alreadyReserved }, if the borrower has already reserved this item. |
| 356 |
|
367 |
|
| 357 |
=cut |
368 |
=cut |
| 358 |
|
369 |
|
|
Lines 386-391
sub CanItemBeReserved {
Link Here
|
| 386 |
return { status =>'itemAlreadyOnHold' } |
397 |
return { status =>'itemAlreadyOnHold' } |
| 387 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
398 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
| 388 |
|
399 |
|
|
|
400 |
# Check if borrower has reached the maximum number of holds allowed |
| 401 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 402 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
| 403 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 404 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 405 |
} |
| 406 |
|
| 389 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
407 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
| 390 |
|
408 |
|
| 391 |
my $querycount = q{ |
409 |
my $querycount = q{ |
|
Lines 420-425
sub CanItemBeReserved {
Link Here
|
| 420 |
$ruleitemtype = undef; |
438 |
$ruleitemtype = undef; |
| 421 |
} |
439 |
} |
| 422 |
|
440 |
|
|
|
441 |
<<<<<<< HEAD |
| 423 |
my $search_params = { |
442 |
my $search_params = { |
| 424 |
borrowernumber => $borrowernumber, |
443 |
borrowernumber => $borrowernumber, |
| 425 |
biblionumber => $item->biblionumber, |
444 |
biblionumber => $item->biblionumber, |
|
Lines 429-434
sub CanItemBeReserved {
Link Here
|
| 429 |
my $holds = Koha::Holds->search($search_params); |
448 |
my $holds = Koha::Holds->search($search_params); |
| 430 |
if ( defined $holds_per_record && $holds_per_record ne '' |
449 |
if ( defined $holds_per_record && $holds_per_record ne '' |
| 431 |
&& $holds->count() >= $holds_per_record ) { |
450 |
&& $holds->count() >= $holds_per_record ) { |
|
|
451 |
======= |
| 452 |
$holds = Koha::Holds->search( |
| 453 |
{ |
| 454 |
borrowernumber => $borrowernumber, |
| 455 |
biblionumber => $item->biblionumber, |
| 456 |
} |
| 457 |
); |
| 458 |
if ( $holds->count() >= $holds_per_record ) { |
| 459 |
>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved |
| 432 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
460 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
| 433 |
} |
461 |
} |
| 434 |
|
462 |
|