-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'";
- my $sth=$dbh->prepare($query);
- $sth->execute;
- my $data=$sth->fetchrow_hashref;
- $sth->finish;
-# print $query;
- $dbh->disconnect;
- return($data->{'count(*)'});
+ #module to insert stats data into stats table
+ my (
+ $branch, $type,
+ $amount, $other, $itemnum,
+ $itemtype, $borrowernumber, $accountno
+ )
+ = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ "INSERT INTO statistics
+ (datetime, branch, type, value,
+ other, itemnumber, itemtype, borrowernumber, proccode)
+ VALUES (now(),?,?,?,?,?,?,?,?)"
+ );
+ $sth->execute(
+ $branch, $type, $amount,
+ $other, $itemnum, $itemtype, $borrowernumber,
+ $accountno
+ );