|
Lines 317-322
See CanItemBeReserved() for possible return values.
Link Here
|
| 317 |
|
317 |
|
| 318 |
sub CanBookBeReserved{ |
318 |
sub CanBookBeReserved{ |
| 319 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
319 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
|
|
320 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 321 |
my $borrower = $patron->unblessed; |
| 320 |
|
322 |
|
| 321 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
323 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
| 322 |
#get items linked via host records |
324 |
#get items linked via host records |
|
Lines 326-333
sub CanBookBeReserved{
Link Here
|
| 326 |
} |
328 |
} |
| 327 |
|
329 |
|
| 328 |
my $canReserve = { status => '' }; |
330 |
my $canReserve = { status => '' }; |
|
|
331 |
my ($rights,$item); |
| 332 |
|
| 329 |
foreach my $itemnumber (@itemnumbers) { |
333 |
foreach my $itemnumber (@itemnumbers) { |
| 330 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); |
334 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); |
|
|
335 |
return { status => 'RecordHoldNotAllowed' } if $canReserve->{rights}->{opacitemholds} eq 'F'; |
| 331 |
return { status => 'OK' } if $canReserve->{status} eq 'OK'; |
336 |
return { status => 'OK' } if $canReserve->{status} eq 'OK'; |
| 332 |
} |
337 |
} |
| 333 |
return $canReserve; |
338 |
return $canReserve; |
|
Lines 364-369
sub CanItemBeReserved {
Link Here
|
| 364 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
369 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
| 365 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
370 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
| 366 |
my $holds_per_day; # Default to unlimited |
371 |
my $holds_per_day; # Default to unlimited |
|
|
372 |
my $opacitemholds = 'Y'; # Itemlevel holds default to allowed |
| 367 |
|
373 |
|
| 368 |
# we retrieve borrowers and items informations # |
374 |
# we retrieve borrowers and items informations # |
| 369 |
# item->{itype} will come for biblioitems if necessery |
375 |
# item->{itype} will come for biblioitems if necessery |
|
Lines 415-420
sub CanItemBeReserved {
Link Here
|
| 415 |
$allowedreserves = $rights->{reservesallowed} // $allowedreserves; |
421 |
$allowedreserves = $rights->{reservesallowed} // $allowedreserves; |
| 416 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
422 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
| 417 |
$holds_per_day = $rights->{holds_per_day}; |
423 |
$holds_per_day = $rights->{holds_per_day}; |
|
|
424 |
$opacitemholds = $rights->{opacitemholds}; |
| 418 |
} |
425 |
} |
| 419 |
else { |
426 |
else { |
| 420 |
$ruleitemtype = undef; |
427 |
$ruleitemtype = undef; |
|
Lines 427-432
sub CanItemBeReserved {
Link Here
|
| 427 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
434 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
| 428 |
|
435 |
|
| 429 |
my $holds = Koha::Holds->search($search_params); |
436 |
my $holds = Koha::Holds->search($search_params); |
|
|
437 |
|
| 438 |
if ( $opacitemholds eq "N" ) { |
| 439 |
return { status => "notReservable" }; |
| 440 |
} |
| 441 |
|
| 442 |
$item = Koha::Items->find( $itemnumber ); |
| 443 |
|
| 444 |
my $holds = Koha::Holds->search( |
| 445 |
{ |
| 446 |
borrowernumber => $borrowernumber, |
| 447 |
biblionumber => $item->biblionumber, |
| 448 |
} |
| 449 |
); |
| 450 |
|
| 430 |
if ( defined $holds_per_record && $holds_per_record ne '' |
451 |
if ( defined $holds_per_record && $holds_per_record ne '' |
| 431 |
&& $holds->count() >= $holds_per_record ) { |
452 |
&& $holds->count() >= $holds_per_record ) { |
| 432 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
453 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
|
Lines 547-553
sub CanItemBeReserved {
Link Here
|
| 547 |
} |
568 |
} |
| 548 |
} |
569 |
} |
| 549 |
|
570 |
|
| 550 |
return { status => 'OK' }; |
571 |
return { status => 'OK', rights => $rights }; |
| 551 |
} |
572 |
} |
| 552 |
|
573 |
|
| 553 |
=head2 CanReserveBeCanceledFromOpac |
574 |
=head2 CanReserveBeCanceledFromOpac |
|
Lines 2270-2276
sub GetHoldRule {
Link Here
|
| 2270 |
itemtype => $itemtype, |
2291 |
itemtype => $itemtype, |
| 2271 |
categorycode => $categorycode, |
2292 |
categorycode => $categorycode, |
| 2272 |
branchcode => $branchcode, |
2293 |
branchcode => $branchcode, |
| 2273 |
rules => ['holds_per_record', 'holds_per_day'], |
2294 |
rules => ['holds_per_record', 'holds_per_day', 'opacitemholds'], |
| 2274 |
order_by => { |
2295 |
order_by => { |
| 2275 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
2296 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
| 2276 |
} |
2297 |
} |
|
Lines 2278-2283
sub GetHoldRule {
Link Here
|
| 2278 |
); |
2299 |
); |
| 2279 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
2300 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
| 2280 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
2301 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
|
|
2302 |
$rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds}; |
| 2281 |
|
2303 |
|
| 2282 |
return $rules; |
2304 |
return $rules; |
| 2283 |
} |
2305 |
} |
| 2284 |
- |
|
|