From f4051fe718d6eec21671b664101352530ae61d2a Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 8 Apr 2024 15:58:59 -0400 Subject: [PATCH] Updated Ticket details to include Tasks Completion Status and Collaborators --- ticket.php | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/ticket.php b/ticket.php index 719ab501..a6ea8864 100644 --- a/ticket.php +++ b/ticket.php @@ -260,6 +260,34 @@ if (isset($_GET['ticket_id'])) { // Get Tasks $sql_tasks = mysqli_query( $mysqli, "SELECT * FROM tasks WHERE task_ticket_id = $ticket_id ORDER BY task_created_at ASC"); + $task_count = mysqli_num_rows($sql_tasks); + + // Get Completed Task Count + $sql_tasks_completed = mysqli_query($mysqli, + "SELECT * FROM tasks + WHERE task_ticket_id = $ticket_id + AND task_completed_at IS NOT NULL" + ); + $completed_task_count = mysqli_num_rows($sql_tasks_completed); + + // Tasks Completed Percent + if($task_count) { + $tasks_completed_percent = ($completed_task_count / $task_count) * 100; + } + + // Get all Assigned ticket Users as a comma-separated string + $sql_ticket_collaborators = mysqli_query($mysqli, " + SELECT GROUP_CONCAT(DISTINCT user_name SEPARATOR ', ') AS user_names + FROM users + LEFT JOIN ticket_replies ON user_id = ticket_reply_by + WHERE ticket_reply_archived_at IS NULL AND ticket_reply_ticket_id = $ticket_id + "); + + // Fetch the result + $row = mysqli_fetch_assoc($sql_ticket_collaborators); + + // The user names in a comma-separated string + $ticket_collaborators = nullable_htmlentities($row['user_names']); ?> @@ -275,7 +303,7 @@ if (isset($_GET['ticket_id'])) {
-
+
@@ -319,7 +347,7 @@ if (isset($_GET['ticket_id'])) {
-
+
@@ -361,11 +389,22 @@ if (isset($_GET['ticket_id'])) {
-
+
+ + Tasks Completed% +
+
/
+
+ + +
+ +
+
-
+