5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
25 use vars qw($VERSION @ISA @EXPORT);
27 # set the version for version checking
28 $VERSION = $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
29 shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
34 C4::Stats - Update Koha statistics (log)
42 The C<&UpdateStats> function adds an entry to the statistics table in
43 the Koha database, which acts as an activity log.
59 &UpdateStats($branch, $type, $value, $other, $itemnumber,
60 $itemtype, $borrowernumber);
62 Adds a line to the statistics table of the Koha database. In effect,
65 C<$branch>, C<$type>, C<$value>, C<$other>, C<$itemnumber>,
66 C<$itemtype>, and C<$borrowernumber> correspond to the fields of the
67 statistics table in the Koha database.
74 #module to insert stats data into stats table
77 $amount, $other, $itemnum,
78 $itemtype, $borrowernumber
81 my $dbh = C4::Context->dbh;
82 # FIXME - Use $dbh->do() instead
83 my $sth = $dbh->prepare(
84 "Insert into statistics (datetime,branch,type,value,
85 other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?)"
88 $branch, $type, $amount,
89 $other, $itemnum, $itemtype, $borrowernumber,
94 # Otherwise, it'd need a POD.
96 my ( $time, $time2, $spreadsheet ) = @_;
97 $time2 = $time unless $time2;
98 my $dbh = C4::Context->dbh;
99 my $query = "SELECT * FROM statistics,borrowers
100 WHERE statistics.borrowernumber= borrowers.borrowernumber
101 AND (statistics.type='payment' OR statistics.type='writeoff') ";
102 if ( $time eq 'today' ) {
103 $query = $query . " AND datetime = now()";
106 $query .= " AND datetime > '$time'";
108 if ( $time2 ne '' ) {
109 $query .= " AND datetime < '$time2'";
112 $query .= " ORDER BY branch, type";
114 my $sth = $dbh->prepare($query);
117 while ( my $data = $sth->fetchrow_hashref ) {
118 push @results, $data;
131 Koha Developement team <info@koha.org>