$from, 'end' => $to])); $from_other = $totals['total'] - $from_invoices; $months_elapsed = reportMonthsElapsed($year); $average = $months_elapsed ? $totals['total'] / $months_elapsed : 0; $best_month = 0; foreach ($totals['months'] as $m => $v) { if ($v > ($totals['months'][$best_month] ?? 0)) { $best_month = $m; } } // Last year month by month, as a line behind this year's bars $prev_full = reportGridTotals(reportIncomeByCategory(($year - 1) . '-01-01', ($year - 1) . '-12-31'))['months']; require_once "includes/inc_report_layout.php"; ?>
[$year, $years], 'subtitle' => $current_year ? "$year to date" : (string) $year, ]); ?> 'Income', 'value' => reportMoney($totals['total']), 'sub' => reportChangeHtml($totals['total'], $prev_total, 'up', $compare), 'url' => "/agent/income.php?canned_date=custom&dtf=$from&dtt=$to"], ['label' => 'Invoice payments', 'value' => reportMoney($from_invoices), 'sub' => escapeHtml(reportPercent(reportShare($from_invoices, $totals['total']))) . ' of income', 'url' => "/agent/income.php?show=payments&canned_date=custom&dtf=$from&dtt=$to"], ['label' => 'Other income', 'value' => reportMoney($from_other), 'sub' => escapeHtml(reportPercent(reportShare($from_other, $totals['total']))) . ' of income', 'url' => "/agent/income.php?show=other&canned_date=custom&dtf=$from&dtt=$to"], ['label' => 'Monthly average', 'value' => reportMoney($average), 'sub' => $best_month ? 'Best month ' . date('F', mktime(0, 0, 0, $best_month, 1)) . '' : ''], ]) ?>
(string) ($year - 1), 'data' => array_map(function ($v) { return round($v, 2); }, array_values($prev_full)), 'tone' => 'muted', 'type' => 'line', 'dashed' => true]; echo reportChart([ 'type' => 'bar', 'labels' => array_map(function ($m) { return date('M', mktime(0, 0, 0, $m, 1)); }, range(1, 12)), 'series' => $series, 'stacked' => true, 'format' => 'money', ], 'lg', 'Income per month by category, with last year as a line'); ?>