#!/usr/bin/perl\r
\r
-\r
use strict;\r
use CGI;\r
use C4::Output;\r
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
$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
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
\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
print ",,Total Amount Paid, $totalpaid\n";\r
print ",,Total Number Written, $totalwritten\n";\r
print ",,Total Amount Credits, $totalcredits\n";\r
-\r