telling the user what stopwords have been removed from the
[koha_fer] / C4 / Stats.pm
index 0ff9059..6c2be74 100644 (file)
@@ -1,6 +1,5 @@
 package C4::Stats;
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -21,14 +20,11 @@ package C4::Stats;
 
 use strict;
 require Exporter;
-use DBI;
 use C4::Context;
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
-    shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
-};
+$VERSION = 3.00;
 
 =head1 NAME
 
@@ -50,7 +46,10 @@ the Koha database, which acts as an activity log.
 =cut
 
 @ISA    = qw(Exporter);
-@EXPORT = qw(&UpdateStats);
+@EXPORT = qw(
+    &UpdateStats
+    &TotalPaid
+);
 
 =item UpdateStats
 
@@ -80,7 +79,7 @@ sub UpdateStats {
     # FIXME - Use $dbh->do() instead
     my $sth = $dbh->prepare(
         "Insert into statistics (datetime,branch,type,value,
-                                        other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?,?)"
+                                        other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?)"
     );
     $sth->execute(
         $branch,    $type,    $amount,
@@ -89,6 +88,36 @@ sub UpdateStats {
     $sth->finish;
 }
 
+# Otherwise, it'd need a POD.
+sub TotalPaid {
+    my ( $time, $time2, $spreadsheet ) = @_;
+    $time2 = $time unless $time2;
+    my $dbh   = C4::Context->dbh;
+    my $query = "SELECT * FROM statistics 
+  LEFT JOIN borrowers ON statistics.borrowernumber= borrowers.borrowernumber
+  WHERE (statistics.type='payment' OR statistics.type='writeoff') ";
+    if ( $time eq 'today' ) {
+        $query = $query . " AND datetime = now()";
+    }
+    else {
+        $query .= " AND datetime > '$time'";
+    }
+    if ( $time2 ne '' ) {
+        $query .= " AND datetime < '$time2'";
+    }
+    if ($spreadsheet) {
+        $query .= " ORDER BY branch, type";
+    }
+    my $sth = $dbh->prepare($query);
+    $sth->execute();
+    my @results;
+    while ( my $data = $sth->fetchrow_hashref ) {
+        push @results, $data;
+    }
+    $sth->finish;
+    return (@results);
+}
+
 1;
 __END__