X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-reserve.pl;h=58dac17b48787ace63cfca60d9cd4efd372df911;hb=59ac9be07e70b23c2dfcd009f6d5f689d1065c9b;hp=60232cc6ee191b7b79b2d92425385f1695957cf0;hpb=7a46b1599e3a7600e4383ad11932b98e3c5eca06;p=koha.git diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 60232cc6ee..58dac17b48 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -18,8 +18,8 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; + use CGI qw ( -utf8 ); use C4::Auth; # checkauth, getborrowernumber. use C4::Koha; @@ -34,9 +34,10 @@ use C4::Branch; # GetBranches use C4::Overdues; use C4::Debug; use Koha::DateUtils; -use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Libraries; +use Koha::Patrons; use Date::Calc qw/Today Date_to_Days/; -# use Data::Dumper; +use List::MoreUtils qw/uniq/; my $maxreserves = C4::Context->preference("maxreserves"); @@ -228,7 +229,7 @@ if ( $query->param('place_reserve') ) { my $canreserve = 0; - my $singleBranchMode = C4::Context->preference("singleBranchMode"); + my $singleBranchMode = Koha::Libraries->search->count == 1; if ( $singleBranchMode || !$OPACChooseBranch ) { # single branch mode or disabled user choosing $branch = $borr->{'branchcode'}; @@ -281,15 +282,16 @@ if ( $query->param('place_reserve') ) { $canreserve = 0; } + my $itemtype = $query->param('itemtype') || undef; + $itemtype = undef if $itemNum; + # Here we actually do the reserveration. Stage 3. if ($canreserve) { my $reserve_id = AddReserve( - $branch, $borrowernumber, - $biblioNum, - [$biblioNum], $rank, - $startdate, $expiration_date, - $notes, $biblioData->{title}, - $itemNum, $found + $branch, $borrowernumber, $biblioNum, + [$biblioNum], $rank, $startdate, + $expiration_date, $notes, $biblioData->{title}, + $itemNum, $found, $itemtype, ); $failed_holds++ unless $reserve_id; ++$reserve_cnt; @@ -314,6 +316,7 @@ if ( $borr->{'amountoutstanding'} && ($borr->{'amountoutstanding'} > $maxoutstan $noreserves = 1; $template->param( too_much_oweing => $amount ); } + if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) { $noreserves = 1; $template->param( @@ -321,6 +324,7 @@ if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) { GNA => 1 ); } + if ( $borr->{lost} && ($borr->{lost} == 1) ) { $noreserves = 1; $template->param( @@ -328,11 +332,14 @@ if ( $borr->{lost} && ($borr->{lost} == 1) ) { lost => 1 ); } -if ( IsDebarred($borrowernumber) ) { + +if ( Koha::Patrons->find( $borrowernumber )->is_debarred ) { $noreserves = 1; $template->param( - message => 1, - debarred => 1 + message => 1, + debarred => 1, + debarred_comment => $borr->{debarredcomment}, + debarred_date => $borr->{debarred}, ); } @@ -436,6 +443,7 @@ foreach my $biblioNum (@biblionumbers) { $itemLoopIter->{copynumber} = $itemInfo->{copynumber}; if ($itemLevelTypes) { $itemLoopIter->{translated_description} = $itemInfo->{translated_description}; + $itemLoopIter->{itype} = $itemInfo->{itype}; $itemLoopIter->{imageurl} = $itemInfo->{imageurl}; } @@ -566,6 +574,7 @@ foreach my $biblioNum (@biblionumbers) { $anyholdable = 1 if $biblioLoopIter{holdable}; } + if ( $numBibsAvailable == 0 || $anyholdable == 0) { $template->param( none_available => 1 ); }