add security for the item barcode
[koha.git] / 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($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 =cut
68
69 #'
70 sub UpdateStats {
71
72     #module to insert stats data into stats table
73     my (
74         $branch,         $type,
75         $amount,   $other,          $itemnum,
76         $itemtype, $borrowernumber
77       )
78       = @_;
79     my $dbh = C4::Context->dbh;
80     # FIXME - Use $dbh->do() instead
81     my $sth = $dbh->prepare(
82         "Insert into statistics (datetime,branch,type,value,
83                                         other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?,?)"
84     );
85     $sth->execute(
86         $branch,    $type,    $amount,
87         $other,     $itemnum, $itemtype, $borrowernumber,
88     );
89     $sth->finish;
90 }
91
92 1;
93 __END__
94
95 =back
96
97 =head1 AUTHOR
98
99 Koha Developement team <info@koha.org>
100
101 =cut
102