mirror of
https://github.com/itflow-org/itflow
synced 2026-09-22 14:41:17 +00:00
Allow Project template ticket templates to be Drag and drop sorted instead of manually typing in the order
This commit is contained in:
@@ -130,10 +130,9 @@ if (isset($_GET['project_template_id'])) {
|
|||||||
|
|
||||||
<h5 class="text-secondary"><i class="fa fa-fw fa-life-ring mr-2"></i>Project Ticket Templates</h5>
|
<h5 class="text-secondary"><i class="fa fa-fw fa-life-ring mr-2"></i>Project Ticket Templates</h5>
|
||||||
<div class="table-responsive-sm">
|
<div class="table-responsive-sm">
|
||||||
<table class="table table-striped table-borderless table-hover">
|
<table class="table table-striped table-borderless table-hover" id="ticket_templates">
|
||||||
<thead class="text-dark">
|
<thead class="text-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Order</th>
|
|
||||||
<th>Template Name</th>
|
<th>Template Name</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Ticket Subject</th>
|
<th>Ticket Subject</th>
|
||||||
@@ -154,17 +153,9 @@ if (isset($_GET['project_template_id'])) {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr data-task-id="<?php echo $ticket_template_id; ?>">
|
||||||
<td class="pr-0">
|
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
|
||||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
||||||
<input type="hidden" name="edit_ticket_template_order">
|
|
||||||
<input type="hidden" name="project_template_id" value="<?php echo $project_template_id; ?>">
|
|
||||||
<input type="hidden" name="ticket_template_id" value="<?php echo $ticket_template_id; ?>">
|
|
||||||
<input type="text" class="form-control pr-0" onchange="this.form.submit()" name="order" value="<?php echo $ticket_template_order; ?>">
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
|
<a href="#" class="drag-handle"><i class="fas fa-bars text-muted mr-2"></i></a>
|
||||||
<a href="ticket_template_details.php?ticket_template_id=<?php echo $ticket_template_id; ?>">
|
<a href="ticket_template_details.php?ticket_template_id=<?php echo $ticket_template_id; ?>">
|
||||||
<?php echo $ticket_template_name; ?>
|
<?php echo $ticket_template_name; ?>
|
||||||
</a>
|
</a>
|
||||||
@@ -221,6 +212,28 @@ if (isset($_GET['project_template_id'])) {
|
|||||||
|
|
||||||
</div> <!-- End row -->
|
</div> <!-- End row -->
|
||||||
|
|
||||||
|
<script src="../plugins/SortableJS/Sortable.min.js"></script>
|
||||||
|
<script>
|
||||||
|
new Sortable(document.querySelector('table#ticket_templates tbody'), {
|
||||||
|
handle: '.drag-handle',
|
||||||
|
animation: 150,
|
||||||
|
onEnd: function (evt) {
|
||||||
|
const rows = document.querySelectorAll('table#ticket_templates tbody tr');
|
||||||
|
const positions = Array.from(rows).map((row, index) => ({
|
||||||
|
id: row.dataset.taskId,
|
||||||
|
order: index
|
||||||
|
}));
|
||||||
|
|
||||||
|
$.post('/agent/ajax.php', {
|
||||||
|
update_project_template_ticket_order: true,
|
||||||
|
csrf_token: '<?= $_SESSION['csrf_token'] ?>',
|
||||||
|
project_template_id: <?php echo $project_template_id; ?>,
|
||||||
|
positions: positions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -612,6 +612,27 @@ if (isset($_POST['update_task_templates_order'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['update_project_template_ticket_order'])) {
|
||||||
|
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
enforceUserPermission('module_support', 2);
|
||||||
|
|
||||||
|
$positions = $_POST['positions'];
|
||||||
|
$project_template_id = intval($_POST['project_template_id']);
|
||||||
|
|
||||||
|
foreach ($positions as $position) {
|
||||||
|
$id = intval($position['id']);
|
||||||
|
$order = intval($position['order']);
|
||||||
|
|
||||||
|
mysqli_query($mysqli, "UPDATE project_template_ticket_templates SET ticket_template_order = $order WHERE project_template_id = $project_template_id AND ticket_template_id = $id");
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a response
|
||||||
|
echo json_encode(['status' => 'success']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST['update_quote_items_order'])) {
|
if (isset($_POST['update_quote_items_order'])) {
|
||||||
// Update multiple quote items order
|
// Update multiple quote items order
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user