4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
24 use vars
qw($VERSION @ISA @EXPORT);
27 # set the version for version checking
39 C4::Stats - Update Koha statistics (log)
47 The C<&UpdateStats> function adds an entry to the statistics table in
48 the Koha database, which acts as an activity log.
56 &UpdateStats($branch, $type, $value, $other, $itemnumber,
57 $itemtype, $borrowernumber);
59 Adds a line to the statistics table of the Koha database. In effect,
62 C<$branch>, C<$type>, C<$value>, C<$other>, C<$itemnumber>,
63 C<$itemtype>, and C<$borrowernumber> correspond to the fields of the
64 statistics table in the Koha database.
71 #module to insert stats data into stats table
74 $amount, $other, $itemnum,
75 $itemtype, $borrowernumber, $accountno
78 my $dbh = C4
::Context
->dbh;
79 my $sth = $dbh->prepare(
80 "INSERT INTO statistics (datetime,branch,type,value,
81 other,itemnumber,itemtype,borrowernumber,proccode) VALUES (now(),?,?,?,?,?,?,?,?)"
84 $branch, $type, $amount,
85 $other, $itemnum, $itemtype, $borrowernumber,
91 # Otherwise, it'd need a POD.
93 my ( $time, $time2, $spreadsheet ) = @_;
94 $time2 = $time unless $time2;
95 my $dbh = C4
::Context
->dbh;
96 my $query = "SELECT * FROM statistics
97 LEFT JOIN borrowers ON statistics.borrowernumber= borrowers.borrowernumber
98 WHERE (statistics.type='payment' OR statistics.type='writeoff') ";
99 if ( $time eq 'today' ) {
100 $query = $query . " AND datetime = now()";
103 $query .= " AND datetime > '$time'";
105 if ( $time2 ne '' ) {
106 $query .= " AND datetime < '$time2'";
109 $query .= " ORDER BY branch, type";
111 my $sth = $dbh->prepare($query);
115 while ( my $data = $sth->fetchrow_hashref ) {
116 push @results, $data;
129 Koha Developement team <info@koha.org>