|
Lines 330-336
sub CanBookBeReserved{
Link Here
|
| 330 |
# Check if borrower has reached the maximum number of holds allowed |
330 |
# Check if borrower has reached the maximum number of holds allowed |
| 331 |
my $maxreserves = C4::Context->preference('maxreserves'); |
331 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 332 |
if ($maxreserves && $holds->count >= $maxreserves) { |
332 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 333 |
return { status => 'tooManyReserves' }; |
333 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 334 |
} |
334 |
} |
| 335 |
|
335 |
|
| 336 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
336 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
|
Lines 382-387
sub CanItemBeReserved {
Link Here
|
| 382 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
382 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
| 383 |
my $holds_per_day; # Default to unlimited |
383 |
my $holds_per_day; # Default to unlimited |
| 384 |
|
384 |
|
|
|
385 |
# Get calling context |
| 386 |
my $caller = (caller(1))[3]; |
| 387 |
|
| 385 |
# we retrieve borrowers and items informations # |
388 |
# we retrieve borrowers and items informations # |
| 386 |
# item->{itype} will come for biblioitems if necessery |
389 |
# item->{itype} will come for biblioitems if necessery |
| 387 |
my $item = Koha::Items->find($itemnumber); |
390 |
my $item = Koha::Items->find($itemnumber); |
|
Lines 403-420
sub CanItemBeReserved {
Link Here
|
| 403 |
return { status =>'itemAlreadyOnHold' } |
406 |
return { status =>'itemAlreadyOnHold' } |
| 404 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
407 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
| 405 |
|
408 |
|
| 406 |
<<<<<<< HEAD |
|
|
| 407 |
# Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) |
409 |
# Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) |
| 408 |
if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') |
410 |
if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') |
| 409 |
&& C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { |
411 |
&& C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { |
| 410 |
return { status =>'alreadypossession' }; |
412 |
return { status =>'alreadypossession' }; |
| 411 |
======= |
413 |
} |
|
|
414 |
|
| 412 |
# Check if borrower has reached the maximum number of holds allowed |
415 |
# Check if borrower has reached the maximum number of holds allowed |
| 413 |
my $maxreserves = C4::Context->preference('maxreserves'); |
416 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 414 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
417 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
| 415 |
if ($maxreserves && $holds->count >= $maxreserves) { |
418 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 416 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
419 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 417 |
>>>>>>> Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved |
|
|
| 418 |
} |
420 |
} |
| 419 |
|
421 |
|
| 420 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
422 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
|
Lines 451-475
sub CanItemBeReserved {
Link Here
|
| 451 |
$ruleitemtype = undef; |
453 |
$ruleitemtype = undef; |
| 452 |
} |
454 |
} |
| 453 |
|
455 |
|
| 454 |
<<<<<<< HEAD |
|
|
| 455 |
my $search_params = { |
456 |
my $search_params = { |
| 456 |
borrowernumber => $borrowernumber, |
457 |
borrowernumber => $borrowernumber, |
| 457 |
biblionumber => $item->biblionumber, |
458 |
biblionumber => $item->biblionumber, |
| 458 |
}; |
459 |
}; |
| 459 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
460 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
| 460 |
|
461 |
|
| 461 |
my $holds = Koha::Holds->search($search_params); |
462 |
$holds = Koha::Holds->search($search_params); |
| 462 |
if ( defined $holds_per_record && $holds_per_record ne '' |
463 |
if ( defined $holds_per_record && $holds_per_record ne '' |
| 463 |
&& $holds->count() >= $holds_per_record ) { |
464 |
&& $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 |
| 473 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
465 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
| 474 |
} |
466 |
} |
| 475 |
|
467 |
|