From e0b088b76b515acfced6df17e8861c00aabcfbd9 Mon Sep 17 00:00:00 2001 From: wrongecho Date: Mon, 30 Sep 2024 21:31:04 +0100 Subject: [PATCH] Projects - Add archive and unarchive ability - Improve logic around Open > Close > Archive > Delete - Change to new perms system - Tidy and formatting - TODO: CSRF --- project_details.php | 495 ++++++++++++++++++++++---------------------- 1 file changed, 248 insertions(+), 247 deletions(-) diff --git a/project_details.php b/project_details.php index 04fe51536..c80b267a6 100644 --- a/project_details.php +++ b/project_details.php @@ -22,7 +22,7 @@ } $row = mysqli_fetch_array($sql_project); - + $project_id = intval($row['project_id']); $project_prefix = nullable_htmlentities($row['project_prefix']); $project_number = intval($row['project_number']); @@ -50,7 +50,7 @@ $project_manager_display = "-"; } - if($project_completed_at) { + if ($project_completed_at) { $project_status_display = "Closed"; $project_completed_date_display = "
" . date('Y-m-d', strtotime($project_completed_at)) . "
"; } else { @@ -96,7 +96,7 @@ $completed_task_count = mysqli_num_rows($sql_tasks_completed); // Tasks Completed Percent - if($task_count) { + if ($task_count) { $tasks_completed_percent = round(($completed_task_count / $task_count) * 100); } @@ -121,290 +121,291 @@ // The user names in a comma-separated string $ticket_collaborators = nullable_htmlentities($row['user_names']); - - ?> - - + ?> - -
-
-
-
- -
-

$project_name"; ?>

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

$project_name"; ?>

+
+
-
-
-
-
-
-
- - -
- Total time worked: +
+
+
+
+
+ + +
+ Total time worked: +
+
- -
-
- -
- -
/
-
- - -
- -
/
-
- - -
- -
- -
- -
-
- - - Close - - - +
+ +
+ +
/
+
+ + +
+ +
/
+
-
-
- -
-
- - - 0) { ?> -
- -
Project Tickets
-
- - - - - - - - - - - - - Never

"; +
+
+ + + 0) { ?> +
+ +
Project Tickets
+
+
TicketPriorityStatusAssignedLast ResponseClient
+ + + + + + + + + + + + Never

"; + } else { + $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']); + + if ($ticket_priority == "High") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Medium") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Low") { + $ticket_priority_display = "$ticket_priority"; + } else{ + $ticket_priority_display = "-"; + } + + $ticket_assigned_to = intval($row['ticket_assigned_to']); + if (empty($ticket_assigned_to)) { + if ($ticket_status == 5) { + $ticket_assigned_to_display = "

Not Assigned

"; + } else { + $ticket_assigned_to_display = "

Not Assigned

"; + } + } else { + $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); + } + + $project_id = intval($row['ticket_project_id']); + + $client_id = intval($row['client_id']); + $client_name = nullable_htmlentities($row['client_name']); + + $contact_name = nullable_htmlentities($row['contact_name']); + $contact_email = nullable_htmlentities($row['contact_email']); + $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); + if (empty($contact_archived_at)) { + $contact_archived_display = ""; } else { - $ticket_updated_at_display = "

Never

"; + $contact_archived_display = "Archived - "; } - } else { - $ticket_updated_at_display = "$ticket_updated_at_time_ago
$ticket_updated_at"; - } - $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); - - if ($ticket_priority == "High") { - $ticket_priority_display = "$ticket_priority"; - } elseif ($ticket_priority == "Medium") { - $ticket_priority_display = "$ticket_priority"; - } elseif ($ticket_priority == "Low") { - $ticket_priority_display = "$ticket_priority"; - } else{ - $ticket_priority_display = "-"; - } - - $ticket_assigned_to = intval($row['ticket_assigned_to']); - if (empty($ticket_assigned_to)) { - if ($ticket_status == 5) { - $ticket_assigned_to_display = "

Not Assigned

"; + if (empty($contact_name)) { + $contact_display = "-"; } else { - $ticket_assigned_to_display = "

Not Assigned

"; + $contact_display = "$contact_archived_display$contact_name
$contact_email"; } - } else { - $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); - } - - $project_id = intval($row['ticket_project_id']); - - $client_id = intval($row['client_id']); - $client_name = nullable_htmlentities($row['client_name']); - - $contact_name = nullable_htmlentities($row['contact_name']); - $contact_email = nullable_htmlentities($row['contact_email']); - $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); - if (empty($contact_archived_at)) { - $contact_archived_display = ""; - } else { - $contact_archived_display = "Archived - "; - } - if (empty($contact_name)) { - $contact_display = "-"; - } else { - $contact_display = "$contact_archived_display$contact_name
$contact_email"; - } - - // 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 + + // 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']); + ); + $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']); + } } - } - ?> + ?> - + - - - - + + + + - - + + - - + + - + + + + + + + + + +
TicketPriorityStatusAssignedLast ResponseClient
- - - - - + + + + + - - + + +
+
+
+
+
+ +
+ +
+ + + 0) { ?> +
+
All Tasks
+ + + - - - - -
-
-
+ + + + + + + +
-
- -
- -
- - - 0) { ?> -
-
All Tasks
- - - - - - -
- - - - - - - - -
-
- - + + -
+
-
+
-