From ccb1bf9b0d8df83f7c97e45e563c06c843889721 Mon Sep 17 00:00:00 2001
From: Marcus Hill
$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']);
+ }
+ }
?>
">
-
-
+
@@ -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:
+
+
+
+
+
+
+
-
-
-
-
- $";
- } else {
- echo "X";
- }
- ?>
+
+
+
+
+
+
+
+
+ $";
+ } else {
+ echo "X";
+ }
+ ?>
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
Priority:
+
+
+ Assigned to:
+