From a0cd266c8bda538f36096787c1693383a3405b4e Mon Sep 17 00:00:00 2001 From: Andrew Malsbury Date: Tue, 14 Nov 2023 15:53:04 +0000 Subject: [PATCH 1/5] Add Client-Replied to ticket sort dropdown --- tickets.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tickets.php b/tickets.php index 16e2ac8e..0ecdae08 100644 --- a/tickets.php +++ b/tickets.php @@ -33,6 +33,9 @@ if (!isset($_GET['status'])) { } elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') { $status = 'Closed'; $ticket_status_snippet = "ticket_status = 'Closed'"; +} else if (isset($_GET['status']) && ($_GET['status']) == 'Client-Replied') { + $status = 'Client-Replied'; + $ticket_status_snippet = "ticket_status = 'Client-Replied'"; } else { $status = '%'; $ticket_status_snippet = "ticket_status LIKE '%'"; @@ -207,6 +210,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']); - - - - - - - - + From 973307524d9767faf6a7141bd1e16bc7dddcd829 Mon Sep 17 00:00:00 2001 From: Andrew Malsbury Date: Tue, 14 Nov 2023 17:23:13 +0000 Subject: [PATCH 3/5] Update to fix main screen --- tickets.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tickets.php b/tickets.php index 3307774a..939b7a75 100644 --- a/tickets.php +++ b/tickets.php @@ -17,13 +17,18 @@ while ($row = mysqli_fetch_assoc($result)) { // Set Ticket statuses sort if (isset($_GET['status']) && !empty($_GET['status'])) { $ticket_statuses = $_GET['status']; - $ticket_status_clause = "ticket_status != 'Closed'"; } else { $ticekt_status = "Open"; +} + +// Set Status Clause for SQL Query +if (!isset($_GET['status']) || empty($_GET['status'])) { + $ticket_status_clause = "ticket_status != 'Closed'"; +} else { $ticket_status_clause = "ticket_status IN ('" . implode("','", $ticket_statuses) . "')"; } -// Make array no matter if one or none items selected. +// Set Statuses if (!empty($_GET['status'])) { $ticket_statuses = is_array($_GET['status']) ? $_GET['status'] : array($_GET['status']); } else { From 4060bea7a65afb91efb7cc4d7ce2b1a7af50b1c8 Mon Sep 17 00:00:00 2001 From: Andrew Malsbury Date: Tue, 14 Nov 2023 17:41:30 +0000 Subject: [PATCH 4/5] Add new ticket status and refactor ticket status filter. --- get_settings.php | 1 + tickets.php | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/get_settings.php b/get_settings.php index b05d5268..80080ae4 100644 --- a/get_settings.php +++ b/get_settings.php @@ -204,6 +204,7 @@ $asset_status_array = array ( $ticket_status_array = array ( 'Pending-Assignment', 'Assigned', + 'Client-Replied', 'In-Progress', 'Pending-Shipment', 'Pending-Client', diff --git a/tickets.php b/tickets.php index 939b7a75..d869a025 100644 --- a/tickets.php +++ b/tickets.php @@ -6,35 +6,24 @@ $order = "DESC"; require_once "inc_all.php"; -// Get Statuses from DB -$statuses = array(); -$query = "SELECT DISTINCT ticket_status FROM tickets ORDER BY ticket_status"; -$result = mysqli_query($mysqli, $query); -while ($row = mysqli_fetch_assoc($result)) { - $statuses[] = $row['ticket_status']; -} -// Set Ticket statuses sort -if (isset($_GET['status']) && !empty($_GET['status'])) { - $ticket_statuses = $_GET['status']; +// Set Statuses from URL +if (!empty($_GET['status'])) { + $raw_statuses = is_array($_GET['status']) ? $_GET['status'] : array($_GET['status']); + $ticket_statuses = array_map(function($status) use ($mysqli) { + return mysqli_real_escape_string($mysqli, $status); + }, $raw_statuses); } else { - $ticekt_status = "Open"; + $ticket_statuses = array(); } // Set Status Clause for SQL Query -if (!isset($_GET['status']) || empty($_GET['status'])) { +if (empty($ticket_statuses)) { $ticket_status_clause = "ticket_status != 'Closed'"; } else { $ticket_status_clause = "ticket_status IN ('" . implode("','", $ticket_statuses) . "')"; } -// Set Statuses -if (!empty($_GET['status'])) { - $ticket_statuses = is_array($_GET['status']) ? $_GET['status'] : array($_GET['status']); -} else { - $ticket_statuses = array(); -} - // Ticket assignment status filter if (isset($_GET['assigned']) & !empty($_GET['assigned'])) { if ($_GET['assigned'] == 'unassigned') { @@ -204,7 +193,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']); fetch_assoc()) { $ticket_id = intval($row['ticket_id']); $ticket_prefix = nullable_htmlentities($row['ticket_prefix']); $ticket_number = intval($row['ticket_number']);