Lines 324-330
sub CanBookBeReserved{
Link Here
|
324 |
return { status =>'alreadypossession' }; |
324 |
return { status =>'alreadypossession' }; |
325 |
} |
325 |
} |
326 |
|
326 |
|
|
|
327 |
my $patron = Koha::Patrons->find($borrowernumber); |
328 |
my $holds = $patron->holds; |
329 |
|
330 |
# Check if borrower has reached the maximum number of holds allowed |
331 |
my $maxreserves = C4::Context->preference('maxreserves'); |
332 |
if ($maxreserves && $holds->count >= $maxreserves) { |
333 |
return { status => 'tooManyReserves' }; |
334 |
} |
335 |
|
327 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
336 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
|
|
337 |
|
328 |
#get items linked via host records |
338 |
#get items linked via host records |
329 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
339 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
330 |
if (@hostitems){ |
340 |
if (@hostitems){ |
Lines 359-364
sub CanBookBeReserved{
Link Here
|
359 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
369 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
360 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
370 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
361 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
371 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
|
|
372 |
{ status => alreadyReserved }, if the borrower has already reserved this item. |
362 |
|
373 |
|
363 |
=cut |
374 |
=cut |
364 |
|
375 |
|
Lines 392-401
sub CanItemBeReserved {
Link Here
|
392 |
return { status =>'itemAlreadyOnHold' } |
403 |
return { status =>'itemAlreadyOnHold' } |
393 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
404 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
394 |
|
405 |
|
|
|
406 |
<<<<<<< HEAD |
395 |
# Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) |
407 |
# Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) |
396 |
if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') |
408 |
if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') |
397 |
&& C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { |
409 |
&& C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { |
398 |
return { status =>'alreadypossession' }; |
410 |
return { status =>'alreadypossession' }; |
|
|
411 |
======= |
412 |
# Check if borrower has reached the maximum number of holds allowed |
413 |
my $maxreserves = C4::Context->preference('maxreserves'); |
414 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
415 |
if ($maxreserves && $holds->count >= $maxreserves) { |
416 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
417 |
>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved |
399 |
} |
418 |
} |
400 |
|
419 |
|
401 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
420 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
Lines 432-437
sub CanItemBeReserved {
Link Here
|
432 |
$ruleitemtype = undef; |
451 |
$ruleitemtype = undef; |
433 |
} |
452 |
} |
434 |
|
453 |
|
|
|
454 |
<<<<<<< HEAD |
435 |
my $search_params = { |
455 |
my $search_params = { |
436 |
borrowernumber => $borrowernumber, |
456 |
borrowernumber => $borrowernumber, |
437 |
biblionumber => $item->biblionumber, |
457 |
biblionumber => $item->biblionumber, |
Lines 441-446
sub CanItemBeReserved {
Link Here
|
441 |
my $holds = Koha::Holds->search($search_params); |
461 |
my $holds = Koha::Holds->search($search_params); |
442 |
if ( defined $holds_per_record && $holds_per_record ne '' |
462 |
if ( defined $holds_per_record && $holds_per_record ne '' |
443 |
&& $holds->count() >= $holds_per_record ) { |
463 |
&& $holds->count() >= $holds_per_record ) { |
|
|
464 |
======= |
465 |
$holds = Koha::Holds->search( |
466 |
{ |
467 |
borrowernumber => $borrowernumber, |
468 |
biblionumber => $item->biblionumber, |
469 |
} |
470 |
); |
471 |
if ( $holds->count() >= $holds_per_record ) { |
472 |
>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved |
444 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
473 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
445 |
} |
474 |
} |
446 |
|
475 |
|