From c0eb94efc397b91d1491fbd9258bfc26216f63c4 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 25 Nov 2023 11:29:08 +0000 Subject: [PATCH] Ticketing updates - Client ticket view now defaults to showing Open tickets - Client ticket view now has ability to quick filter between open/closed tickets - Don't render modals for closed tickets (~6x performance boost 0.030 seconds before vs 0.005 seconds after) (we really need dynamic modals for ticketing!) --- client_tickets.php | 49 +++- footer.php | 2 +- header.php | 2 +- tickets.php | 573 +++++++++++++++++++++++---------------------- 4 files changed, 331 insertions(+), 295 deletions(-) diff --git a/client_tickets.php b/client_tickets.php index 30cb59b8..f2ed111c 100644 --- a/client_tickets.php +++ b/client_tickets.php @@ -6,6 +6,16 @@ $order = "DESC"; require_once "inc_all_client.php"; +if (isset($_GET['status']) && ($_GET['status']) == 'Open') { + $status = 'Open'; + $ticket_status_snippet = "ticket_status != 'Closed'"; +} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') { + $status = 'Closed'; + $ticket_status_snippet = "ticket_status = 'Closed'"; +} else { + $status = 'Open'; + $ticket_status_snippet = "ticket_status != 'Closed'"; +} //Rebuild URL $url_query_strings_sort = http_build_query($get_copy); @@ -19,17 +29,33 @@ $sql = mysqli_query( LEFT JOIN locations ON ticket_location_id = location_id LEFT JOIN vendors ON ticket_vendor_id = vendor_id WHERE ticket_client_id = $client_id + AND $ticket_status_snippet AND (CONCAT(ticket_prefix,ticket_number) LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR ticket_status LIKE '%$q%' OR ticket_priority LIKE '%$q%' OR user_name LIKE '%$q%' OR contact_name LIKE '%$q%' OR asset_name LIKE '%$q%' OR vendor_name LIKE '%$q%' OR ticket_vendor_ticket_number LIKE '%q%') ORDER BY $sort $order LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); +//Get Total tickets open +$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_client_id = $client_id AND ticket_status != 'Closed'"); +$row = mysqli_fetch_array($sql_total_tickets_open); +$total_tickets_open = intval($row['total_tickets_open']); + +//Get Total tickets closed +$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_client_id = $client_id AND ticket_status = 'Closed'"); +$row = mysqli_fetch_array($sql_total_tickets_closed); +$total_tickets_closed = intval($row['total_tickets_closed']); + ?>
-

Tickets

+

Tickets + + Open | + Closed + +

+ ?>
diff --git a/footer.php b/footer.php index 0c4364cf..d23f72e5 100644 --- a/footer.php +++ b/footer.php @@ -41,4 +41,4 @@ //$time_end = microtime(true); //$execution_time = ($time_end - $time_start); -//echo 'Total Execution Time: '.number_format((float) $execution_time, 10) .' seconds'; +//echo '

Total Execution Time: '.number_format((float) $execution_time, 10) .' seconds

'; diff --git a/header.php b/header.php index 4ca84faf..3eddc8ae 100644 --- a/header.php +++ b/header.php @@ -2,7 +2,7 @@ // Calculate Execution time start // uncomment for test - //$time_start = microtime(true); + // $time_start = microtime(true); header("X-Frame-Options: DENY"); diff --git a/tickets.php b/tickets.php index fec4f7e6..1d471b30 100644 --- a/tickets.php +++ b/tickets.php @@ -88,304 +88,307 @@ $row = mysqli_fetch_array($sql_total_tickets_assigned); $user_active_assigned_tickets = intval($row['total_tickets_assigned']); ?> - -
-
-

Support Tickets - - Open | - Closed - -

-
-
- -
+ +
+
+

Support Tickets + + Open | + Closed + +

+
+
+
-
-
+
+
+ +
+
+
+ +
+ + +
+
+
+
+ +
+
+ +
" id="advancedFilter">
-
-
- -
- - -
+
+
+ +
-
-
- - - - Unassigned Tickets | - +
+
+ +
-
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + - - - - - - - - - - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
+
- -
-
- - "> - - - - - - - - + + +
+
+
Number - Subject - Client / Contact - Priority - Status - Assigned - Last Response - Created -
+ "> + + + + + + + + - - - - - Action + + + + Never

"; - } else { - $ticket_updated_at_display = "

Never

