s/Catalogue/Search/
[koha.git] / reports / acquisitions_stats.pl
index 0b9a19f..ae09354 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -29,6 +28,7 @@ use C4::Context;
 use C4::Output;
 use C4::Koha;
 use C4::Circulation;
+use C4::Dates qw/format_date format_date_in_iso/;
 
 =head1 NAME
 
@@ -36,8 +36,7 @@ plugin that shows a stats on borrowers
 
 =head1 DESCRIPTION
 
-
-=over2
+=over 2
 
 =cut
 
@@ -47,6 +46,10 @@ my $fullreportname = "reports/acquisitions_stats.tmpl";
 my $line           = $input->param("Line");
 my $column         = $input->param("Column");
 my @filters        = $input->param("Filter");
+$filters[0]=format_date_in_iso($filters[0]);
+$filters[1]=format_date_in_iso($filters[1]);
+$filters[2]=format_date_in_iso($filters[2]);
+$filters[3]=format_date_in_iso($filters[3]);
 my $podsp          = $input->param("PlacedOnDisplay");
 my $rodsp          = $input->param("ReceivedOnDisplay");
 my $aodsp          = $input->param("AcquiredOnDisplay");    ##added by mason.
@@ -66,21 +69,15 @@ my ($template, $borrowernumber, $cookie)
                                debug => 1,
                                });
 $template->param(do_it => $do_it,
-               intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-               intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-               IntranetNav => C4::Context->preference("IntranetNav"),
+        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
                );
 if ($do_it) {
-
-    #warn
-"line=$line, col=$column, pod=$podsp, rod=$rodsp, aod=$aodsp, calc=$calc, filters=@filters\n";
-
+    # warn "line=$line, col=$column, pod=$podsp, rod=$rodsp, aod=$aodsp, calc=$calc, filters=@filters\n";
     my $results =
       calculate( $line, $column, $podsp, $rodsp, $aodsp, $calc, \@filters );
     if ( $output eq "screen" ) {
         $template->param( mainloop => $results );
         output_html_with_http_headers $input, $cookie, $template->output;
-        exit(1);
     }
     else {
         print $input->header(
@@ -113,8 +110,8 @@ if ($do_it) {
             print $sep. $col->{totalcol};
         }
         print $sep. @$results[0]->{total};
-        exit(1);
     }
+    exit(1);
 }
 else {
     my $dbh = C4::Context->dbh;
@@ -122,9 +119,7 @@ else {
     my %labels;
     my %select;
     my $req;
-    $req =
-      $dbh->prepare(
-        "SELECT distinctrow id,name FROM aqbooksellers ORDER BY name");
+    $req = $dbh->prepare("SELECT distinctrow id,name FROM aqbooksellers ORDER BY name");
     $req->execute;
     my @select;
     push @select, "";
@@ -137,7 +132,7 @@ else {
     }
     my $CGIBookSellers = CGI::scrolling_list(
         -name   => 'Filter',
-        -id     => 'Filter',
+        -id     => 'supplier',
         -values => \@select,
 
         #                               -labels   => \%select,
@@ -160,7 +155,7 @@ else {
     }
     my $CGIItemTypes = CGI::scrolling_list(
         -name     => 'Filter',
-        -id       => 'Filter',
+        -id       => 'itemtypes',
         -values   => \@select,
         -labels   => \%select,
         -size     => 1,
@@ -183,7 +178,7 @@ else {
     }
     my $CGIBudget = CGI::scrolling_list(
         -name     => 'Filter',
-        -id       => 'Filter',
+        -id       => 'budget',
         -values   => \@select,
         -labels   => \%select,
         -size     => 1,
@@ -204,7 +199,7 @@ else {
     }
     my $CGISort1 = CGI::scrolling_list(
         -name     => 'Filter',
-        -id       => 'Filter',
+        -id       => 'sort1',
         -values   => \@select,
         -size     => 1,
         -multiple => 0
@@ -227,7 +222,7 @@ else {
     }
     my $CGISort2 = CGI::scrolling_list(
         -name     => 'Filter',
-        -id       => 'Filter',
+        -id       => 'sort2',
         -values   => \@select,
         -size     => 1,
         -multiple => 0
@@ -235,7 +230,6 @@ else {
 
     my @mime = ( C4::Context->preference("MIME") );
     foreach my $mime (@mime) {
-
         #               warn "".$mime;
     }
 
@@ -295,7 +289,12 @@ sub calculate {
             if ( ( ( $i == 1 ) or ( $i == 3 ) ) and ( @$filters[ $i - 1 ] ) ) {
                 $cell{err} = 1 if ( @$filters[$i] < @$filters[ $i - 1 ] );
             }
-            $cell{filter} .= @$filters[$i];
+            # format the dates filters, otherwise just fill as is
+            if ($i>=4) {
+                $cell{filter} .= @$filters[$i];
+            } else {
+                $cell{filter} .= format_date(@$filters[$i]);
+            }
             $cell{crit}   .= "Placed On From" if ( $i == 0 );
             $cell{crit}   .= "Placed On To" if ( $i == 1 );
             $cell{crit}   .= "Received On From" if ( $i == 2 );