|
Lines 915-921
sub CheckReserves {
Link Here
|
| 915 |
itemtypes.notforloan, |
915 |
itemtypes.notforloan, |
| 916 |
items.notforloan AS itemnotforloan, |
916 |
items.notforloan AS itemnotforloan, |
| 917 |
items.itemnumber, |
917 |
items.itemnumber, |
| 918 |
items.damaged |
918 |
items.damaged, |
|
|
919 |
items.homebranch, |
| 920 |
items.holdingbranch |
| 919 |
FROM items |
921 |
FROM items |
| 920 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
922 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
| 921 |
LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype |
923 |
LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype |
|
Lines 928-934
sub CheckReserves {
Link Here
|
| 928 |
itemtypes.notforloan, |
930 |
itemtypes.notforloan, |
| 929 |
items.notforloan AS itemnotforloan, |
931 |
items.notforloan AS itemnotforloan, |
| 930 |
items.itemnumber, |
932 |
items.itemnumber, |
| 931 |
items.damaged |
933 |
items.damaged, |
|
|
934 |
items.homebranch, |
| 935 |
items.holdingbranch |
| 932 |
FROM items |
936 |
FROM items |
| 933 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
937 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
| 934 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
938 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
|
Lines 944-957
sub CheckReserves {
Link Here
|
| 944 |
$sth->execute($barcode); |
948 |
$sth->execute($barcode); |
| 945 |
} |
949 |
} |
| 946 |
# note: we get the itemnumber because we might have started w/ just the barcode. Now we know for sure we have it. |
950 |
# note: we get the itemnumber because we might have started w/ just the barcode. Now we know for sure we have it. |
| 947 |
my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, $itemnumber, $damaged ) = $sth->fetchrow_array; |
951 |
my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, $itemnumber, $damaged, $item_homebranch, $item_holdingbranch ) = $sth->fetchrow_array; |
| 948 |
|
952 |
|
| 949 |
return if ( $damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') ); |
953 |
return if ( $damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') ); |
| 950 |
|
954 |
|
| 951 |
return unless $itemnumber; # bail if we got nothing. |
955 |
return unless $itemnumber; # bail if we got nothing. |
| 952 |
|
956 |
|
| 953 |
# if item is not for loan it cannot be reserved either..... |
957 |
# if item is not for loan it cannot be reserved either..... |
| 954 |
# execpt where items.notforloan < 0 : This indicates the item is holdable. |
958 |
# except where items.notforloan < 0 : This indicates the item is holdable. |
| 955 |
return if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
959 |
return if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
| 956 |
|
960 |
|
| 957 |
# Find this item in the reserves |
961 |
# Find this item in the reserves |
|
Lines 963-983
sub CheckReserves {
Link Here
|
| 963 |
# $highest is the most important item we've seen so far. |
967 |
# $highest is the most important item we've seen so far. |
| 964 |
my $highest; |
968 |
my $highest; |
| 965 |
if (scalar @reserves) { |
969 |
if (scalar @reserves) { |
|
|
970 |
my $LocalHoldsPriority = C4::Context->preference('LocalHoldsPriority'); |
| 971 |
my $LocalHoldsPriorityPatronControl = C4::Context->preference('LocalHoldsPriorityPatronControl'); |
| 972 |
my $LocalHoldsPriorityItemControl = C4::Context->preference('LocalHoldsPriorityItemControl'); |
| 973 |
|
| 966 |
my $priority = 10000000; |
974 |
my $priority = 10000000; |
| 967 |
foreach my $res (@reserves) { |
975 |
foreach my $res (@reserves) { |
| 968 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
976 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
| 969 |
return ( "Waiting", $res, \@reserves ); # Found it |
977 |
return ( "Waiting", $res, \@reserves ); # Found it |
| 970 |
} else { |
978 |
} else { |
|
|
979 |
# Lazy fetch for borrower and item. We only need to know about the patron and item |
| 980 |
# each and every time if we are using LocalHoldsPriority. This is a great place to |
| 981 |
# leverage the inherent lazy fetching of DBIx::Class. |
| 982 |
my $borrowerinfo; |
| 983 |
my $iteminfo; |
| 984 |
|
| 985 |
my $local_hold_match; |
| 986 |
if ($LocalHoldsPriority) { |
| 987 |
$borrowerinfo = C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} ); |
| 988 |
$iteminfo = C4::Items::GetItem($itemnumber); |
| 989 |
|
| 990 |
my $local_holds_priority_item_branchcode = |
| 991 |
$iteminfo->{$LocalHoldsPriorityItemControl}; |
| 992 |
my $local_holds_priority_patron_branchcode = |
| 993 |
( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) |
| 994 |
? $res->{branchcode} |
| 995 |
: ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' ) |
| 996 |
? $borrowerinfo->{branchcode} |
| 997 |
: undef; |
| 998 |
$local_hold_match = |
| 999 |
$local_holds_priority_item_branchcode eq |
| 1000 |
$local_holds_priority_patron_branchcode; |
| 1001 |
} |
| 1002 |
|
| 971 |
# See if this item is more important than what we've got so far |
1003 |
# See if this item is more important than what we've got so far |
| 972 |
if ( $res->{'priority'} && $res->{'priority'} < $priority ) { |
1004 |
if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) { |
| 973 |
my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'}); |
1005 |
$borrowerinfo ||= C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} ); |
| 974 |
my $iteminfo=C4::Items::GetItem($itemnumber); |
1006 |
$iteminfo ||= C4::Items::GetItem($itemnumber); |
| 975 |
my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo ); |
1007 |
my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo ); |
| 976 |
my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); |
1008 |
my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); |
| 977 |
next if ($branchitemrule->{'holdallowed'} == 0); |
1009 |
next if ($branchitemrule->{'holdallowed'} == 0); |
| 978 |
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'})); |
1010 |
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'})); |
| 979 |
$priority = $res->{'priority'}; |
1011 |
$priority = $res->{'priority'}; |
| 980 |
$highest = $res; |
1012 |
$highest = $res; |
|
|
1013 |
last if $local_hold_match; |
| 981 |
} |
1014 |
} |
| 982 |
} |
1015 |
} |
| 983 |
} |
1016 |
} |