[Koha-cvs] koha C4/Stats.pm koha-tmpl/intranet-tmpl/defaul... [rel_2_2]
paul poulain
paul at koha-fr.org
Fri May 12 11:35:42 CEST 2006
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_2_2
Changes by: paul poulain <tipaul at savannah.gnu.org> 06/05/12 09:35:42
Modified files:
C4 : Stats.pm
koha-tmpl/intranet-tmpl/default/en: stats.tmpl
. : stats.pl
Log message:
fixing stats.pl that was not working + updating templates
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Stats.pm.diff?only_with_tag=rel_2_2&tr1=1.18&tr2=1.18.4.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/koha-tmpl/intranet-tmpl/default/en/stats.tmpl.diff?only_with_tag=rel_2_2&tr1=1.4&tr2=1.4.2.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/stats.pl.diff?only_with_tag=rel_2_2&tr1=1.10.4.3&tr2=1.10.4.4&r1=text&r2=text
Patches:
Index: koha/C4/Stats.pm
diff -u /dev/null koha/C4/Stats.pm:1.18.4.1
--- /dev/null Fri May 12 09:35:42 2006
+++ koha/C4/Stats.pm Fri May 12 09:35:42 2006
@@ -0,0 +1,203 @@
+package C4::Stats;
+
+# $Id: Stats.pm,v 1.18.4.1 2006/05/12 09:35:42 tipaul Exp $
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# 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
+
+use strict;
+require Exporter;
+use DBI;
+use C4::Context;
+use vars qw($VERSION @ISA @EXPORT);
+
+# set the version for version checking
+$VERSION = 0.01;
+
+=head1 NAME
+
+C4::Stats - Update Koha statistics (log)
+
+=head1 SYNOPSIS
+
+ use C4::Stats;
+
+=head1 DESCRIPTION
+
+The C<&UpdateStats> function adds an entry to the statistics table in
+the Koha database, which acts as an activity log.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+ at ISA = qw(Exporter);
+ at EXPORT = qw(&UpdateStats &statsreport &TotalOwing
+&TotalPaid &getcharges &Getpaidbranch &unfilledreserves);
+
+=item UpdateStats
+
+ &UpdateStats($env, $branch, $type, $value, $other, $itemnumber,
+ $itemtype, $borrowernumber);
+
+Adds a line to the statistics table of the Koha database. In effect,
+it logs an event.
+
+C<$branch>, C<$type>, C<$value>, C<$other>, C<$itemnumber>,
+C<$itemtype>, and C<$borrowernumber> correspond to the fields of the
+statistics table in the Koha database.
+
+If C<$branch> is the empty string, the branch code will be taken from
+C<$env-E<gt>{branchcode}>.
+
+C<$env-E<gt>{usercode}> specifies the value of the C<usercode> field.
+
+=cut
+#'
+sub UpdateStats {
+ #module to insert stats data into stats table
+ my ($env,$branch,$type,$amount,$other,$itemnum,$itemtype,$borrowernumber)=@_;
+ my $dbh = C4::Context->dbh;
+ if ($branch eq ''){
+ $branch=$env->{'branchcode'};
+ }
+ my $user = $env->{'usercode'};
+ print $borrowernumber;
+ # FIXME - Use $dbh->do() instead
+ my $sth=$dbh->prepare("Insert into statistics (datetime,branch,type,usercode,value,
+ other,itemnumber,itemtype,borrowernumber) values (now(),?,?,?,?,?,?,?,?)");
+ $sth->execute($branch,$type,$user,$amount,$other,$itemnum,$itemtype,$borrowernumber);
+ $sth->finish;
+}
+
+# Otherwise, it'd need a POD.
+sub TotalPaid {
+ my ($time,$time2)=@_;
+ $time2=$time unless $time2;
+ my $dbh = C4::Context->dbh;
+ my $query="Select * from accountlines,borrowers where (accounttype = 'Pay' or accounttype ='W' or accounttype='C')
+ and accountlines.borrowernumber = borrowers.borrowernumber";
+ my @bind = ();
+ if ($time eq 'today'){
+ $query .= " and date = now()";
+ } else {
+ $query.=" and date>=? and date<=?";
+ @bind = ($time,$time2);
+ }
+ # my $query="Select * from statistics,borrowers
+ # where statistics.borrowernumber= borrowers.borrowernumber
+ # and (statistics.type='payment' or statistics.type='writeoff') ";
+ # if ($time eq 'today'){
+ # $query=$query." and datetime = now()";
+ # } else {
+ # $query.=" and datetime > '$time'";
+ # }
+ $query.=" order by timestamp";
+ warn $query;
+ my $sth=$dbh->prepare($query);
+ $sth->execute(@bind);
+ my @results;
+ while (my $data=$sth->fetchrow_hashref){
+ push @results,$data;
+ }
+ $sth->finish;
+ # print $query;
+ return(@results);
+}
+
+# Otherwise, it needs a POD.
+sub getcharges{
+ my($borrowerno,$timestamp)=@_;
+ my $dbh = C4::Context->dbh;
+ my $timestamp2=$timestamp-1;
+ my $query="";
+ my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=?
+ and timestamp = ? and accounttype <> 'Pay' and
+ accounttype <> 'W'");
+ # print $query,"<br>";
+ $sth->execute($borrowerno,$timestamp);
+ my $i=0;
+ my @results;
+ while (my $data=$sth->fetchrow_hashref){
+ # if ($data->{'timestamp'} == $timestamp){
+ $results[$i]=$data;
+ $i++;
+ # }
+ }
+ return(@results);
+}
+
+# Otherwise, this needs a POD.
+sub Getpaidbranch{
+ my($date,$borrno)=@_;
+ my $dbh = C4::Context->dbh;
+ my $sth=$dbh->prepare("select * from statistics where type='payment' and datetime >? and borrowernumber=?");
+ $sth->execute($date,$borrno);
+ # print $query;
+ my $data=$sth->fetchrow_hashref;
+ $sth->finish;
+ return($data->{'branch'});
+}
+
+# FIXME - This is only used in reservereport.pl and reservereport.xls,
+# neither of which is used.
+# Otherwise, it needs a POD.
+sub unfilledreserves {
+ my $dbh = C4::Context->dbh;
+ my $sth=$dbh->prepare("select *,biblio.title from reserves,reserveconstraints,biblio,borrowers,biblioitems where found <> 'F' and cancellationdate
+ is NULL and biblio.biblionumber=reserves.biblionumber and
+ reserves.constrainttype='o'
+ and (reserves.biblionumber=reserveconstraints.biblionumber
+ and reserves.borrowernumber=reserveconstraints.borrowernumber)
+ and
+ reserves.borrowernumber=borrowers.borrowernumber and
+ biblioitems.biblioitemnumber=reserveconstraints.biblioitemnumber order by
+ biblio.title,reserves.reservedate");
+ $sth->execute;
+ my $i=0;
+ my @results;
+ while (my $data=$sth->fetchrow_hashref){
+ $results[$i]=$data;
+ $i++;
+ }
+ $sth->finish;
+ $sth=$dbh->prepare("select *,biblio.title from reserves,biblio,borrowers where found <> 'F' and cancellationdate
+ is NULL and biblio.biblionumber=reserves.biblionumber and reserves.constrainttype='a' and
+ reserves.borrowernumber=borrowers.borrowernumber
+ order by
+ biblio.title,reserves.reservedate");
+ $sth->execute;
+ while (my $data=$sth->fetchrow_hashref){
+ $results[$i]=$data;
+ $i++;
+ }
+ $sth->finish;
+ return($i,\@results);
+}
+
+1;
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Developement team <info at koha.org>
+
+=cut
Index: koha/koha-tmpl/intranet-tmpl/default/en/stats.tmpl
diff -u /dev/null koha/koha-tmpl/intranet-tmpl/default/en/stats.tmpl:1.4.2.1
--- /dev/null Fri May 12 09:35:42 2006
+++ koha/koha-tmpl/intranet-tmpl/default/en/stats.tmpl Fri May 12 09:35:42 2006
@@ -0,0 +1,34 @@
+<!-- TMPL_INCLUDE NAME="reports-top.inc" -->
+
+<div id="mainbloc">
+ <table border="0" cellspacing="0" cellpadding="5" align="center">
+ <tr bgcolor="#99cc33">
+ <th>Name</th>
+ <th>Description</th>
+ <th>Type</th>
+ <th>Date/time</th>
+ <th>Amount</th>
+ <th>Branch</th>
+
+ <tr>
+ <!-- TMPL_LOOP NAME=loop1 -->
+ <tr>
+ <td><!-- TMPL_VAR NAME="name" --></td>
+ <td><!-- TMPL_VAR NAME="description" --></td>
+ <td><!-- TMPL_VAR NAME="type" --></td>
+ <td><!-- TMPL_VAR NAME="time" --></td>
+ <td><!-- TMPL_VAR NAME="amount" --></td>
+ <td><!-- TMPL_VAR NAME="branch" --></td>
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+
+
+<p>
+ <b>Total paid: <!-- TMPL_VAR NAME="total" --></b>
+ <br>
+ <b>Total written off: <!-- TMPL_VAR NAME="totalw" --></b>
+</p>
+
+</div>
+<!-- TMPL_INCLUDE NAME="reports-bottom.inc" -->
\ No newline at end of file
Index: koha/stats.pl
diff -u koha/stats.pl:1.10.4.3 koha/stats.pl:1.10.4.4
--- koha/stats.pl:1.10.4.3 Sun Feb 5 21:59:21 2006
+++ koha/stats.pl Fri May 12 09:35:42 2006
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: stats.pl,v 1.10.4.3 2006/02/05 21:59:21 kados Exp $
+# $Id: stats.pl,v 1.10.4.4 2006/05/12 09:35:42 tipaul Exp $
#written 14/1/2000
#script to display reports
@@ -78,10 +78,10 @@
my $oldtime;
my $totalw=0;
my @loop;
-my %row;
my $i=0;
+# parse all lines for today
while ($i<$count){
- warn " pay : ".$payments[$i]{'timestamp'};
+# warn " pay : ".$payments[$i]{'timestamp'};
my $time=$payments[$i]{'datetime'};
my $payments=$payments[$i]{'value'};
my $charge=0;
@@ -95,13 +95,14 @@
my $temptotalren=0;
my $temptotalw=0;
for (my $i2=0;$i2<$count;$i2++){
+# warn "I2 : $i2 i=$i";
$charge+=$charges[$i2]->{'amount'};
- %row = ( name => $charges[$i2]->{'description'},
- type => $charges[$i2]->{'accounttype'},
- time => $charges[$i2]->{'timestamp'},
- amount => $charges[$i2]->{'amount'},
- branch => $charges[$i2]->{'amountoutstanding'} );
- push(@loop, \%row);
+# %row = ( name => $charges[$i2]->{'description'},
+# type => $charges[$i2]->{'accounttype'},
+# time => $charges[$i2]->{'timestamp'},
+# amount => $charges[$i2]->{'amount'},
+# branch => $charges[$i2]->{'amountoutstanding'} );
+# push(@loop, \%row);
if ($payments[$i]{'accountytpe'} ne 'W'){
if ($charges[$i2]->{'accounttype'} eq 'Rent'){
$temptotalr+=$charges[$i2]->{'amount'}-$charges[$i2]->{'amountoutstanding'};
@@ -139,10 +140,10 @@
$payments[$i]{'amount'}=$payments[$i]{'amount'}*-1;
$total+=$payments[$i]{'amount'};
}
-
- %row = ( name => "<b>".$payments[$i]{'firstname'}.$payments[$i]{'surname'} . "</b>",
+ my %row = ( name => "<b>".$payments[$i]{'firstname'}.' '.$payments[$i]{'surname'} . "</b>",
type => $payments[$i]{'accounttype'}, time => $payments[$i]{'date'},
- amount => $payments[$i]{'amount'}, branch => $branch );
+ amount => $payments[$i]{'amount'}, branch => $branch,
+ description => $payments[$i]{'description'});
push(@loop, \%row);
$oldtype=$payments[$i]{'accounttype'};
$oldtime=$payments[$i]{'timestamp'};
More information about the Koha-cvs
mailing list