6 #script to display reports
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
30 use C4::Interface::CGI::Output;
36 my $time=$input->param('time');
37 my $date=$input->param('from');
38 my $date2=$input->param('to');
39 my ($template, $loggedinuser, $cookie)
40 = get_template_and_user({template_name => "stats.tmpl",
44 flagsrequired => {borrowers => 1},
50 my @payments=TotalPaid($date,$date2);
59 # warn " pay : ".$payments[$i]{'timestamp'};
60 my $time=$payments[$i]{'datetime'};
61 my $payments=$payments[$i]{'value'};
63 my @temp=split(/ /,$payments[$i]{'datetime'});
64 my $date=$payments[$i]{'date'};
66 my @charges=getcharges($payments[$i]{'borrowernumber'},$payments[$i]{'date'});
74 for (my $i2=0;$i2<$count2;$i2++){
75 $charge+=$charges[$i2]->{'amount'};
76 %row = ( name => $charges[$i2]->{'description'},
77 type => $charges[$i2]->{'accounttype'},
78 time => $charges[$i2]->{'timestamp'},
79 amount => $charges[$i2]->{'amount'},
80 branch => $charges[$i2]->{'amountoutstanding'} );
82 if ($payments[$i]{'accountytpe'} ne 'W'){
83 if ($charges[$i2]->{'accounttype'} eq 'Rent'){
84 $temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
86 if ($charges[$i2]->{'accounttype'} eq 'F' || $charges[$i2]->{'accounttype'} eq 'FU' || $charges[$i2]->{'accounttype'} eq 'FN' ){
87 $temptotalf+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
89 if ($charges[$i2]->{'accounttype'} eq 'Res'){
90 $temptotalres+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
92 if ($charges[$i2]->{'accounttype'} eq 'R'){
93 $temptotalren+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
97 my $hour=substr($payments[$i]{'timestamp'},8,2);
98 my $min=substr($payments[$i]{'timestamp'},10,2);
99 my $sec=substr($payments[$i]{'timestamp'},12,2);
100 my $time="$hour:$min:$sec";
101 my $time2="$payments[$i]{'date'}";
102 my $branch=Getpaidbranch($time2,$payments[$i]{'borrowernumber'});
103 my $bornum=$payments[$i]{'borrowernumber'};
104 my $oldtime=$payments[$i]{'timestamp'};
105 my $oldtype=$payments[$i]{'accounttype'};
106 while ($bornum eq $payments[$i]{'borrowernumber'} && $oldtype == $payments[$i]{'accounttype'} && $oldtime eq $payments[$i]{'timestamp'}){
107 my $hour=substr($payments[$i]{'timestamp'},8,2);
108 my $min=substr($payments[$i]{'timestamp'},10,2);
109 my $sec=substr($payments[$i]{'timestamp'},12,2);
110 my $time="$hour:$min:$sec";
111 my $time2="$payments[$i]{'date'}";
112 my $branch=Getpaidbranch($time2,$payments[$i]{'borrowernumber'});
113 if ($payments[$i]{'accounttype'} eq 'W'){
114 $totalw+=$payments[$i]{'amount'};
116 $payments[$i]{'amount'}=$payments[$i]{'amount'}*-1;
117 $total+=$payments[$i]{'amount'};
120 %row = ( name => "<b>".$payments[$i]{'firstname'}.$payments[$i]{'surname'} . "</b>",
121 type => $payments[$i]{'accounttype'}, time => $payments[$i]{'date'},
122 amount => $payments[$i]{'amount'}, branch => $branch );
124 $oldtype=$payments[$i]{'accounttype'};
125 $oldtime=$payments[$i]{'timestamp'};
126 $bornum=$payments[$i]{'borrowernumber'};
132 $template->param( loop1 => \@loop,
136 output_html_with_http_headers $input, $cookie, $template->output;