Bug 16256 - Can't edit library EAN if you leave EAN empty
[koha.git] / reports / reserves_stats.pl
index a2b3737..792a772 100755 (executable)
@@ -21,7 +21,7 @@
 use strict;
 use warnings;
 
-use CGI;
+use CGI qw ( -utf8 );
 
 use C4::Auth;
 use C4::Debug;
@@ -31,8 +31,8 @@ use C4::Koha;
 use C4::Output;
 use C4::Reports;
 use C4::Members;
-use C4::Dates qw/format_date format_date_in_iso/;
 use C4::Category;
+use Koha::DateUtils;
 use List::MoreUtils qw/any/;
 use YAML;
 
@@ -48,7 +48,7 @@ plugin that shows circulation stats
 
 # my $debug = 1;       # override for now.
 my $input = new CGI;
-my $fullreportname = "reports/reserves_stats.tmpl";
+my $fullreportname = "reports/reserves_stats.tt";
 my $do_it    = $input->param('do_it');
 my $line     = $input->param("Line");
 my $column   = $input->param("Column");
@@ -78,7 +78,6 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
 our $sep     = $input->param("sep") || '';
 $sep = "\t" if ($sep eq 'tabulation');
 $template->param(do_it => $do_it,
-       DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
 );
 
 my $itemtypes = GetItemTypes();
@@ -130,7 +129,7 @@ if ($do_it) {
                print map {$sep.$_->{totalcol}} @$cols;
         print $sep.@$results[0]->{total};
        }
-       exit(1); # exit either way after $do_it
+       exit; # exit either way after $do_it
 }
 
 my $dbh = C4::Context->dbh;
@@ -140,8 +139,8 @@ my %select;
 
 # create itemtype arrayref for <select>.
 my @itemtypeloop;
-for my $itype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys(%$itemtypes)) {
-       push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{description} } ;
+for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
+       push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
 }
 
     # location list
@@ -156,15 +155,7 @@ foreach (sort {$ccodes->{$a} cmp $ccodes->{$b}} keys %$ccodes) {
 }
 
 # various
-my @mime = (C4::Context->preference("MIME"));
-
-my $CGIextChoice=CGI::scrolling_list(
-       -name     => 'MIME',
-       -id       => 'MIME',
-       -values   => \@mime,
-       -size     => 1,
-       -multiple => 0 );
-    
+my $CGIextChoice = ( 'CSV' ); # FIXME translation
 my $CGIsepChoice=GetDelimiterChoices;
  
 $template->param(
@@ -199,9 +190,10 @@ sub calculate {
     my @loopfilter;
     foreach my $filter ( keys %$filters_hashref ) {
         $filters_hashref->{$filter} =~ s/\*/%/;
-        $filters_hashref->{$filter} =
-          format_date_in_iso( $filters_hashref->{$filter} )
-          if ( $filter =~ /date/ );
+        if ( $filter =~ /date/ ) {
+            $filters_hashref->{$filter} =
+                eval { output_pref( { dt => dt_from_string( $filters_hashref->{$filter} ), dateonly => 1, dateformat => 'iso' }); };
+        }
     }
 
     #display
@@ -210,7 +202,7 @@ sub calculate {
             crit   => $_,
             filter => (
                 $_ =~ /date/
-                ? format_date( $filters_hashref->{$_} )
+                ? eval { output_pref( { dt => dt_from_string( $filters_hashref->{$_} ), dateonly => 1 }); }
                 : $filters_hashref->{$_}
             )
         }