From ccb1bf9b0d8df83f7c97e45e563c06c843889721 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 24 Mar 2024 11:31:46 +0000 Subject: [PATCH] General ticket updates/cleanup - Tickets & Client Tickets: General tidy up, fix broken vars, remove unneeded vars, add comments - Client Portal: Show assigned agent for open tickets --- client_tickets.php | 125 +++++++------ portal/ticket.php | 13 +- tickets.php | 437 +++++++++++++++++++++++---------------------- 3 files changed, 301 insertions(+), 274 deletions(-) diff --git a/client_tickets.php b/client_tickets.php index 0b6881edd..2e36fbbdd 100644 --- a/client_tickets.php +++ b/client_tickets.php @@ -144,7 +144,6 @@ $ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_status = nullable_htmlentities($row['ticket_status']); $ticket_billable = intval($row['ticket_billable']); - $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']); @@ -192,13 +191,8 @@ } else { $ticket_assigned_to_display = nullable_htmlentities($row['user_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']); $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); if (empty($contact_archived_at)) { $contact_archived_display = ""; @@ -211,76 +205,93 @@ $contact_display = "$contact_archived_display$contact_name
$contact_email"; } - - $asset_id = intval($row['ticket_asset_id']); - $vendor_id = intval($row['ticket_vendor_id']); - - - // Get Ticket Last updated By in the last ticket reply to be show in the last Response column - $sql_ticket_reply = mysqli_query($mysqli, "SELECT * FROM ticket_replies - LEFT JOIN users ON ticket_reply_by = user_id - LEFT JOIN contacts ON ticket_reply_by = contact_id - WHERE ticket_reply_ticket_id = $ticket_id - AND ticket_reply_archived_at IS NULL - ORDER BY ticket_reply_id DESC LIMIT 1" - ); - $row = mysqli_fetch_array($sql_ticket_reply); - $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); - $ticket_reply_by = intval($row['ticket_reply_by']); - if ($ticket_reply_type == "Client") { - $ticket_reply_by_display = nullable_htmlentities($row['contact_name']); - $user_initials = initials($row['contact_name']); - $user_avatar = nullable_htmlentities($row['contact_photo']); - $avatar_link = "uploads/clients/$client_id/$user_avatar"; - } else { - $ticket_reply_by_display = nullable_htmlentities($row['user_name']); - $user_id = intval($row['user_id']); - $user_avatar = nullable_htmlentities($row['user_avatar']); - $user_initials = initials($row['user_name']); - $avatar_link = "uploads/users/$user_id/$user_avatar"; - } + // Get who last updated the ticket - to be shown in the last Response column + $ticket_reply_type = "Client"; // Default to client for unreplied tickets + $ticket_reply_by_display = ""; // Default none + $sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply_type, contact_name, user_name FROM ticket_replies + LEFT JOIN users ON ticket_reply_by = user_id + LEFT JOIN contacts ON ticket_reply_by = contact_id + WHERE ticket_reply_ticket_id = $ticket_id + AND ticket_reply_archived_at IS NULL + ORDER BY ticket_reply_id DESC LIMIT 1" + ); + $row = mysqli_fetch_array($sql_ticket_reply); + + if ($row) { + $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); + if ($ticket_reply_type == "Client") { + $ticket_reply_by_display = nullable_htmlentities($row['contact_name']); + } else { + $ticket_reply_by_display = nullable_htmlentities($row['user_name']); + } + } ?> "> - + + + + + + + - - - - - $"; - } else { - echo "X"; - } - ?> + + + + + + + + + $"; + } else { + echo "X"; + } + ?> + - - - + + + + + + + + + + + + + + + +
- - + + +
+ - + @@ -311,4 +323,3 @@ require_once "footer.php"; -?> diff --git a/portal/ticket.php b/portal/ticket.php index 4a9ad0530..cee3b2f64 100644 --- a/portal/ticket.php +++ b/portal/ticket.php @@ -19,9 +19,11 @@ $ticket_id = intval($_GET['id']); if ($session_contact_primary == 1 || $session_contact_is_technical_contact) { - $ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id"); + // For a primary / technical contact viewing all tickets + $ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id"); } else { - $ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id"); + // For a user viewing their own ticket + $ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id"); } $ticket_row = mysqli_fetch_array($ticket_sql); @@ -34,6 +36,7 @@ $ticket_priority = nullable_htmlentities($ticket_row['ticket_priority']); $ticket_subject = nullable_htmlentities($ticket_row['ticket_subject']); $ticket_details = $purifier->purify($ticket_row['ticket_details']); + $ticket_assigned_to = nullable_htmlentities($ticket_row['user_name']); $ticket_feedback = nullable_htmlentities($ticket_row['ticket_feedback']); ?> @@ -66,6 +69,10 @@ State:
Priority: +
+ + Assigned to: +

