$calc_period_start = isset($_GET['period_start']) ? $_GET['period_start'] : date('Ym'); $calc_period_end = isset($_GET['period_end']) ? $_GET['period_end'] : date('Ym'); $year_start = substr($calc_period_start, 0, 4); $month_start = substr($calc_period_start, 4, 2); $year_end = substr($calc_period_end, 0, 4); $month_end = substr($calc_period_end, 4, 2); if ($year_end < $year_start || $year_end == $year_start && $month_end < $month_start) { die('Period end > Period start!'); } else { for ($y = $year_start; $y <= $year_end; $y++) { $m_start = $y == $year_start ? intval($month_start) : 1; $m_end = $y == $year_end ? intval($month_end) : 12; for ($m = $m_start; $m <= $m_end; $m++) { $period = $y . str_pad($m, 2, '0', STR_PAD_LEFT); ReportBookkeeping::$output_query_as_table = true; $result = ReportBookkeeping::queryInvoices($period); echo '<h3 style="margin:0 0 10px 0;">' . $period . '</h3>'; foreach ($result as $key => $value) { if (strpos($key, 'qty') !== false) { $value_used = intval($value); } else { $value_used = number_format($value, 2); } echo '<div>' . ucwords(str_replace('_', ' ', $key)) . ' = ' . $value_used . '</div>'; } $receipts = ReportBookkeeping::getTotalReceipts($period); $returns = ReportBookkeeping::getTotalReturns($period); echo '<div>Total Amount Received = ' . number_format($receipts, 2) . '</div>' . '<div>Total Returns (including refund & non refund, ' . 'shipping cost and small amount adjustment) = ' . number_format($returns, 2) . '</div>' . '<div> <br /> </div>'; } } }