|
Lines 3-8
package C4::Reserves;
Link Here
|
| 3 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
| 4 |
# 2006 SAN Ouest Provence |
4 |
# 2006 SAN Ouest Provence |
| 5 |
# 2007-2010 BibLibre Paul POULAIN |
5 |
# 2007-2010 BibLibre Paul POULAIN |
|
|
6 |
# 2011 Catalyst IT |
| 6 |
# |
7 |
# |
| 7 |
# This file is part of Koha. |
8 |
# This file is part of Koha. |
| 8 |
# |
9 |
# |
|
Lines 471-477
sub CanItemBeReserved{
Link Here
|
| 471 |
if(my $rowcount = $sthcount->fetchrow_hashref()){ |
472 |
if(my $rowcount = $sthcount->fetchrow_hashref()){ |
| 472 |
$reservecount = $rowcount->{count}; |
473 |
$reservecount = $rowcount->{count}; |
| 473 |
} |
474 |
} |
| 474 |
|
|
|
| 475 |
# we check if it's ok or not |
475 |
# we check if it's ok or not |
| 476 |
if( $reservecount < $allowedreserves ){ |
476 |
if( $reservecount < $allowedreserves ){ |
| 477 |
return 1; |
477 |
return 1; |
|
Lines 1299-1305
sub GetReserveInfo {
Link Here
|
| 1299 |
|
1299 |
|
| 1300 |
=head2 IsAvailableForItemLevelRequest |
1300 |
=head2 IsAvailableForItemLevelRequest |
| 1301 |
|
1301 |
|
| 1302 |
my $is_available = IsAvailableForItemLevelRequest($itemnumber); |
1302 |
my $is_available = IsAvailableForItemLevelRequest($itemnumber,$borrowernumber,$branchcode); |
| 1303 |
|
1303 |
|
| 1304 |
Checks whether a given item record is available for an |
1304 |
Checks whether a given item record is available for an |
| 1305 |
item-level hold request. An item is available if |
1305 |
item-level hold request. An item is available if |
|
Lines 1309-1320
item-level hold request. An item is available if
Link Here
|
| 1309 |
* it is not withdrawn AND |
1309 |
* it is not withdrawn AND |
| 1310 |
* does not have a not for loan value > 0 |
1310 |
* does not have a not for loan value > 0 |
| 1311 |
|
1311 |
|
| 1312 |
Whether or not the item is currently on loan is |
1312 |
Need to check the issuingrules onshelfholds column, |
| 1313 |
also checked - if the AllowOnShelfHolds system preference |
1313 |
if this is set items on the shelf can be placed on hold |
| 1314 |
is ON, an item can be requested even if it is currently |
|
|
| 1315 |
on loan to somebody else. If the system preference |
| 1316 |
is OFF, an item that is currently checked out cannot |
| 1317 |
be the target of an item-level hold request. |
| 1318 |
|
1314 |
|
| 1319 |
Note that IsAvailableForItemLevelRequest() does not |
1315 |
Note that IsAvailableForItemLevelRequest() does not |
| 1320 |
check if the staff operator is authorized to place |
1316 |
check if the staff operator is authorized to place |
|
Lines 1326-1334
and canreservefromotherbranches.
Link Here
|
| 1326 |
|
1322 |
|
| 1327 |
sub IsAvailableForItemLevelRequest { |
1323 |
sub IsAvailableForItemLevelRequest { |
| 1328 |
my $itemnumber = shift; |
1324 |
my $itemnumber = shift; |
| 1329 |
|
1325 |
my $borrowernumber = shift; |
|
|
1326 |
my $branchcode = shift; |
| 1330 |
my $item = GetItem($itemnumber); |
1327 |
my $item = GetItem($itemnumber); |
| 1331 |
|
|
|
| 1332 |
# must check the notforloan setting of the itemtype |
1328 |
# must check the notforloan setting of the itemtype |
| 1333 |
# FIXME - a lot of places in the code do this |
1329 |
# FIXME - a lot of places in the code do this |
| 1334 |
# or something similar - need to be |
1330 |
# or something similar - need to be |
|
Lines 1361-1374
sub IsAvailableForItemLevelRequest {
Link Here
|
| 1361 |
$item->{wthdrawn} or |
1357 |
$item->{wthdrawn} or |
| 1362 |
$notforloan_per_itemtype; |
1358 |
$notforloan_per_itemtype; |
| 1363 |
|
1359 |
|
| 1364 |
|
1360 |
# check issuingrules |
| 1365 |
if (C4::Context->preference('AllowOnShelfHolds')) { |
1361 |
|
|
|
1362 |
if (OnShelfHoldsAllowed($itemnumber,$borrowernumber,$branchcode)) { |
| 1366 |
return $available_per_item; |
1363 |
return $available_per_item; |
| 1367 |
} else { |
1364 |
} else { |
| 1368 |
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "W")); |
1365 |
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "W")); |
| 1369 |
} |
1366 |
} |
| 1370 |
} |
1367 |
} |
| 1371 |
|
1368 |
|
|
|
1369 |
=head2 OnShelfHoldsAllowed |
| 1370 |
|
| 1371 |
OnShelfHoldsAllowed($itemnumber,$borrowernumber,$branchcode); |
| 1372 |
|
| 1373 |
Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see if onshelf |
| 1374 |
holds are allowed, returns true if so. |
| 1375 |
|
| 1376 |
=cut |
| 1377 |
|
| 1378 |
sub OnShelfHoldsAllowed { |
| 1379 |
my ($itemnumber,$borrowernumber,$branchcode) = @_; |
| 1380 |
my $item = GetItem($itemnumber); |
| 1381 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
| 1382 |
my $itype; |
| 1383 |
my $dbh = C4::Context->dbh; |
| 1384 |
if (C4::Context->preference('item-level_itypes')) { |
| 1385 |
# We cant trust GetItem to honour the syspref, so safest to do it ourselves |
| 1386 |
# When GetItem is fixed, we can remove this |
| 1387 |
$itype = $item->{itype}; |
| 1388 |
} |
| 1389 |
else { |
| 1390 |
my $query = "SELECT itemtype FROM biblioitems WHERE biblioitemnumber = ? "; |
| 1391 |
my $sth = $dbh->prepare($query); |
| 1392 |
$sth->execute($item->{biblioitemnumber}); |
| 1393 |
if (my $data = $sth->fetchrow_hashref()){ |
| 1394 |
$itype = $data->{itemtype}; |
| 1395 |
} |
| 1396 |
} |
| 1397 |
|
| 1398 |
my $query = "SELECT onshelfholds,categorycode,itemtype,branchcode FROM issuingrules WHERE |
| 1399 |
(issuingrules.categorycode = ? OR issuingrules.categorycode = '*') |
| 1400 |
AND |
| 1401 |
(issuingrules.itemtype = ? OR issuingrules.itemtype = '*') |
| 1402 |
AND |
| 1403 |
(issuingrules.branchcode = ? OR issuingrules.branchcode = '*') |
| 1404 |
ORDER BY |
| 1405 |
issuingrules.categorycode desc, |
| 1406 |
issuingrules.itemtype desc, |
| 1407 |
issuingrules.branchcode desc |
| 1408 |
LIMIT 1"; |
| 1409 |
my $dbh = C4::Context->dbh; |
| 1410 |
my $sth = $dbh->prepare($query); |
| 1411 |
$sth->execute($borrower->{categorycode},$itype,$branchcode); |
| 1412 |
my $data = $sth->fetchrow_hashref; |
| 1413 |
if ($data->{onshelfholds}){ |
| 1414 |
return 1; |
| 1415 |
} |
| 1416 |
else { |
| 1417 |
return 0; |
| 1418 |
} |
| 1419 |
} |
| 1420 |
|
| 1372 |
=head2 AlterPriority |
1421 |
=head2 AlterPriority |
| 1373 |
|
1422 |
|
| 1374 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |
1423 |
AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate ); |