X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FStats.pm;h=11710f82a775d184c4de45f74d433cd76dbbff9d;hb=03eea72de3973595b4ea03080d083fb31cf4215b;hp=4988ea8419e00779443cf966c34f4c73a00eff91;hpb=04a108482dafd286a1c6bd8c4becc8cf56e1a46a;p=koha_gimpoz diff --git a/C4/Stats.pm b/C4/Stats.pm index 4988ea8419..11710f82a7 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -1,6 +1,5 @@ package C4::Stats; -# $Id$ # Copyright 2000-2002 Katipo Communications # @@ -15,19 +14,29 @@ package C4::Stats; # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +use warnings; require Exporter; use C4::Context; +use C4::Debug; use vars qw($VERSION @ISA @EXPORT); -# set the version for version checking -$VERSION = $VERSION = do { my @v = '$Revision$' =~ /\d+/g; - shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); -}; +our $debug; + +BEGIN { + # set the version for version checking + $VERSION = 3.01; + @ISA = qw(Exporter); + @EXPORT = qw( + &UpdateStats + &TotalPaid + ); +} + =head1 NAME @@ -46,14 +55,6 @@ the Koha database, which acts as an activity log. =over 2 -=cut - -@ISA = qw(Exporter); -@EXPORT = qw( - &UpdateStats - &TotalPaid -); - =item UpdateStats &UpdateStats($branch, $type, $value, $other, $itemnumber, @@ -75,20 +76,21 @@ sub UpdateStats { my ( $branch, $type, $amount, $other, $itemnum, - $itemtype, $borrowernumber + $itemtype, $borrowernumber, $accountno ) = @_; my $dbh = C4::Context->dbh; - # FIXME - Use $dbh->do() instead my $sth = $dbh->prepare( - "Insert into statistics (datetime,branch,type,value, - other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?)" + "INSERT INTO statistics + (datetime, branch, type, value, + other, itemnumber, itemtype, borrowernumber, proccode) + VALUES (now(),?,?,?,?,?,?,?,?)" ); $sth->execute( $branch, $type, $amount, $other, $itemnum, $itemtype, $borrowernumber, + $accountno ); - $sth->finish; } # Otherwise, it'd need a POD. @@ -100,25 +102,20 @@ sub TotalPaid { LEFT JOIN borrowers ON statistics.borrowernumber= borrowers.borrowernumber WHERE (statistics.type='payment' OR statistics.type='writeoff') "; if ( $time eq 'today' ) { - $query = $query . " AND datetime = now()"; - } - else { - $query .= " AND datetime > '$time'"; + $query .= " AND datetime = now()"; + } else { + $query .= " AND datetime > '$time'"; # FIXME: use placeholders } if ( $time2 ne '' ) { - $query .= " AND datetime < '$time2'"; + $query .= " AND datetime < '$time2'"; # FIXME: use placeholders } if ($spreadsheet) { $query .= " ORDER BY branch, type"; } + $debug and warn "TotalPaid query: $query"; my $sth = $dbh->prepare($query); $sth->execute(); - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results, $data; - } - $sth->finish; - return (@results); + return @{$sth->fetchall_arrayref({})}; } 1; @@ -128,7 +125,7 @@ __END__ =head1 AUTHOR -Koha Developement team +Koha Development Team =cut