-sub TotalOwing{
- my ($type)=@_;
- my $dbh=C4Connect;
- my $query="Select sum(amountoutstanding) from accountlines";
- if ($type eq 'fine'){
- $query=$query." where accounttype='F' or accounttype='FN'";
- }
- my $sth=$dbh->prepare($query);
-# print $query;
- $sth->execute;
- my $total=$sth->fetchrow_hashref;
- $sth->finish;
- $dbh->disconnect;
- return($total->{'sum(amountoutstanding)'});
+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.
+
+=cut
+
+#'
+sub UpdateStats {
+
+ #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
+ );