|
Lines 448-454
sub GetReservesFromBorrowernumber {
Link Here
|
| 448 |
#------------------------------------------------------------------------------------- |
448 |
#------------------------------------------------------------------------------------- |
| 449 |
=head2 CanBookBeReserved |
449 |
=head2 CanBookBeReserved |
| 450 |
|
450 |
|
| 451 |
$error = &CanBookBeReserved($borrowernumber, $biblionumber) |
451 |
$canReserve = &CanBookBeReserved($borrowernumber, $biblionumber) |
|
|
452 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
| 453 |
|
| 454 |
See CanItemBeReserved() for possible return values. |
| 452 |
|
455 |
|
| 453 |
=cut |
456 |
=cut |
| 454 |
|
457 |
|
|
Lines 462-478
sub CanBookBeReserved{
Link Here
|
| 462 |
push (@$items,@hostitems); |
465 |
push (@$items,@hostitems); |
| 463 |
} |
466 |
} |
| 464 |
|
467 |
|
|
|
468 |
my $canReserve; |
| 465 |
foreach my $item (@$items){ |
469 |
foreach my $item (@$items){ |
| 466 |
return 1 if CanItemBeReserved($borrowernumber, $item); |
470 |
$canReserve = CanItemBeReserved($borrowernumber, $item); |
|
|
471 |
return 'OK' if $canReserve eq 'OK'; |
| 467 |
} |
472 |
} |
| 468 |
return 0; |
473 |
return $canReserve; |
| 469 |
} |
474 |
} |
| 470 |
|
475 |
|
| 471 |
=head2 CanItemBeReserved |
476 |
=head2 CanItemBeReserved |
| 472 |
|
477 |
|
| 473 |
$error = &CanItemBeReserved($borrowernumber, $itemnumber) |
478 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber) |
|
|
479 |
if ($canReserve eq 'OK') { #We can reserve this Item! } |
| 474 |
|
480 |
|
| 475 |
This function return 1 if an item can be issued by this borrower. |
481 |
@RETURNS OK, if the Item can be reserved. |
|
|
482 |
ageRestricted, if the Item is age restricted for this borrower. |
| 483 |
damaged, if the Item is damaged. |
| 484 |
cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. |
| 485 |
tooManyReserves, if the borrower has exceeded his maximum reserve amount. |
| 476 |
|
486 |
|
| 477 |
=cut |
487 |
=cut |
| 478 |
|
488 |
|
|
Lines 490-500
sub CanItemBeReserved{
Link Here
|
| 490 |
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); |
500 |
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); |
| 491 |
|
501 |
|
| 492 |
# If an item is damaged and we don't allow holds on damaged items, we can stop right here |
502 |
# If an item is damaged and we don't allow holds on damaged items, we can stop right here |
| 493 |
return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); |
503 |
return 'damaged' if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') ); |
| 494 |
|
504 |
|
| 495 |
#Check for the age restriction |
505 |
#Check for the age restriction |
| 496 |
my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); |
506 |
my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); |
| 497 |
return 0 if $daysToAgeRestriction && $daysToAgeRestriction > 0; |
507 |
return 'ageRestricted' if $daysToAgeRestriction && $daysToAgeRestriction > 0; |
| 498 |
|
508 |
|
| 499 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
509 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
| 500 |
my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; |
510 |
my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; |
|
Lines 561-567
sub CanItemBeReserved{
Link Here
|
| 561 |
|
571 |
|
| 562 |
# we check if it's ok or not |
572 |
# we check if it's ok or not |
| 563 |
if( $reservecount >= $allowedreserves ){ |
573 |
if( $reservecount >= $allowedreserves ){ |
| 564 |
return 0; |
574 |
return 'tooManyReserves'; |
| 565 |
} |
575 |
} |
| 566 |
|
576 |
|
| 567 |
# If reservecount is ok, we check item branch if IndependentBranches is ON |
577 |
# If reservecount is ok, we check item branch if IndependentBranches is ON |
|
Lines 571-581
sub CanItemBeReserved{
Link Here
|
| 571 |
{ |
581 |
{ |
| 572 |
my $itembranch = $item->{homebranch}; |
582 |
my $itembranch = $item->{homebranch}; |
| 573 |
if ($itembranch ne $borrower->{branchcode}) { |
583 |
if ($itembranch ne $borrower->{branchcode}) { |
| 574 |
return 0; |
584 |
return 'cannotReserveFromOtherBranches'; |
| 575 |
} |
585 |
} |
| 576 |
} |
586 |
} |
| 577 |
|
587 |
|
| 578 |
return 1; |
588 |
return 'OK'; |
| 579 |
} |
589 |
} |
| 580 |
|
590 |
|
| 581 |
=head2 CanReserveBeCanceledFromOpac |
591 |
=head2 CanReserveBeCanceledFromOpac |