[Koha-cvs] CVS: koha/C4 Stats.pm,1.8,1.9
Andrew Arensburger
arensb at users.sourceforge.net
Sat Oct 5 11:53:25 CEST 2002
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv23049/C4
Modified Files:
Stats.pm
Log Message:
Merged with arensb-context branch: use C4::Context->dbh instead of
&C4Connect, and generally prefer C4::Context over C4::Database.
Index: Stats.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Stats.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Stats.pm 28 Sep 2002 04:56:52 -0000 1.8
--- Stats.pm 5 Oct 2002 09:53:23 -0000 1.9
***************
*** 22,26 ****
require Exporter;
use DBI;
! use C4::Database;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
--- 22,26 ----
require Exporter;
use DBI;
! use C4::Context;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 73,77 ****
#module to insert stats data into stats table
my ($env,$branch,$type,$amount,$other,$itemnum,$itemtype,$borrowernumber)=@_;
! my $dbh=C4Connect();
if ($branch eq ''){
$branch=$env->{'branchcode'};
--- 73,77 ----
#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'};
***************
*** 79,83 ****
my $user = $env->{'usercode'};
print $borrowernumber;
! # FIXME - Use $dbh->do() instead?
my $sth=$dbh->prepare("Insert into statistics
(datetime,branch,type,usercode,value,
--- 79,83 ----
my $user = $env->{'usercode'};
print $borrowernumber;
! # FIXME - Use $dbh->do() instead
my $sth=$dbh->prepare("Insert into statistics
(datetime,branch,type,usercode,value,
***************
*** 87,91 ****
$sth->execute;
$sth->finish;
- $dbh->disconnect;
}
--- 87,90 ----
***************
*** 111,115 ****
sub circrep {
my ($time,$type)=@_;
! my $dbh=C4Connect;
my $query="Select * from statistics";
if ($time eq 'today'){
--- 110,114 ----
sub circrep {
my ($time,$type)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from statistics";
if ($time eq 'today'){
***************
*** 128,134 ****
$sth->finish;
# print $query;
- $dbh->disconnect;
return(@results);
-
}
--- 127,131 ----
***************
*** 137,141 ****
sub Count {
my ($type,$branch,$time,$time2)=@_;
! my $dbh=C4Connect;
my $query="Select count(*) from statistics where type='$type'";
$query.=" and datetime >= '$time' and datetime< '$time2' and branch='$branch'";
--- 134,138 ----
sub Count {
my ($type,$branch,$time,$time2)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select count(*) from statistics where type='$type'";
$query.=" and datetime >= '$time' and datetime< '$time2' and branch='$branch'";
***************
*** 145,149 ****
$sth->finish;
# print $query;
- $dbh->disconnect;
return($data->{'count(*)'});
}
--- 142,145 ----
***************
*** 151,155 ****
# XXX - POD. Doesn't appear to be used
sub Overdues{
! my $dbh=C4Connect;
my $query="Select count(*) from issues where date_due >= now()";
my $sth=$dbh->prepare($query);
--- 147,151 ----
# XXX - POD. Doesn't appear to be used
sub Overdues{
! my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where date_due >= now()";
my $sth=$dbh->prepare($query);
***************
*** 157,161 ****
my $count=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($count->{'count(*)'});
}
--- 153,156 ----
***************
*** 164,168 ****
sub TotalOwing{
my ($type)=@_;
! my $dbh=C4Connect;
my $query="Select sum(amountoutstanding) from accountlines";
if ($type eq 'fine'){
--- 159,163 ----
sub TotalOwing{
my ($type)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select sum(amountoutstanding) from accountlines";
if ($type eq 'fine'){
***************
*** 174,178 ****
my $total=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($total->{'sum(amountoutstanding)'});
}
--- 169,172 ----
***************
*** 181,185 ****
sub TotalPaid {
my ($time)=@_;
! my $dbh=C4Connect;
my $query="Select * from accountlines,borrowers where (accounttype = 'Pay'
or accounttype ='W')
--- 175,179 ----
sub TotalPaid {
my ($time)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from accountlines,borrowers where (accounttype = 'Pay'
or accounttype ='W')
***************
*** 209,213 ****
}
$sth->finish;
- $dbh->disconnect;
# print $query;
return(@results);
--- 203,206 ----
***************
*** 217,221 ****
sub getcharges{
my($borrowerno,$timestamp)=@_;
! my $dbh=C4Connect;
my $timestamp2=$timestamp-1;
my $query="Select * from accountlines where borrowernumber=$borrowerno
--- 210,214 ----
sub getcharges{
my($borrowerno,$timestamp)=@_;
! my $dbh = C4::Context->dbh;
my $timestamp2=$timestamp-1;
my $query="Select * from accountlines where borrowernumber=$borrowerno
***************
*** 233,237 ****
# }
}
- $dbh->disconnect;
return(@results);
}
--- 226,229 ----
***************
*** 241,245 ****
sub Getpaidbranch{
my($date,$borrno)=@_;
! my $dbh=C4Connect;
my $query="select * from statistics where type='payment' and datetime
>'$date' and borrowernumber='$borrno'";
--- 233,237 ----
sub Getpaidbranch{
my($date,$borrno)=@_;
! my $dbh = C4::Context->dbh;
my $query="select * from statistics where type='payment' and datetime
>'$date' and borrowernumber='$borrno'";
***************
*** 249,253 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
return($data->{'branch'});
}
--- 241,244 ----
***************
*** 256,260 ****
# reservereport.xls, neither of which is used.
sub unfilledreserves {
! my $dbh=C4Connect;
my $query="select *,biblio.title from reserves,reserveconstraints,biblio,borrowers,biblioitems where found <> 'F' and cancellationdate
is NULL and biblio.biblionumber=reserves.biblionumber and
--- 247,251 ----
# reservereport.xls, neither of which is used.
sub unfilledreserves {
! my $dbh = C4::Context->dbh;
my $query="select *,biblio.title from reserves,reserveconstraints,biblio,borrowers,biblioitems where found <> 'F' and cancellationdate
is NULL and biblio.biblionumber=reserves.biblionumber and
***************
*** 287,291 ****
}
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
--- 278,281 ----
More information about the Koha-cvs
mailing list