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