|
Lines 418-424
sub GetReservesFromBorrowernumber {
Link Here
|
| 418 |
|
418 |
|
| 419 |
=head2 CanBookBeReserved |
419 |
=head2 CanBookBeReserved |
| 420 |
|
420 |
|
| 421 |
$canReserve = &CanBookBeReserved($borrowernumber, $biblionumber) |
421 |
$canReserve = &CanBookBeReserved($borrowernumber, $biblionumber, $branchcode) |
| 422 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
422 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
| 423 |
|
423 |
|
| 424 |
See CanItemBeReserved() for possible return values. |
424 |
See CanItemBeReserved() for possible return values. |
|
Lines 426-432
See CanItemBeReserved() for possible return values.
Link Here
|
| 426 |
=cut |
426 |
=cut |
| 427 |
|
427 |
|
| 428 |
sub CanBookBeReserved{ |
428 |
sub CanBookBeReserved{ |
| 429 |
my ($borrowernumber, $biblionumber) = @_; |
429 |
my ($borrowernumber, $biblionumber, $branchcode) = @_; |
| 430 |
|
430 |
|
| 431 |
my $items = GetItemnumbersForBiblio($biblionumber); |
431 |
my $items = GetItemnumbersForBiblio($biblionumber); |
| 432 |
#get items linked via host records |
432 |
#get items linked via host records |
|
Lines 437-443
sub CanBookBeReserved{
Link Here
|
| 437 |
|
437 |
|
| 438 |
my $canReserve; |
438 |
my $canReserve; |
| 439 |
foreach my $item (@$items) { |
439 |
foreach my $item (@$items) { |
| 440 |
$canReserve = CanItemBeReserved( $borrowernumber, $item ); |
440 |
$canReserve = CanItemBeReserved( $borrowernumber, $item, $branchcode ); |
| 441 |
return 'OK' if $canReserve eq 'OK'; |
441 |
return 'OK' if $canReserve eq 'OK'; |
| 442 |
} |
442 |
} |
| 443 |
return $canReserve; |
443 |
return $canReserve; |
|
Lines 445-451
sub CanBookBeReserved{
Link Here
|
| 445 |
|
445 |
|
| 446 |
=head2 CanItemBeReserved |
446 |
=head2 CanItemBeReserved |
| 447 |
|
447 |
|
| 448 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber) |
448 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode) |
| 449 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
449 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
| 450 |
|
450 |
|
| 451 |
@RETURNS OK, if the Item can be reserved. |
451 |
@RETURNS OK, if the Item can be reserved. |
|
Lines 454-464
sub CanBookBeReserved{
Link Here
|
| 454 |
cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. |
454 |
cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. |
| 455 |
tooManyReserves, if the borrower has exceeded his maximum reserve amount. |
455 |
tooManyReserves, if the borrower has exceeded his maximum reserve amount. |
| 456 |
notReservable, if holds on this item are not allowed |
456 |
notReservable, if holds on this item are not allowed |
|
|
457 |
libraryNotFound if given branchcode is not an existing library |
| 458 |
libraryNotPickupLocation if given branchcode is not configured to be a pickup location |
| 459 |
cannotBeTransferred if branch transfer limit applies on given item and branchcode |
| 457 |
|
460 |
|
| 458 |
=cut |
461 |
=cut |
| 459 |
|
462 |
|
| 460 |
sub CanItemBeReserved { |
463 |
sub CanItemBeReserved { |
| 461 |
my ( $borrowernumber, $itemnumber ) = @_; |
464 |
my ( $borrowernumber, $itemnumber, $branchcode_to ) = @_; |
| 462 |
|
465 |
|
| 463 |
my $dbh = C4::Context->dbh; |
466 |
my $dbh = C4::Context->dbh; |
| 464 |
my $ruleitemtype; # itemtype of the matching issuing rule |
467 |
my $ruleitemtype; # itemtype of the matching issuing rule |
|
Lines 587-592
sub CanItemBeReserved {
Link Here
|
| 587 |
} |
590 |
} |
| 588 |
} |
591 |
} |
| 589 |
|
592 |
|
|
|
593 |
if ($branchcode_to) { |
| 594 |
my $destination = Koha::Libraries->find({ |
| 595 |
branchcode => $branchcode_to, |
| 596 |
}); |
| 597 |
unless ($destination) { |
| 598 |
return 'libraryNotFound'; |
| 599 |
} |
| 600 |
unless ($destination->pickup_location) { |
| 601 |
return 'libraryNotPickupLocation'; |
| 602 |
} |
| 603 |
unless ($item->can_be_transferred({ to => $destination->branchcode })) { |
| 604 |
return 'cannotBeTransferred'; |
| 605 |
} |
| 606 |
} |
| 607 |
|
| 590 |
return 'OK'; |
608 |
return 'OK'; |
| 591 |
} |
609 |
} |
| 592 |
|
610 |
|