Lines 348-353
sub CanBookBeReserved{
Link Here
|
348 |
current checkout against the high holds threshold |
348 |
current checkout against the high holds threshold |
349 |
|
349 |
|
350 |
@RETURNS { status => OK }, if the Item can be reserved. |
350 |
@RETURNS { status => OK }, if the Item can be reserved. |
|
|
351 |
{ status => onShelfHoldsNotAllowed }, if onShelfHoldsAllowed parameter and item availability combination doesn't allow holds. |
351 |
{ status => ageRestricted }, if the Item is age restricted for this borrower. |
352 |
{ status => ageRestricted }, if the Item is age restricted for this borrower. |
352 |
{ status => damaged }, if the Item is damaged. |
353 |
{ status => damaged }, if the Item is damaged. |
353 |
{ status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. |
354 |
{ status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. |
Lines 370-379
sub CanItemBeReserved {
Link Here
|
370 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
371 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
371 |
my $holds_per_day; # Default to unlimited |
372 |
my $holds_per_day; # Default to unlimited |
372 |
my $opacitemholds = 'Y'; # Itemlevel holds default to allowed |
373 |
my $opacitemholds = 'Y'; # Itemlevel holds default to allowed |
|
|
374 |
my $on_shelf_holds = 0; # Default to "if any unavailable" |
373 |
my $context = $params->{context} // ''; |
375 |
my $context = $params->{context} // ''; |
374 |
|
376 |
|
375 |
# we retrieve borrowers and items informations # |
377 |
# we retrieve borrowers and items informations # |
376 |
# item->{itype} will come for biblioitems if necessery |
378 |
# item->{itype} will come for biblioitems if necessery |
|
|
379 |
|
377 |
my $item = Koha::Items->find($itemnumber); |
380 |
my $item = Koha::Items->find($itemnumber); |
378 |
my $biblio = $item->biblio; |
381 |
my $biblio = $item->biblio; |
379 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
382 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
Lines 424-429
sub CanItemBeReserved {
Link Here
|
424 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
427 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
425 |
$holds_per_day = $rights->{holds_per_day}; |
428 |
$holds_per_day = $rights->{holds_per_day}; |
426 |
$opacitemholds = $rights->{opacitemholds}; |
429 |
$opacitemholds = $rights->{opacitemholds}; |
|
|
430 |
$on_shelf_holds = $rights->{onshelfholds}; |
427 |
} |
431 |
} |
428 |
else { |
432 |
else { |
429 |
$ruleitemtype = undef; |
433 |
$ruleitemtype = undef; |
Lines 433-440
sub CanItemBeReserved {
Link Here
|
433 |
borrowernumber => $borrowernumber, |
437 |
borrowernumber => $borrowernumber, |
434 |
biblionumber => $item->biblionumber, |
438 |
biblionumber => $item->biblionumber, |
435 |
}; |
439 |
}; |
|
|
440 |
|
436 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
441 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
437 |
|
442 |
|
|
|
443 |
# Check for item on shelves and OnShelfHoldsAllowed |
444 |
return { status => 'onShelfHoldsNotAllowed' } |
445 |
unless IsAvailableForItemLevelRequest($item, $patron, $pickup_branchcode,1); |
446 |
|
438 |
my $holds = Koha::Holds->search($search_params); |
447 |
my $holds = Koha::Holds->search($search_params); |
439 |
|
448 |
|
440 |
if ( $opacitemholds eq "N" && $context ne 'staff' ) { |
449 |
if ( $opacitemholds eq "N" && $context ne 'staff' ) { |
Lines 1285-1290
checks with CanItemBeReserved or CanBookBeReserved.
Link Here
|
1285 |
|
1294 |
|
1286 |
=cut |
1295 |
=cut |
1287 |
|
1296 |
|
|
|
1297 |
|
1288 |
sub IsAvailableForItemLevelRequest { |
1298 |
sub IsAvailableForItemLevelRequest { |
1289 |
my $item = shift; |
1299 |
my $item = shift; |
1290 |
my $patron = shift; |
1300 |
my $patron = shift; |
Lines 1326-1332
sub IsAvailableForItemLevelRequest {
Link Here
|
1326 |
if ( $on_shelf_holds == 1 ) { |
1336 |
if ( $on_shelf_holds == 1 ) { |
1327 |
return 1; |
1337 |
return 1; |
1328 |
} elsif ( $on_shelf_holds == 2 ) { |
1338 |
} elsif ( $on_shelf_holds == 2 ) { |
1329 |
|
|
|
1330 |
# if we have this param predefined from outer caller sub, we just need |
1339 |
# if we have this param predefined from outer caller sub, we just need |
1331 |
# to return it, so we saving from having loop inside other loop: |
1340 |
# to return it, so we saving from having loop inside other loop: |
1332 |
return $items_any_available ? 0 : 1 |
1341 |
return $items_any_available ? 0 : 1 |
Lines 2284-2290
sub GetHoldRule {
Link Here
|
2284 |
itemtype => $itemtype, |
2293 |
itemtype => $itemtype, |
2285 |
categorycode => $categorycode, |
2294 |
categorycode => $categorycode, |
2286 |
branchcode => $branchcode, |
2295 |
branchcode => $branchcode, |
2287 |
rules => ['holds_per_record', 'holds_per_day', 'opacitemholds'], |
2296 |
rules => ['holds_per_record', 'holds_per_day', 'opacitemholds', 'onshelfholds'], |
2288 |
order_by => { |
2297 |
order_by => { |
2289 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
2298 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
2290 |
} |
2299 |
} |
Lines 2293-2298
sub GetHoldRule {
Link Here
|
2293 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
2302 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
2294 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
2303 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
2295 |
$rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds} // 'Y'; |
2304 |
$rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds} // 'Y'; |
|
|
2305 |
$rules->{onshelfholds} = $holds_per_x_rules->{onshelfholds} // '0'; |
2296 |
|
2306 |
|
2297 |
return $rules; |
2307 |
return $rules; |
2298 |
} |
2308 |
} |