From 77333e7b76d04c3c3e53672c4b6725217a633e7e Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Apr 2019 13:28:20 -0400 Subject: [PATCH] Balance now works under clients and client as well as well as a paid to date total under client --- client.php | 19 +++++++++++++++++-- clients.php | 22 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/client.php b/client.php index 02b034ac..dee02027 100644 --- a/client.php +++ b/client.php @@ -21,6 +21,21 @@ if(isset($_GET['client_id'])){ $client_website = $row['client_website']; $client_net_terms = $row['client_net_terms']; + //Add up all the payments for the invoice and get the total amount paid to the invoice + $sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft'"); + $row = mysqli_fetch_array($sql_invoice_amounts); + + $invoice_amounts = $row['invoice_amounts']; + + $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id"); + $row = mysqli_fetch_array($sql_amount_paid); + + $amount_paid = $row['amount_paid']; + + $balance = $invoice_amounts - $amount_paid; + + + //Badge Counts $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('client_contact_id') AS num FROM client_contacts WHERE client_id = $client_id")); @@ -77,8 +92,8 @@ if(isset($_GET['client_id'])){

Standings

-
Paid to Date $0.00 -
Balance $0.00 +
Paid to Date $ +
Balance $