Fixes for Bug 926 (forms lack method and/or action attributes). Also hiding 'delete...
[koha.git] / stats.print.pl
index ceba030..30ab529 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl\r
 \r
-\r
 use strict;\r
 use CGI;\r
 use C4::Output;\r
@@ -10,6 +9,17 @@ use C4::Interface::CGI::Output;
 use C4::Context;\r
 use Date::Manip;\r
 use C4::Stats;\r
+use Text::CSV_XS;\r
+&Date_Init("DateFormat=non-US"); # set non-USA date, eg:19/08/2005\r
+\r
+my $csv = Text::CSV_XS->new(\r
+    {\r
+        'quote_char'  => '"',\r
+        'escape_char' => '"',\r
+        'sep_char'    => ',',\r
+        'binary'      => 1\r
+    }\r
+);\r
 \r
 my $input=new CGI;\r
 my $time=$input->param('time');\r
@@ -41,9 +51,16 @@ if ($time=~ /\//){
         $date2=DateCalc($date,$date2);\r
 }\r
 \r
+if ($time eq ''){\r
+        $date=ParseDate('today');\r
+        $date2=ParseDate('tomorrow');\r
+}\r
+\r
+\r
 my $date=UnixDate($date,'%Y-%m-%d');\r
 my $date2=UnixDate($date2,'%Y-%m-%d');\r
 \r
+#warn "MASON: DATE: $date, $date2";\r
 \r
 #get a list of every payment\r
 my @payments=TotalPaid($date,$date2);\r
@@ -117,22 +134,21 @@ while ($i<$count ){
        push (@loop2, \@rows2);\r
        $i++;\r
        $totalcredits = $totalcredits + $credits[$i]->{'amount'};\r
-       ;\r
-\r
 }\r
+\r
 #takes off first char minus sign "-100.00"\r
 $totalcredits = substr($totalcredits, 1);\r
 \r
 print $input->header(\r
     -type       => 'application/vnd.ms-excel',\r
-    -attachment => "moo.csv",\r
+    -attachment => "moo.csv",         \r
 );\r
 print "Branch, Datetime, Surame, Firstnames, Description, Type, Invoice amount, Payment type, Payment Amount\n";\r
 \r
 \r
 for my $row ( @loop1 ) {\r
 \r
-    my $csv->combine(@$row);\r
+    $csv->combine(@$row);\r
     my $string = $csv->string;\r
     print $string, "\n";\r
 }\r
@@ -141,7 +157,7 @@ print ",,,,,,,\n";
 \r
 for my $row ( @loop2 ) {\r
 \r
-    my $csv->combine(@$row);\r
+    $csv->combine(@$row);\r
     my $string = $csv->string;\r
     print $string, "\n";\r
 }\r
@@ -151,4 +167,3 @@ print ",,,,,,,\n";
 print ",,Total Amount Paid, $totalpaid\n";\r
 print ",,Total Number Written, $totalwritten\n";\r
 print ",,Total Amount Credits, $totalcredits\n";\r
-\r