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
31 use C4
::Interface
::CGI
::Output
;
37 my $time=$input->param('time');
39 my ($template, $loggedinuser, $cookie)
40 = get_template_and_user
({template_name
=> "stats.tmpl",
44 flagsrequired
=> {borrowers
=> 1},
50 if ($time eq 'yesterday'){
51 $date=ParseDate
('yesterday');
52 $date2=ParseDate
('today');
54 if ($time eq 'today'){
55 $date=ParseDate
('today');
56 $date2=ParseDate
('tomorrow');
58 if ($time eq 'daybefore'){
59 $date=ParseDate
('2 days ago');
60 $date2=ParseDate
('yesterday');
63 $date=ParseDate
($time);
64 $date2=ParseDateDelta
('+ 1 day');
65 $date2=DateCalc
($date,$date2);
67 $date=UnixDate
($date,'%Y-%m-%d');
68 $date2=UnixDate
($date2,'%Y-%m-%d');
69 my @payments=TotalPaid
($date);
78 my $time=$payments[$i]{'datetime'};
79 my $payments=$payments[$i]{'value'};
81 my @temp=split(/ /,$payments[$i]{'datetime'});
83 my @charges=getcharges
($payments[$i]{'borrowernumber'},$payments[$i]{'timestamp'});
90 for (my $i2=0;$i2<$count;$i2++){
91 $charge+=$charges[$i2]->{'amount'};
92 %row = ( name
=> $charges[$i2]->{'description'},
93 type
=> $charges[$i2]->{'accounttype'},
94 time => $charges[$i2]->{'timestamp'},
95 amount
=> $charges[$i2]->{'amount'},
96 branch
=> $charges[$i2]->{'amountoutstanding'} );
98 if ($payments[$i]{'accountytpe'} ne 'W'){
99 if ($charges[$i2]->{'accounttype'} eq 'Rent'){
100 $temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
102 if ($charges[$i2]->{'accounttype'} eq 'F' || $charges[$i2]->{'accounttype'} eq 'FU' || $charges[$i2]->{'accounttype'} eq 'FN' ){
103 $temptotalf+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
105 if ($charges[$i2]->{'accounttype'} eq 'Res'){
106 $temptotalres+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
108 if ($charges[$i2]->{'accounttype'} eq 'R'){
109 $temptotalren+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
114 my $hour=substr($payments[$i]{'timestamp'},8,2);
115 my $min=substr($payments[$i]{'timestamp'},10,2);
116 my $sec=substr($payments[$i]{'timestamp'},12,2);
117 my $time="$hour:$min:$sec";
118 my $time2="$payments[$i]{'date'}";
119 my $branch=Getpaidbranch
($time2,$payments[$i]{'borrowernumber'});
120 my $bornum=$payments[$i]{'borrowernumber'};
121 my $oldtime=$payments[$i]{'timestamp'};
122 my $oldtype=$payments[$i]{'accounttype'};
123 while ($bornum eq $payments[$i]{'borrowernumber'} && $oldtype == $payments[$i]{'accounttype'} && $oldtime eq $payments[$i]{'timestamp'}){
124 my $hour=substr($payments[$i]{'timestamp'},8,2);
125 my $min=substr($payments[$i]{'timestamp'},10,2);
126 my $sec=substr($payments[$i]{'timestamp'},12,2);
127 my $time="$hour:$min:$sec";
128 my $time2="$payments[$i]{'date'}";
129 my $branch=Getpaidbranch
($time2,$payments[$i]{'borrowernumber'});
131 if ($payments[$i]{'accounttype'} eq 'W'){
132 $totalw+=$payments[$i]{'amount'};
134 $payments[$i]{'amount'}=$payments[$i]{'amount'}*-1;
135 $total+=$payments[$i]{'amount'};
138 %row = ( name
=> $payments[$i]{'firstname'} . " <b>" . $payments[$i]{'surname'} . "</b>",
139 type
=> $payments[$i]{'accounttype'},
140 time => $payments[$i]{'date'},
141 amount
=> $payments[$i]{'amount'},
146 $oldtype=$payments[$i]{'accounttype'};
147 $oldtime=$payments[$i]{'timestamp'};
148 $bornum=$payments[$i]{'borrowernumber'};
154 $template->param( loop => \
@loop,
158 output_html_with_http_headers
$input, $cookie, $template->output;