|
|
|
@@ -1,10 +1,4 @@
|
|
|
|
<?php include("inc_all_reports.php"); ?>
|
|
|
|
<?php include("inc_all_reports.php");
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function roundUpToNearestMultiple($n, $increment = 1000)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (int) ($increment * ceil($n / $increment));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['year'])) {
|
|
|
|
if (isset($_GET['year'])) {
|
|
|
|
$year = intval($_GET['year']);
|
|
|
|
$year = intval($_GET['year']);
|
|
|
|
@@ -34,13 +28,13 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="card-body">
|
|
|
|
<form class="mb-3">
|
|
|
|
<form class="mb-3">
|
|
|
|
<select onchange="this.form.submit()" class="form-control" name="year">
|
|
|
|
<select onchange="this.form.submit()" class="form-control" name="year">
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
while ($row = mysqli_fetch_array($sql_expense_years)) {
|
|
|
|
while ($row = mysqli_fetch_array($sql_expense_years)) {
|
|
|
|
$expense_year = $row['expense_year'];
|
|
|
|
$expense_year = $row['expense_year'];
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<option <?php if ($year == $expense_year) { ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
|
|
|
|
<option <?php if ($year == $expense_year) { ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
@@ -79,7 +73,7 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
|
|
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td><?php echo $category_name; ?></td>
|
|
|
|
<td><?php echo $category_name; ?></td>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
$total_expense_for_all_months = 0;
|
|
|
|
$total_expense_for_all_months = 0;
|
|
|
|
@@ -89,36 +83,36 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
|
|
|
|
$expense_amount_for_month = $row['expense_amount_for_month'];
|
|
|
|
$expense_amount_for_month = $row['expense_amount_for_month'];
|
|
|
|
$total_expense_for_all_months = $expense_amount_for_month + $total_expense_for_all_months;
|
|
|
|
$total_expense_for_all_months = $expense_amount_for_month + $total_expense_for_all_months;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<td class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_amount_for_month, $session_company_currency); ?></a></td>
|
|
|
|
<td class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_amount_for_month, $session_company_currency); ?></a></td>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<th class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></a></th>
|
|
|
|
<th class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></a></th>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<th>Total</th>
|
|
|
|
<th>Total</th>
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
for($month = 1; $month<=12; $month++) {
|
|
|
|
for($month = 1; $month<=12; $month++) {
|
|
|
|
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND company_id = $session_company_id");
|
|
|
|
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND company_id = $session_company_id");
|
|
|
|
$row = mysqli_fetch_array($sql_expenses);
|
|
|
|
$row = mysqli_fetch_array($sql_expenses);
|
|
|
|
$expense_total_amount_for_month = $row['expense_total_amount_for_month'];
|
|
|
|
$expense_total_amount_for_month = $row['expense_total_amount_for_month'];
|
|
|
|
$total_expense_for_all_months = $expense_total_amount_for_month + $total_expense_for_all_months;
|
|
|
|
$total_expense_for_all_months = $expense_total_amount_for_month + $total_expense_for_all_months;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_total_amount_for_month, $session_company_currency); ?></a></th>
|
|
|
|
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_total_amount_for_month, $session_company_currency); ?></a></th>
|
|
|
|
@@ -162,24 +156,24 @@ var myLineChart = new Chart(ctx, {
|
|
|
|
pointBorderWidth: 2,
|
|
|
|
pointBorderWidth: 2,
|
|
|
|
data: [
|
|
|
|
data: [
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
$largest_expense_month = 0;
|
|
|
|
$largest_expense_month = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for($month = 1; $month<=12; $month++) {
|
|
|
|
for($month = 1; $month<=12; $month++) {
|
|
|
|
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND expenses.company_id = $session_company_id");
|
|
|
|
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND expenses.company_id = $session_company_id");
|
|
|
|
$row = mysqli_fetch_array($sql_expenses);
|
|
|
|
$row = mysqli_fetch_array($sql_expenses);
|
|
|
|
$expenses_for_month = $row['expense_amount_for_month'];
|
|
|
|
$expenses_for_month = $row['expense_amount_for_month'];
|
|
|
|
|
|
|
|
|
|
|
|
if ($expenses_for_month > 0 && $expenses_for_month > $largest_expense_month) {
|
|
|
|
if ($expenses_for_month > 0 && $expenses_for_month > $largest_expense_month) {
|
|
|
|
$largest_expense_month = $expenses_for_month;
|
|
|
|
$largest_expense_month = $expenses_for_month;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<?php echo "$expenses_for_month,"; ?>
|
|
|
|
<?php echo "$expenses_for_month,"; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
@@ -217,4 +211,4 @@ var myLineChart = new Chart(ctx, {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|