Browse Source

more reports

master
chris 25 years ago
parent
commit
9edc07b061
  1. 19
      C4/Stats.pm
  2. 1
      countowing.pl
  3. 13
      countpaid.pl

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

1
countowing.pl

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

@ -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;
Loading…
Cancel
Save