diff --git a/guest_view_invoice.php b/guest_view_invoice.php index bdcdad30..89ae4568 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -87,9 +87,10 @@ if (isset($_GET['invoice_id'], $_GET['url_key'])) { mysqli_query($mysqli, "INSERT INTO history SET history_status = '$invoice_status', history_description = 'Invoice viewed - $ip - $os - $browser', history_created_at = NOW(), history_invoice_id = $invoice_id, company_id = $company_id"); //Prevent SQL Error if client_name has ' in their name example Bill's Market - $client_name_escaped = mysqli_escape_string($mysqli,$row['client_name']); - mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Invoice Viewed', notification = 'Invoice $invoice_prefix$invoice_number has been viewed by $client_name_escaped - $ip - $os - $browser', notification_timestamp = NOW(), notification_client_id = $client_id, company_id = $company_id"); - + if ($invoice_status !== 'Paid') { + $client_name_escaped = mysqli_real_escape_string($mysqli, $row['client_name']); + mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Invoice Viewed', notification = 'Invoice $invoice_prefix$invoice_number has been viewed by $client_name_escaped - $ip - $os - $browser', notification_timestamp = NOW(), notification_client_id = $client_id, company_id = $company_id"); + } $sql_payments = mysqli_query($mysqli, "SELECT * FROM payments, accounts WHERE payment_account_id = account_id AND payment_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