From 5c626f4ad098075bcde11d744799298d4e66ca7b Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 21 May 2009 20:37:48 -0500 Subject: [PATCH] Cleanup C4/Stats.pm Use C4::Debug. Remove $sth->finish and an unconditional warn. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Stats.pm | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/C4/Stats.pm b/C4/Stats.pm index 0afd810d4f..77d5d1442b 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -19,10 +19,14 @@ package C4::Stats; # Suite 330, Boston, MA 02111-1307 USA use strict; +#use warnings; # FIXME require Exporter; use C4::Context; +use C4::Debug; use vars qw($VERSION @ISA @EXPORT); +our $debug; + BEGIN { # set the version for version checking $VERSION = 3.01; @@ -77,15 +81,16 @@ sub UpdateStats { = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( - "INSERT INTO statistics (datetime,branch,type,value, - other,itemnumber,itemtype,borrowernumber,proccode) 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. @@ -97,26 +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); -warn $query; $sth->execute(); - my @results; - while ( my $data = $sth->fetchrow_hashref ) { - push @results, $data; - } - $sth->finish; - return (@results); + return @{$sth->fetchall_arrayref({})}; } 1; -- 2.39.5