@@ -180,7 +187,7 @@ - - -
-
-

Support Tickets - - Open | - Closed - -

-
- + +
+
+

Support Tickets + + Open | + Closed + +

+
+ +
-
-
-
-
-
-
- -
- - +
+ +
+
+
+ +
+ + +
-
-
-
-
- - -
" id="advancedFilter"> -
-
-
- - +
" id="advancedFilter"> +
+
+
+ + +
-
-
-
- - +
+
+ + +
-
-
-
- - +
+
+ + +
-
-
-
- - +
+
+ + +
-
-
-
- - +
+
+ + +
-
- -
-
- -
- - "> + +
+ + +
+
+ "> - - + + $contact_email"; } - $asset_id = intval($row['ticket_asset_id']); - $vendor_id = intval($row['ticket_vendor_id']); - - - // Get Ticket Last updated By in the last ticket reply to be show in the last Response column - $sql_ticket_reply = mysqli_query($mysqli, "SELECT * FROM ticket_replies - LEFT JOIN users ON ticket_reply_by = user_id - LEFT JOIN contacts ON ticket_reply_by = contact_id - WHERE ticket_reply_ticket_id = $ticket_id - AND ticket_reply_archived_at IS NULL - ORDER BY ticket_reply_id DESC LIMIT 1" + // Get who last updated the ticket - to be shown in the last Response column + $ticket_reply_type = "Client"; // Default to client for unreplied tickets + $ticket_reply_by_display = ""; // Default none + $sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply_type, contact_name, user_name FROM ticket_replies + LEFT JOIN users ON ticket_reply_by = user_id + LEFT JOIN contacts ON ticket_reply_by = contact_id + WHERE ticket_reply_ticket_id = $ticket_id + AND ticket_reply_archived_at IS NULL + ORDER BY ticket_reply_id DESC LIMIT 1" ); $row = mysqli_fetch_array($sql_ticket_reply); - $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); - $ticket_reply_by = intval($row['ticket_reply_by']); - if ($ticket_reply_type == "Client") { - $ticket_reply_by_display = nullable_htmlentities($row['contact_name']); - $user_initials = initials($row['contact_name']); - $user_avatar = nullable_htmlentities($row['contact_photo']); - $avatar_link = "uploads/clients/$client_id/$user_avatar"; - } else { - $ticket_reply_by_display = nullable_htmlentities($row['user_name']); - $user_id = intval($row['user_id']); - $user_avatar = nullable_htmlentities($row['user_avatar']); - $user_initials = initials($row['user_name']); - $avatar_link = "uploads/users/$user_id/$user_avatar"; + + if ($row) { + $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); + + if ($ticket_reply_type == "Client") { + $ticket_reply_by_display = nullable_htmlentities($row['contact_name']); + } else { + $ticket_reply_by_display = nullable_htmlentities($row['user_name']); + } } - ?> + ?> - "> + "> + + + + + + + + + - - - + + + + + + + + + + + + - - + - -
@@ -301,8 +301,8 @@
@@ -416,20 +404,27 @@
@@ -443,24 +438,39 @@ $ticket_scheduled_for "; } ?> + + + $ticket_scheduled_for "; } ?> + + +

-
- - - - - - + + +
+ + + + + + +
-
- +