Files
HotLunches/hotlunch.trx.php
T
2026-10-19 15:22:52 -07:00

40 lines
1.1 KiB
PHP

<?php
include "/m/data1/app.hotlunches.net/db.php";
$year = date("Y",time() + 60 * 60 * 24 * 27);
$month = date("m",time() + 60 * 60 * 24 * 27);
$total = 0;
$gtotal = 0;
$ttotal = 0;
$Amounts = array();
for ($i = 1; $i < 13; $i++) {
$m = $month - $i;
if ($m < 1) {
$m += 12;
if ($m < 1) $m += 12;
if ($m < 1) $m += 12;
if ($m < 1) $m += 12;
if ($m == 12) $year--;
}
$m = sprintf("%02d",$m);
$date = "$year-$m";
$query = "SELECT sum(transaction_amount) AS total, count(*) AS number FROM `user_account` WHERE transaction_type = 'Payment' AND `transaction_datetime` LIKE '$date-%' AND deleted != 'Y'";
$results = db_query($query);
$row = db_fetch_assoc($results);
extract($row);
$total = abs($total);
$gtotal += $total;
$ttotal += $number;
$Amounts[$date] = sprintf("%8s: %8d %16s\n",$date,$number,'$'.number_format($total,2));
// $Amounts[$date] = sprintf("%s,%d,%s\n",$date,$number,$total);
}
sort($Amounts);
for ($i = 0; $i < count($Amounts); $i++) echo($Amounts[$i]);
printf("%8s: %8d %16s\n","TOTAL",$ttotal,'$'.number_format($gtotal,2));
?>