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
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use vars
qw($VERSION @ISA @EXPORT);
31 # set the version for version checking
43 C4::Stats - Update Koha statistics (log)
51 The C<&UpdateStats> function adds an entry to the statistics table in
52 the Koha database, which acts as an activity log.
60 &UpdateStats($branch, $type, $value, $other, $itemnumber,
61 $itemtype, $borrowernumber);
63 Adds a line to the statistics table of the Koha database. In effect,
66 C<$branch>, C<$type>, C<$value>, C<$other>, C<$itemnumber>,
67 C<$itemtype>, and C<$borrowernumber> correspond to the fields of the
68 statistics table in the Koha database.
75 #module to insert stats data into stats table
78 $amount, $other, $itemnum,
79 $itemtype, $borrowernumber, $accountno
82 my $dbh = C4
::Context
->dbh;
83 my $sth = $dbh->prepare(
84 "INSERT INTO statistics
85 (datetime, branch, type, value,
86 other, itemnumber, itemtype, borrowernumber, proccode)
87 VALUES (now(),?,?,?,?,?,?,?,?)"
90 $branch, $type, $amount,
91 $other, $itemnum, $itemtype, $borrowernumber,
96 # Otherwise, it'd need a POD.
98 my ( $time, $time2, $spreadsheet ) = @_;
99 $time2 = $time unless $time2;
100 my $dbh = C4
::Context
->dbh;
101 my $query = "SELECT * FROM statistics
102 LEFT JOIN borrowers ON statistics.borrowernumber= borrowers.borrowernumber
103 WHERE (statistics.type='payment' OR statistics.type='writeoff') ";
104 if ( $time eq 'today' ) {
105 $query .= " AND datetime = now()";
107 $query .= " AND datetime > '$time'"; # FIXME: use placeholders
109 if ( $time2 ne '' ) {
110 $query .= " AND datetime < '$time2'"; # FIXME: use placeholders
113 $query .= " ORDER BY branch, type";
115 $debug and warn "TotalPaid query: $query";
116 my $sth = $dbh->prepare($query);
118 return @
{$sth->fetchall_arrayref({})};
128 Koha Development Team <http://koha-community.org/>