|
Lines 479-485
sub CanItemBeReserved{
Link Here
|
| 479 |
if(my $rowcount = $sthcount->fetchrow_hashref()){ |
479 |
if(my $rowcount = $sthcount->fetchrow_hashref()){ |
| 480 |
$reservecount = $rowcount->{count}; |
480 |
$reservecount = $rowcount->{count}; |
| 481 |
} |
481 |
} |
| 482 |
|
|
|
| 483 |
# we check if it's ok or not |
482 |
# we check if it's ok or not |
| 484 |
if( $reservecount < $allowedreserves ){ |
483 |
if( $reservecount < $allowedreserves ){ |
| 485 |
return 1; |
484 |
return 1; |
|
Lines 1321-1327
sub GetReserveInfo {
Link Here
|
| 1321 |
|
1320 |
|
| 1322 |
=head2 IsAvailableForItemLevelRequest |
1321 |
=head2 IsAvailableForItemLevelRequest |
| 1323 |
|
1322 |
|
| 1324 |
my $is_available = IsAvailableForItemLevelRequest($itemnumber); |
1323 |
my $is_available = IsAvailableForItemLevelRequest($itemnumber,$borrowernumber,$branchcode); |
| 1325 |
|
1324 |
|
| 1326 |
Checks whether a given item record is available for an |
1325 |
Checks whether a given item record is available for an |
| 1327 |
item-level hold request. An item is available if |
1326 |
item-level hold request. An item is available if |
|
Lines 1331-1342
item-level hold request. An item is available if
Link Here
|
| 1331 |
* it is not withdrawn AND |
1330 |
* it is not withdrawn AND |
| 1332 |
* does not have a not for loan value > 0 |
1331 |
* does not have a not for loan value > 0 |
| 1333 |
|
1332 |
|
| 1334 |
Whether or not the item is currently on loan is |
1333 |
Need to check the issuingrules onshelfholds column, |
| 1335 |
also checked - if the AllowOnShelfHolds system preference |
1334 |
if this is set items on the shelf can be placed on hold |
| 1336 |
is ON, an item can be requested even if it is currently |
|
|
| 1337 |
on loan to somebody else. If the system preference |
| 1338 |
is OFF, an item that is currently checked out cannot |
| 1339 |
be the target of an item-level hold request. |
| 1340 |
|
1335 |
|
| 1341 |
Note that IsAvailableForItemLevelRequest() does not |
1336 |
Note that IsAvailableForItemLevelRequest() does not |
| 1342 |
check if the staff operator is authorized to place |
1337 |
check if the staff operator is authorized to place |
|
Lines 1348-1356
and canreservefromotherbranches.
Link Here
|
| 1348 |
|
1343 |
|
| 1349 |
sub IsAvailableForItemLevelRequest { |
1344 |
sub IsAvailableForItemLevelRequest { |
| 1350 |
my $itemnumber = shift; |
1345 |
my $itemnumber = shift; |
| 1351 |
|
1346 |
my $borrowernumber = shift; |
|
|
1347 |
my $branchcode = shift; |
| 1352 |
my $item = GetItem($itemnumber); |
1348 |
my $item = GetItem($itemnumber); |
| 1353 |
|
|
|
| 1354 |
# must check the notforloan setting of the itemtype |
1349 |
# must check the notforloan setting of the itemtype |
| 1355 |
# FIXME - a lot of places in the code do this |
1350 |
# FIXME - a lot of places in the code do this |
| 1356 |
# or something similar - need to be |
1351 |
# or something similar - need to be |
|
Lines 1383-1396
sub IsAvailableForItemLevelRequest {
Link Here
|
| 1383 |
$item->{wthdrawn} or |
1378 |
$item->{wthdrawn} or |
| 1384 |
$notforloan_per_itemtype; |
1379 |
$notforloan_per_itemtype; |
| 1385 |
|
1380 |
|
| 1386 |
|
1381 |
# check issuingrules |
| 1387 |
if (C4::Context->preference('AllowOnShelfHolds')) { |
1382 |
|
|
|
1383 |
if (OnShelfHoldsAllowed($itemnumber,$borrowernumber,$branchcode)) { |
| 1388 |
return $available_per_item; |
1384 |
return $available_per_item; |
| 1389 |
} else { |
1385 |
} else { |
| 1390 |
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "W")); |
1386 |
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "W")); |
| 1391 |
} |
1387 |
} |
| 1392 |
} |
1388 |
} |
| 1393 |
|
1389 |
|
|
|
1390 |
=head2 OnShelfHoldsAllowed |
| 1391 |
|
| 1392 |
OnShelfHoldsAllowed($itemnumber,$borrowernumber,$branchcode); |
| 1393 |
|
| 1394 |
Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see if onshelf |
| 1395 |
holds are allowed, returns true if so. |
| 1396 |
|
| 1397 |
=cut |
| 1398 |
|
| 1399 |
sub OnShelfHoldsAllowed { |
| 1400 |
my ($itemnumber,$borrowernumber,$branchcode) = @_; |
| 1401 |
my $item = GetItem($itemnumber); |
| 1402 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
| 1403 |
my $itype; |
| 1404 |
my $dbh = C4::Context->dbh; |
| 1405 |
if (C4::Context->preference('item-level_itypes')) { |
| 1406 |
# We cant trust GetItem to honour the syspref, so safest to do it ourselves |
| 1407 |
# When GetItem is fixed, we can remove this |
| 1408 |
$itype = $item->{itype}; |
| 1409 |
} |
| 1410 |
else { |
| 1411 |
my $query = "SELECT itemtype FROM biblioitems WHERE biblioitemnumber = ? "; |
| 1412 |
my $sth = $dbh->prepare($query); |
| 1413 |
$sth->execute($item->{biblioitemnumber}); |
| 1414 |
if (my $data = $sth->fetchrow_hashref()){ |
| 1415 |
$itype = $data->{itemtype}; |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
my $query = "SELECT onshelfholds,categorycode,itemtype,branchcode FROM issuingrules WHERE |
| 1420 |
(issuingrules.categorycode = ? OR issuingrules.categorycode = '*') |
| 1421 |
AND |
| 1422 |
(issuingrules.itemtype = ? OR issuingrules.itemtype = '*') |
| 1423 |
AND |
| 1424 |
(issuingrules.branchcode = ? OR issuingrules.branchcode = '*') |
| 1425 |
ORDER BY |
| 1426 |
issuingrules.categorycode desc, |
| 1427 |
issuingrules.itemtype desc, |
| 1428 |
issuingrules.branchcode desc |
| 1429 |
LIMIT 1"; |
| 1430 |
my $dbh = C4::Context->dbh; |
| 1431 |
my $sth = $dbh->prepare($query); |
| 1432 |
$sth->execute($borrower->{categorycode},$itype,$branchcode); |
| 1433 |
my $data = $sth->fetchrow_hashref; |
| 1434 |
if ($data->{onshelfholds}){ |
| 1435 |
return 1; |
| 1436 |
} |
| 1437 |
else { |
| 1438 |
return 0; |
| 1439 |
} |
| 1440 |
} |
| 1441 |
|
| 1394 |
=head2 AlterPriority |
1442 |
=head2 AlterPriority |
| 1395 |
|
1443 |
|
| 1396 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |
1444 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |