2){ $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); } $client_website = $row['client_website']; $client_net_terms = $row['client_net_terms']; if($client_net_terms == 0){ $client_net_terms = $config_default_net_terms; } $company_id = $row['company_id']; $sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id"); $row = mysqli_fetch_array($sql_company); $company_name = $row['company_name']; $config_company_address = $row['config_company_address']; $config_company_city = $row['config_company_city']; $config_company_state = $row['config_company_state']; $config_company_zip = $row['config_company_zip']; $config_company_phone = $row['config_company_phone']; if(strlen($config_company_phone)>2){ $config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4); } $config_company_email = $row['config_company_email']; //Mark viewed in history mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id"); $sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); //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; //check to see if overdue $unixtime_invoice_due = strtotime($invoice_due); if($unixtime_invoice_due < time()){ $invoice_status = "Overdue"; $invoice_color = "text-danger"; } //Set Badge color based off of invoice status if($invoice_status == "Sent"){ $invoice_badge_color = "warning text-white"; }elseif($invoice_status == "Partial"){ $invoice_badge_color = "primary"; }elseif($invoice_status == "Paid"){ $invoice_badge_color = "success"; }elseif($invoice_status == "Cancelled"){ $invoice_badge_color = "danger"; }else{ $invoice_badge_color = "secondary"; } ?>
| Product | Description | Qty | Price | Tax | Total |
|---|---|---|---|---|---|
| $ | $ | $ |
| Subtotal | $ |
| Discount | $ |
| Tax | $ |
Paid to Date |
$ |
| Balance Due | $ |