OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"),
OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"),
OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"),
- OPACItemHolds => C4::Context->preference("OPACItemHolds"),
OPACShelfBrowser => "" . C4::Context->preference("OPACShelfBrowser"),
OPACURLOpenInNewWindow => "" . C4::Context->preference("OPACURLOpenInNewWindow"),
OPACUserCSS => "" . C4::Context->preference("OPACUserCSS"),
sub GetIssuingRule {
my ( $borrowertype, $itemtype, $branchcode ) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare( "select * from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" );
+ my $sth = $dbh->prepare( "select * from issuingrules where categorycode=? and itemtype=? and branchcode=?" );
my $irule;
- $sth->execute( $borrowertype, $itemtype, $branchcode );
+ $sth->execute( $borrowertype, $itemtype, $branchcode );
$irule = $sth->fetchrow_hashref;
return $irule if defined($irule) ;
# by pushing all the elements onto an array and removing the duplicates.
my @reservable;
foreach my $b (@borrowernumbers) {
+ my ( $borr ) = C4::Members::GetMemberDetails( $b );
foreach my $i (@itemnumbers) {
- if ( IsAvailableForItemLevelRequest($i)
+ my $item = GetItem($i);
+ if ( IsAvailableForItemLevelRequest($item, $borr)
&& CanItemBeReserved( $b, $i )
&& !IsItemOnHoldAndFound($i) )
{
my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber );
if ($canbookbereserved eq 'OK') {
push @availablefor, 'title level hold';
- my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber);
+ my $canitembereserved = IsAvailableForItemLevelRequest($item, $borrower);
if ($canitembereserved) {
push @availablefor, 'item level hold';
}
($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array();
}
#if we don't have an items.itype, use biblioitems.itemtype.
+ # FIXME this should respect the itypes systempreference
+ # if (C4::Context->preference('item-level_itypes')) {
if( ! $data->{'itype'} ) {
my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
$sth->execute($data->{'biblionumber'});
The complete workflow is :
==== 1st use case ====
patron request a document, 1st available : P >0, F=NULL, I=NULL
- a library having it run "transfertodo", and clic on the list
+ a library having it run "transfertodo", and clic on the list
if there is no transfer to do, the reserve waiting
- patron can pick it up P =0, F=W, I=filled
+ patron can pick it up P =0, F=W, I=filled
if there is a transfer to do, write in branchtransfer P =0, F=T, I=filled
The pickup library recieve the book, it check in P =0, F=W, I=filled
The patron borrow the book P =0, F=F, I=filled
-
+
==== 2nd use case ====
patron requests a document, a given item,
If pickup is holding branch P =0, F=W, I=filled
&GetReserveFee
&GetReserveInfo
&GetReserveStatus
-
+
&GetOtherReserves
-
+
&ModReserveFill
&ModReserveAffect
&ModReserve
&ModReserveCancelAll
&ModReserveMinusPriority
&MoveReserve
-
+
&CheckReserves
&CanBookBeReserved
&CanItemBeReserved
&AutoUnsuspendReserves
&IsAvailableForItemLevelRequest
-
+
+ &OPACItemHoldsAllowed
+
&AlterPriority
&ToggleLowestPriority
IsItemOnHoldAndFound
);
@EXPORT_OK = qw( MergeHolds );
-}
+}
=head2 AddReserve
push( @bibitemno, $bibitemnos ); # FIXME: inefficient: use fetchall_arrayref
}
my $count = scalar @bibitemno;
-
+
# if we have two or more different specific itemtypes
# reserved by same person on same day
my $bdata;
sub CanItemBeReserved{
my ($borrowernumber, $itemnumber) = @_;
-
+
my $dbh = C4::Context->dbh;
my $ruleitemtype; # itemtype of the matching issuing rule
my $allowedreserves = 0;
my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
# we retrieve user rights on this itemtype and branchcode
- my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed
- FROM issuingrules
- WHERE (categorycode in (?,'*') )
- AND (itemtype IN (?,'*'))
- AND (branchcode IN (?,'*'))
- ORDER BY
- categorycode DESC,
- itemtype DESC,
+ my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed
+ FROM issuingrules
+ WHERE (categorycode in (?,'*') )
+ AND (itemtype IN (?,'*'))
+ AND (branchcode IN (?,'*'))
+ ORDER BY
+ categorycode DESC,
+ itemtype DESC,
branchcode DESC;"
);
-
- my $querycount ="SELECT
+
+ my $querycount ="SELECT
count(*) as count
FROM reserves
LEFT JOIN items USING (itemnumber)
my $branchcode = "";
my $branchfield = "reserves.branchcode";
-
+
if( $controlbranch eq "ItemHomeLibrary" ){
$branchfield = "items.homebranch";
$branchcode = $item->{homebranch};
}else{
$ruleitemtype = '*';
}
-
+
# we retrieve count
-
+
$querycount .= "AND $branchfield = ?";
$querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*");
}else{
$sthcount->execute($borrowernumber, $branchcode, $ruleitemtype);
}
-
+
my $reservecount = "0";
if(my $rowcount = $sthcount->fetchrow_hashref()){
$reservecount = $rowcount->{count};
}
-
# we check if it's ok or not
if( $reservecount >= $allowedreserves ){
return 'tooManyReserves';
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
";
}
-
+
if ($item) {
$sth = $dbh->prepare("$select WHERE itemnumber = ?");
$sth->execute($item);
# Cancel reserves that have passed their expiration date.
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare( "
- SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() )
+ SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() )
AND expirationdate IS NOT NULL
AND found IS NULL
" );
while ( my $res = $sth->fetchrow_hashref() ) {
CancelReserve({ reserve_id => $res->{'reserve_id'} });
}
-
+
# Cancel reserves that have been waiting too long
if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
If C<$rank> is an integer greater than zero, the priority of
the request is set to that value. Since priority != 0 means
-that the item is not waiting on the hold shelf, setting the
+that the item is not waiting on the hold shelf, setting the
priority to a non-zero value also sets the request's found
-status and waiting date to NULL.
+status and waiting date to NULL.
The optional C<$itemnumber> parameter is used only when
-C<$rank> is a non-zero integer; if supplied, the itemnumber
+C<$rank> is a non-zero integer; if supplied, the itemnumber
of the hold request is set accordingly; if omitted, the itemnumber
is cleared.
";
$sth = $dbh->prepare($query);
$sth->execute( $biblionumber, $resdate, $borrowernumber );
-
+
# now fix the priority on the others (if the priority wasn't
# already sorted!)....
unless ( $priority == 0 ) {
to the correct reserve.
if $transferToDo is not set, then the status is set to "Waiting" as well.
-otherwise, a transfer is on the way, and the end of the transfer will
+otherwise, a transfer is on the way, and the end of the transfer will
take care of the waiting status
=cut
=head2 IsAvailableForItemLevelRequest
- my $is_available = IsAvailableForItemLevelRequest($itemnumber);
+ my $is_available = IsAvailableForItemLevelRequest($item_record,$borrower_record);
Checks whether a given item record is available for an
item-level hold request. An item is available if
-* it is not lost AND
-* it is not damaged AND
-* it is not withdrawn AND
+* it is not lost AND
+* it is not damaged AND
+* it is not withdrawn AND
* does not have a not for loan value > 0
-Whether or not the item is currently on loan is
-also checked - if the AllowOnShelfHolds system preference
-is ON, an item can be requested even if it is currently
-on loan to somebody else. If the system preference
-is OFF, an item that is currently checked out cannot
-be the target of an item-level hold request.
+Need to check the issuingrules onshelfholds column,
+if this is set items on the shelf can be placed on hold
Note that IsAvailableForItemLevelRequest() does not
check if the staff operator is authorized to place
=cut
sub IsAvailableForItemLevelRequest {
- my $itemnumber = shift;
-
- my $item = GetItem($itemnumber);
+ my $item = shift;
+ my $borrower = shift;
+ my $dbh = C4::Context->dbh;
# must check the notforloan setting of the itemtype
# FIXME - a lot of places in the code do this
# or something similar - need to be
# consolidated
- my $dbh = C4::Context->dbh;
- my $notforloan_query;
+ my $itype = _get_itype($item);
+ my $notforloan_per_itemtype
+ = $dbh->selectrow_array("SELECT notforloan FROM itemtypes WHERE itemtype = ?",
+ undef, $itype);
+
+ return 0 if
+ $notforloan_per_itemtype ||
+ $item->{itemlost} ||
+ $item->{notforloan} > 0 ||
+ $item->{wthdrawn} ||
+ ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems'));
+
+
+ return 1 if _OnShelfHoldsAllowed($itype,$borrower->{categorycode},$item->{holdingbranch});
+
+ return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
+}
+
+=head2 OnShelfHoldsAllowed
+
+ OnShelfHoldsAllowed($itemtype,$borrowercategory,$branchcode);
+
+Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see if onshelf
+holds are allowed, returns true if so.
+
+=cut
+
+sub OnShelfHoldsAllowed {
+ my ($item, $borrower) = @_;
+
+ my $itype = _get_itype($item);
+ return _OnShelfHoldsAllowed($itype,$borrower->{categorycode},$item->{holdingbranch});
+}
+
+sub _get_itype {
+ my $item = shift;
+
+ my $itype;
if (C4::Context->preference('item-level_itypes')) {
- $notforloan_query = "SELECT itemtypes.notforloan
- FROM items
- JOIN itemtypes ON (itemtypes.itemtype = items.itype)
- WHERE itemnumber = ?";
- } else {
- $notforloan_query = "SELECT itemtypes.notforloan
- FROM items
- JOIN biblioitems USING (biblioitemnumber)
- JOIN itemtypes USING (itemtype)
- WHERE itemnumber = ?";
+ # We cant trust GetItem to honour the syspref, so safest to do it ourselves
+ # When GetItem is fixed, we can remove this
+ $itype = $item->{itype};
}
- my $sth = $dbh->prepare($notforloan_query);
- $sth->execute($itemnumber);
- my $notforloan_per_itemtype = 0;
- if (my ($notforloan) = $sth->fetchrow_array) {
- $notforloan_per_itemtype = 1 if $notforloan;
+ else {
+ # XXX This is a bit dodgy. It relies on biblio itemtype column having different name.
+ # So if we already have a biblioitems join when calling this function,
+ # we don't need to access the database again
+ $itype = $item->{itemtype};
+ }
+ unless ($itype) {
+ my $dbh = C4::Context->dbh;
+ my $query = "SELECT itemtype FROM biblioitems WHERE biblioitemnumber = ? ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($item->{biblioitemnumber});
+ if (my $data = $sth->fetchrow_hashref()){
+ $itype = $data->{itemtype};
+ }
}
+ return $itype;
+}
- my $available_per_item = 1;
- $available_per_item = 0 if $item->{itemlost} or
- ( $item->{notforloan} > 0 ) or
- ($item->{damaged} and not C4::Context->preference('AllowHoldsOnDamagedItems')) or
- $item->{withdrawn} or
- $notforloan_per_itemtype;
-
+sub _OnShelfHoldsAllowed {
+ my ($itype,$borrowercategory,$branchcode) = @_;
- if (C4::Context->preference('AllowOnShelfHolds')) {
- return $available_per_item;
- } else {
- return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "Waiting"));
- }
+ my $rule = C4::Circulation::GetIssuingRule($borrowercategory, $itype, $branchcode);
+ return $rule->{onshelfholds};
}
=head2 AlterPriority
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
$sth->execute();
-
+
unless ( $ignoreSetLowestRank ) {
while ( my $res = $sth->fetchrow_hashref() ) {
_FixPriority({
unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ;
}
return @results if @results;
-
+
# check for title-level targetted match
my $title_level_target_query = qq{
SELECT reserves.biblionumber AS biblionumber,
my $dbh = C4::Context->dbh;
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
-
+
# Try to get the borrower's email address
my $to_address = C4::Members::GetNoticeEmailAddress($borrowernumber);
return $new_priority; # so the caller knows what priority they wind up receiving
}
+=head2 OPACItemHoldsAllowed
+
+ OPACItemHoldsAllowed($item_record,$borrower_record);
+
+Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see
+if specific item holds are allowed, returns true if so.
+
+=cut
+
+sub OPACItemHoldsAllowed {
+ my ($item,$borrower) = @_;
+
+ my $branchcode = $item->{homebranch} or die "No homebranch";
+ my $itype;
+ my $dbh = C4::Context->dbh;
+ if (C4::Context->preference('item-level_itypes')) {
+ # We cant trust GetItem to honour the syspref, so safest to do it ourselves
+ # When GetItem is fixed, we can remove this
+ $itype = $item->{itype};
+ }
+ else {
+ my $query = "SELECT itemtype FROM biblioitems WHERE biblioitemnumber = ? ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($item->{biblioitemnumber});
+ if (my $data = $sth->fetchrow_hashref()){
+ $itype = $data->{itemtype};
+ }
+ }
+
+ my $query = "SELECT opacitemholds,categorycode,itemtype,branchcode FROM issuingrules WHERE
+ (issuingrules.categorycode = ? OR issuingrules.categorycode = '*')
+ AND
+ (issuingrules.itemtype = ? OR issuingrules.itemtype = '*')
+ AND
+ (issuingrules.branchcode = ? OR issuingrules.branchcode = '*')
+ ORDER BY
+ issuingrules.categorycode desc,
+ issuingrules.itemtype desc,
+ issuingrules.branchcode desc
+ LIMIT 1";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($borrower->{categorycode},$itype,$branchcode);
+ my $data = $sth->fetchrow_hashref;
+ my $opacitemholds = uc substr ($data->{opacitemholds}, 0, 1);
+ return '' if $opacitemholds eq 'N';
+ return $opacitemholds;
+}
+
=head2 MoveReserve
MoveReserve( $itemnumber, $borrowernumber, $cancelreserve )
AllowHoldPolicyOverride
AllowHoldsOnDamagedItems
AllowHoldsOnPatronsPossessions
- AllowOnShelfHolds
AutoResumeSuspendedHolds
canreservefromotherbranches
decreaseLoanHighHolds
AllowPurchaseSuggestionBranchChoice
OpacAllowPublicListCreation
OpacAllowSharingPrivateLists
- OPACItemHolds
OpacRenewalAllowed
OpacRenewalBranch
OPACViewOthersSuggestions
use C4::VirtualShelves qw/:DEFAULT ShelvesMax/;
use C4::Biblio;
use C4::Items;
+use C4::Reserves;
use C4::Koha;
use C4::Auth qw/get_session/;
use C4::Members;
my ($shelfnumber2,$shelfname,$owner,$category,$sorton) = GetShelf($shelfnumber);
$template->param(
- 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds'),
'DisplayMultiPlaceHold' => C4::Context->preference('DisplayMultiPlaceHold'),
);
if (C4::Context->preference('TagsEnabled')) {
@cart_list = split(/\//, $cart_list);
}
+ my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
+
for my $this_item (@$items) {
my $biblionumber = $this_item->{'biblionumber'};
my $record = GetMarcBiblio($biblionumber);
});
}
+ $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
}
if($type eq 'intranet'){
# Build drop-down list for 'Add To:' menu...
# save the values entered
elsif ($op eq 'add') {
my $sth_search = $dbh->prepare('SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?');
- my $sth_insert = $dbh->prepare('INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, renewalperiod, norenewalbefore, auto_renew, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, maxsuspensiondays, firstremind, chargeperiod,rentaldiscount, overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
- my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, maxsuspensiondays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, renewalperiod=?, norenewalbefore=?, auto_renew=?, reservesallowed=?, issuelength=?, lengthunit = ?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?");
+ my $sth_insert = $dbh->prepare('INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, norenewalbefore, auto_renew, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, maxsuspensiondays, firstremind, chargeperiod,rentaldiscount, onshelfholds, opacitemholds, overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
+ my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, maxsuspensiondays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, renewalperiod=?, norenewalbefore=?, auto_renew=?, reservesallowed=?, issuelength=?, lengthunit=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, onshelfholds=?, opacitemholds=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?");
my $br = $branch; # branch
my $bor = $input->param('categorycode'); # borrower category
- my $cat = $input->param('itemtype'); # item type
+ my $itemtype = $input->param('itemtype'); # item type
my $fine = $input->param('fine');
my $finedays = $input->param('finedays');
my $maxsuspensiondays = $input->param('maxsuspensiondays');
$norenewalbefore = undef if $norenewalbefore eq '0' or $norenewalbefore =~ /^\s*$/;
my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
my $reservesallowed = $input->param('reservesallowed');
+ my $onshelfholds = $input->param('onshelfholds') || 0;
$maxissueqty =~ s/\s//g;
$maxissueqty = undef if $maxissueqty !~ /^\d+/;
my $issuelength = $input->param('issuelength');
$hardduedate = format_date_in_iso($hardduedate);
my $hardduedatecompare = $input->param('hardduedatecompare');
my $rentaldiscount = $input->param('rentaldiscount');
+ my $opacitemholds = $input->param('opacitemholds') || 0;
my $overduefinescap = $input->param('overduefinescap') || undef;
- $debug and warn "Adding $br, $bor, $cat, $fine, $maxissueqty";
+ $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty";
- $sth_search->execute($br,$bor,$cat);
+ $sth_search->execute($br,$bor,$itemtype);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
- $sth_update->execute($fine, $finedays, $maxsuspensiondays, $firstremind, $chargeperiod, $maxissueqty, $renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount,$overduefinescap, $br,$bor,$cat);
+ $sth_update->execute($fine, $finedays, $maxsuspensiondays, $firstremind, $chargeperiod, $maxissueqty, $renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount, $onshelfholds, $opacitemholds, $overduefinescap, $br,$bor,$itemtype);
} else {
- $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays, $maxsuspensiondays, $firstremind,$chargeperiod,$rentaldiscount,$overduefinescap);
+ $sth_insert->execute($br,$bor,$itemtype,$maxissueqty,$renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays, $maxsuspensiondays, $firstremind,$chargeperiod,$rentaldiscount,$onshelfholds,$opacitemholds,$overduefinescap);
}
}
elsif ($op eq "set-branch-defaults") {
$row->{'humancategorycode'} ||= $row->{'categorycode'};
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
$row->{'fine'} = sprintf('%.2f', $row->{'fine'});
- if ($row->{'hardduedate'} ne '0000-00-00') {
+ if ($row->{'hardduedate'} && $row->{'hardduedate'} ne '0000-00-00') {
$row->{'hardduedate'} = format_date( $row->{'hardduedate'});
$row->{'hardduedatebefore'} = 1 if ($row->{'hardduedatecompare'} == -1);
$row->{'hardduedateexact'} = 1 if ($row->{'hardduedatecompare'} == 0);
-- 51 Franklin Street' WHERE variable = ' Fifth Floor' WHERE variable = ' Boston' WHERE variable = ' MA 02110-1301 USA.
UPDATE systempreferences SET value = 'cataloguing' WHERE variable = 'AcqCreateItem';
-UPDATE systempreferences SET value = '1' WHERE variable = 'AllowOnShelfHolds';
UPDATE systempreferences SET value = '1' WHERE variable = 'AllowRenewalLimitOverride';
UPDATE systempreferences SET value = 'annual' WHERE variable = 'autoBarcode';
UPDATE systempreferences SET value = 'email' WHERE variable = 'AutoEmailPrimaryAddress';
`reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
`branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
+ onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
+ opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`),
KEY `categorycode` (`categorycode`),
KEY `itemtype` (`itemtype`)
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
-('AllowOnShelfHolds','0','','Allow hold requests to be placed on items that are not on loan','YesNo'),
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
('AllowPurchaseSuggestionBranchChoice','0','1','Allow user to choose branch when making a purchase suggestion','YesNo'),
('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'),
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'),
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'),
-('OPACItemHolds','1','0|1|force','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy.','Choice'),
('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'),
('OPACItemsResultsDisplay','0','','If OFF : show only the status of items in result list.If ON : show full location of items (branch+location+callnumber) as in staff interface','YesNo'),
('OpacKohaUrl','1',NULL,'Show \'Powered by Koha\' text on OPAC footer.',NULL),
$dbh->do(q|SET foreign_key_checks = 1|);;
print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.19.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ # First create the column
+ $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL");
+ # Now update the column
+ if (C4::Context->preference("AllowOnShelfHolds")){
+ # Pref is on, set allow for all rules
+ $dbh->do("UPDATE issuingrules SET onshelfholds=1");
+ } else {
+ # If the preference is not set, leave off
+ $dbh->do("UPDATE issuingrules SET onshelfholds=0");
+ }
+ # Remove from the systempreferences table
+ $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'");
+
+ # First create the column
+ $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL");
+ # Now update the column
+ my $opacitemholds = C4::Context->preference("OPACItemHolds") || '';
+ if (lc ($opacitemholds) eq 'force') {
+ $opacitemholds = 'F';
+ }
+ else {
+ $opacitemholds = $opacitemholds ? 'Y' : 'N';
+ }
+ # Set allow for all rules
+ $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'");
+
+ # Remove from the systempreferences table
+ $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'");
+
+ print "Upgrade to $DBversion done (Bug 5786 - Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n";
SetVersion ($DBversion);
}
"SyndeticsEnabled", "OpacRenewalAllowed", "item_level_itypes","noItemTypeImages",
"virtualshelves", "RequestOnOpac", "COinSinOPACResults", "OPACXSLTResultsDisplay",
"OPACItemsResultsDisplay", "LibraryThingForLibrariesID", "opacuserlogin", "TagsEnabled",
-"TagsShowOnList", "TagsInputOnList","loggedinusername","AllowOnShelfHolds","opacbookbag",
+"TagsShowOnList", "TagsInputOnList","loggedinusername","opacbookbag",
"OPACAmazonEnabled", "SyndeticsCoverImages","using_https");
# Arguments:
yes: Allow
no: "Don't allow"
- hold requests to be placed on and filled by damaged items.
- -
- - pref: AllowOnShelfHolds
- choices:
- yes: Allow
- no: "Don't allow"
- - hold requests to be placed on items that are not checked out.
-
- pref: AllowHoldDateInFuture
choices:
# - pref: OpacCloud
# choices:
# - If ON, enables subject cloud on OPAC
- -
- - pref: OPACItemHolds
- choices:
- no: "Don't allow"
- yes: Allow
- force: Force
- - patrons to place holds on specific items in the OPAC. If this is disabled, users can only put a hold on the next available item. If this is forced, users must put a hold on a specific item.
-
- pref: OpacRenewalAllowed
choices:
<th>No renewal before</th>
<th>Automatic renewal</th>
<th>Holds allowed (count)</th>
+ <th>On shelf holds allowed</th>
+ <th>Item level holds</th>
<th>Rental discount (%)</th>
<th colspan="2"> </th>
</tr>
[% END %]
</td>
<td>[% rule.reservesallowed %]</td>
+ <td>[% IF rule.onshelfholds %]Yes[% ELSE %]No[% END %]</td>
+ <td>[% IF rule.opacitemholds == 'F'%]Enforce[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
<td>[% rule.rentaldiscount %]</td>
<td><a href="#" class="editrule">Edit</a></td>
<td>
</select>
</td>
<td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
+ <td>
+ <select name="onshelfholds" id="onshelfholds">
+ <option value="0" selected>No</option>
+ <option value="1">Yes</option>
+ </select>
+ </td>
+ <td>
+ <select id="opacitemholds" name="opacitemholds">
+ <option value="N">Don't allow</option>
+ <option value="Y">Allow</option>
+ <option value="F">Enforce</option>
+ </select>
+ </td>
<td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
<td colspan="2">
<input type="hidden" name="branch" value="[% current_branch %]"/>
[% UNLESS ( norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
- [% IF ( AllowOnShelfHolds ) %]
+ [% IF ( AllowOnShelfHolds OR ItemsIssued ) %]
<li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li>
- [% ELSE %]
- [% IF ( ItemsIssued ) %]
- <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber %]">Place hold</a></li>
- [% END %]
[% END %]
[% END %]
[% END %]
</li>
[% END # / IF OpacHoldNotes %]
- [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
+ <li>
+ </li>
+ [% IF bibitemloo.itemholdable %]
<!-- ITEM HOLDS -->
<li class="lradio place_on_type" style="display:none;">
- <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
- [% IF OPACItemHolds == "1" %]
+ [% IF NOT bibitemloo.force_hold %]
+ <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
<input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
id="reqany_[% bibitemloo.biblionumber %]"
class="selectany"
value="Any"
checked="checked"
/>
- [% ELSE %]
- <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
- id="reqany_[% bibitemloo.biblionumber %]"
- class="selectany"
- value="Any"
- />
[% END %]
<label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
- [% IF OPACItemHolds == "force" %]
- <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
- id="reqspecific_[% bibitemloo.biblionumber %]"
- class="selectspecific"
- value="Specific"
- checked="checked"
- />
- [% ELSE %]
- <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
- id="reqspecific_[% bibitemloo.biblionumber %]"
- class="selectspecific"
- value="Specific"
- />
- [% END %]
+ <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
+ id="reqspecific_[% bibitemloo.biblionumber %]"
+ class="selectspecific"
+ value="Specific"
+ />
</li>
- [% END # / IF OPACItemHolds %]
+ [% END # / IF bibitemloo.itemholdable %]
</ul>
- [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
+ [% IF bibitemloo.itemholdable %]
<table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
<caption>Select a specific item:</caption>
<tr>
</tr>
[% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
</table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
- [% END # / IF ( OPACItemHolds )%]
+ [% END # / IF ( bibitemloo.itemholdable )%]
</div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
</fieldset>
[% END # / IF ( bibitemloo.holdable ) %]
// Hides all 'specific copy' table rows on load.
$(".copiesrow").hide();
- [% IF OPACItemHolds == 'force' %]
- [% FOREACH bibitemloo IN bibitemloop %]
- [% IF bibitemloo.holdable %]
- $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
- $("#copiesrow_[% bibitemloo.biblionumber %]").show();
- [% END %]
+ [% FOREACH bibitemloo IN bibitemloop %]
+ [% IF bibitemloo.force_hold %]
+ $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
+ $("#reqspecific_[% bibitemloo.biblionumber %]").click();
+ $("#copiesrow_[% bibitemloo.biblionumber %]").show();
[% END %]
[% END %]
$("#place_on_hdr").show();
- [% IF OPACItemHolds == '1' %]
- $(".place_on_type").show();
- // onload, selectany is checked
- $(".selectany").attr("checked", "checked");
- [% END %]
+ $(".place_on_type").show();
+ // onload, selectany is checked
+ $(".selectany").attr("checked", "checked");
// If the user is *allowed* to choose a specific item
// The first one is preselected
- [% IF OPACItemHolds =="1" %]
- $("table.copiesrow").each(function(){
- var id = suffixOf($(this).attr("id"), "_");
- select_first_available(id);
- });
- [% END %]
+ $("table.copiesrow").each(function(){
+ var id = suffixOf($(this).attr("id"), "_");
+ select_first_available(id);
+ });
// On confirmsjs change
$(".confirmjs").change(function(){
<p>
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( GROUP_RESULT.norequests ) %]
- [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
- [% IF ( AllowOnShelfHolds ) %]
- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue-->
- [% ELSE %]
- [% IF ( GROUP_RESULT.itemsissued ) %]
- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue-->
- [% END %]
- [% END %]
+ [% IF Koha.Preference( 'opacuserlogin' ) == 1 && GROUP_RESULT.holdable %]
+ <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue-->
[% END %]
[% END %]
[% END %]
<div class="actions-menu noprint">
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( SEARCH_RESULT.norequests ) %]
- [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && AllowOnShelfHolds ) %]
+ [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && SEARCH_RESULT.holdable %]
<span class="actions"><a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a></span><!-- add back when available 0 holds in queue-->
- [% ELSE %]
- [% IF ( SEARCH_RESULT.itemsissued ) %]
- <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue-->
- [% END %]
- [% END # / IF opacuserlogin && AllowOnShelfHolds %]
+ [% END # / IF opacuserlogin && holdable %]
[% END # UNLESS SEARCH_RESULT.norequests %]
[% END # IF RequestOnOpac %]
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( itemsloo.norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
- [% IF ( AllowOnShelfHolds ) %]
+ [% IF ( itemsloo.allow_onshelf_holds ) %]
<span class="actions"><a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% itemsloo.biblionumber %]">Place hold</a><!-- add back when available 0 holds in queue--></span>
[% ELSE %]
[% IF ( itemsloo.itemsissued ) %]
use MARC::Record;
use C4::Biblio;
use C4::Items;
+use C4::Reserves;
use C4::Acquisition;
use C4::Review;
use C4::Serials; # uses getsubscriptionfrom biblionumber
$biblionumber = int($biblionumber);
# get biblionumbers stored in the cart
-my @cart_list;
-
-if($query->cookie("bib_list")){
- my $cart_list = $query->cookie("bib_list");
- @cart_list = split(/\//, $cart_list);
+if(my $cart_list = $query->cookie("bib_list")){
+ my @cart_list = split(/\//, $cart_list);
if ( grep {$_ eq $biblionumber} @cart_list) {
$template->param( incart => 1 );
}
}
-$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
my $marcflavour = C4::Context->preference("marcflavour");
);
my $norequests = 1;
+my $allow_onshelf_holds;
my $res = GetISBDView($biblionumber, "opac");
my $itemtypes = GetItemTypes();
+my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
for my $itm (@items) {
$norequests = 0
- if ( (not $itm->{'withdrawn'} )
- && (not $itm->{'itemlost'} )
- && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
- && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
- && ($itm->{'itemnumber'} ) );
+ if $norequests
+ && !$itm->{'withdrawn'}
+ && !$itm->{'itemlost'}
+ && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
+ && !$itemtypes->{$itm->{'itype'}}->{notforloan}
+ && $itm->{'itemnumber'};
+
+ $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
+ unless $allow_onshelf_holds;
}
my $reviews = getreviews( $biblionumber, 1 );
$template->param(
RequestOnOpac => C4::Context->preference("RequestOnOpac"),
- AllowOnShelfHolds => C4::Context->preference('AllowOnShelfHolds'),
+ AllowOnShelfHolds => $allow_onshelf_holds,
norequests => $norequests,
ISBD => $res,
biblionumber => $biblionumber,
use MARC::Record;
use C4::Biblio;
use C4::Items;
+use C4::Reserves;
+use C4::Members;
use C4::Acquisition;
use C4::Koha;
use List::MoreUtils qw/any/;
);
# get biblionumbers stored in the cart
-my @cart_list;
-
-if($query->cookie("bib_list")){
- my $cart_list = $query->cookie("bib_list");
- @cart_list = split(/\//, $cart_list);
+if(my $cart_list = $query->cookie("bib_list")){
+ my @cart_list = split(/\//, $cart_list);
if ( grep {$_ eq $biblionumber} @cart_list) {
$template->param( incart => 1 );
}
}
-$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+my $allow_onshelf_holds;
+my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
+for my $itm (@all_items) {
+ $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower);
+ last if $allow_onshelf_holds;
+}
+
+$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
# adding the $RequestOnOpac param
}
-
-$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
-
-
-
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
$template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") );
items_count => scalar( @items ),
);
} else {
+ my $allow_onshelf_holds;
+ my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
for my $itm (@items) {
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} };
$itm->{priority} = $priority{ $itm->{itemnumber} };
$norequests = 0
- if ( (not $itm->{'withdrawn'} )
- && (not $itm->{'itemlost'} )
- && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
- && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
- && ($itm->{'itemnumber'} ) );
+ if $norequests
+ && !$itm->{'withdrawn'}
+ && !$itm->{'itemlost'}
+ && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
+ && !$itemtypes->{$itm->{'itype'}}->{notforloan}
+ && $itm->{'itemnumber'};
+
+ $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
+ unless $allow_onshelf_holds;
# get collection code description, too
my $ccode = $itm->{'ccode'};
push @itemloop, $itm;
}
}
+ $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
}
# Display only one tab if one items list is empty
$biblioLoopIter{itemLoop} = [];
my $numCopiesAvailable = 0;
+ my $numCopiesOPACAvailable = 0;
foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
my $itemNum = $itemInfo->{itemnumber};
my $itemLoopIter = {};
my $branch = GetReservesControlBranch( $itemInfo, $borr );
- my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} );
- my $policy_holdallowed = 1;
-
- if ( $branchitemrule->{'holdallowed'} == 0 ||
- ( $branchitemrule->{'holdallowed'} == 1 && $borr->{'branchcode'} ne $itemInfo->{'homebranch'} ) ) {
- $policy_holdallowed = 0;
+ my $policy_holdallowed = !$itemLoopIter->{already_reserved};
+ if ($policy_holdallowed) {
+ if (my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} )) {
+ $policy_holdallowed =
+ ($branchitemrule->{'holdallowed'} == 2) ||
+ ($branchitemrule->{'holdallowed'} == 1
+ && $borr->{'branchcode'} eq $itemInfo->{'homebranch'});
+ } else {
+ $policy_holdallowed = 0; # No rule - not allowed
+ }
}
-
- if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) eq 'OK' and ($itemLoopIter->{already_reserved} ne 1)) {
- $itemLoopIter->{available} = 1;
+ $policy_holdallowed &&=
+ IsAvailableForItemLevelRequest($itemInfo,$borr) &&
+ CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
+
+ if ($policy_holdallowed) {
+ if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $borr ) ) {
+ $itemLoopIter->{available} = 1;
+ $numCopiesOPACAvailable++;
+ $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
+ }
$numCopiesAvailable++;
}
$numBibsAvailable++;
$biblioLoopIter{bib_available} = 1;
$biblioLoopIter{holdable} = 1;
+ $biblioLoopIter{itemholdable} = 1 if $numCopiesOPACAvailable;
}
if ($biblioLoopIter{already_reserved}) {
$biblioLoopIter{holdable} = undef;
- }
- my $canReserve = CanBookBeReserved($borrowernumber,$biblioNum);
- unless ($canReserve eq 'OK') {
- $biblioLoopIter{holdable} = undef;
- $biblioLoopIter{ $canReserve } = 1;
+ $biblioLoopIter{itemholdable} = undef;
}
if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
$biblioLoopIter{holdable} = undef;
$biblioLoopIter{already_patron_possession} = 1;
}
- if( $biblioLoopIter{holdable} ){ $anyholdable++; }
+ $biblioLoopIter{holdable} &&= CanBookBeReserved($borrowernumber,$biblioNum) eq 'OK';
push @$biblioLoop, \%biblioLoopIter;
+
+ $anyholdable = 1 if $biblioLoopIter{holdable};
}
if ( $numBibsAvailable == 0 || $anyholdable == 0) {
use C4::SocialData;
use C4::Ratings;
use C4::External::OverDrive;
+use C4::Members;
+use C4::Reserves;
use POSIX qw(ceil floor strftime);
use URI::Escape;
elsif (C4::Context->preference("marcflavour") eq "MARC21" ) {
$template->param('usmarc' => 1);
}
-$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+
$template->param( 'OPACNoResultsFound' => C4::Context->preference('OPACNoResultsFound') );
$template->param(
exit;
}
+my $borrower = $borrowernumber ? GetMember( borrowernumber => $borrowernumber ) : undef;
+
# At this point, each server has given us a result set
# now we build that set for template display
+my %allow_onshelf_holds;
my @sup_results_array;
for (my $i=0;$i<@servers;$i++) {
my $server = $servers[$i];
# we need to set the offset parameter of searchResults to 0
my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
$group->{"RECORDS"});
+ if ($borrower) {
+ $_->{holdable} =
+ IsAvailableForItemLevelRequest($_, $borrower) &&
+ OPACItemHoldsAllowed($_, $borrower)
+ foreach @group_results;
+ }
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
}
} else {
@newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
$results_hashref->{$server}->{"RECORDS"});
+ if ($borrower) {
+ $_->{holdable} =
+ IsAvailableForItemLevelRequest($_, $borrower) &&
+ OPACItemHoldsAllowed($_, $borrower)
+ foreach @newresults;
+ }
}
$hits = 0 unless @newresults;
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
}
- # add information
- $item->{itemcallnumber} = $item->{itemcallnumber};
-
# if the item is currently on loan, we display its return date and
# change the background color
my $issues= GetItemIssue($itemnumber);
# checking reserve
my ($reservedate,$reservedfor,$expectedAt,$reserve_id,$wait) = GetReservesFromItemnumber($itemnumber);
- my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $reservedfor );
-
if ( defined $reservedate ) {
+ my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $reservedfor );
+
$item->{backgroundcolor} = 'reserved';
$item->{reservedate} = format_date($reservedate);
$item->{ReservedForBorrowernumber} = $reservedfor;
}
# If there is no loan, return and transfer, we show a checkbox.
- $item->{notforloan} = $item->{notforloan} || 0;
+ $item->{notforloan} ||= 0;
# if independent branches is on we need to check if the person can reserve
# for branches they arent logged in to
if (
$policy_holdallowed
&& !$item->{cantreserve}
- && IsAvailableForItemLevelRequest($itemnumber)
+ && IsAvailableForItemLevelRequest($item, $borrowerinfo)
&& CanItemBeReserved(
$borrowerinfo->{borrowernumber}, $itemnumber
) eq 'OK'
);
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds
- C4::Context->set_preference('AllowOnShelfHolds', 1 );
+ C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 1 );
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
itemtype => 'BOOK',
categorycode => $samplecat->{categorycode},
maxsuspensiondays => 0,
+ onshelfholds => 0,
+ opacitemholds => 'N',
};
my $sampleissuingrule2 = {
branchcode => $samplebranch2->{branchcode},
chargename => 'Null',
restrictedtype => 'Null',
maxsuspensiondays => 0,
+ onshelfholds => 1,
+ opacitemholds => 'Y',
};
my $sampleissuingrule3 = {
branchcode => $samplebranch1->{branchcode},
chargename => 'Null',
restrictedtype => 'Null',
maxsuspensiondays => 0,
+ onshelfholds => 1,
+ opacitemholds => 'F',
};
$query = 'INSERT INTO issuingrules (
branchcode,
use Modern::Perl;
-use Test::More tests => 53;
+use Test::More tests => 56;
use MARC::Record;
use DateTime::Duration;
####### EO Bug 13113 <<<
####
+my $item = GetItem($itemnumber);
+
+ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" );
+
+my $itype = C4::Reserves::_get_itype($item);
+my $categorycode = $borrower->{categorycode};
+my $holdingbranch = $item->{holdingbranch};
+my $rule = C4::Circulation::GetIssuingRule($categorycode, $itype, $holdingbranch);
+
+$dbh->do(
+ "UPDATE issuingrules SET onshelfholds = 1 WHERE categorycode = ? AND itemtype= ? and branchcode = ?",
+ undef,
+ $rule->{categorycode}, $rule->{itemtype}, $rule->{branchcode}
+);
+ok( C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() allowed" );
+$dbh->do(
+ "UPDATE issuingrules SET onshelfholds = 0 WHERE categorycode = ? AND itemtype= ? and branchcode = ?",
+ undef,
+ $rule->{categorycode}, $rule->{itemtype}, $rule->{branchcode}
+);
+ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" );
+
$dbh->rollback;
sub count_hold_print_messages {