Continuing work on Z39.50 search tool. Daemon now forks up to 12 processes
[koha.git] / stats2.pl
blob5464597e4cbbdf0b470b325953f3ce7d93e1f0ea
1 #!/usr/bin/perl
3 #written 14/1/2000
4 #script to display reports
6 use C4::Stats;
7 use strict;
8 use Date::Manip;
9 use CGI;
10 use C4::Output;
11 use DBI;
12 use C4::Database;
14 my $input=new CGI;
15 my $time=$input->param('time');
16 print $input->header;
18 print startpage;
19 print startmenu('report');
20 print center;
22 my $date;
23 my $date2;
24 if ($time eq 'yesterday'){
25 $date=ParseDate('yesterday');
26 $date2=ParseDate('today');
28 if ($time eq 'today'){
29 $date=ParseDate('today');
30 $date2=ParseDate('tomorrow');
32 if ($time eq 'daybefore'){
33 $date=ParseDate('2 days ago');
34 $date2=ParseDate('yesterday');
36 if ($time=~ /\//){
37 $date=ParseDate($time);
38 $date2=ParseDateDelta('+ 1 day');
39 $date2=DateCalc($date,$date2);
41 $date=UnixDate($date,'%Y-%m-%d');
42 $date2=UnixDate($date2,'%Y-%m-%d');
44 my $dbh=C4Connect;
45 my $query="select *
46 from accountlines,accountoffsets,borrowers where
47 accountlines.borrowernumber=accountoffsets.borrowernumber and
48 (accountlines.accountno=accountoffsets.accountno or accountlines.accountno
49 =accountoffsets.offsetaccount) and accountlines.timestamp >=20000621000000
50 and borrowers.borrowernumber=accountlines.borrowernumber
51 group by accountlines.borrowernumber,accountlines.accountno";
52 my $sth=$dbh->prepare($query);
53 $sth->execute;
57 print mktablehdr;
58 while (my $data=$sth->fetchrow_hashref){
59 print "<TR><Td>$data->{'surname'}</td><td>$data->{'description'}</td><td>$data->{'amount'}
60 </td>";
61 if ($data->{'accountype'}='Pay'){
62 my $branch=Getpaidbranch($data->{'timestamp'});
63 print "<td>$branch</td>";
65 print "</tr>";
70 print mktableft;
71 print endcenter;
72 #print "<p><b>$total</b>";
76 print endmenu('report');
77 print endpage;
78 $sth->finish;
79 $dbh->disconnect;