diff --git a/client_invoices.php b/client_invoices.php index 0baa4de0..d3d4d8ea 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -10,6 +10,7 @@ Number Amount + Balance Date Due Status @@ -47,11 +48,27 @@ $invoice_badge_color = "secondary"; } + //Add up all the payments for the invoice and get the total amount paid to the invoice + + $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE invoice_id = $invoice_id"); + $row = mysqli_fetch_array($sql_amount_paid); + + $amount_paid = $row['amount_paid']; + + $balance = $invoice_amount - $amount_paid; + //set Text color on balance + if($balance > 0){ + $balance_text_color = "text-danger"; + }else{ + $balance_text_color = ""; + } + ?> INV- $ + $
diff --git a/invoices.php b/invoices.php index 2675633c..c6b7efcf 100644 --- a/invoices.php +++ b/invoices.php @@ -72,7 +72,6 @@ $balance_text_color = ""; } - ?>