diff --git a/C4/Stats.pm b/C4/Stats.pm index d5833f0..f2c7a39 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -13,7 +13,8 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&UpdateStats &statsreport &Count &Overdues &TotalOwing); +@EXPORT = qw(&UpdateStats &statsreport &Count &Overdues &TotalOwing +&TotalPaid); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -129,7 +130,7 @@ sub TotalOwing{ my $dbh=C4Connect; my $query="Select sum(amountoutstanding) from accountlines"; if ($type eq 'fine'){ - $query=$query." where accounttype='F'"; + $query=$query." where accounttype='F' or accounttype='FN'"; } my $sth=$dbh->prepare($query); $sth->execute; @@ -139,6 +140,20 @@ sub TotalOwing{ return($total->{'sum'}); } +sub TotalPaid { + my ($time)=@_; + my $dbh=C4Connect; + my $query="Select sum(amount) from accountlines where accounttype='Pay'"; + if ($time eq 'today'){ + $query=$query." and datetime(date::date) >= datetime('yesterday'::date)"; + } + my $sth=$dbh->prepare($query); + $sth->execute; + my $total=$sth->fetchrow_hashref; + $sth->finish; + $dbh->disconnect; + return($total->{'sum'}); +} END { } # module clean-up code here (global destructor) diff --git a/countowing.pl b/countowing.pl index 7c5faec..6a3e6be 100755 --- a/countowing.pl +++ b/countowing.pl @@ -9,4 +9,5 @@ use CGI; my $input=new CGI; print $input->header; my $count=TotalOwing('fine'); +$count=$count*1; print $count; diff --git a/countpaid.pl b/countpaid.pl new file mode 100755 index 0000000..b4569c1 --- /dev/null +++ b/countpaid.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +#script to keep total of number of issues; + +use C4::Output; +use C4::Stats; +use CGI; + +my $input=new CGI; +print $input->header; +my $count=TotalPaid('today'); +$count=$count*-1; +print $count;