Add default values for largest income/invoice month to 0. This fixes undefined errors and makes the chart show properly
This commit is contained in:
@@ -22,6 +22,10 @@ $sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS
|
||||
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
||||
// Default values
|
||||
$largest_income_month = 0;
|
||||
$largest_invoice_month = 0;
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
@@ -178,6 +182,7 @@ var myLineChart = new Chart(ctx, {
|
||||
pointBorderWidth: 2,
|
||||
data: [
|
||||
<?php
|
||||
|
||||
for ($month = 1; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month AND payments.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
|
||||
Reference in New Issue
Block a user