mirror of https://github.com/itflow-org/itflow
Added Report Clients with a Balance
This commit is contained in:
parent
090ecf2e80
commit
0c7fbda127
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
require_once("inc_all_reports.php");
|
||||
validateAccountantRole();
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fas fa-fw fa-exclamation-triangle mr-2"></i>Clients with a Balance</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<?php
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT c.client_id, c.client_name,
|
||||
IFNULL(SUM(i.invoice_amount), 0) AS invoice_amounts,
|
||||
IFNULL(SUM(p.payment_amount), 0) AS amount_paid
|
||||
FROM
|
||||
clients c
|
||||
LEFT JOIN
|
||||
invoices i ON c.client_id = i.invoice_client_id AND i.invoice_status NOT IN ('Draft', 'Cancelled')
|
||||
LEFT JOIN
|
||||
payments p ON i.invoice_id = p.payment_invoice_id
|
||||
GROUP BY
|
||||
c.client_id
|
||||
HAVING
|
||||
IFNULL(SUM(i.invoice_amount), 0) - IFNULL(SUM(p.payment_amount), 0) != 0
|
||||
");
|
||||
|
||||
?>
|
||||
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client</th>
|
||||
<th class="text-right">Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$invoice_amounts = floatval($row['invoice_amounts']);
|
||||
$amount_paid = floatval($row['amount_paid']);
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $balance, $session_company_currency); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once("footer.php");
|
||||
|
|
@ -37,6 +37,12 @@
|
|||
<p>Recurring Income By Client</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_clients_with_balance.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_clients_with_balance.php") { echo "active"; } ?>">
|
||||
<i class="fa fa-exclamation-triangle nav-icon"></i>
|
||||
<p>Clients with a Balance</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_expense_summary.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_expense_summary.php") { echo "active"; } ?>">
|
||||
<i class="far fa-credit-card nav-icon"></i>
|
||||
|
|
|
|||
Loading…
Reference in New Issue