"; - } + while ($row = mysqli_fetch_array($sql)) { + $ticket_id = intval($row['ticket_id']); + $ticket_prefix = nullable_htmlentities($row['ticket_prefix']); + $ticket_number = intval($row['ticket_number']); + $ticket_subject = nullable_htmlentities($row['ticket_subject']); + $ticket_details = nullable_htmlentities($row['ticket_details']); + $ticket_priority = nullable_htmlentities($row['ticket_priority']); + $ticket_status = nullable_htmlentities($row['ticket_status']); + $ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']); + $ticket_created_at = nullable_htmlentities($row['ticket_created_at']); + $ticket_created_at_time_ago = timeAgo($row['ticket_created_at']); + $ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']); + $ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']); + if (empty($ticket_updated_at)) { + if ($ticket_status == "Closed") { + $ticket_updated_at_display = "

Never

"; } else { - $ticket_updated_at_display = "$ticket_updated_at_time_ago
$ticket_updated_at"; - } - $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); - $client_id = intval($row['ticket_client_id']); - $client_name = nullable_htmlentities($row['client_name']); - $contact_id = intval($row['ticket_contact_id']); - $contact_name = nullable_htmlentities($row['contact_name']); - $contact_title = nullable_htmlentities($row['contact_title']); - $contact_email = nullable_htmlentities($row['contact_email']); - $contact_phone = formatPhoneNumber($row['contact_phone']); - $contact_extension = nullable_htmlentities($row['contact_extension']); - $contact_mobile = formatPhoneNumber($row['contact_mobile']); - if ($ticket_status == "Pending-Assignment") { - $ticket_status_color = "danger"; - } elseif ($ticket_status == "Assigned") { - $ticket_status_color = "primary"; - } elseif ($ticket_status == "In-Progress") { - $ticket_status_color = "success"; - } elseif ($ticket_status == "Closed") { - $ticket_status_color = "dark"; - } else{ - $ticket_status_color = "secondary"; + $ticket_updated_at_display = "

Never

"; } + } else { + $ticket_updated_at_display = "$ticket_updated_at_time_ago
$ticket_updated_at"; + } + $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); + $client_id = intval($row['ticket_client_id']); + $client_name = nullable_htmlentities($row['client_name']); + $contact_id = intval($row['ticket_contact_id']); + $contact_name = nullable_htmlentities($row['contact_name']); + $contact_title = nullable_htmlentities($row['contact_title']); + $contact_email = nullable_htmlentities($row['contact_email']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = nullable_htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + if ($ticket_status == "Pending-Assignment") { + $ticket_status_color = "danger"; + } elseif ($ticket_status == "Assigned") { + $ticket_status_color = "primary"; + } elseif ($ticket_status == "In-Progress") { + $ticket_status_color = "success"; + } elseif ($ticket_status == "Closed") { + $ticket_status_color = "dark"; + } else{ + $ticket_status_color = "secondary"; + } - if ($ticket_priority == "High") { - $ticket_priority_color = "danger"; - } elseif ($ticket_priority == "Medium") { - $ticket_priority_color = "warning"; - } else{ - $ticket_priority_color = "info"; - } - $ticket_assigned_to = intval($row['ticket_assigned_to']); - if (empty($ticket_assigned_to)) { - if ($ticket_status == "Closed") { - $ticket_assigned_to_display = "

Not Assigned

"; - } else { - $ticket_assigned_to_display = "

Not Assigned

"; - } + if ($ticket_priority == "High") { + $ticket_priority_color = "danger"; + } elseif ($ticket_priority == "Medium") { + $ticket_priority_color = "warning"; + } else{ + $ticket_priority_color = "info"; + } + $ticket_assigned_to = intval($row['ticket_assigned_to']); + if (empty($ticket_assigned_to)) { + if ($ticket_status == "Closed") { + $ticket_assigned_to_display = "

Not Assigned

"; } else { - $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); + $ticket_assigned_to_display = "

Not Assigned

"; } + } else { + $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); + } - if (empty($contact_name)) { - $contact_display = "-"; - } else { - $contact_display = "$contact_name
$contact_email"; - } + if (empty($contact_name)) { + $contact_display = "-"; + } else { + $contact_display = "$contact_name
$contact_email"; + } - $asset_id = intval($row['ticket_asset_id']); - $vendor_id = intval($row['ticket_vendor_id']); + $asset_id = intval($row['ticket_asset_id']); + $vendor_id = intval($row['ticket_vendor_id']); - ?> + ?> - "> - - - - - - - - - "> + + + + + + + + + - - + + - } + + } - -
Number + Subject + Client / Contact + Priority + Status + Assigned + Last Response + Created + Action
- - - - - - - - -
-
- -
- -
- -
+ + + + + + + + +
+
+ +
+ +
+ + - + -
-
- + ?> + + +
+
+
- \ No newline at end of file +