diff --git a/report_budget.php b/report_budget.php new file mode 100644 index 00000000..0c35ea86 --- /dev/null +++ b/report_budget.php @@ -0,0 +1,105 @@ + 0 ORDER BY expense_year DESC"); + +$categories = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Expense' ORDER BY category_name ASC"); +$monthlyTotals = array_fill(1, 12, 0); // Initialize monthly totals for each month + +?> + +
+
+

Annual Budget

+
+ +
+
+
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + num_rows > 0) { + while($category = $categories->fetch_assoc()) { + echo ""; + echo ""; + $categoryTotal = 0; + for ($month = 1; $month <= 12; $month++) { + // Fetch the monthly budget for this category for 2022 + $sql = "SELECT budget_amount FROM budget WHERE budget_category_id = " . $category['category_id'] . " AND budget_month = $month AND budget_year = $year"; + $result = $mysqli->query($sql); + if ($result->num_rows > 0) { + $budget = $result->fetch_assoc(); + $amount = $budget['budget_amount']; + $categoryTotal += $amount; + $monthlyTotals[$month] += $amount; + echo ""; + } else { + echo ""; + } + } + echo ""; + echo ""; + } + + // Displaying the monthly totals row + echo ""; + $grandTotal = 0; + for ($month = 1; $month <= 12; $month++) { + $grandTotal += $monthlyTotals[$month]; + echo ""; + } + echo ""; + echo ""; + } + ?> + +
CategoryJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberTotal
" . $category['category_name'] . "" . $amount . "0" . $categoryTotal . "
Total" . $monthlyTotals[$month] . "" . $grandTotal . "
+
+
+
+ + \ No newline at end of file diff --git a/reports_side_nav.php b/reports_side_nav.php index 9bcb5ffc..f764a8a3 100644 --- a/reports_side_nav.php +++ b/reports_side_nav.php @@ -55,6 +55,12 @@

Expense By Vendor

+