mirror of
https://github.com/itflow-org/itflow
synced 2026-03-28 00:05:40 +00:00
Modified Report Client with a Balance to Sort Highest Balance First
This commit is contained in:
@@ -15,9 +15,13 @@ validateAccountantRole();
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$sql_clients = mysqli_query($mysqli, "SELECT c.client_id, c.client_name,
|
$sql_clients = mysqli_query($mysqli, "
|
||||||
IFNULL(SUM(i.invoice_amount), 0) AS invoice_amounts,
|
SELECT
|
||||||
IFNULL(SUM(p.payment_amount), 0) AS amount_paid
|
c.client_id,
|
||||||
|
c.client_name,
|
||||||
|
IFNULL(SUM(i.invoice_amount), 0) AS invoice_amounts,
|
||||||
|
IFNULL(SUM(p.payment_amount), 0) AS amount_paid,
|
||||||
|
IFNULL(SUM(i.invoice_amount), 0) - IFNULL(SUM(p.payment_amount), 0) AS balance
|
||||||
FROM
|
FROM
|
||||||
clients c
|
clients c
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
@@ -27,7 +31,9 @@ validateAccountantRole();
|
|||||||
GROUP BY
|
GROUP BY
|
||||||
c.client_id
|
c.client_id
|
||||||
HAVING
|
HAVING
|
||||||
IFNULL(SUM(i.invoice_amount), 0) - IFNULL(SUM(p.payment_amount), 0) != 0
|
balance != 0
|
||||||
|
ORDER BY
|
||||||
|
balance DESC
|
||||||
");
|
");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -45,10 +51,7 @@ validateAccountantRole();
|
|||||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||||
$client_id = intval($row['client_id']);
|
$client_id = intval($row['client_id']);
|
||||||
$client_name = nullable_htmlentities($row['client_name']);
|
$client_name = nullable_htmlentities($row['client_name']);
|
||||||
$invoice_amounts = floatval($row['invoice_amounts']);
|
$balance = floatval($row['balance']);
|
||||||
$amount_paid = floatval($row['amount_paid']);
|
|
||||||
|
|
||||||
$balance = $invoice_amounts - $amount_paid;
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user