|
Lines 1188-1194
and canreservefromotherbranches.
Link Here
|
| 1188 |
=cut |
1188 |
=cut |
| 1189 |
|
1189 |
|
| 1190 |
sub IsAvailableForItemLevelRequest { |
1190 |
sub IsAvailableForItemLevelRequest { |
| 1191 |
my ( $item, $patron, $pickup_branchcode ) = @_; |
1191 |
my $item = shift; |
|
|
1192 |
my $patron = shift; |
| 1193 |
my $pickup_branchcode = shift; |
| 1194 |
my $caches = shift; |
| 1192 |
|
1195 |
|
| 1193 |
my $dbh = C4::Context->dbh; |
1196 |
my $dbh = C4::Context->dbh; |
| 1194 |
# must check the notforloan setting of the itemtype |
1197 |
# must check the notforloan setting of the itemtype |
|
Lines 1223-1241
sub IsAvailableForItemLevelRequest {
Link Here
|
| 1223 |
my $any_available = 0; |
1226 |
my $any_available = 0; |
| 1224 |
|
1227 |
|
| 1225 |
foreach my $i (@items) { |
1228 |
foreach my $i (@items) { |
| 1226 |
my $reserves_control_branch = GetReservesControlBranch( $i->unblessed(), $patron->unblessed ); |
1229 |
my $reserves_control_branch = |
| 1227 |
my $branchitemrule = C4::Circulation::GetBranchItemRule( $reserves_control_branch, $i->itype ); |
1230 |
GetReservesControlBranch( $i->unblessed(), $patron->unblessed ); |
|
|
1231 |
|
| 1232 |
my $onholdandfound; |
| 1233 |
my $itemtype_notforloan; |
| 1234 |
my $branchitemrule; |
| 1235 |
|
| 1236 |
# caching algorithm implemented and keys/values pairs stored in provided from upper-level sub |
| 1237 |
# reference to hash, but if no ref provided, it works in old-style (for compatibility): |
| 1238 |
if($caches) { |
| 1239 |
|
| 1240 |
# %$caches has three subkeys: |
| 1241 |
# {branchitemrule} values cached by two-levels: $reserves_control_branch + $i->itype |
| 1242 |
# {onholdandfound} values cached by $i->id |
| 1243 |
# {notforloan} values cached by $i->effective_itemtype() |
| 1244 |
|
| 1245 |
my $i_itype = $i->itype; |
| 1246 |
$branchitemrule = |
| 1247 |
exists $caches->{branchitemrule}{$reserves_control_branch}{$i_itype} |
| 1248 |
? $caches->{branchitemrule}{$reserves_control_branch}{$i_itype} |
| 1249 |
: ( |
| 1250 |
$caches->{branchitemrule}{$reserves_control_branch}{$i_itype} = |
| 1251 |
C4::Circulation::GetBranchItemRule( |
| 1252 |
$reserves_control_branch, $i_itype |
| 1253 |
) ); |
| 1254 |
|
| 1255 |
my $i_id = $i->id; |
| 1256 |
$onholdandfound = |
| 1257 |
exists $caches->{onholdandfound}{$i_id} |
| 1258 |
? $caches->{onholdandfound}{$i_id} |
| 1259 |
: ( $caches->{onholdandfound}{$i_id} = IsItemOnHoldAndFound($i_id) ); |
| 1260 |
|
| 1261 |
my $effective_itemtype = $i->effective_itemtype(); |
| 1262 |
$itemtype_notforloan = |
| 1263 |
$caches && exists $caches->{notforloan}{$effective_itemtype} |
| 1264 |
? $caches->{notforloan}{$effective_itemtype} |
| 1265 |
: ( $caches->{notforloan}{$effective_itemtype} = |
| 1266 |
Koha::ItemTypes->find($effective_itemtype)->notforloan ); |
| 1267 |
} |
| 1268 |
else { |
| 1269 |
$branchitemrule = |
| 1270 |
C4::Circulation::GetBranchItemRule( $reserves_control_branch, $i->itype ); |
| 1271 |
$onholdandfound = IsItemOnHoldAndFound( $i->id ); |
| 1272 |
$itemtype_notforloan = Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan; |
| 1273 |
} |
| 1228 |
|
1274 |
|
| 1229 |
$any_available = 1 |
1275 |
$any_available = 1 |
| 1230 |
unless $i->itemlost |
1276 |
unless $i->itemlost |
| 1231 |
|| $i->notforloan > 0 |
1277 |
|| $i->notforloan > 0 |
| 1232 |
|| $i->withdrawn |
1278 |
|| $i->withdrawn |
| 1233 |
|| $i->onloan |
1279 |
|| $i->onloan |
| 1234 |
|| IsItemOnHoldAndFound( $i->id ) |
1280 |
|| $onholdandfound |
| 1235 |
|| ( $i->damaged |
1281 |
|| ( $i->damaged |
| 1236 |
&& !C4::Context->preference('AllowHoldsOnDamagedItems') ) |
1282 |
&& ! C4::Context->preference('AllowHoldsOnDamagedItems') ) |
| 1237 |
|| Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan |
1283 |
|| $itemtype_notforloan |
| 1238 |
|| $branchitemrule->{holdallowed} == 1 && $patron->branchcode ne $i->homebranch; |
1284 |
|| $branchitemrule->{holdallowed} == 1 && $patron->branchcode ne $i->homebranch; |
| 1239 |
} |
1285 |
} |
| 1240 |
|
1286 |
|
| 1241 |
return $any_available ? 0 : 1; |
1287 |
return $any_available ? 0 : 1; |