";
echo "| " . nullable_htmlentities($tax_name_raw) . " | ";
if ($view == 'monthly') {
for ($i = 1; $i <= 12; $i++) {
$monthly_tax = (float) getMonthlyTax($tax_name, $i, $year, $mysqli);
// Accumulate totals
$monthly_totals[$i] += $monthly_tax;
$grand_total += $monthly_tax;
echo "" . numfmt_format_currency($currency_format, $monthly_tax, $company_currency) . " | ";
}
// Row total = sum of this tax’s 12 months
$row_total = 0.0;
for ($i = 1; $i <= 12; $i++) {
$row_total += (float) getMonthlyTax($tax_name, $i, $year, $mysqli);
}
echo "" . numfmt_format_currency($currency_format, $row_total, $company_currency) . " | ";
} else {
$row_total = 0.0;
for ($q = 1; $q <= 4; $q++) {
$quarterly_tax = (float) getQuarterlyTax($tax_name, $q, $year, $mysqli);
// Accumulate totals
$quarterly_totals[$q] += $quarterly_tax;
$grand_total += $quarterly_tax;
$row_total += $quarterly_tax;
echo "" . numfmt_format_currency($currency_format, $quarterly_tax, $company_currency) . " | ";
}
echo "" . numfmt_format_currency($currency_format, $row_total, $company_currency) . " | ";
}
echo "";
}
// Totals row
echo "";
echo "| Total | ";
if ($view == 'monthly') {
for ($i = 1; $i <= 12; $i++) {
echo "" . numfmt_format_currency($currency_format, $monthly_totals[$i], $company_currency) . " | ";
}
} else {
for ($q = 1; $q <= 4; $q++) {
echo "" . numfmt_format_currency($currency_format, $quarterly_totals[$q], $company_currency) . " | ";
}
}
echo "" . numfmt_format_currency($currency_format, $grand_total, $company_currency) . " | ";
echo "
";
?>