@@ -, +, @@ placed in OPAC --- opac/opac-reserve.pl | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) --- a/opac/opac-reserve.pl +++ a/opac/opac-reserve.pl @@ -44,6 +44,7 @@ use Koha::Libraries; use Koha::Patrons; use Date::Calc qw/Today Date_to_Days/; use List::MoreUtils qw/uniq/; +use Data::Dumper; my $maxreserves = C4::Context->preference("maxreserves"); @@ -191,6 +192,24 @@ if ( $query->param('place_reserve') ) { my @itemnumbers = $query->param("checkitem_$biblioNum"); my $branch = $query->param("branch_$biblioNum"); my $reqtype = $query->param("reqtype_$biblioNum"); + warn $biblioNum; + if (!$reqtype) { + #If no $reqtype value has been passed from the form this means both reqany and reqspecific radio buttons are disabled because a hold has been placed on this biblio previously and so a forced_hold_level exists. + # Determine what the forced_hold_level is. + my $holds = Koha::Holds->search( + { + borrowernumber => $borrowernumber, + biblionumber => $biblioNum, + found => undef, + } + ); + my $forced_hold_level = $holds->forced_hold_level(); + if ($forced_hold_level eq "item") { + $reqtype = "Specific"; + } elsif ($forced_hold_level eq "record") { + $reqtype = "Any"; + } + } my $holds_to_place_count = $query->param("holds_to_place_count_$biblioNum") || 1; my $notes = $query->param('notes_'.$biblioNum) || ''; my $nbRequested = $reqtype eq 'Specific' ? @itemnumbers : $holds_to_place_count; @@ -241,16 +260,18 @@ if ( $query->param('place_reserve') ) { if ( $hostbiblioNum ne $biblioNum ) { $biblionumber = $hostbiblioNum; } - - $canreserve = 0 unless CanItemBeReserved( $borrowernumber, $itemnumber ) eq 'OK'; + my $reservestatus = CanItemBeReserved( $borrowernumber, $itemnumber); + $canreserve = 0 if !($reservestatus->{status} eq 'OK'); $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); my $item = GetItem($itemnumber); if ( $item->{'holdingbranch'} eq $branch ) { $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); } - + warn $itemnumber; + warn $canreserve; if ($canreserve) { + warn $canreserve; my $reserve_id = AddReserve( $branch, $borrowernumber, $biblionumber, @@ -598,6 +619,7 @@ foreach my $biblioNum (@biblionumbers) { } ); my $forced_hold_level = $holds->forced_hold_level(); + warn $forced_hold_level; if ($forced_hold_level) { #$biblioLoopIter{force_hold} = 1 if $forced_hold_level eq 'item'; #$biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record'; --