First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
include "db.php";
|
||||
|
||||
|
||||
$Months = array();
|
||||
$currYr = date("Y",time());
|
||||
for ($yr = 2009; $yr <= $currYr; $yr++) {
|
||||
for ($mo = 1; $mo <= 12; $mo++) {
|
||||
if ($yr == 2009 && $mo < 8) continue;
|
||||
|
||||
$month = sprintf("%4d-%02d",$yr,$mo);
|
||||
$Months[$month] = array(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = "SELECT SUBSTRING(payment_date,1,7) AS pdate, SUM(subtotal) AS subtotal, SUM(amount_paid) AS amount FROM invoice_header GROUP BY 1 ORDER BY pdate";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results)) {
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
extract($row);
|
||||
$Months[$pdate] = array($subtotal,$amount);
|
||||
// echo("$pdate $subtotal $amount\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ($yr = 2009; $yr <= $currYr; $yr++) {
|
||||
$ytd = 0;
|
||||
for ($mo = 1; $mo <= 12; $mo++) {
|
||||
if ($yr == 2009 && $mo < 8) continue;
|
||||
|
||||
$month = sprintf("%4d-%02d",$yr,$mo);
|
||||
$subtotal = $Months[$month][0];
|
||||
$amount = $Months[$month][1];
|
||||
$ytd += $subtotal;
|
||||
printf("%7s %12s %12s %12s\n",$month,'$'.number_format($subtotal,2),'$'.number_format($amount,2),'$'.number_format($ytd,2));
|
||||
}
|
||||
printf(". . . . . %7s %12s\n",$yr,'$'.number_format($ytd,2));
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user