$itm->{'itemtype'} = $itm->{'itype'} if(C4::Context->preference('item-level_itypes'));
$itemhash{$itm->{'itemnumber'}}=$itm;
if (!$itm->{'notforloan'} && !($itm->{'itemnotforloan'} > 0)){
- $forloan=1;
- }
+ $forloan=1;
+ }
}
if ( $query->param('place_reserve') ) {
my $notes=$query->param('notes');
my $checkitem=$query->param('checkitem');
my $found;
+ my $canreserve=0;
#if we have an item selectionned, and the pickup branch is the same as the holdingbranch of the document, we force the value $rank and $found.
if ($checkitem ne ''){
$i2++;
}
}
- # here we actually do the reserveration. Stage 3.
- if ($query->param('request') eq 'any'){
- # place a request on 1st available
- AddReserve($branch,$borrowernumber,$biblionumber,'a',\@realbi,$rank,$notes,$bibdata->{'title'},$checkitem,$found);
- } else {
- AddReserve($branch,$borrowernumber,$biblionumber,'a',\@realbi,$rank,$notes,$bibdata->{'title'},$checkitem, $found);
+
+ if ($checkitem ne ''){
+ $canreserve = 1 if CanItemBeReserved($borrowernumber,$checkitem);
+ $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
+ my $item = GetItem($checkitem);
+ if ( $item->{'holdingbranch'} eq $branch ){
+ $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
+ }
+ }
+ else {
+ $canreserve = 1 if CanBookBeReserved($borrowernumber,$biblionumber);
+ # Inserts a null into the 'itemnumber' field of 'reserves' table.
+ $checkitem = undef;
}
+
+ # here we actually do the reserveration. Stage 3.
+ AddReserve($branch,$borrowernumber,$biblionumber,'a',\@realbi,$rank,$notes,
+ $bibdata->{'title'},$checkitem, $found) if ($canreserve);
print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
}
else {
}
my @bibitemloop;
+my $num_available = 0;
foreach my $biblioitemnumber (@biblioitemnumbers) {
my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
# If there is no loan, return and transfer, we show a checkbox.
$item->{notforloan} = $item->{notforloan} || 0;
- if (IsAvailableForItemLevelRequest($itemnumber)) {
+ my $branch = C4::Circulation::_GetCircControlBranch($item, $borr);
+
+ my $branchitemrule = GetBranchItemRule( $branch, $item->{'itemtype'} );
+
+ my $policy_holdallowed = 1;
+
+ if ( $branchitemrule->{'holdallowed'} == 0 ||
+ ( $branchitemrule->{'holdallowed'} == 1 && $borr->{'branchcode'} ne $item->{'homebranch'} ) ) {
+ $policy_holdallowed = 0;
+ }
+
+ if (IsAvailableForItemLevelRequest($itemnumber) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemnumber)) {
$item->{available} = 1;
+ $num_available++;
}
# FIXME: move this to a pm
while (my $wait_hashref = $sth2->fetchrow_hashref) {
$item->{waitingdate} = format_date($wait_hashref->{waitingdate});
}
- $item->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $item->{itype} }{imageurl} );
+
+ $item->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $item->{itype} }{imageurl} );
+
push @{ $biblioitem->{itemloop} }, $item;
}
-
+
+ if(not CanBookBeReserved($borrowernumber,$biblionumber)){
+ $biblioitem->{available} = undef;
+ $biblioitem->{notholdable} = 1;
+ }
+
push @bibitemloop, $biblioitem;
}
+if ( $num_available == 0 ) {
+ $template->param( none_available => 1, message => 1 );
+}
+
# display infos
$template->param(
forloan => $forloan,