From 231694aabeb7c6a3df0e9b0c929e26d155606b6e Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 27 Mar 2025 13:38:22 -0400 Subject: [PATCH] Fix Invoice Vars in ticket, return empty string instead of null for getFieldByID() --- functions.php | 2 +- ticket.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/functions.php b/functions.php index 82e1b682..3176c6ba 100644 --- a/functions.php +++ b/functions.php @@ -1573,7 +1573,7 @@ function getFieldById($table, $id, $field, $escape_method = 'sql') { // Apply the desired escaping method or auto-detect integer type if using SQL escaping switch ($escape_method) { case 'html': - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); // Escape for HTML + return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8'); // Escape for HTML case 'json': return json_encode($value); // Escape for JSON case 'int': diff --git a/ticket.php b/ticket.php index 86f531e1..4f60601f 100644 --- a/ticket.php +++ b/ticket.php @@ -161,6 +161,11 @@ if (isset($_GET['ticket_id'])) { $location_zip = nullable_htmlentities($row['location_zip']); $location_phone = formatPhoneNumber($row['location_phone']); + $invoice_id = intval($row['ticket_invoice_id']); + $invoice_prefix = nullable_htmlentities($row['invoice_prefix']); + $invoice_number = intval($row['invoice_number']); + $invoice_created_at = nullable_htmlentities($row['invoice_created_at']); + $project_id = intval($row['project_id']); $project_prefix = nullable_htmlentities($row['project_prefix']); $project_number = intval($row['project_number']); @@ -175,10 +180,7 @@ if (isset($_GET['ticket_id'])) { $project_manager_name = nullable_htmlentities($row['user_name']); } - $invoice_id = intval($row['ticket_invoice_id']); - $invoice_prefix = nullable_htmlentities($row['invoice_prefix']); - $invoice_number = intval($row['invoice_number']); - $invoice_created_at = nullable_htmlentities($row['invoice_created_at']); + if ($contact_id) { //Get Contact Ticket Stats