|
30 | 30 | $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"); |
31 | 31 |
|
32 | 32 | ?> |
33 | | -<link rel="stylesheet" href="plugins/dragula/dragula.min.css"> |
34 | | - |
35 | | - <ol class="breadcrumb d-print-none"> |
36 | | - <li class="breadcrumb-item"> |
37 | | - <a href="clients.php">Home</a> |
38 | | - </li> |
39 | | - <li class="breadcrumb-item"> |
40 | | - <a href="admin_user.php">Admin</a> |
41 | | - </li> |
42 | | - <li class="breadcrumb-item"> |
43 | | - <a href="admin_ticket_template.php">Ticket Templates</a> |
44 | | - </li> |
45 | | - <li class="breadcrumb-item active"><i class="fas fa-life-ring mr-2"></i><?php echo $ticket_template_name; ?></li> |
46 | | - </ol> |
47 | | - |
48 | | - <div class="row"> |
49 | | - <div class="col-8"> |
50 | | - |
51 | | - <div class="card card-dark"> |
52 | | - <div class="card-header"> |
53 | | - <h3 class="card-title mt-2"> |
54 | | - <div class="media"> |
55 | | - <i class="fa fa-fw fa-2x fa-life-ring mr-3"></i> |
56 | | - <div class="media-body"> |
57 | | - <h3 class="mb-0"><?php echo $ticket_template_name; ?></h3> |
58 | | - <div><small class="text-secondary"><?php echo $ticket_template_description; ?></small></div> |
59 | | - </div> |
| 33 | + |
| 34 | +<ol class="breadcrumb d-print-none"> |
| 35 | + <li class="breadcrumb-item"> |
| 36 | + <a href="clients.php">Home</a> |
| 37 | + </li> |
| 38 | + <li class="breadcrumb-item"> |
| 39 | + <a href="admin_user.php">Admin</a> |
| 40 | + </li> |
| 41 | + <li class="breadcrumb-item"> |
| 42 | + <a href="admin_ticket_template.php">Ticket Templates</a> |
| 43 | + </li> |
| 44 | + <li class="breadcrumb-item active"><i class="fas fa-life-ring mr-2"></i><?php echo $ticket_template_name; ?></li> |
| 45 | +</ol> |
| 46 | + |
| 47 | +<div class="row"> |
| 48 | + <div class="col-8"> |
| 49 | + |
| 50 | + <div class="card card-dark"> |
| 51 | + <div class="card-header"> |
| 52 | + <h3 class="card-title mt-2"> |
| 53 | + <div class="media"> |
| 54 | + <i class="fa fa-fw fa-2x fa-life-ring mr-3"></i> |
| 55 | + <div class="media-body"> |
| 56 | + <h3 class="mb-0"><?php echo $ticket_template_name; ?></h3> |
| 57 | + <div><small class="text-secondary"><?php echo $ticket_template_description; ?></small></div> |
60 | 58 | </div> |
61 | | - </h3> |
62 | | - <div class="card-tools"> |
63 | | - <button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#editTicketTemplateModal"> |
64 | | - <i class="fas fa-edit"></i> |
65 | | - </button> |
66 | 59 | </div> |
67 | | - </div> |
68 | | - <h5><?php echo $ticket_template_subject; ?></h5> |
69 | | - <div class="card-body prettyContent"> |
70 | | - <?php echo $ticket_template_details; ?> |
| 60 | + </h3> |
| 61 | + <div class="card-tools"> |
| 62 | + <button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#editTicketTemplateModal"> |
| 63 | + <i class="fas fa-edit"></i> |
| 64 | + </button> |
71 | 65 | </div> |
72 | 66 | </div> |
73 | | - |
| 67 | + <h5><?php echo $ticket_template_subject; ?></h5> |
| 68 | + <div class="card-body prettyContent"> |
| 69 | + <?php echo $ticket_template_details; ?> |
| 70 | + </div> |
74 | 71 | </div> |
75 | 72 |
|
76 | | - <div class="col-4"> |
| 73 | + </div> |
77 | 74 |
|
78 | | - <div class="card card-dark"> |
79 | | - <div class="card-header"> |
80 | | - <h5 class="card-title"><i class="fa fa-fw fa-tasks mr-2"></i>Tasks</h5> |
81 | | - </div> |
82 | | - <div class="card-body"> |
83 | | - <form action="post.php" method="post" autocomplete="off"> |
84 | | - <input type="hidden" name="ticket_template_id" value="<?php echo $ticket_template_id; ?>"> |
85 | | - <div class="form-group"> |
86 | | - <div class="input-group"> |
87 | | - <div class="input-group-prepend"> |
88 | | - <span class="input-group-text"><i class="fa fa-fw fa-tasks"></i></span> |
89 | | - </div> |
90 | | - <input type="text" class="form-control" name="task_name" placeholder="Create a task" required> |
91 | | - <div class="input-group-append"> |
92 | | - <button type="submit" name="add_ticket_template_task" class="btn btn-primary"><i class="fas fa-fw fa-check"></i></button> |
93 | | - </div> |
| 75 | + <div class="col-4"> |
| 76 | + |
| 77 | + <div class="card card-dark"> |
| 78 | + <div class="card-header"> |
| 79 | + <h5 class="card-title"><i class="fa fa-fw fa-tasks mr-2"></i>Tasks</h5> |
| 80 | + </div> |
| 81 | + <div class="card-body"> |
| 82 | + <form action="post.php" method="post" autocomplete="off"> |
| 83 | + <input type="hidden" name="ticket_template_id" value="<?php echo $ticket_template_id; ?>"> |
| 84 | + <div class="form-group"> |
| 85 | + <div class="input-group"> |
| 86 | + <div class="input-group-prepend"> |
| 87 | + <span class="input-group-text"><i class="fa fa-fw fa-tasks"></i></span> |
| 88 | + </div> |
| 89 | + <input type="text" class="form-control" name="task_name" placeholder="Create a task" required> |
| 90 | + <div class="input-group-append"> |
| 91 | + <button type="submit" name="add_ticket_template_task" class="btn btn-primary"><i class="fas fa-fw fa-check"></i></button> |
94 | 92 | </div> |
95 | 93 | </div> |
96 | | - </form> |
97 | | - <table class="table table-striped table-sm"> |
98 | | - <?php |
99 | | - while($row = mysqli_fetch_array($sql_task_templates)){ |
100 | | - $task_id = intval($row['task_template_id']); |
101 | | - $task_name = nullable_htmlentities($row['task_template_name']); |
102 | | - $task_completion_estimate = intval($row['task_template_completion_estimate']); |
103 | | - $task_description = nullable_htmlentities($row['task_template_description']); |
104 | | - ?> |
105 | | - <tr data-task-id="<?php echo $task_id; ?>"> |
106 | | - <td><i class="far fa-fw fa-square text-secondary"></i></td> |
107 | | - <td> |
108 | | - <a href="#" class="grab-cursor"> |
109 | | - <span class="text-secondary"><?php echo $task_completion_estimate; ?>m</span> |
110 | | - <span class="text-dark"> - <?php echo $task_name; ?></span> |
111 | | - </a> |
112 | | - </td> |
113 | | - <td class="text-right"> |
114 | | - <div class="float-right"> |
115 | | - <div class="dropdown dropleft text-center"> |
116 | | - <button class="btn btn-link text-secondary btn-sm" type="button" data-toggle="dropdown"> |
117 | | - <i class="fas fa-fw fa-ellipsis-v"></i> |
118 | | - </button> |
119 | | - <div class="dropdown-menu"> |
120 | | - <a class="dropdown-item" href="#" |
121 | | - data-toggle = "ajax-modal" |
122 | | - data-ajax-url = "ajax/ajax_ticket_template_task_edit.php" |
123 | | - data-ajax-id = "<?php echo $task_id; ?>" |
124 | | - > |
125 | | - <i class="fas fa-fw fa-edit mr-2"></i>Edit |
126 | | - </a> |
127 | | - <div class="dropdown-divider"></div> |
128 | | - <a class="dropdown-item text-danger confirm-link" href="post.php?delete_task_template=<?php echo $task_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> |
129 | | - <i class="fas fa-fw fa-trash-alt mr-2"></i>Delete |
130 | | - </a> |
131 | | - </div> |
| 94 | + </div> |
| 95 | + </form> |
| 96 | + <table class="table table-sm" id="tasks"> |
| 97 | + <?php |
| 98 | + while($row = mysqli_fetch_array($sql_task_templates)){ |
| 99 | + $task_id = intval($row['task_template_id']); |
| 100 | + $task_name = nullable_htmlentities($row['task_template_name']); |
| 101 | + $task_completion_estimate = intval($row['task_template_completion_estimate']); |
| 102 | + $task_description = nullable_htmlentities($row['task_template_description']); |
| 103 | + ?> |
| 104 | + <tr data-task-id="<?php echo $task_id; ?>"> |
| 105 | + <td> |
| 106 | + <a href="#" class="drag-handle"><i class="fas fa-bars text-muted mr-1"></i></a> |
| 107 | + <span class="text-secondary"><?php echo $task_completion_estimate; ?>m</span> |
| 108 | + <span class="text-dark"> - <?php echo $task_name; ?></span> |
| 109 | + </td> |
| 110 | + <td class="text-right"> |
| 111 | + <div class="float-right"> |
| 112 | + <div class="dropdown dropleft text-center"> |
| 113 | + <button class="btn btn-link text-secondary btn-sm" type="button" data-toggle="dropdown"> |
| 114 | + <i class="fas fa-fw fa-ellipsis-v"></i> |
| 115 | + </button> |
| 116 | + <div class="dropdown-menu"> |
| 117 | + <a class="dropdown-item" href="#" |
| 118 | + data-toggle = "ajax-modal" |
| 119 | + data-ajax-url = "ajax/ajax_ticket_template_task_edit.php" |
| 120 | + data-ajax-id = "<?php echo $task_id; ?>" |
| 121 | + > |
| 122 | + <i class="fas fa-fw fa-edit mr-2"></i>Edit |
| 123 | + </a> |
| 124 | + <div class="dropdown-divider"></div> |
| 125 | + <a class="dropdown-item text-danger confirm-link" href="post.php?delete_task_template=<?php echo $task_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> |
| 126 | + <i class="fas fa-fw fa-trash-alt mr-2"></i>Delete |
| 127 | + </a> |
132 | 128 | </div> |
133 | 129 | </div> |
134 | | - </td> |
135 | | - </tr> |
136 | | - <?php |
137 | | - } |
138 | | - ?> |
139 | | - </table> |
140 | | - </div> |
| 130 | + </div> |
| 131 | + </td> |
| 132 | + </tr> |
| 133 | + <?php |
| 134 | + } |
| 135 | + ?> |
| 136 | + </table> |
141 | 137 | </div> |
142 | | - |
143 | 138 | </div> |
144 | 139 |
|
145 | 140 | </div> |
146 | 141 |
|
147 | | - <script src="js/pretty_content.js"></script> |
148 | | - <script src="plugins/dragula/dragula.min.js"></script> |
149 | | - <script> |
150 | | - $(document).ready(function() { |
151 | | - var container = $('.table tbody')[0]; |
152 | | - |
153 | | - dragula([container]) |
154 | | - .on('drop', function (el, target, source, sibling) { |
155 | | - // Handle the drop event to update the order in the database |
156 | | - var rows = $(container).children(); |
157 | | - var positions = rows.map(function(index, row) { |
158 | | - return { |
159 | | - id: $(row).data('taskId'), |
160 | | - order: index |
161 | | - }; |
162 | | - }).get(); |
163 | | - |
164 | | - // Send the new order to the server |
165 | | - $.ajax({ |
166 | | - url: 'ajax.php', |
167 | | - method: 'POST', |
168 | | - data: { |
169 | | - update_task_templates_order: true, // Adjust the parameter name if needed |
170 | | - ticket_template_id: <?php echo $ticket_template_id; ?>, |
171 | | - positions: positions |
172 | | - }, |
173 | | - success: function(data) { |
174 | | - // Handle success |
175 | | - }, |
176 | | - error: function(error) { |
177 | | - console.error('Error updating order:', error); |
178 | | - } |
179 | | - }); |
180 | | - }); |
181 | | - }); |
182 | | - </script> |
| 142 | +</div> |
| 143 | + |
| 144 | +<script src="js/pretty_content.js"></script> |
| 145 | + |
| 146 | +<script src="plugins/SortableJS/Sortable.min.js"></script> |
| 147 | +<script> |
| 148 | +new Sortable(document.querySelector('table#tasks tbody'), { |
| 149 | + handle: '.drag-handle', |
| 150 | + animation: 150, |
| 151 | + onEnd: function (evt) { |
| 152 | + const rows = document.querySelectorAll('table#tasks tbody tr'); |
| 153 | + const positions = Array.from(rows).map((row, index) => ({ |
| 154 | + id: row.dataset.taskId, |
| 155 | + order: index |
| 156 | + })); |
| 157 | + |
| 158 | + $.post('ajax.php', { |
| 159 | + update_task_templates_order: true, |
| 160 | + ticket_template_id: <?php echo $ticket_template_id; ?>, |
| 161 | + positions: positions |
| 162 | + }); |
| 163 | + } |
| 164 | +}); |
| 165 | +</script> |
183 | 166 |
|
184 | 167 | <?php |
185 | 168 |
|
|
0 commit comments