From 78418007fe8eb89dbfe915ae4e0c17d67c7dcfc5 Mon Sep 17 00:00:00 2001 From: rangi Date: Wed, 21 Feb 2001 22:27:59 +0000 Subject: [PATCH] Fixed a little glitch in the daily stats script that meant it wasnt counting renewals --- stats.pl | 65 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/stats.pl b/stats.pl index d30d9640d2..84c383d26a 100755 --- a/stats.pl +++ b/stats.pl @@ -45,7 +45,7 @@ my %levin; my %foxton; my %shannon; my $oldtime; -#my $totalc=0; +my $totalw=0; #my $totalcf=0; print mktablehdr; print mktablerow(5,'#99cc33',bold('Name'),bold('Type'),bold('Date/time'),bold('Amount'), bold('Branch'),'/images/background-mem.gif'); @@ -54,32 +54,44 @@ for (my $i=0;$i<$count;$i++){ my $min=substr($payments[$i]{'timestamp'},10,2); my $sec=substr($payments[$i]{'timestamp'},12,2); my $time="$hour:$min:$sec"; - $payments[$i]{'amount'}*=-1; - $total+=$payments[$i]{'amount'}; + if ($payments[$i]{'accounttype'} ne 'W'){ + $payments[$i]{'amount'}*=-1; + $total+=$payments[$i]{'amount'}; + } + my @charges=getcharges($payments[$i]{'borrowernumber'},$payments[$i]{'timestamp'}); my $count=@charges; my $temptotalf=0; my $temptotalr=0; my $temptotalres=0; my $temptotalren=0; - for (my $i2=0;$i2<$count;$i2++){ + my $temptotalw=0; + + + for (my $i2=0;$i2<$count;$i2++){ if ($charges[$i2]->{'amountoutstanding'} != $oldtime){ - print mktablerow(6,'red',$charges[$i2]->{'description'},$charges[$i2]->{'accounttype'},'', - $charges[$i2]->{'amount'},$charges[$i2]->{'amountoutstanding'}); - if ($charges[$i2]->{'accounttype'} eq 'Rent'){ - $temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; - } - if ($charges[$i2]->{'accounttype'} eq 'F' || $charges[$i2]->{'accounttype'} eq 'FU'){ - $temptotalf+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; - } - if ($charges[$i2]->{'accounttype'} eq 'Res'){ - $temptotalres+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; + print mktablerow(6,'red',$charges[$i2]->{'description'},$charges[$i2]->{'accounttype'},'', + $charges[$i2]->{'amount'},$charges[$i2]->{'amountoutstanding'}); + if ($payments[$i]{'accounttype'} ne 'W'){ +# print $payments[$i]{'accounttype'}; + if ($charges[$i2]->{'accounttype'} eq 'Rent'){ + $temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; + } + if ($charges[$i2]->{'accounttype'} eq 'F' || $charges[$i2]->{'accounttype'} eq 'FU'){ + $temptotalf+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; + } + if ($charges[$i2]->{'accounttype'} eq 'Res'){ + $temptotalres+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; + } + if ($charges[$i2]->{'accounttype'} eq 'R'){ + $temptotalren+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; + } + } } - if ($charges[$i2]->{'accounttype'} eq 'R'){ - $temptotalren+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'}; - } - } - } + } + if ($payments[$i]{'accounttype'} eq 'W'){ + $totalw+=$payments[$i]{'amount'}; + } my $time2="$payments[$i]{'date'} $time"; my $branch=Getpaidbranch($time2); $branch=~ s/Levi/C/; @@ -111,8 +123,9 @@ for (my $i=0;$i<$count;$i++){ } print mktableft; print endcenter; -print "

$total"; -#print "Total Paid $total"; +print "
total written off $totalw"; print mktablehdr; $levin{'issues'}=Count('issue','C',$date,$date2); $foxton{'issues'}=Count('issue','F',$date,$date2); @@ -120,12 +133,16 @@ $shannon{'issues'}=Count('issue','S',$date,$date2); $levin{'returns'}=Count('return','C',$date,$date2); $foxton{'returns'}=Count('return','F',$date,$date2); $shannon{'returns'}=Count('return','S',$date,$date2); +$levin{'renewals'}=Count('renew','C',$date,$date2); +$foxton{'renewals'}=Count('renew','F',$date,$date2); +$shannon{'renewals'}=Count('renew','S',$date,$date2); + print mktablerow(9,'white',"Levin","Fines $levin{'totalf'}","Rental Charges $levin{'totalr'}", -"Reserve Charges $levin{'totalres'}","Renewal Charges $levin{'totalren'}","Total $levin{'total'}", +"Reserve Charges $levin{'totalres'}","Renewal Charges $levin{'totalren'}","Total $levin{'total'}", "Issues $levin{'issues'}","Renewals $levin{'renewals'}","Returns $levin{'returns'}"); -print mktablerow(9,'white',"foxton","Fines $foxton{'totalf'}","Rental Charges $foxton{'totalr'}","Reserve Charges $foxton{'totalres'}","Renewal Charges $foxton{'totalren'}","Total $foxton{'total'}", +print mktablerow(9,'white',"foxton","Fines $foxton{'totalf'}","Rental Charges $foxton{'totalr'}","Reserve Charges $foxton{'totalres'}","Renewal Charges $foxton{'totalren'}","Total $foxton{'total'}", "Issues $foxton{'issues'}","Renewals $foxton{'renewals'}","Returns $foxton{'returns'}"); -print mktablerow(9,'white',"shannon","Fines $shannon{'totalf'}","Rental Charges $shannon{'totalr'}","Reserve Charges $shannon{'totalres'}","Renewal Charges $shannon{'totalren'}","Total $shannon{'total'}", +print mktablerow(9,'white',"shannon","Fines $shannon{'totalf'}","Rental Charges $shannon{'totalr'}","Reserve Charges $shannon{'totalres'}","Renewal Charges $shannon{'totalren'}","Total $shannon{'total'}", "Issues $shannon{'issues'}","Renewals $shannon{'renewals'}","Returns $shannon{'returns'}"); print mktableft; -- 2.39.5