koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4 Stats.pm


From: Antoine Farnault
Subject: [Koha-cvs] koha/C4 Stats.pm
Date: Tue, 05 Jun 2007 10:01:17 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Antoine Farnault <toins>        07/06/05 10:01:17

Modified files:
        C4             : Stats.pm 

Log message:
        re introducing TotalPaid function as circ/stat.pl use it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Stats.pm?cvsroot=koha&r1=1.32&r2=1.33

Patches:
Index: Stats.pm
===================================================================
RCS file: /sources/koha/koha/C4/Stats.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- Stats.pm    22 May 2007 09:13:55 -0000      1.32
+++ Stats.pm    5 Jun 2007 10:01:17 -0000       1.33
@@ -1,6 +1,6 @@
 package C4::Stats;
 
-# $Id: Stats.pm,v 1.32 2007/05/22 09:13:55 tipaul Exp $
+# $Id: Stats.pm,v 1.33 2007/06/05 10:01:17 toins Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -21,12 +21,11 @@
 
 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: 1.32 $' =~ /\d+/g;
+$VERSION = $VERSION = do { my @v = '$Revision: 1.33 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -50,7 +49,10 @@
 =cut
 
 @ISA    = qw(Exporter);
address@hidden = qw(&UpdateStats);
address@hidden = qw(
+    &UpdateStats
+    &TotalPaid
+);
 
 =item UpdateStats
 
@@ -89,6 +91,36 @@
     $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,borrowers
+  WHERE statistics.borrowernumber= borrowers.borrowernumber
+  AND (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__
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]