Bug 9206 - Only allow place holds in records that the patron don't have in his possession
[koha.git] / opac / opac-reserve.pl
index bb23752..4ff9478 100755 (executable)
@@ -490,7 +490,7 @@ foreach my $biblioNum (@biblionumbers) {
         # If there is no loan, return and transfer, we show a checkbox.
         $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
 
-        my $branch = C4::Circulation::_GetCircControlBranch($itemLoopIter, $borr);
+        my $branch = ( C4::Context->preference('ReservesControlBranch') eq 'ItemHomeLibrary' ) ? $itemInfo->{'homebranch'} : $borr->{'branchcode'};
 
         my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} );
         my $policy_holdallowed = 1;
@@ -537,6 +537,11 @@ foreach my $biblioNum (@biblionumbers) {
         $biblioLoopIter{holdable} = undef;
         $anyholdable = undef;
     }
+    if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
+        $biblioLoopIter{holdable} = undef;
+        $biblioLoopIter{already_patron_possession} = 1;
+        $anyholdable = undef;
+    }
 
     push @$biblioLoop, \%biblioLoopIter;
 }