Lines 315-320
See CanItemBeReserved() for possible return values.
Link Here
|
315 |
|
315 |
|
316 |
sub CanBookBeReserved{ |
316 |
sub CanBookBeReserved{ |
317 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
317 |
my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; |
|
|
318 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
319 |
my $borrower = $patron->unblessed; |
318 |
|
320 |
|
319 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
321 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
320 |
#get items linked via host records |
322 |
#get items linked via host records |
Lines 324-331
sub CanBookBeReserved{
Link Here
|
324 |
} |
326 |
} |
325 |
|
327 |
|
326 |
my $canReserve = { status => '' }; |
328 |
my $canReserve = { status => '' }; |
|
|
329 |
my ($rights,$item); |
330 |
|
327 |
foreach my $itemnumber (@itemnumbers) { |
331 |
foreach my $itemnumber (@itemnumbers) { |
328 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); |
332 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); |
|
|
333 |
return { status => 'RecordHoldNotAllowed' } if $canReserve->{rights}->{opacitemholds} eq 'F'; |
329 |
return { status => 'OK' } if $canReserve->{status} eq 'OK'; |
334 |
return { status => 'OK' } if $canReserve->{status} eq 'OK'; |
330 |
} |
335 |
} |
331 |
return $canReserve; |
336 |
return $canReserve; |
Lines 362-367
sub CanItemBeReserved {
Link Here
|
362 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
367 |
my $allowedreserves = 0; # Total number of holds allowed across all records |
363 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
368 |
my $holds_per_record = 1; # Total number of holds allowed for this one given record |
364 |
my $holds_per_day; # Default to unlimited |
369 |
my $holds_per_day; # Default to unlimited |
|
|
370 |
my $opacitemholds = 'Y'; # Itemlevel holds default to allowed |
365 |
|
371 |
|
366 |
# we retrieve borrowers and items informations # |
372 |
# we retrieve borrowers and items informations # |
367 |
# item->{itype} will come for biblioitems if necessery |
373 |
# item->{itype} will come for biblioitems if necessery |
Lines 413-418
sub CanItemBeReserved {
Link Here
|
413 |
$allowedreserves = $rights->{reservesallowed} // $allowedreserves; |
419 |
$allowedreserves = $rights->{reservesallowed} // $allowedreserves; |
414 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
420 |
$holds_per_record = $rights->{holds_per_record} // $holds_per_record; |
415 |
$holds_per_day = $rights->{holds_per_day}; |
421 |
$holds_per_day = $rights->{holds_per_day}; |
|
|
422 |
$opacitemholds = $rights->{opacitemholds}; |
416 |
} |
423 |
} |
417 |
else { |
424 |
else { |
418 |
$ruleitemtype = undef; |
425 |
$ruleitemtype = undef; |
Lines 425-430
sub CanItemBeReserved {
Link Here
|
425 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
432 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
426 |
|
433 |
|
427 |
my $holds = Koha::Holds->search($search_params); |
434 |
my $holds = Koha::Holds->search($search_params); |
|
|
435 |
|
436 |
if ( $opacitemholds eq "N" ) { |
437 |
return { status => "notReservable" }; |
438 |
} |
439 |
|
440 |
$item = Koha::Items->find( $itemnumber ); |
441 |
|
442 |
my $holds = Koha::Holds->search( |
443 |
{ |
444 |
borrowernumber => $borrowernumber, |
445 |
biblionumber => $item->biblionumber, |
446 |
} |
447 |
); |
448 |
|
428 |
if ( defined $holds_per_record && $holds_per_record ne '' |
449 |
if ( defined $holds_per_record && $holds_per_record ne '' |
429 |
&& $holds->count() >= $holds_per_record ) { |
450 |
&& $holds->count() >= $holds_per_record ) { |
430 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
451 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
Lines 545-551
sub CanItemBeReserved {
Link Here
|
545 |
} |
566 |
} |
546 |
} |
567 |
} |
547 |
|
568 |
|
548 |
return { status => 'OK' }; |
569 |
return { status => 'OK', rights => $rights }; |
549 |
} |
570 |
} |
550 |
|
571 |
|
551 |
=head2 CanReserveBeCanceledFromOpac |
572 |
=head2 CanReserveBeCanceledFromOpac |
Lines 2250-2256
sub GetHoldRule {
Link Here
|
2250 |
itemtype => $itemtype, |
2271 |
itemtype => $itemtype, |
2251 |
categorycode => $categorycode, |
2272 |
categorycode => $categorycode, |
2252 |
branchcode => $branchcode, |
2273 |
branchcode => $branchcode, |
2253 |
rules => ['holds_per_record', 'holds_per_day'], |
2274 |
rules => ['holds_per_record', 'holds_per_day', 'opacitemholds'], |
2254 |
order_by => { |
2275 |
order_by => { |
2255 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
2276 |
-desc => [ 'categorycode', 'itemtype', 'branchcode' ] |
2256 |
} |
2277 |
} |
Lines 2258-2263
sub GetHoldRule {
Link Here
|
2258 |
); |
2279 |
); |
2259 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
2280 |
$rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; |
2260 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
2281 |
$rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; |
|
|
2282 |
$rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds}; |
2261 |
|
2283 |
|
2262 |
return $rules; |
2284 |
return $rules; |
2263 |
} |
2285 |
} |
2264 |
- |
|
|