Skip to content

Commit e3ae8df

Browse files
committed
new changes
1 parent f4eaba4 commit e3ae8df

8 files changed

+107
-72
lines changed

ajax.php

+77
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,80 @@
529529
if (isset($_GET['get_readable_pass'])) {
530530
echo json_encode(GenerateReadablePassword(4));
531531
}
532+
533+
/*
534+
* ITFlow - POST request handler for client tickets
535+
*/
536+
if (isset($_POST['update_kanban_status_position'])) {
537+
// Update multiple ticket status kanban orders
538+
enforceUserPermission('module_support', 2);
539+
540+
$positions = $_POST['positions'];
541+
542+
foreach ($positions as $position) {
543+
$status_id = intval($position['status_id']);
544+
$kanban = intval($position['status_kanban']);
545+
546+
mysqli_query($mysqli, "UPDATE ticket_statuses SET ticket_status_order = $kanban WHERE ticket_status_id = $status_id");
547+
}
548+
549+
// return a response
550+
echo json_encode(['status' => 'success']);
551+
exit;
552+
}
553+
554+
if (isset($_POST['update_kanban_ticket'])) {
555+
// Update ticket kanban order and status
556+
enforceUserPermission('module_support', 2);
557+
558+
559+
// have to do new logic, to update only one dragged ticket
560+
$positions = $_POST['positions']; //old and new position
561+
562+
563+
564+
565+
// old logic that updated all tickets on the column
566+
$positions = $_POST['positions'];
567+
568+
foreach ($positions as $position) {
569+
$ticket_id = intval($position['ticket_id']);
570+
$kanban = intval($position['ticket_kanban']); // ticket kanban position
571+
$status = intval($position['ticket_status']); // ticket statuses
572+
$oldStatus = intval($position['ticket_oldStatus']); // ticket old status if moved
573+
574+
$statuses['Closed'] = 5;
575+
$statuses['Resolved'] = 4;
576+
577+
// Continue if status is null / Closed
578+
if ($status === null || $status === $statuses['Closed']) {
579+
continue;
580+
}
581+
582+
583+
if ($oldStatus === false) {
584+
// if ticket was not moved, just uptdate the order on kanban
585+
mysqli_query($mysqli, "UPDATE tickets SET ticket_kanban = $kanban WHERE ticket_id = $ticket_id");
586+
customAction('ticket_update', $ticket_id);
587+
} else {
588+
// If the ticket was moved from a resolved status to another status, we need to update ticket_resolved_at
589+
if ($oldStatus === $statuses['Resolved']) {
590+
mysqli_query($mysqli, "UPDATE tickets SET ticket_kanban = $kanban, ticket_status = $status, ticket_resolved_at = NULL WHERE ticket_id = $ticket_id");
591+
customAction('ticket_update', $ticket_id);
592+
} elseif ($status === $statuses['Resolved']) {
593+
// If the ticket was moved to a resolved status, we need to update ticket_resolved_at
594+
mysqli_query($mysqli, "UPDATE tickets SET ticket_kanban = $kanban, ticket_status = $status, ticket_resolved_at = NOW() WHERE ticket_id = $ticket_id");
595+
customAction('ticket_update', $ticket_id);
596+
} else {
597+
// If the ticket was moved from any status to another status
598+
mysqli_query($mysqli, "UPDATE tickets SET ticket_kanban = $kanban, ticket_status = $status WHERE ticket_id = $ticket_id");
599+
customAction('ticket_update', $ticket_id);
600+
}
601+
}
602+
603+
}
604+
605+
// return a response
606+
echo json_encode(['status' => 'success','payload' => $positions]);
607+
exit;
608+
}

database_updates.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2472,7 +2472,7 @@ function processFile($file_path, $file_name, $mysqli) {
24722472
if (CURRENT_DATABASE_VERSION == '1.8.0') {
24732473

24742474

2475-
mysqli_query($mysqli, "ALTER TABLE `ticket_statuses` ADD `ticket_status_kanban` int(11)");
2475+
mysqli_query($mysqli, "ALTER TABLE `ticket_statuses` ADD `ticket_status_order` int(11)");
24762476

24772477
mysqli_query($mysqli, "ALTER TABLE `tickets` ADD `ticket_kanban` int(11);");
24782478

db.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ CREATE TABLE `ticket_statuses` (
20192019
`ticket_status_name` varchar(200) NOT NULL,
20202020
`ticket_status_color` varchar(200) NOT NULL,
20212021
`ticket_status_active` tinyint(1) NOT NULL DEFAULT 1,
2022-
`ticket_status_kanban` int(11),
2022+
`ticket_status_order` int(11),
20232023
PRIMARY KEY (`ticket_status_id`)
20242024
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
20252025
/*!40101 SET character_set_client = @saved_cs_client */;

plugins/dragula/dragula.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/dragula/dragula.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

post/user/ticket_kanban.php

-50
This file was deleted.

0 commit comments

Comments
 (0)