|
Lines 847-853
sub CheckReserves {
Link Here
|
| 847 |
items.biblioitemnumber, |
847 |
items.biblioitemnumber, |
| 848 |
itemtypes.notforloan, |
848 |
itemtypes.notforloan, |
| 849 |
items.notforloan AS itemnotforloan, |
849 |
items.notforloan AS itemnotforloan, |
| 850 |
items.itemnumber |
850 |
items.itemnumber, |
|
|
851 |
items.homebranch, |
| 852 |
items.holdingbranch |
| 851 |
FROM items |
853 |
FROM items |
| 852 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
854 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
| 853 |
LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype |
855 |
LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype |
|
Lines 859-865
sub CheckReserves {
Link Here
|
| 859 |
items.biblioitemnumber, |
861 |
items.biblioitemnumber, |
| 860 |
itemtypes.notforloan, |
862 |
itemtypes.notforloan, |
| 861 |
items.notforloan AS itemnotforloan, |
863 |
items.notforloan AS itemnotforloan, |
| 862 |
items.itemnumber |
864 |
items.itemnumber, |
|
|
865 |
items.homebranch, |
| 866 |
items.holdingbranch |
| 863 |
FROM items |
867 |
FROM items |
| 864 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
868 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
| 865 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
869 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
|
Lines 875-886
sub CheckReserves {
Link Here
|
| 875 |
$sth->execute($barcode); |
879 |
$sth->execute($barcode); |
| 876 |
} |
880 |
} |
| 877 |
# note: we get the itemnumber because we might have started w/ just the barcode. Now we know for sure we have it. |
881 |
# note: we get the itemnumber because we might have started w/ just the barcode. Now we know for sure we have it. |
| 878 |
my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, $itemnumber ) = $sth->fetchrow_array; |
882 |
my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, |
|
|
883 |
$itemnumber, $item_homebranch, $item_holdingbranch ) |
| 884 |
= $sth->fetchrow_array; |
| 879 |
|
885 |
|
| 880 |
return ( '' ) unless $itemnumber; # bail if we got nothing. |
886 |
return ( '' ) unless $itemnumber; # bail if we got nothing. |
| 881 |
|
887 |
|
| 882 |
# if item is not for loan it cannot be reserved either..... |
888 |
# if item is not for loan it cannot be reserved either..... |
| 883 |
# execpt where items.notforloan < 0 : This indicates the item is holdable. |
889 |
# except where items.notforloan < 0 : This indicates the item is holdable. |
| 884 |
return ( '' ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
890 |
return ( '' ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
| 885 |
|
891 |
|
| 886 |
# Find this item in the reserves |
892 |
# Find this item in the reserves |
|
Lines 892-912
sub CheckReserves {
Link Here
|
| 892 |
# $highest is the most important item we've seen so far. |
898 |
# $highest is the most important item we've seen so far. |
| 893 |
my $highest; |
899 |
my $highest; |
| 894 |
if (scalar @reserves) { |
900 |
if (scalar @reserves) { |
|
|
901 |
my $LocalHoldsPriority = C4::Context->preference('LocalHoldsPriority'); |
| 902 |
my $LocalHoldsPriorityPatronControl = C4::Context->preference('LocalHoldsPriorityPatronControl'); |
| 903 |
my $LocalHoldsPriorityItemControl = C4::Context->preference('LocalHoldsPriorityItemControl'); |
| 904 |
|
| 895 |
my $priority = 10000000; |
905 |
my $priority = 10000000; |
| 896 |
foreach my $res (@reserves) { |
906 |
foreach my $res (@reserves) { |
| 897 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
907 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
| 898 |
return ( "Waiting", $res, \@reserves ); # Found it |
908 |
return ( "Waiting", $res, \@reserves ); # Found it |
| 899 |
} else { |
909 |
} else { |
|
|
910 |
# Lazy fetch for borrower and item. We only need to know about the patron and item |
| 911 |
# each and every time if we are using LocalHoldsPriority. This is a great place to |
| 912 |
# leverage the inherent lazy fetching of DBIx::Class. |
| 913 |
my $borrowerinfo; |
| 914 |
my $iteminfo; |
| 915 |
|
| 916 |
my $local_hold_match; |
| 917 |
if ($LocalHoldsPriority) { |
| 918 |
$borrowerinfo = C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} ); |
| 919 |
$iteminfo = C4::Items::GetItem($itemnumber); |
| 920 |
|
| 921 |
my $local_holds_priority_item_branchcode = |
| 922 |
$iteminfo->{$LocalHoldsPriorityItemControl}; |
| 923 |
my $local_holds_priority_patron_branchcode = |
| 924 |
( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) |
| 925 |
? $res->{branchcode} |
| 926 |
: ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' ) |
| 927 |
? $borrowerinfo->{branchcode} |
| 928 |
: undef; |
| 929 |
$local_hold_match = |
| 930 |
$local_holds_priority_item_branchcode eq |
| 931 |
$local_holds_priority_patron_branchcode; |
| 932 |
} |
| 933 |
|
| 900 |
# See if this item is more important than what we've got so far |
934 |
# See if this item is more important than what we've got so far |
| 901 |
if ( $res->{'priority'} && $res->{'priority'} < $priority ) { |
935 |
if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) { |
| 902 |
my $borrowerinfo=C4::Members::GetMember(borrowernumber => $res->{'borrowernumber'}); |
936 |
$borrowerinfo ||= C4::Members::GetMember( borrowernumber => $res->{'borrowernumber'} ); |
| 903 |
my $iteminfo=C4::Items::GetItem($itemnumber); |
937 |
$iteminfo ||= C4::Items::GetItem($itemnumber); |
| 904 |
my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo ); |
938 |
my $branch = GetReservesControlBranch( $iteminfo, $borrowerinfo ); |
| 905 |
my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); |
939 |
my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); |
| 906 |
next if ($branchitemrule->{'holdallowed'} == 0); |
940 |
next if ($branchitemrule->{'holdallowed'} == 0); |
| 907 |
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'})); |
941 |
next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $borrowerinfo->{'branchcode'})); |
| 908 |
$priority = $res->{'priority'}; |
942 |
$priority = $res->{'priority'}; |
| 909 |
$highest = $res; |
943 |
$highest = $res; |
|
|
944 |
last if $local_hold_match; |
| 910 |
} |
945 |
} |
| 911 |
} |
946 |
} |
| 912 |
} |
947 |
} |