- #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(),'$branch','$type','$user','$amount',
- '$other','$itemnum','$itemtype','$borrowernumber')");
- $sth->execute;
- $sth->finish;
-}
-
-# XXX - POD
-# FIXME - Why does this function exist? Why not just rename &circrep
-# to &statsreport?
-# Then again, it only appears to be used in reports.pl which, in turn,
-# doesn't appear to be used. So presumably this function is obsolete.
-sub statsreport {
- #module to return a list of stats for a given day,time,branch type
- #or to return search stats
- my ($type,$time)=@_;
- my @data;
-# print "here";
-# if ($type eq 'issue'){
- @data=circrep($time,$type);
-# }
- return(@data);
-}
-
-# XXX - Doc. Only used internally. Probably useless: see comment for
-# &statsreport.
-sub circrep {
- my ($time,$type)=@_;
- my $dbh = C4::Context->dbh;
- my $query="Select * from statistics";
- if ($time eq 'today'){
- # FIXME - What is this supposed to do? MySQL 3.23.42 barfs on it.
- $query=$query." where type='$type' and datetime
- >=datetime('yesterday'::date)";
- }
- my $sth=$dbh->prepare($query);
- $sth->execute;
- my $i=0;
- my @results;
- while (my $data=$sth->fetchrow_hashref){
- $results[$i]="$data->{'datetime'}\t$data->{'branch'}";
- $i++;
- }
- $sth->finish;
-# print $query;
- return(@results);
-}