(bug #3819) variable name typo
[koha.git] / opac / opac-reserve.pl
index 552cffb..194a28e 100755 (executable)
@@ -136,8 +136,8 @@ foreach my $itm (@items) {
     $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') ) {
@@ -250,6 +250,7 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
 }
 
 my @bibitemloop;
+my $num_available = 0;
 
 foreach my $biblioitemnumber (@biblioitemnumbers) {
     my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
@@ -330,8 +331,17 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
         # If there is no loan, return and transfer, we show a checkbox.
         $item->{notforloan} = $item->{notforloan} || 0;
 
-        if (IsAvailableForItemLevelRequest($itemnumber)) {
+        my $branchitemrule = GetBranchItemRule( $borr->{'branchcode'}, $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) {
             $item->{available} = 1;
+            $num_available++;
         }
 
        # FIXME: move this to a pm
@@ -348,6 +358,10 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
     push @bibitemloop, $biblioitem;
 }
 
+if ( $num_available == 0 ) {
+        $template->param( none_available => 1, message => 1 );
+}
+
 # display infos
 $template->param(
        forloan           => $forloan,