Bug 17600: Standardize our EXPORT_OK
[srvgit] / reports / issues_avg_stats.pl
index 1e8e138..7be36a5 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-#use warnings; FIXME - Bug 2505
-use C4::Auth;
+use Modern::Perl;
+use C4::Auth qw( get_template_and_user );
 use CGI qw ( -utf8 );
 use C4::Context;
-use C4::Output;
-use C4::Koha;
-use C4::Circulation;
-use C4::Reports;
-use Koha::DateUtils;
+use C4::Output qw( output_html_with_http_headers );
+use C4::Reports qw( GetDelimiterChoices );
+use Koha::DateUtils qw( dt_from_string output_pref );
 use Koha::ItemTypes;
 use Koha::Patron::Categories;
-use Date::Calc qw(Delta_Days);
+use Date::Calc qw( Delta_Days );
 
 =head1 NAME
 
@@ -40,7 +37,7 @@ plugin that shows a stats on borrowers
 
 =cut
 
-my $input = new CGI;
+my $input = CGI->new;
 my $do_it=$input->param('do_it');
 my $fullreportname = "reports/issues_avg_stats.tt";
 my $line = $input->param("Line");
@@ -61,16 +58,13 @@ my $rodsp = $input->param("ReturnDisplay");
 my $calc = $input->param("Cellvalue");
 my $output = $input->param("output");
 my $basename = $input->param("basename");
-my $itype = C4::Context->preference('item-level_itypes') ? "items.itype" : "biblioitems.itemtype";
 
 #warn "calcul : ".$calc;
 my ($template, $borrowernumber, $cookie)
     = get_template_and_user({template_name => $fullreportname,
                 query => $input,
                 type => "intranet",
-                authnotrequired => 0,
                 flagsrequired => {reports => '*'},
-                debug => 1,
                     });
 our $sep     = $input->param("sep");
 $sep = "\t" if ($sep eq 'tabulation');
@@ -178,6 +172,7 @@ sub calculate {
     my @looprow;
     my %globalline;
     my $grantotal =0;
+    my $itype = C4::Context->preference('item-level_itypes') ? "items.itype" : "biblioitems.itemtype";
 # extract parameters
     my $dbh = C4::Context->dbh;
 
@@ -390,7 +385,6 @@ sub calculate {
 #      warn "fin des titres colonnes";
 
     my $i=0;
-    my @totalcol;
     my $hilighted=-1;
     
     #Initialization of cell values.....
@@ -443,12 +437,8 @@ sub calculate {
     $dbcalc->execute;
 #      warn "filling table";
     my $issues_count=0;
-    my $previous_row; 
-    my $previous_col;
     my $loanlength; 
-    my $err;
     my $emptycol;
-    my $weightrow;
 
     while (my  @data = $dbcalc->fetchrow) {
         my ($row, $col, $issuedate, $returndate, $weight)=@data;
@@ -456,8 +446,6 @@ sub calculate {
         $emptycol=1 if (!defined($col));
         $col = "zzEMPTY" if (!defined($col));
         $row = "zzEMPTY" if (!defined($row));
-        # fill returndate to avoid an error with date calc (needed for all non returned issues)
-        $returndate= join '-',Date::Calc::Today if $returndate eq '0000-00-00';
     #  DateCalc returns => 0:0:WK:DD:HH:MM:SS   the weeks, days, hours, minutes,
     #  and seconds between the two
         $loanlength = Delta_Days(split(/-/,$issuedate),split (/-/,$returndate)) ;