more reports

This commit is contained in:
chris 1999-11-12 01:46:43 +00:00
parent 9faad76fad
commit 9edc07b061
3 changed files with 31 additions and 2 deletions

View file

@ -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)

View file

@ -9,4 +9,5 @@ use CGI;
my $input=new CGI;
print $input->header;
my $count=TotalOwing('fine');
$count=$count*1;
print $count;

13
countpaid.pl Executable file
View file

@ -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;