|
Lines 25-30
use warnings;
Link Here
|
| 25 |
use C4::Context; |
25 |
use C4::Context; |
| 26 |
use C4::Search; |
26 |
use C4::Search; |
| 27 |
use C4::Circulation qw( GetTransfers GetBranchItemRule ); |
27 |
use C4::Circulation qw( GetTransfers GetBranchItemRule ); |
|
|
28 |
use C4::Reserves qw( CanItemBeReserved ); |
| 28 |
use Koha::DateUtils qw( dt_from_string ); |
29 |
use Koha::DateUtils qw( dt_from_string ); |
| 29 |
use Koha::Items; |
30 |
use Koha::Items; |
| 30 |
use Koha::Patrons; |
31 |
use Koha::Patrons; |
|
Lines 409-414
sub _checkHoldPolicy {
Link Here
|
| 409 |
|
410 |
|
| 410 |
} |
411 |
} |
| 411 |
|
412 |
|
|
|
413 |
=head2 _checkCirculationRules |
| 414 |
|
| 415 |
_checkCirculationRules($item, $request); |
| 416 |
|
| 417 |
Check if the patron is eligible to reserve this item. |
| 418 |
|
| 419 |
=cut |
| 420 |
|
| 421 |
sub _checkCirculationRules { |
| 422 |
|
| 423 |
my ( $item, $request ) = @_; |
| 424 |
|
| 425 |
return 0 |
| 426 |
if (CanItemBeReserved( $request->{borrowernumber}, $item->{itemnumber}, $request->{branchcode}, { ignore_hold_counts => 1 } )->{status} ne 'OK'); |
| 427 |
|
| 428 |
return 1; |
| 429 |
|
| 430 |
} |
| 431 |
|
| 412 |
=head2 MapItemsToHoldRequests |
432 |
=head2 MapItemsToHoldRequests |
| 413 |
|
433 |
|
| 414 |
MapItemsToHoldRequests($hold_requests, $available_items, $branches, $transport_cost_matrix) |
434 |
MapItemsToHoldRequests($hold_requests, $available_items, $branches, $transport_cost_matrix) |
|
Lines 461-466
sub MapItemsToHoldRequests {
Link Here
|
| 461 |
|
481 |
|
| 462 |
next unless _checkHoldPolicy($item, $request); |
482 |
next unless _checkHoldPolicy($item, $request); |
| 463 |
|
483 |
|
|
|
484 |
# Check the patron is eligible to reserve this item type |
| 485 |
next unless _checkCirculationRules($item, $request); |
| 486 |
|
| 464 |
next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; |
487 |
next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; |
| 465 |
|
488 |
|
| 466 |
next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
489 |
next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
|
Lines 515-520
sub MapItemsToHoldRequests {
Link Here
|
| 515 |
exists $items_by_itemnumber{ $request->{itemnumber} } |
538 |
exists $items_by_itemnumber{ $request->{itemnumber} } |
| 516 |
and not exists $allocated_items{ $request->{itemnumber} } |
539 |
and not exists $allocated_items{ $request->{itemnumber} } |
| 517 |
and _checkHoldPolicy($items_by_itemnumber{ $request->{itemnumber} }, $request) # Don't fill item level holds that contravene the hold pickup policy at this time |
540 |
and _checkHoldPolicy($items_by_itemnumber{ $request->{itemnumber} }, $request) # Don't fill item level holds that contravene the hold pickup policy at this time |
|
|
541 |
and _checkCirculationRules($items_by_itemnumber{ $request->{itemnumber} }, $request) # Don't fill item level hold if the patron is not eligible to reserve this item |
| 518 |
and ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match |
542 |
and ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match |
| 519 |
|| $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) |
543 |
|| $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) |
| 520 |
|
544 |
|
|
Lines 572-577
sub MapItemsToHoldRequests {
Link Here
|
| 572 |
if ( |
596 |
if ( |
| 573 |
$request->{borrowerbranch} eq $item->{homebranch} |
597 |
$request->{borrowerbranch} eq $item->{homebranch} |
| 574 |
&& _checkHoldPolicy($item, $request) # Don't fill item level holds that contravene the hold pickup policy at this time |
598 |
&& _checkHoldPolicy($item, $request) # Don't fill item level holds that contravene the hold pickup policy at this time |
|
|
599 |
&& _checkCirculationRules($item, $request) # Don't fill item level hold if the patron is not eligible to reserve this item |
| 575 |
&& ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match |
600 |
&& ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match |
| 576 |
|| ( $request->{itemnumber} && ( $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) ) ) |
601 |
|| ( $request->{itemnumber} && ( $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) ) ) |
| 577 |
) |
602 |
) |
|
Lines 595-600
sub MapItemsToHoldRequests {
Link Here
|
| 595 |
# Don't fill item level holds that contravene the hold pickup policy at this time |
620 |
# Don't fill item level holds that contravene the hold pickup policy at this time |
| 596 |
next unless _checkHoldPolicy($item, $request); |
621 |
next unless _checkHoldPolicy($item, $request); |
| 597 |
|
622 |
|
|
|
623 |
# Don't fill item level hold if the patron is not eligible to reserve this item |
| 624 |
next unless _checkCirculationRules($item, $request); |
| 625 |
|
| 598 |
# If hold itemtype is set, item's itemtype must match |
626 |
# If hold itemtype is set, item's itemtype must match |
| 599 |
next unless ( !$request->{itemtype} |
627 |
next unless ( !$request->{itemtype} |
| 600 |
|| $item->{itype} eq $request->{itemtype} ); |
628 |
|| $item->{itype} eq $request->{itemtype} ); |
|
Lines 636-641
sub MapItemsToHoldRequests {
Link Here
|
| 636 |
next unless ( !$request->{itemtype} |
664 |
next unless ( !$request->{itemtype} |
| 637 |
|| $item->{itype} eq $request->{itemtype} ); |
665 |
|| $item->{itype} eq $request->{itemtype} ); |
| 638 |
|
666 |
|
|
|
667 |
# Check if the patron is eligible to reserve this item type |
| 668 |
next unless _checkCirculationRules($item, $request); |
| 669 |
|
| 639 |
$itemnumber = $item->{itemnumber}; |
670 |
$itemnumber = $item->{itemnumber}; |
| 640 |
$holdingbranch = $branch; |
671 |
$holdingbranch = $branch; |
| 641 |
last PULL_BRANCHES; |
672 |
last PULL_BRANCHES; |
|
Lines 653-658
sub MapItemsToHoldRequests {
Link Here
|
| 653 |
|
684 |
|
| 654 |
next unless $items_by_itemnumber{ $current_item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
685 |
next unless $items_by_itemnumber{ $current_item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
| 655 |
|
686 |
|
|
|
687 |
# Check if the patron is eligible to reserve this item |
| 688 |
next unless _checkCirculationRules($current_item, $request); |
| 689 |
|
| 656 |
$itemnumber = $current_item->{itemnumber}; |
690 |
$itemnumber = $current_item->{itemnumber}; |
| 657 |
last; # quit this loop as soon as we have a suitable item |
691 |
last; # quit this loop as soon as we have a suitable item |
| 658 |
} |
692 |
} |
|
Lines 675-680
sub MapItemsToHoldRequests {
Link Here
|
| 675 |
|
709 |
|
| 676 |
next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
710 |
next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); |
| 677 |
|
711 |
|
|
|
712 |
# Check if the patron is eligible to reserve this item |
| 713 |
next unless _checkCirculationRules($item, $request); |
| 714 |
|
| 678 |
$itemnumber = $item->{itemnumber}; |
715 |
$itemnumber = $item->{itemnumber}; |
| 679 |
$holdingbranch = $branch; |
716 |
$holdingbranch = $branch; |
| 680 |
last PULL_BRANCHES2; |
717 |
last PULL_BRANCHES2; |
| 681 |
- |
|
|