4 #script to display reports
13 my $time=$input->param('time');
17 print startmenu
('report');
22 if ($time eq 'yesterday'){
23 $date=ParseDate
('yesterday');
24 $date2=ParseDate
('today');
26 if ($time eq 'today'){
27 $date=ParseDate
('today');
28 $date2=ParseDate
('tomorrow');
30 if ($time eq 'daybefore'){
31 $date=ParseDate
('2 days ago');
32 $date2=ParseDate
('yesterday');
35 $date=ParseDate
($time);
36 $date2=ParseDateDelta
('+ 1 day');
37 $date2=DateCalc
($date,$date2);
39 $date=UnixDate
($date,'%Y-%m-%d');
40 $date2=UnixDate
($date2,'%Y-%m-%d');
41 my @payments=TotalPaid
($date);
51 print mktablerow
(5,'#99cc33',bold
('Name'),bold
('Type'),bold
('Date/time'),bold
('Amount'), bold
('Branch'),'/images/background-mem.gif');
54 my $time=$payments[$i]{'datetime'};
55 my $payments=$payments[$i]{'value'};
57 my @temp=split(/ /,$payments[$i]{'datetime'});
59 my @charges=getcharges
($payments[$i]{'borrowernumber'},$payments[$i]{'timestamp'});
66 for (my $i2=0;$i2<$count;$i2++){
67 $charge+=$charges[$i2]->{'amount'};
68 print mktablerow
(6,'red',$charges[$i2]->{'description'},$charges[$i2]->{'accounttype'},$charges[$i2]->{'timestamp'},
69 $charges[$i2]->{'amount'},$charges[$i2]->{'amountoutstanding'});
70 if ($payments[$i]{'accountytpe'} ne 'W'){
71 if ($charges[$i2]->{'accounttype'} eq 'Rent'){
72 $temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
74 if ($charges[$i2]->{'accounttype'} eq 'F' || $charges[$i2]->{'accounttype'} eq 'FU' || $charges[$i2]->{'accounttype'} eq 'FN' ){
75 $temptotalf+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
77 if ($charges[$i2]->{'accounttype'} eq 'Res'){
78 $temptotalres+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
80 if ($charges[$i2]->{'accounttype'} eq 'R'){
81 $temptotalren+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
87 my $hour=substr($payments[$i]{'timestamp'},8,2);
88 my $min=substr($payments[$i]{'timestamp'},10,2);
89 my $sec=substr($payments[$i]{'timestamp'},12,2);
90 my $time="$hour:$min:$sec";
91 my $time2="$payments[$i]{'date'}";
92 my $branch=Getpaidbranch
($time2,$payments[$i]{'borrowernumber'});
94 $levin{'totalf'}+=$temptotalf;
95 $levin{'totalres'}+=$temptotalres;
96 $levin{'totalren'}+=$temptotalren;
97 $levin{'totalr'}+=$temptotalr;
98 } elsif ($branch eq 'F'){
99 $foxton{'totalf'}+=$temptotalf;
100 $foxton{'totalres'}+=$temptotalres;
101 $foxton{'totalren'}+=$temptotalren;
102 $foxton{'totalr'}+=$temptotalr;
103 } elsif ($branch eq 'S'){
104 $shannon{'totalf'}+=$temptotalf;
105 $shannon{'totalres'}+=$temptotalres;
106 $shannon{'totalren'}+=$temptotalren;
107 $shannon{'totalr'}+=$temptotalr;
109 my $bornum=$payments[$i]{'borrowernumber'};
110 my $oldtime=$payments[$i]{'timestamp'};
111 my $oldtype=$payments[$i]{'accounttype'};
112 while ($bornum eq $payments[$i]{'borrowernumber'} && $oldtype == $payments[$i]{'accounttype'} && $oldtime eq $payments[$i]{'timestamp'}){
113 my $hour=substr($payments[$i]{'timestamp'},8,2);
114 my $min=substr($payments[$i]{'timestamp'},10,2);
115 my $sec=substr($payments[$i]{'timestamp'},12,2);
116 my $time="$hour:$min:$sec";
117 my $time2="$payments[$i]{'date'}";
118 my $branch=Getpaidbranch
($time2,$payments[$i]{'borrowernumber'});
120 if ($payments[$i]{'accounttype'} eq 'W'){
121 $totalw+=$payments[$i]{'amount'};
123 $payments[$i]{'amount'}=$payments[$i]{'amount'}*-1;
124 $total+=$payments[$i]{'amount'};
126 $levin{'total'}+=$payments[$i]{'amount'};
129 $foxton{'total'}+=$payments[$i]{'amount'};
132 $shannon{'total'}+=$payments[$i]{'amount'};
136 # my $time2="$payments[$i]{'date'} $time";
139 print mktablerow
(6,'white',"$payments[$i]{'firstname'} <b>$payments[$i]{'surname'}</b>",
140 ,$payments[$i]{'accounttype'},"$payments[$i]{'date'} $time",$payments[$i]{'amount'}
142 $oldtype=$payments[$i]{'accounttype'};
143 $oldtime=$payments[$i]{'timestamp'};
144 $bornum=$payments[$i]{'borrowernumber'};
148 print mktablerow
('6','white','','','','','','');
152 #$totalw=$totalw * -1;
153 print "<p><b>Total Paid $total</b>";
154 print "<br><b>total written off $totalw</b>";
156 $levin{'issues'}=Count
('issue','C',$date,$date2);
157 $foxton{'issues'}=Count
('issue','F',$date,$date2);
158 $shannon{'issues'}=Count
('issue','S',$date,$date2);
159 $levin{'returns'}=Count
('return','C',$date,$date2);
160 $foxton{'returns'}=Count
('return','F',$date,$date2);
161 $shannon{'returns'}=Count
('return','S',$date,$date2);
162 $levin{'renewals'}=Count
('renew','C',$date,$date2);
163 $foxton{'renewals'}=Count
('renew','F',$date,$date2);
164 $shannon{'renewals'}=Count
('renew','S',$date,$date2);
165 $levin{'unknown'}=$levin{'total'}-($levin{'totalf'}+$levin{'totalr'}+$levin{'totalres'}+$levin{'totalren'});
166 $foxton{'unknown'}=$foxton{'total'}-($foxton{'totalf'}+$foxton{'totalr'}+$foxton{'totalres'}+$foxton{'totalren'});
167 $foxton{'unknown'}=$foxton{'total'}-($foxton{'totalf'}+$foxton{'totalr'}+$foxton{'totalres'}+$foxton{'totalren'});
168 print mktablerow
(10,'white',"<b>Levin</b>","Fines $levin{'totalf'}","Rental Charges $levin{'totalr'}",
169 "Reserve Charges $levin{'totalres'}","Renewal Charges $levin{'totalren'}","Unknown $levin{'unknown'}","<b>Total $levin{'total'}</b>",
170 "Issues $levin{'issues'}","Renewals $levin{'renewals'}","Returns $levin{'returns'}");
171 print mktablerow
(10,'white',"<b>foxton</b>","Fines $foxton{'totalf'}","Rental Charges $foxton{'totalr'}","Reserve Charges $foxton{'totalres'}","Renewal Charges $foxton{'totalren'}","Unknown $foxton{'unknown'}","<b>Total $foxton{'total'}</b>",
172 "Issues $foxton{'issues'}","Renewals $foxton{'renewals'}","Returns $foxton{'returns'}");
173 print mktablerow
(10,'white',"<b>shannon</b>","Fines $shannon{'totalf'}","Rental Charges $shannon{'totalr'}","Reserve Charges $shannon{'totalres'}","Renewal Charges $shannon{'totalren'}","Unknown $shannon{'unknown'}","<b>Total $shannon{'total'}</b>",
174 "Issues $shannon{'issues'}","Renewals $shannon{'renewals'}","Returns $shannon{'returns'}");
178 print endmenu
('report');