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