From 159338a18ce012026102563c6695187c47e20a30 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 8 Sep 2008 01:54:26 +0000 Subject: [PATCH] really added report page git-svn-id: svn://anubis/tipman@4 ce01c143-e732-0410-ac0e-c064f6e6c7ef --- report.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 report.php diff --git a/report.php b/report.php new file mode 100644 index 0000000..4861d59 --- /dev/null +++ b/report.php @@ -0,0 +1,88 @@ +No year specified'); + exit(0); + } + + /* Some variables */ + $user = $_SESSION['user']; + $year = $_GET['year']; + $tip_totals = Array(); + + /* Print some header HTML */ + print << + + TipMan Report for $year + + +EOP; + + /* Do a query to get the tip totals per period */ + $dbc = connect_db(); + $qRes = do_query(<<'); + print('MonthPeriodAmountTotal'); + for ($monthIndex = 1; $monthIndex <= 12; $monthIndex++) + { + /* Get a timestamp for the current month */ + $monthTimestamp = mktime(0, 0, 0, $monthIndex, 1, $year); + + /* Set the tip totals for each period to 0 if they are not set */ + if (!isset($tip_totals[$monthIndex][1])) + $tip_totals[$monthIndex][1] = 0; + if (!isset($tip_totals[$monthIndex][2])) + $tip_totals[$monthIndex][2] = 0; + + /* Print a row in the report table */ + print(''); + printf('%s', date('F', $monthTimestamp)); + print('1 - 15'); + printf('$%.2f', $tip_totals[$monthIndex][1]); + printf('$%.2f', + $tip_totals[$monthIndex][1] + $tip_totals[$monthIndex][2]); + printf('16 - %d', date('t', $monthTimestamp)); + printf('$%.2f', $tip_totals[$monthIndex][2]); + print("\n"); + + /* Increment the year's total tips */ + $yearTotal += $tip_totals[$monthIndex][1]; + $yearTotal += $tip_totals[$monthIndex][2]; + } + printf(' + Total:$%.2f', + $yearTotal); + print(''); +?> + +