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

This commit is contained in:
johnnyq 2024-06-03 19:36:16 -04:00
parent 1076ffb5f7
commit 8bc7c849ef
4 changed files with 17 additions and 6 deletions

View File

@ -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']);
?>
<tr>

View File

@ -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");

View File

@ -24,6 +24,16 @@
</div>
</div>
<div class="form-group">
<label>Order</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-sort-numeric-down"></i></span>
</div>
<input type="number" class="form-control" name="order" placeholder="Order" value="<?php echo $task_order; ?>">
</div>
</div>
</div>
<div class="modal-footer bg-white">

View File

@ -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']);
?>