Lines 290-296
See CanItemBeReserved() for possible return values.
Link Here
|
290 |
sub CanBookBeReserved{ |
290 |
sub CanBookBeReserved{ |
291 |
my ($borrowernumber, $biblionumber, $pickup_branchcode) = @_; |
291 |
my ($borrowernumber, $biblionumber, $pickup_branchcode) = @_; |
292 |
|
292 |
|
|
|
293 |
my $patron = Koha::Patrons->find($borrowernumber); |
294 |
my $holds = $patron->holds; |
295 |
|
296 |
# Check if borrower has reached the maximum number of holds allowed |
297 |
my $maxreserves = C4::Context->preference('maxreserves'); |
298 |
if ($maxreserves && $holds->count >= $maxreserves) { |
299 |
return { status => 'tooManyReserves' }; |
300 |
} |
301 |
|
293 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
302 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
|
|
303 |
|
294 |
#get items linked via host records |
304 |
#get items linked via host records |
295 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
305 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
296 |
if (@hostitems){ |
306 |
if (@hostitems){ |
Lines 321-326
sub CanBookBeReserved{
Link Here
|
321 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
331 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
322 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
332 |
{ status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode |
323 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
333 |
{ status => pickupNotInHoldGroup }, pickup location is not in hold group, and pickup locations are only allowed from hold groups. |
|
|
334 |
{ status => alreadyReserved }, if the borrower has already reserved this item. |
324 |
|
335 |
|
325 |
=cut |
336 |
=cut |
326 |
|
337 |
|
Lines 354-359
sub CanItemBeReserved {
Link Here
|
354 |
return { status =>'itemAlreadyOnHold' } |
365 |
return { status =>'itemAlreadyOnHold' } |
355 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
366 |
if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); |
356 |
|
367 |
|
|
|
368 |
# Check if borrower has reached the maximum number of holds allowed |
369 |
my $maxreserves = C4::Context->preference('maxreserves'); |
370 |
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); |
371 |
if ($maxreserves && $holds->count >= $maxreserves) { |
372 |
return { status => 'tooManyReserves', limit => $maxreserves }; |
373 |
} |
374 |
|
357 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
375 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
358 |
|
376 |
|
359 |
my $querycount = q{ |
377 |
my $querycount = q{ |
Lines 388-394
sub CanItemBeReserved {
Link Here
|
388 |
$ruleitemtype = '*'; |
406 |
$ruleitemtype = '*'; |
389 |
} |
407 |
} |
390 |
|
408 |
|
391 |
my $holds = Koha::Holds->search( |
409 |
$holds = Koha::Holds->search( |
392 |
{ |
410 |
{ |
393 |
borrowernumber => $borrowernumber, |
411 |
borrowernumber => $borrowernumber, |
394 |
biblionumber => $item->biblionumber, |
412 |
biblionumber => $item->biblionumber, |