X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FStats.pm;h=e1cbd4210ff41d2d9e86238ba6566a17ec35fbe2;hb=5d6c092921919526ade501facb1220f8a108a08f;hp=0afd810d4f5ca86af6c5b9dab54977b54a93bcde;hpb=ca4b23e929b2636054263cab35f50a07dc8a02e4;p=koha_fer diff --git a/C4/Stats.pm b/C4/Stats.pm index 0afd810d4f..e1cbd4210f 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -14,18 +14,22 @@ 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); +our $debug; + BEGIN { # set the version for version checking - $VERSION = 3.01; + $VERSION = 3.07.00.049; @ISA = qw(Exporter); @EXPORT = qw( &UpdateStats @@ -72,20 +76,21 @@ sub UpdateStats { my ( $branch, $type, $amount, $other, $itemnum, - $itemtype, $borrowernumber, $accountno + $itemtype, $borrowernumber, $accountno, $ccode ) = @_; 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, ccode) + VALUES (now(),?,?,?,?,?,?,?,?,?)" ); $sth->execute( $branch, $type, $amount, $other, $itemnum, $itemtype, $borrowernumber, - $accountno + $accountno, $ccode ); - $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; @@ -126,7 +125,7 @@ __END__ =head1 AUTHOR -Koha Developement team +Koha Development Team =cut