$spent) { ?>
[], 'total_spent' => 0, 'datasets' => [ 'data' => [], 'backgroundColor' => [] ] ]; $total_spent = 0; foreach ($spent["report"] as $rows) { $total_spent += (float)$rows['spent']; } foreach ($spent["report"] as $rows) { $ii++; $prc = $total_spent > 0 ? ((float)$rows['spent']??0)*100/($total_spent?:1) : 0; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; //echo ""; $spent_chart_item['labels'][] = $rows["type"] ?? '-'; $spent_chart_item['datasets']['data'][] = (float)$rows["spent"] ?? 0; $spent_chart_item['datasets']['backgroundColor'][] = isset($colors[$ii - 1]) ? $colors[$ii - 1] : '#49ff00'; } $spent_chart_item['total_spent'] = $total_spent; $spent_charts[$spent_id] = $spent_chart_item; ?>
# Type Amount Percent Detail
'.$ii.''.$rows["type"].''.$rows["spent"].'0?'style="font-weight:bold;"':'').'>'.number_format($prc,2,'.','').'%
$ii" . $rows["type"] . "" . $rows["spent"] . "
' . $id . ''; } ?>
'; } ?>