+++ /dev/null
-#!/usr/bin/perl\r
-\r
-use strict;\r
-use CGI;\r
-use C4::Output;\r
-use HTML::Template;\r
-use C4::Auth;\r
-use C4::Interface::CGI::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
-\r
-my @loop1;\r
-my @loop2;\r
-my $date;\r
-my $date2;\r
-if ($time eq 'yesterday'){\r
- $date=ParseDate('yesterday');\r
- $date2=ParseDate('today');\r
-}\r
-if ($time eq 'today'){\r
- $date=ParseDate('today');\r
- $date2=ParseDate('tomorrow');\r
-}\r
-if ($time eq 'daybefore'){\r
- $date=ParseDate('2 days ago');\r
- $date2=ParseDate('yesterday');\r
-}\r
-if ($time eq 'month') {\r
- $date = ParseDate('1 month ago');\r
- $date2 = ParseDate('today');\r
-\r
-}\r
-if ($time=~ /\//){\r
- $date=ParseDate($time);\r
- $date2=ParseDateDelta('+ 1 day');\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
-\r
-my $count=@payments;\r
-# print "MASON: number of payments=$count\n";\r
-\r
-my $i=0;\r
-my $totalcharges=0;\r
-my $totalcredits=0;\r
-my $totalpaid=0;\r
-my $totalwritten=0;\r
-\r
-# lets get a a list of all individual item charges paid for by that payment\r
-while ($i<$count ){\r
-\r
- my $count;\r
- my @charges;\r
-\r
- if ($payments[$i]{'type'} ne 'writeoff'){ # lets ignore writeoff payments!.\r
- @charges=getcharges($payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'}, $payments[$i]{'proccode'});\r
- $totalcharges++;\r
- $count=@charges;\r
-\r
- # getting each of the charges and putting them into a array to be printed out\r
- #this loops per charge per person\r
- for (my $i2=0;$i2<$count;$i2++){\r
-\r
- my $hour=substr($payments[$i]{'timestamp'},8,2);\r
- my $min=substr($payments[$i]{'timestamp'},10,2);\r
- my $sec=substr($payments[$i]{'timestamp'},12,2);\r
- my $time="$hour:$min:$sec";\r
- my $time2="$payments[$i]{'date'}";\r
- my $branch=Getpaidbranch($time2,$payments[$i]{'borrowernumber'});\r
-\r
- my @rows1 = ($branch, # lets build up a row\r
- $payments[$i]->{'datetime'},\r
- $payments[$i]->{'surname'},\r
- $payments[$i]->{'firstname'},\r
- $charges[$i2]->{'description'},\r
- $charges[$i2]->{'accounttype'},\r
- sprintf("%.2f", $charges[$i2]->{'amount'}), # rounding amounts to 2dp\r
- $payments[$i]->{'type'},\r
- $payments[$i]->{'value'});\r
-\r
- push (@loop1, \@rows1);\r
- }\r
- } else {\r
- ++$totalwritten;\r
- }\r
- $i++; #increment the while loop\r
- $totalpaid = $totalpaid + $payments[$i]->{'value'};\r
-}\r
-\r
-#get credits and append to the bottom of payments\r
-my @credits=getcredits($date,$date2);\r
-\r
-my $count=@credits;\r
-my $i=0;\r
-\r
-while ($i<$count ){\r
-\r
- my @rows2 = ($credits[$i]->{'branchcode'},\r
- $credits[$i]->{'date'},\r
- $credits[$i]->{'surname'},\r
- $credits[$i]->{'firstname'},\r
- $credits[$i]->{'description'},\r
- $credits[$i]->{'accounttype'},\r
- $credits[$i]->{'amount'});\r
-\r
- push (@loop2, \@rows2);\r
- $i++;\r
- $totalcredits = $totalcredits + $credits[$i]->{'amount'};\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
-);\r
-print "Branch, Datetime, Surame, Firstnames, Description, Type, Invoice amount, Payment type, Payment Amount\n";\r
-\r
-\r
-for my $row ( @loop1 ) {\r
-\r
- $csv->combine(@$row);\r
- my $string = $csv->string;\r
- print $string, "\n";\r
-}\r
-\r
-print ",,,,,,,\n";\r
-\r
-for my $row ( @loop2 ) {\r
-\r
- $csv->combine(@$row);\r
- my $string = $csv->string;\r
- print $string, "\n";\r
-}\r
-\r
-print ",,,,,,,\n";\r
-print ",,,,,,,\n";\r
-print ",,Total Amount Paid, $totalpaid\n";\r
-print ",,Total Number Written, $totalwritten\n";\r
-print ",,Total Amount Credits, $totalcredits\n";\r
+++ /dev/null
-#!/usr/bin/perl\r
-\r
-use strict;\r
-use CGI;\r
-use C4::Output;\r
-use HTML::Template;\r
-use C4::Auth;\r
-use C4::Interface::CGI::Output;\r
-use C4::Context;\r
-use Date::Manip;\r
-use C4::Stats;\r
-use Data::Dumper;\r
-\r
-&Date_Init("DateFormat=non-US"); # set non-USA date, eg:19/08/2005\r
-\r
-my $input=new CGI;\r
-my $time=$input->param('time');\r
-my $time2=$input->param('time2');\r
-\r
-\r
-my ($template, $loggedinuser, $cookie)\r
- = get_template_and_user({template_name => "stats_screen.tmpl",\r
- query => $input,\r
- type => "intranet",\r
- authnotrequired => 1,\r
- flagsrequired => {borrowers => 1},\r
- debug => 1,\r
- });\r
-\r
-my $date;\r
-my $date2;\r
-if ($time eq 'yesterday'){\r
- $date=ParseDate('yesterday');\r
- $date2=ParseDate('today');\r
-}\r
-if ($time eq 'today'){\r
- $date=ParseDate('today');\r
- $date2=ParseDate('tomorrow');\r
-}\r
-if ($time eq 'daybefore'){\r
- $date=ParseDate('2 days ago');\r
- $date2=ParseDate('yesterday');\r
-}\r
-if ($time eq 'month') {\r
- $date = ParseDate('1 month ago');\r
- $date2 = ParseDate('today');\r
-\r
-}\r
-if ($time=~ /\//){\r
- $date=ParseDate($time);\r
- $date2=ParseDateDelta('+ 1 day');\r
- $date2=DateCalc($date,$date2);\r
-}\r
-# if time is blank\r
-if ($time eq ''){\r
- $date=ParseDate('today');\r
- $date2=ParseDate('tomorrow');\r
-}\r
-\r
-# if script is called with a start and finsh date range...\r
-if ($time ne '' && $time2 ne ''){\r
- $date=ParseDate($time);\r
- $date2=ParseDate($time2);\r
-}\r
-\r
-\r
-my $date=UnixDate($date,'%Y-%m-%d');\r
-my $date2=UnixDate($date2,'%Y-%m-%d');\r
-warn "MASON: TIME: $time, $time2";\r
-warn "MASON: DATE: $date, $date2";\r
-\r
-#get a list of every payment\r
-my @payments=TotalPaid($date,$date2);\r
-\r
-\r
-my $count=@payments;\r
-# print "MASON: number of payments=$count\n";\r
-\r
-my $i=0;\r
-my $totalcharges=0;\r
-my $totalcredits=0;\r
-my $totalpaid=0;\r
-my $totalwritten=0;\r
-my @loop1;\r
-my @loop2;\r
-\r
-\r
-# lets get a a list of all individual item charges paid for by that payment\r
-while ($i<$count ){\r
-\r
- my $count;\r
- my @charges;\r
-\r
-\r
- if ($payments[$i]{'type'} ne 'writeoff'){\r
-\r
-# warn Dumper $payments[$i];\r
-\r
- @charges=getcharges($payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'}, $payments[$i]{'proccode'});\r
- $totalcharges++;\r
- $count=@charges;\r
-\r
- # getting each of the charges and putting them into a array to be printed out\r
- #this loops per charge per person\r
- for (my $i2=0;$i2<$count;$i2++){\r
- my $hour=substr($payments[$i]{'timestamp'},8,2);\r
- my $min=substr($payments[$i]{'timestamp'},10,2);\r
- my $sec=substr($payments[$i]{'timestamp'},12,2);\r
- my $time="$hour:$min:$sec";\r
- my $time2="$payments[$i]{'date'}";\r
- my $branch=Getpaidbranch($time2,$payments[$i]{'borrowernumber'});\r
-\r
- # lets build up a row\r
- my %rows1 = (branch => $branch,\r
- datetime => $payments[$i]->{'datetime'},\r
- surname => $payments[$i]->{'surname'},\r
- firstname => $payments[$i]->{'firstname'},\r
- description => $charges[$i2]->{'description'},\r
- accounttype => $charges[$i2]->{'accounttype'},\r
- amount => sprintf("%.2f", $charges[$i2]->{'amount'}), # rounding amounts to 2dp\r
- type => $payments[$i]->{'type'},\r
- value => sprintf("%.2f", $charges[$i2]->{'type'})); # rounding amounts to 2dp\r
-\r
- push (@loop1, \%rows1);\r
- }\r
- } else {\r
- ++$totalwritten;\r
- }\r
- $i++; #increment the while loop\r
- $totalpaid = $totalpaid + $payments[$i]->{'value'};\r
-}\r
-\r
-#get credits and append to the bottom of payments\r
-my @credits=getcredits($date,$date2);\r
-\r
-my $count=@credits;\r
-my $i=0;\r
-\r
-while ($i<$count ){\r
-\r
- my %rows2 = (creditbranch => $credits[$i]->{'branchcode'},\r
- creditdate => $credits[$i]->{'date'},\r
- creditsurname => $credits[$i]->{'surname'},\r
- creditfirstname => $credits[$i]->{'firstname'},\r
- creditdescription => $credits[$i]->{'description'},\r
- creditaccounttype => $credits[$i]->{'accounttype'},\r
- creditamount => sprintf("%.2f", $credits[$i]->{'amount'})\r
- );\r
-\r
- push (@loop2, \%rows2);\r
- $i++; #increment the while loop\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
-$template->param( loop1 => \@loop1,\r
- loop2 => \@loop2,\r
- totalpaid => $totalpaid,\r
- totalcredits => $totalcredits,\r
- totalwritten => $totalwritten );\r
-\r
-output_html_with_http_headers $input, $cookie, $template->output;\r
-\r