fixing stats.pl that was not working + updating templates

This commit is contained in:
tipaul 2006-05-12 09:35:42 +00:00
parent f6e217ef37
commit fa94e5bd75
3 changed files with 26 additions and 24 deletions

View File

@ -91,7 +91,7 @@ sub TotalPaid {
my ($time,$time2)=@_;
$time2=$time unless $time2;
my $dbh = C4::Context->dbh;
my $query="Select * from accountlines,borrowers where (accounttype = 'Pay' or accounttype ='W')
my $query="Select * from accountlines,borrowers where (accounttype = 'Pay' or accounttype ='W' or accounttype='C')
and accountlines.borrowernumber = borrowers.borrowernumber";
my @bind = ();
if ($time eq 'today'){
@ -109,14 +109,12 @@ sub TotalPaid {
# $query.=" and datetime > '$time'";
# }
$query.=" order by timestamp";
# print $query;
warn $query;
my $sth=$dbh->prepare($query);
$sth->execute(@bind);
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
push @results,$data;
}
$sth->finish;
# print $query;

View File

@ -1,16 +1,20 @@
<!-- TMPL_INCLUDE NAME="reports-top.inc" -->
<div id="mainbloc">
<table border="0" cellspacing="0" cellpadding="5" align="center">
<tr bgcolor="#99cc33">
<td background="/images/background-mem.gif"><b>Name</b></td>
<td background="/images/background-mem.gif"><b>Type</b></td>
<td background="/images/background-mem.gif"><b>Date/time</b></td>
<td background="/images/background-mem.gif"><b>Amount</b></td>
<td background="/images/background-mem.gif"><b>Branch</b></td>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Date/time</th>
<th>Amount</th>
<th>Branch</th>
<tr>
<!-- TMPL_LOOP NAME=loop1 -->
<tr>
<td><!-- TMPL_VAR NAME="name" --></td>
<td><!-- TMPL_VAR NAME="description" --></td>
<td><!-- TMPL_VAR NAME="type" --></td>
<td><!-- TMPL_VAR NAME="time" --></td>
<td><!-- TMPL_VAR NAME="amount" --></td>
@ -26,6 +30,5 @@
<b>Total written off: <!-- TMPL_VAR NAME="totalw" --></b>
</p>
<!-- TMPL_INCLUDE NAME="reports-bottom.inc" -->
</body>
</html>
</div>
<!-- TMPL_INCLUDE NAME="reports-bottom.inc" -->

View File

@ -78,10 +78,10 @@ my $total=0;
my $oldtime;
my $totalw=0;
my @loop;
my %row;
my $i=0;
# parse all lines for today
while ($i<$count){
warn " pay : ".$payments[$i]{'timestamp'};
# warn " pay : ".$payments[$i]{'timestamp'};
my $time=$payments[$i]{'datetime'};
my $payments=$payments[$i]{'value'};
my $charge=0;
@ -95,13 +95,14 @@ while ($i<$count){
my $temptotalren=0;
my $temptotalw=0;
for (my $i2=0;$i2<$count;$i2++){
# warn "I2 : $i2 i=$i";
$charge+=$charges[$i2]->{'amount'};
%row = ( name => $charges[$i2]->{'description'},
type => $charges[$i2]->{'accounttype'},
time => $charges[$i2]->{'timestamp'},
amount => $charges[$i2]->{'amount'},
branch => $charges[$i2]->{'amountoutstanding'} );
push(@loop, \%row);
# %row = ( name => $charges[$i2]->{'description'},
# type => $charges[$i2]->{'accounttype'},
# time => $charges[$i2]->{'timestamp'},
# amount => $charges[$i2]->{'amount'},
# branch => $charges[$i2]->{'amountoutstanding'} );
# push(@loop, \%row);
if ($payments[$i]{'accountytpe'} ne 'W'){
if ($charges[$i2]->{'accounttype'} eq 'Rent'){
$temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
@ -139,10 +140,10 @@ while ($i<$count){
$payments[$i]{'amount'}=$payments[$i]{'amount'}*-1;
$total+=$payments[$i]{'amount'};
}
%row = ( name => "<b>".$payments[$i]{'firstname'}.$payments[$i]{'surname'} . "</b>",
my %row = ( name => "<b>".$payments[$i]{'firstname'}.' '.$payments[$i]{'surname'} . "</b>",
type => $payments[$i]{'accounttype'}, time => $payments[$i]{'date'},
amount => $payments[$i]{'amount'}, branch => $branch );
amount => $payments[$i]{'amount'}, branch => $branch,
description => $payments[$i]{'description'});
push(@loop, \%row);
$oldtype=$payments[$i]{'accounttype'};
$oldtime=$payments[$i]{'timestamp'};