Lines 265-271
sub AddReserve {
Link Here
|
265 |
|
265 |
|
266 |
=head2 CanBookBeReserved |
266 |
=head2 CanBookBeReserved |
267 |
|
267 |
|
268 |
$canReserve = &CanBookBeReserved($borrowernumber, $biblionumber) |
268 |
$canReserve = &CanBookBeReserved($borrowernumber, $biblionumber, $branchcode) |
269 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
269 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
270 |
|
270 |
|
271 |
See CanItemBeReserved() for possible return values. |
271 |
See CanItemBeReserved() for possible return values. |
Lines 273-279
See CanItemBeReserved() for possible return values.
Link Here
|
273 |
=cut |
273 |
=cut |
274 |
|
274 |
|
275 |
sub CanBookBeReserved{ |
275 |
sub CanBookBeReserved{ |
276 |
my ($borrowernumber, $biblionumber) = @_; |
276 |
my ($borrowernumber, $biblionumber, $branchcode) = @_; |
277 |
|
277 |
|
278 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
278 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
279 |
#get items linked via host records |
279 |
#get items linked via host records |
Lines 284-290
sub CanBookBeReserved{
Link Here
|
284 |
|
284 |
|
285 |
my $canReserve; |
285 |
my $canReserve; |
286 |
foreach my $itemnumber (@itemnumbers) { |
286 |
foreach my $itemnumber (@itemnumbers) { |
287 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber ); |
287 |
$canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $branchcode ); |
288 |
return $canReserve if $canReserve->{status} eq 'OK'; |
288 |
return $canReserve if $canReserve->{status} eq 'OK'; |
289 |
} |
289 |
} |
290 |
return $canReserve; |
290 |
return $canReserve; |
Lines 292-298
sub CanBookBeReserved{
Link Here
|
292 |
|
292 |
|
293 |
=head2 CanItemBeReserved |
293 |
=head2 CanItemBeReserved |
294 |
|
294 |
|
295 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber) |
295 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode) |
296 |
if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } |
296 |
if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } |
297 |
|
297 |
|
298 |
@RETURNS { status => OK }, if the Item can be reserved. |
298 |
@RETURNS { status => OK }, if the Item can be reserved. |
Lines 301-311
sub CanBookBeReserved{
Link Here
|
301 |
{ status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. |
301 |
{ status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. |
302 |
{ status => tooManyReserves, limit => $limit }, if the borrower has exceeded their maximum reserve amount. |
302 |
{ status => tooManyReserves, limit => $limit }, if the borrower has exceeded their maximum reserve amount. |
303 |
{ status => notReservable }, if holds on this item are not allowed |
303 |
{ status => notReservable }, if holds on this item are not allowed |
|
|
304 |
{ status => libraryNotFound }, if given branchcode is not an existing library |
305 |
{ status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location |
304 |
|
306 |
|
305 |
=cut |
307 |
=cut |
306 |
|
308 |
|
307 |
sub CanItemBeReserved { |
309 |
sub CanItemBeReserved { |
308 |
my ( $borrowernumber, $itemnumber ) = @_; |
310 |
my ( $borrowernumber, $itemnumber, $branchcode_to ) = @_; |
309 |
|
311 |
|
310 |
my $dbh = C4::Context->dbh; |
312 |
my $dbh = C4::Context->dbh; |
311 |
my $ruleitemtype; # itemtype of the matching issuing rule |
313 |
my $ruleitemtype; # itemtype of the matching issuing rule |
Lines 458-463
sub CanItemBeReserved {
Link Here
|
458 |
} |
460 |
} |
459 |
} |
461 |
} |
460 |
|
462 |
|
|
|
463 |
if ($branchcode_to) { |
464 |
my $destination = Koha::Libraries->find({ |
465 |
branchcode => $branchcode_to, |
466 |
}); |
467 |
unless ($destination) { |
468 |
return { status => 'libraryNotFound' }; |
469 |
} |
470 |
unless ($destination->pickup_location) { |
471 |
return { status => 'libraryNotPickupLocation' }; |
472 |
} |
473 |
} |
474 |
|
461 |
return { status => 'OK' }; |
475 |
return { status => 'OK' }; |
462 |
} |
476 |
} |
463 |
|
477 |
|