circulation cleaning continued: working on branchtransfers.pl (unfinished, but at...
[koha_gimpoz] / C4 / Stats.pm
1 package C4::Stats;
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
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
12 # version.
13 #
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.
17 #
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
21
22 use strict;
23 require Exporter;
24 use DBI;
25 use C4::Context;
26 use vars qw($VERSION @ISA @EXPORT);
27
28 # set the version for version checking
29 $VERSION = $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
30     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
31 };
32
33 =head1 NAME
34
35 C4::Stats - Update Koha statistics (log)
36
37 =head1 SYNOPSIS
38
39   use C4::Stats;
40
41 =head1 DESCRIPTION
42
43 The C<&UpdateStats> function adds an entry to the statistics table in
44 the Koha database, which acts as an activity log.
45
46 =head1 FUNCTIONS
47
48 =over 2
49
50 =cut
51
52 @ISA    = qw(Exporter);
53 @EXPORT = qw(&UpdateStats);
54
55 =item UpdateStats
56
57   &UpdateStats($env, $branch, $type, $value, $other, $itemnumber,
58                $itemtype, $borrowernumber);
59
60 Adds a line to the statistics table of the Koha database. In effect,
61 it logs an event.
62
63 C<$branch>, C<$type>, C<$value>, C<$other>, C<$itemnumber>,
64 C<$itemtype>, and C<$borrowernumber> correspond to the fields of the
65 statistics table in the Koha database.
66
67 If C<$branch> is the empty string, the branch code will be taken from
68 C<$env-E<gt>{branchcode}>.
69
70 C<$env-E<gt>{usercode}> specifies the value of the C<usercode> field.
71
72 =cut
73
74 #'
75 sub UpdateStats {
76
77     #module to insert stats data into stats table
78     my (
79         $branch,         $type,
80         $amount,   $other,          $itemnum,
81         $itemtype, $borrowernumber
82       )
83       = @_;
84     my $dbh = C4::Context->dbh;
85     # FIXME - Use $dbh->do() instead
86     my $sth = $dbh->prepare(
87         "Insert into statistics (datetime,branch,type,value,
88                                         other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?,?)"
89     );
90     $sth->execute(
91         $branch,    $type,    $amount,
92         $other,     $itemnum, $itemtype, $borrowernumber,
93     );
94     $sth->finish;
95 }
96
97 1;
98 __END__
99
100 =back
101
102 =head1 AUTHOR
103
104 Koha Developement team <info@koha.org>
105
106 =cut
107