From 8bc7c849ef426e0baf54d6d09bb40e5fcde7ea3d Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 3 Jun 2024 19:36:16 -0400 Subject: [PATCH] Feature: Added the ability to edit the order of the tasks this is not the best solution but works we recommend setting them in orders of 5 or 10 so there is wiggle room to add tasks in between --- admin_ticket_template_details.php | 3 ++- post/tasks.php | 7 +++---- task_edit_modal.php | 10 ++++++++++ ticket.php | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/admin_ticket_template_details.php b/admin_ticket_template_details.php index e835a521..1c38a709 100644 --- a/admin_ticket_template_details.php +++ b/admin_ticket_template_details.php @@ -26,7 +26,7 @@ $ticket_template_created_at = nullable_htmlentities($row['ticket_template_create $ticket_template_updated_at = nullable_htmlentities($row['ticket_template_updated_at']); // Get Task Templates -$sql_task_templates = mysqli_query($mysqli, "SELECT * FROM task_templates WHERE task_template_ticket_template_id = $ticket_template_id"); +$sql_task_templates = mysqli_query($mysqli, "SELECT * FROM task_templates WHERE task_template_ticket_template_id = $ticket_template_id ORDER BY task_template_order ASC, task_template_id ASC"); ?> @@ -97,6 +97,7 @@ $sql_task_templates = mysqli_query($mysqli, "SELECT * FROM task_templates WHERE while($row = mysqli_fetch_array($sql_task_templates)){ $task_id = intval($row['task_template_id']); $task_name = nullable_htmlentities($row['task_template_name']); + $task_order = intval($row['task_template_order']); $task_description = nullable_htmlentities($row['task_template_description']); ?> diff --git a/post/tasks.php b/post/tasks.php index ec78b623..f3cc71f8 100644 --- a/post/tasks.php +++ b/post/tasks.php @@ -34,6 +34,7 @@ if (isset($_POST['edit_task'])) { $task_id = intval($_POST['task_id']); $task_name = sanitizeInput($_POST['name']); + $task_order = intval($_POST['order']); $is_ticket = intval($_POST['is_ticket']); if($is_ticket == 1) { @@ -41,14 +42,12 @@ if (isset($_POST['edit_task'])) { $sql = mysqli_query($mysqli, "SELECT * FROM tasks LEFT JOIN tickets ON ticket_id = task_ticket_id WHERE task_id = $task_id"); $row = mysqli_fetch_array($sql); $client_id = intval($row['ticket_client_id']); - mysqli_query($mysqli, "UPDATE tasks SET task_name = '$task_name' WHERE task_id = $task_id"); + mysqli_query($mysqli, "UPDATE tasks SET task_name = '$task_name', task_order = $task_order WHERE task_id = $task_id"); } else { $client_id = 0; - mysqli_query($mysqli, "UPDATE task_templates SET task_template_name = '$task_name' WHERE task_template_id = $task_id"); + mysqli_query($mysqli, "UPDATE task_templates SET task_template_name = '$task_name', task_template_order = $task_order WHERE task_template_id = $task_id"); } - - // Logging mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Task', log_action = 'Edit', log_description = '$session_name edited task $task_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $task_id"); diff --git a/task_edit_modal.php b/task_edit_modal.php index c00f9637..96d69657 100644 --- a/task_edit_modal.php +++ b/task_edit_modal.php @@ -23,6 +23,16 @@ + +
+ +
+
+ +
+ +
+
diff --git a/ticket.php b/ticket.php index b97408f6..cf00fceb 100644 --- a/ticket.php +++ b/ticket.php @@ -286,7 +286,7 @@ 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"); + $sql_tasks = mysqli_query( $mysqli, "SELECT * FROM tasks WHERE task_ticket_id = $ticket_id ORDER BY task_order ASC, task_id ASC"); $task_count = mysqli_num_rows($sql_tasks); // Get Completed Task Count @@ -914,6 +914,7 @@ if (isset($_GET['ticket_id'])) { while($row = mysqli_fetch_array($sql_tasks)){ $task_id = intval($row['task_id']); $task_name = nullable_htmlentities($row['task_name']); + $task_order = intval($row['task_order']); $task_description = nullable_htmlentities($row['task_description']); $task_completed_at = nullable_htmlentities($row['task_completed_at']); ?>