Lines 324-330
sub CanBookBeReserved{
Link Here
|
324 |
# Check if borrower has reached the maximum number of holds allowed |
324 |
# Check if borrower has reached the maximum number of holds allowed |
325 |
my $maxreserves = C4::Context->preference('maxreserves'); |
325 |
my $maxreserves = C4::Context->preference('maxreserves'); |
326 |
if ($maxreserves && $holds->count >= $maxreserves) { |
326 |
if ($maxreserves && $holds->count >= $maxreserves) { |
327 |
return { status => 'tooManyReserves' }; |
327 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
328 |
} |
328 |
} |
329 |
|
329 |
|
330 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
330 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
Lines 376-381
sub CanItemBeReserved {
Link Here
|
376 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
376 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
377 |
my $holds_per_day; # Default to unlimited |
377 |
my $holds_per_day; # Default to unlimited |
378 |
|
378 |
|
|
|
379 |
# Get calling context |
380 |
my $caller = (caller(1))[3]; |
381 |
|
379 |
# we retrieve borrowers and items informations # |
382 |
# we retrieve borrowers and items informations # |
380 |
# item->{itype} will come for biblioitems if necessery |
383 |
# item->{itype} will come for biblioitems if necessery |
381 |
my $item = Koha::Items->find($itemnumber); |
384 |
my $item = Koha::Items->find($itemnumber); |
Lines 397-409
sub CanItemBeReserved {
Link Here
|
397 |
return { status =>'itemAlreadyOnHold' } |
400 |
return { status =>'itemAlreadyOnHold' } |
398 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
401 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
399 |
|
402 |
|
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 |
|
407 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
403 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
408 |
|
404 |
|
409 |
my $querycount = q{ |
405 |
my $querycount = q{ |
Lines 427-432
sub CanItemBeReserved {
Link Here
|
427 |
$branchcode = $borrower->{branchcode}; |
423 |
$branchcode = $borrower->{branchcode}; |
428 |
} |
424 |
} |
429 |
|
425 |
|
|
|
426 |
# Check if borrower has reached the maximum number of holds allowed |
427 |
my $holds = $patron->holds; |
428 |
my $maxreserves = C4::Context->preference('maxreserves'); |
429 |
if ( index($caller,"CanBookBeReserved") eq -1 |
430 |
&& $maxreserves |
431 |
&& $holds->count >= $maxreserves) { |
432 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
433 |
} |
434 |
|
430 |
# we retrieve rights |
435 |
# we retrieve rights |
431 |
if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->effective_itemtype, $branchcode ) ) { |
436 |
if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->effective_itemtype, $branchcode ) ) { |
432 |
$ruleitemtype = $rights->{itemtype}; |
437 |
$ruleitemtype = $rights->{itemtype}; |
Lines 438-462
sub CanItemBeReserved {
Link Here
|
438 |
$ruleitemtype = undef; |
443 |
$ruleitemtype = undef; |
439 |
} |
444 |
} |
440 |
|
445 |
|
441 |
<<<<<<< HEAD |
|
|
442 |
my $search_params = { |
446 |
my $search_params = { |
443 |
borrowernumber => $borrowernumber, |
447 |
borrowernumber => $borrowernumber, |
444 |
biblionumber => $item->biblionumber, |
448 |
biblionumber => $item->biblionumber, |
445 |
}; |
449 |
}; |
446 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
450 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
447 |
|
451 |
|
448 |
my $holds = Koha::Holds->search($search_params); |
452 |
$holds = Koha::Holds->search($search_params); |
449 |
if ( defined $holds_per_record && $holds_per_record ne '' |
453 |
if ( defined $holds_per_record && $holds_per_record ne '' |
450 |
&& $holds->count() >= $holds_per_record ) { |
454 |
&& $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 |
460 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
455 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
461 |
} |
456 |
} |
462 |
|
457 |
|