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">
|
||||
@@ -156,13 +160,13 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
|
||||
<?php include("footer.php"); ?>
|
||||
|
||||
<script>
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Area Chart Example
|
||||
var ctx = document.getElementById("cashFlow");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
// Area Chart Example
|
||||
var ctx = document.getElementById("cashFlow");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
@@ -178,7 +182,8 @@ var myLineChart = new Chart(ctx, {
|
||||
pointBorderWidth: 2,
|
||||
data: [
|
||||
<?php
|
||||
for($month = 1; $month<=12; $month++) {
|
||||
|
||||
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);
|
||||
$payments_for_month = $row['payment_amount_for_month'];
|
||||
@@ -234,6 +239,6 @@ var myLineChart = new Chart(ctx, {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user