Income and Expense Reports completed
This commit is contained in:
+81
-49
@@ -1,17 +1,37 @@
|
|||||||
<?php include("header.php"); ?>
|
<?php include("header.php"); ?>
|
||||||
|
<?php
|
||||||
|
|
||||||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM categories WHERE category type = 'Expense' ORDER BY vendor_id DESC"); ?>
|
if(isset($_GET['year'])){
|
||||||
|
$year = intval($_GET['year']);
|
||||||
|
}else{
|
||||||
|
$year = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_expense_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(expense_date) AS expense_year FROM expenses WHERE category_id > 0 ORDER BY expense_year DESC");
|
||||||
|
|
||||||
|
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Expense' ORDER BY category_name ASC");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h6 class="float-left mt-1"><i class="fa fa-coins"></i> Expense Summary</h6>
|
<h6 class="float-left mt-1"><i class="fa fa-coins"></i> Expense Summary</h6>
|
||||||
<button type="button" class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#print"><i class="fas fa-print"></i> Print</button>
|
<button type="button" class="btn btn-primary btn-sm float-right d-print-none" onclick="window.print();"><i class="fas fa-print"></i> Print</button>
|
||||||
<select class="form-control mt-5">
|
<form>
|
||||||
<option>2019</option>
|
<select onchange="this.form.submit()" class="form-control mt-5" name="year">
|
||||||
<option>2018</option>
|
<?php
|
||||||
<option>2017</option>
|
|
||||||
|
while($row = mysqli_fetch_array($sql_expense_years)){
|
||||||
|
$expense_year = $row['expense_year'];
|
||||||
|
?>
|
||||||
|
<option <?php if($year == $expense_year){ ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
@@ -35,53 +55,65 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row = mysqli_fetch_array($sql_categories)){
|
||||||
|
$category_id = $row['category_id'];
|
||||||
|
$category_name = $row['category_name'];
|
||||||
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Expense Category Type</td>
|
<td><?php echo $category_name; ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
<?php
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
for($month = 1; $month<=12; $month++) {
|
||||||
<td class="text-right">$0.00</td>
|
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||||
<td class="text-right">$0.00</td>
|
$row = mysqli_fetch_array($sql_expenses);
|
||||||
<td class="text-right">$0.00</td>
|
$expense_amount_for_month = $row['expense_amount_for_month'];
|
||||||
<td class="text-right">$0.00</td>
|
$total_expense_for_all_months = $expense_amount_for_month + $total_expense_for_all_months;
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
?>
|
||||||
<td class="text-right">$0.00</td>
|
<td class="text-right">$<?php echo number_format($expense_amount_for_month,2); ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
</tr>
|
<?php
|
||||||
<tr>
|
|
||||||
<td>Expense Category Type 2</td>
|
}
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
?>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
<td class="text-right">$<?php echo number_format($total_expense_for_all_months,2); ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$total_expense_for_all_months = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total</th>
|
<th>Total</th>
|
||||||
<th class="text-right">$0.00</th>
|
<?php
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
for($month = 1; $month<=12; $month++) {
|
||||||
<th class="text-right">$0.00</th>
|
$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 category_id > 0");
|
||||||
<th class="text-right">$0.00</th>
|
$row = mysqli_fetch_array($sql_expenses);
|
||||||
<th class="text-right">$0.00</th>
|
$expense_total_amount_for_month = $row['expense_total_amount_for_month'];
|
||||||
<th class="text-right">$0.00</th>
|
$total_expense_for_all_months = $expense_total_amount_for_month + $total_expense_for_all_months;
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
?>
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
<th class="text-right">$<?php echo number_format($expense_total_amount_for_month,2); ?></th>
|
||||||
<th class="text-right">$0.00</th>
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<th class="text-right">$<?php echo number_format($total_expense_for_all_months,2); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
+81
-49
@@ -1,17 +1,37 @@
|
|||||||
<?php include("header.php"); ?>
|
<?php include("header.php"); ?>
|
||||||
|
<?php
|
||||||
|
|
||||||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM categories WHERE category type = 'Expense' ORDER BY vendor_id DESC"); ?>
|
if(isset($_GET['year'])){
|
||||||
|
$year = intval($_GET['year']);
|
||||||
|
}else{
|
||||||
|
$year = date('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments WHERE invoice_id > 0 ORDER BY payment_year DESC");
|
||||||
|
|
||||||
|
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h6 class="float-left mt-1"><i class="fa fa-coins"></i> Income Summary</h6>
|
<h6 class="float-left mt-1"><i class="fa fa-coins"></i> Income Summary</h6>
|
||||||
<button type="button" class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#print"><i class="fas fa-print"></i> Print</button>
|
<button type="button" class="btn btn-primary btn-sm float-right d-print-none" onclick="window.print();"><i class="fas fa-print"></i> Print</button>
|
||||||
<select class="form-control mt-5">
|
<form>
|
||||||
<option>2019</option>
|
<select onchange="this.form.submit()" class="form-control mt-5" name="year">
|
||||||
<option>2018</option>
|
<?php
|
||||||
<option>2017</option>
|
|
||||||
|
while($row = mysqli_fetch_array($sql_payment_years)){
|
||||||
|
$payment_year = $row['payment_year'];
|
||||||
|
?>
|
||||||
|
<option <?php if($year == $payment_year){ ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
@@ -35,53 +55,65 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row = mysqli_fetch_array($sql_categories)){
|
||||||
|
$category_id = $row['category_id'];
|
||||||
|
$category_name = $row['category_name'];
|
||||||
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Income Category Type</td>
|
<td><?php echo $category_name; ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
<?php
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
for($month = 1; $month<=12; $month++) {
|
||||||
<td class="text-right">$0.00</td>
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||||
<td class="text-right">$0.00</td>
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
<td class="text-right">$0.00</td>
|
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||||
<td class="text-right">$0.00</td>
|
$total_payment_for_all_months = $payment_amount_for_month + $total_payment_for_all_months;
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
?>
|
||||||
<td class="text-right">$0.00</td>
|
<td class="text-right">$<?php echo number_format($payment_amount_for_month,2); ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
</tr>
|
<?php
|
||||||
<tr>
|
|
||||||
<td>Income Category Type 2</td>
|
}
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
?>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
<td class="text-right">$<?php echo number_format($total_payment_for_all_months,2); ?></td>
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
<td class="text-right">$0.00</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$total_payment_for_all_months = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total</th>
|
<th>Total</th>
|
||||||
<th class="text-right">$0.00</th>
|
<?php
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
for($month = 1; $month<=12; $month++) {
|
||||||
<th class="text-right">$0.00</th>
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||||
<th class="text-right">$0.00</th>
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
<th class="text-right">$0.00</th>
|
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||||
<th class="text-right">$0.00</th>
|
$total_payment_for_all_months = $payment_total_amount_for_month + $total_payment_for_all_months;
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
?>
|
||||||
<th class="text-right">$0.00</th>
|
|
||||||
<th class="text-right">$0.00</th>
|
<th class="text-right">$<?php echo number_format($payment_total_amount_for_month,2); ?></th>
|
||||||
<th class="text-right">$0.00</th>
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<th class="text-right">$<?php echo number_format($total_payment_for_all_months,2); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user