|
Lines 317-323
sub CanBookBeReserved{
Link Here
|
| 317 |
# Check if borrower has reached the maximum number of holds allowed |
317 |
# Check if borrower has reached the maximum number of holds allowed |
| 318 |
my $maxreserves = C4::Context->preference('maxreserves'); |
318 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 319 |
if ($maxreserves && $holds->count >= $maxreserves) { |
319 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 320 |
return { status => 'tooManyReserves' }; |
320 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 321 |
} |
321 |
} |
| 322 |
|
322 |
|
| 323 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
323 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
|
Lines 365-370
sub CanItemBeReserved {
Link Here
|
| 365 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
365 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
| 366 |
my $holds_per_day; # Default to unlimited |
366 |
my $holds_per_day; # Default to unlimited |
| 367 |
|
367 |
|
|
|
368 |
# Get calling context |
| 369 |
my $caller = (caller(1))[3]; |
| 370 |
|
| 368 |
# we retrieve borrowers and items informations # |
371 |
# we retrieve borrowers and items informations # |
| 369 |
# item->{itype} will come for biblioitems if necessery |
372 |
# item->{itype} will come for biblioitems if necessery |
| 370 |
my $item = Koha::Items->find($itemnumber); |
373 |
my $item = Koha::Items->find($itemnumber); |
|
Lines 386-398
sub CanItemBeReserved {
Link Here
|
| 386 |
return { status =>'itemAlreadyOnHold' } |
389 |
return { status =>'itemAlreadyOnHold' } |
| 387 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
390 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
| 388 |
|
391 |
|
| 389 |
# Check if borrower has reached the maximum number of holds allowed |
|
|
| 390 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 391 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
| 392 |
if ($maxreserves && $holds->count >= $maxreserves) { |
| 393 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 394 |
} |
| 395 |
|
| 396 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
392 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
| 397 |
|
393 |
|
| 398 |
my $querycount = q{ |
394 |
my $querycount = q{ |
|
Lines 416-421
sub CanItemBeReserved {
Link Here
|
| 416 |
$branchcode = $borrower->{branchcode}; |
412 |
$branchcode = $borrower->{branchcode}; |
| 417 |
} |
413 |
} |
| 418 |
|
414 |
|
|
|
415 |
# Check if borrower has reached the maximum number of holds allowed |
| 416 |
my $holds = $patron->holds; |
| 417 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 418 |
if ( index($caller,"CanBookBeReserved") eq -1 |
| 419 |
&& $maxreserves |
| 420 |
&& $holds->count >= $maxreserves) { |
| 421 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
| 422 |
} |
| 423 |
|
| 419 |
# we retrieve rights |
424 |
# we retrieve rights |
| 420 |
if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->effective_itemtype, $branchcode ) ) { |
425 |
if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->effective_itemtype, $branchcode ) ) { |
| 421 |
$ruleitemtype = $rights->{itemtype}; |
426 |
$ruleitemtype = $rights->{itemtype}; |
|
Lines 433-438
sub CanItemBeReserved {
Link Here
|
| 433 |
biblionumber => $item->biblionumber, |
438 |
biblionumber => $item->biblionumber, |
| 434 |
} |
439 |
} |
| 435 |
); |
440 |
); |
|
|
441 |
|
| 436 |
if ( defined $holds_per_record && $holds_per_record ne '' |
442 |
if ( defined $holds_per_record && $holds_per_record ne '' |
| 437 |
&& $holds->count() >= $holds_per_record ) { |
443 |
&& $holds->count() >= $holds_per_record ) { |
| 438 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
444 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |