diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 2ac58c33c8..812027fe8f 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl - # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. @@ -19,6 +18,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use warnings; use CGI; use C4::Context; use C4::Output; @@ -42,13 +42,11 @@ my $input = new CGI; my $item = $input->param('itemnumber'); my $borrowernumber = $input->param('borrowernumber'); -my $fbr = $input->param('fbr'); -my $tbr = $input->param('tbr'); +my $fbr = $input->param('fbr') || ''; +my $tbr = $input->param('tbr') || ''; my $cancel; -my $theme = $input->param('theme'); # only used if allowthemeoverride is set - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "circ/waitingreserves.tmpl", @@ -64,25 +62,17 @@ my $default = C4::Context->userenv->{'branch'}; # if we have a return from the form we launch the subroutine CancelReserve if ($item) { - my $messages; - my $nextreservinfo; - my $waiting; - ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber ); - - # if we have a result + my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber ); + # if we have a result if ($nextreservinfo) { my $borrowerinfo = GetMemberDetails( $nextreservinfo ); my $iteminfo = GetBiblioFromItemNumber($item); if ( $messages->{'transfert'} ) { - my $branchname = GetBranchName( $messages->{'transfert'} ); $template->param( messagetransfert => $messages->{'transfert'}, - branchname => $branchname, + branchname => GetBranchName($messages->{'transfert'}), ); } - if ( $messages->{'waiting'} ) { - $waiting = 1; - } $template->param( message => 1, @@ -91,75 +81,65 @@ if ($item) { nextreservfirstname => $borrowerinfo->{'firstname'}, nextreservitem => $item, nextreservtitle => $iteminfo->{'title'}, - waiting => $waiting + waiting => ($messages->{'waiting'}) ? 1 : 0, ); } -# if the document is not in his homebranch location and there is not reservation after, we transfer it - if ( ( $fbr ne $tbr ) and ( not $nextreservinfo ) ) { +# if the document is not in his homebranch location and there is not reservation after, we transfer it + if ($fbr ne $tbr and not $nextreservinfo) { ModItemTransfer( $item, $fbr, $tbr ); } } my @reservloop; - -my @getreserves; -if (C4::Context->preference('IndependantBranches')){ - # get reserves for the branch we are logged into - @getreserves = GetReservesForBranch($default); -} -else { - # get all reserves waiting - @getreserves = GetReservesForBranch(); -} +my @getreserves = C4::Context->preference('IndependantBranches') ? GetReservesForBranch($default) : GetReservesForBranch(); +# get reserves for the branch we are logged into, or for all branches +my $today = Date_to_Days(&Today); foreach my $num (@getreserves) { + next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); my %getreserv; my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); # fix up item type for display $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'}; my $getborrower = GetMemberDetails( $num->{'borrowernumber'} ); - my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); + my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype $getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} ); - next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); - my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/, - $num->{'waitingdate'}; + my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/, $num->{'waitingdate'}; ( $waiting_year, $waiting_month, $waiting_day ) = Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, C4::Context->preference('ReservesMaxPickUpDelay')); my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day ); - my $today = Date_to_Days(&Today); - my $warning = ( $today > $calcDate ); - if ( $warning > 0 ) { + if ($today > $calcDate) { $getreserv{'messcompa'} = 1; } - $getreserv{'title'} = $gettitle->{'title'}; - $getreserv{'itemnumber'} = $gettitle->{'itemnumber'}; - $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; - $getreserv{'barcode'} = $gettitle->{'barcode'}; - $getreserv{'itemtype'} = $itemtypeinfo->{'description'}; - $getreserv{'homebranch'} = $gettitle->{'homebranch'}; - $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'}; + $getreserv{'itemtype'} = $itemtypeinfo->{'description'}; + $getreserv{'title'} = $gettitle->{'title'}; + $getreserv{'itemnumber'} = $gettitle->{'itemnumber'}; + $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; + $getreserv{'barcode'} = $gettitle->{'barcode'}; + $getreserv{'homebranch'} = $gettitle->{'homebranch'}; + $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'}; + $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) { $getreserv{'dotransfer'} = 1; } - $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'}; $getreserv{'borrowername'} = $getborrower->{'surname'}; $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'}; + $getreserv{'borrowerphone'} = $getborrower->{'phone'}; if ( $getborrower->{'emailaddress'} ) { - $getreserv{'borrowermail'} = $getborrower->{'emailaddress'}; + $getreserv{'borrowermail'} = $getborrower->{'emailaddress'}; } - $getreserv{'borrowerphone'} = $getborrower->{'phone'}; - push( @reservloop, \%getreserv ); + push @reservloop, \%getreserv; } $template->param( reserveloop => \@reservloop, show_date => format_date(C4::Dates->today('iso')), - dateformat => C4::Context->preference("dateformat"), + dateformat => C4::Context->preference("dateformat"), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl index b1284f90ba..0b42a14fbd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl @@ -2,7 +2,7 @@