No year specified'); exit(0); } /* Some variables */ $userID = get_userID($_SESSION['user']); $year = $_GET['year']; $tip_totals = Array(); $check_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('MonthPeriodTipsChecksTotal'); for ($monthIndex = 1; $monthIndex <= 12; $monthIndex++) { /* Get a timestamp for the current month */ $monthTimestamp = mktime(0, 0, 0, $monthIndex, 1, $year); /* Set the 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; if (!isset($check_totals[$monthIndex][1])) $check_totals[$monthIndex][1] = 0; if (!isset($check_totals[$monthIndex][2])) $check_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', $check_totals[$monthIndex][1]); printf('$%.2f', $tip_totals[$monthIndex][1] + $tip_totals[$monthIndex][2] + $check_totals[$monthIndex][1] + $check_totals[$monthIndex][2]); print(''); printf('16 - %d', date('t', $monthTimestamp)); printf('$%.2f', $tip_totals[$monthIndex][2]); printf('$%.2f', $check_totals[$monthIndex][2]); print("\n"); /* Increment the year's totals */ $yearTipTotal += $tip_totals[$monthIndex][1]; $yearTipTotal += $tip_totals[$monthIndex][2]; $yearChecksTotal += $check_totals[$monthIndex][1]; $yearChecksTotal += $check_totals[$monthIndex][2]; } printf('Total: $%.2f $%.2f $%.2f', $yearTipTotal, $yearChecksTotal, $yearTipTotal + $yearChecksTotal); print(''); ?>