38 lines
927 B
PHP
38 lines
927 B
PHP
<?php
|
|
include "db.php";
|
|
|
|
$year = date("Y",time());
|
|
$month = date("m",time() + 60 * 60 * 24 * 25);
|
|
|
|
$total = 0;
|
|
$gtotal = 0;
|
|
$ttotal = 0;
|
|
|
|
$Amounts = array();
|
|
|
|
for ($i = 1; $i < 38; $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(mc_gross) AS total, count(*) AS number FROM `user_paypal_transactions` WHERE `posting_time` LIKE '$date-%'";
|
|
$results = db_query($query);
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
$gtotal += $total;
|
|
$ttotal += $number;
|
|
$Amounts[$date] = sprintf("%8s: %8d %16s\n",$date,$number,'$'.number_format($total,2));
|
|
}
|
|
|
|
sort($Amounts);
|
|
for ($i = 0; $i < count($Amounts); $i++) echo($Amounts[$i]);
|
|
|
|
printf("%8s: %8d %16s\n","TOTAL",$ttotal,'$'.number_format($gtotal,2));
|
|
?>
|