include quantityrecieved in the code passed to template.
[koha_gimpoz] / stats2.pl
index 5464597..8944b02 100755 (executable)
--- a/stats2.pl
+++ b/stats2.pl
@@ -1,15 +1,35 @@
 #!/usr/bin/perl
 
+# $Id$
+
 #written 14/1/2000
 #script to display reports
 
-use C4::Stats;
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
+use C4::Context;
+use C4::Stats;
 use Date::Manip;
 use CGI;
 use C4::Output;
 use DBI;
-use C4::Database;
 
 my $input=new CGI;
 my $time=$input->param('time');
@@ -41,12 +61,12 @@ if ($time=~ /\//){
 $date=UnixDate($date,'%Y-%m-%d');
 $date2=UnixDate($date2,'%Y-%m-%d');
 
-my $dbh=C4Connect;
-my $query="select * 
+my $dbh = C4::Context->dbh;
+my $query="select *
 from accountlines,accountoffsets,borrowers where
 accountlines.borrowernumber=accountoffsets.borrowernumber and
 (accountlines.accountno=accountoffsets.accountno or accountlines.accountno
-=accountoffsets.offsetaccount) and accountlines.timestamp >=20000621000000 
+=accountoffsets.offsetaccount) and accountlines.timestamp >=20000621000000
 and borrowers.borrowernumber=accountlines.borrowernumber
 group by accountlines.borrowernumber,accountlines.accountno";
 my $sth=$dbh->prepare($query);
@@ -58,7 +78,7 @@ print mktablehdr;
 while (my $data=$sth->fetchrow_hashref){
   print "<TR><Td>$data->{'surname'}</td><td>$data->{'description'}</td><td>$data->{'amount'}
   </td>";
-  if ($data->{'accountype'}='Pay'){
+  if ($data->{'accountype'}='Pay'){    # FIXME - This should be "==", not "=", right?
     my $branch=Getpaidbranch($data->{'timestamp'});
     print "<td>$branch</td>";
   }
@@ -76,4 +96,3 @@ print endcenter;
 print endmenu('report');
 print endpage;
 $sth->finish;
-$dbh->disconnect;