From a7691d0a4d6dad60b34fc17083f3fd707dfee7b6 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Sat, 24 Apr 2010 23:37:29 +0200 Subject: [PATCH] #4239 improved : enable checking of CanHoldMultipleItems at item-level Content-Type: text/plain; charset="utf-8" previously, the feature was working only for libraries with item-level_itype is OFF with this patch, it works also with item-level_itype=ON --- opac/opac-reserve.pl | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 2373465..47785f6 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -340,6 +340,13 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{itemLoop} = []; my $numCopiesAvailable = 0; + # $canReserveMultiple is set to "yes" ( >0 ) if multiple items can be reserved + # it is set to 0 otherwise. depends on item-level_itypes syspref + # and the list of itypes that can be multiple reserved + my $canReserveMultiple=0; + unless (C4::Context->preference("item-level_itypes")) { + $canReserveMultiple = CanHoldMultipleItems($biblioLoopIter{itemtype}); + } foreach my $itemInfo (@{$biblioData->{itemInfos}}) { my $itemNum = $itemInfo->{itemnumber}; my $itemLoopIter = {}; @@ -354,6 +361,13 @@ foreach my $biblioNum (@biblionumbers) { $itemLoopIter->{description} = $itemInfo->{description}; $itemLoopIter->{imageurl} = $itemInfo->{imageurl}; } + # check if the itype is one that can be multiple reserved + if (C4::Context->preference("item-level_itypes")) { + # sum canReserveMultiple : if at least one item can be multiple reserved, then the flag will be >0 + # FIXME : there can be complex & strange cases, where some items can be multiple reserved, and some can't + # this case is not managed. Note it may be only theoric, and have no real case + $canReserveMultiple = $canReserveMultiple+CanHoldMultipleItems($itemInfo->{itype}); + } # If the holdingbranch is different than the homebranch, we show the # holdingbranch of the document too. @@ -457,7 +471,7 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{bib_available} = 1; $biblioLoopIter{holdable} = 1; } - if ( $biblioLoopIter{already_reserved} && !CanHoldMultipleItems($biblioLoopIter{itemtype}) ) { + if ( $biblioLoopIter{already_reserved} && !$canReserveMultiple ) { $biblioLoopIter{holdable} = undef; warn "Already_Reserved"; } -- 1.6.3.3