PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / admin / layouts / taskmanager / board / area.php

area.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/layouts/taskmanager/board/area.php

328 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2025 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Obtain vars from arguments received in the layout file.
16 *
17 * @var array $data The data for rendering the task area plus the related tasks within the board.
18 */
19 extract($displayData);
20
21 // get the task area object
22 if (($data['taskArea'] ?? null) && $data['taskArea'] instanceof VBOTaskArea) {
23 // rendering during page loading
24 $taskArea = $data['taskArea'];
25 } elseif ($data['area_id'] ?? null) {
26 // probably rendering through AJAX
27 $taskArea = VBOTaskArea::getRecordInstance((int) $data['area_id']);
28 } else {
29 // raise an error
30 throw new InvalidArgumentException('Could not load task area object.', 400);
31 }
32
33 ?>
34
35 <div class="vbo-tm-board-area-wrap" data-area-id="<?php echo $taskArea->getID(); ?>">
36 <div class="vbo-tm-board-area-head">
37 <div class="vbo-tm-board-area-head-info">
38 <span class="vbo-tm-board-area-icn"><?php VikBookingIcons::e($taskArea->getIcon()); ?></span>
39 <span class="vbo-tm-board-area-name"><?php echo $taskArea->getName(); ?></span>
40 <div class="vbo-tm-board-area-comments">
41 <?php echo $taskArea->get('comments', ''); ?>
42 </div>
43 </div>
44 </div>
45 <div class="vbo-tm-board-area-newtask">
46 <span class="vbo-tm-board-area-cmd" data-area-id="<?php echo $taskArea->getID(); ?>"><?php VikBookingIcons::e('ellipsis-h'); ?></span>
47 <button type="button" class="btn vbo-newtask-btn"><?php VikBookingIcons::e('plus'); ?> <?php echo JText::translate('VBO_NEW_TASK'); ?></button>
48 </div>
49 </div>
50
51 <script type="text/javascript">
52
53 jQuery(function() {
54
55 /**
56 * Build area commands context menu buttons.
57 */
58 let btns = [
59 {
60 icon: '<?php echo VikBookingIcons::i('edit'); ?>',
61 text: <?php echo json_encode(JText::translate('VBMAINPAYMENTSEDIT')); ?>,
62 action: (root, event) => {
63 // define the modal cancel button
64 let cancel_btn = jQuery('<button></button>')
65 .attr('type', 'button')
66 .addClass('btn')
67 .text(<?php echo json_encode(JText::translate('VBANNULLA')); ?>)
68 .on('click', () => {
69 VBOCore.emitEvent('vbo-tm-editarea-dismiss');
70 });
71
72 // define the modal save button
73 let save_btn = jQuery('<button></button>')
74 .attr('type', 'button')
75 .addClass('btn btn-success')
76 .text(<?php echo json_encode(JText::translate('VBSAVE')); ?>)
77 .on('click', function() {
78 // disable button to prevent double submissions
79 let submit_btn = jQuery(this);
80 submit_btn.prop('disabled', true);
81
82 // start loading animation
83 VBOCore.emitEvent('vbo-tm-editarea-loading');
84
85 // get form data
86 const areaForm = new FormData(document.querySelector('#vbo-tm-area-manage-form'));
87
88 // build query parameters for the request
89 let qpRequest = new URLSearchParams(areaForm);
90
91 // make sure the request always includes the tags query parameter, even if the list is empty
92 if (!qpRequest.has('area[tags][]')) {
93 qpRequest.append('area[tags][]', []);
94 }
95
96 // make sure the request always includes the statuses query parameter, even if the list is empty
97 if (!qpRequest.has('area[status_enums][]')) {
98 qpRequest.append('area[status_enums][]', []);
99 }
100
101 // make the request
102 VBOCore.doAjax(
103 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=taskmanager.updateArea'); ?>",
104 qpRequest.toString(),
105 (resp) => {
106 // reload current page on success
107 window.location.reload();
108 },
109 (error) => {
110 // display error message
111 alert(error.responseText);
112
113 // re-enable submit button
114 submit_btn.prop('disabled', false);
115
116 // stop loading
117 VBOCore.emitEvent('vbo-tm-editarea-loading');
118 }
119 );
120 });
121
122 // display modal
123 let modalBody = VBOCore.displayModal({
124 suffix: 'tm_editarea_modal',
125 title: <?php echo json_encode(JText::translate('VBO_PROJECT_AREA')); ?> + ' - ' + <?php echo json_encode(JText::translate('VBMAINPAYMENTSEDIT')); ?>,
126 extra_class: 'vbo-modal-rounded vbo-modal-tall vbo-modal-taller',
127 body_prepend: true,
128 lock_scroll: true,
129 footer_left: cancel_btn,
130 footer_right: save_btn,
131 loading_event: 'vbo-tm-editarea-loading',
132 dismiss_event: 'vbo-tm-editarea-dismiss',
133 });
134
135 // start loading animation
136 VBOCore.emitEvent('vbo-tm-editarea-loading');
137
138 // make the request
139 VBOCore.doAjax(
140 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=taskmanager.renderLayout'); ?>",
141 {
142 type: 'areas.managearea',
143 data: {
144 id: <?php echo $taskArea->getID(); ?>,
145 form_id: 'vbo-tm-area-manage-form',
146 },
147 },
148 (resp) => {
149 // stop loading
150 VBOCore.emitEvent('vbo-tm-editarea-loading');
151
152 try {
153 // decode the response (if needed), and append the content to the modal body
154 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
155 modalBody.append(obj_res['html']);
156 } catch (err) {
157 console.error('Error decoding the response', err, resp);
158 }
159 },
160 (error) => {
161 // display error message
162 alert(error.responseText);
163
164 // stop loading
165 VBOCore.emitEvent('vbo-tm-editarea-loading');
166 }
167 );
168 },
169 },
170 {
171 icon: '<?php echo VikBookingIcons::i('trash'); ?>',
172 text: <?php echo json_encode(JText::translate('VBELIMINA')); ?>,
173 class: 'vbo-context-menu-entry-danger',
174 action: (root, event) => {
175 if (!confirm(<?php echo json_encode(JText::translate('VBDELCONFIRM')); ?>)) {
176 return;
177 }
178
179 try {
180 // add deleting animation class
181 e.target.closest('.vbo-tm-board-area-wrap').classList.add('deleting');
182 } catch (err) {
183 // do nothing
184 }
185
186 // make the request
187 VBOCore.doAjax(
188 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=taskmanager.deleteArea'); ?>",
189 {
190 area_id: <?php echo $taskArea->getID(); ?>,
191 },
192 (resp) => {
193 // reload current page on success
194 window.location.reload();
195 },
196 (error) => {
197 // display error message
198 alert(error.responseText);
199
200 // reload current page also on error
201 window.location.reload();
202 }
203 );
204 },
205 },
206 ];
207
208 /**
209 * Register context-menu for area commands.
210 */
211 jQuery('.vbo-tm-board-area-cmd[data-area-id="<?php echo $taskArea->getID(); ?>"]').vboContextMenu({
212 placement: 'bottom-right',
213 buttons: btns,
214 });
215
216 /**
217 * Register listener for creating a new task.
218 */
219 document
220 .querySelector('.vbo-tm-board-area-wrap[data-area-id="<?php echo $taskArea->getID(); ?>"]')
221 .querySelector('.vbo-newtask-btn')
222 .addEventListener('click', () => {
223 // define the modal cancel button
224 let cancel_btn = jQuery('<button></button>')
225 .attr('type', 'button')
226 .addClass('btn')
227 .text(<?php echo json_encode(JText::translate('VBANNULLA')); ?>)
228 .on('click', () => {
229 VBOCore.emitEvent('vbo-tm-newtask-dismiss');
230 });
231
232 // define the modal save button
233 let save_btn = jQuery('<button></button>')
234 .attr('type', 'button')
235 .addClass('btn btn-success')
236 .text(<?php echo json_encode(JText::translate('VBSAVE')); ?>)
237 .on('click', function() {
238 // disable button to prevent double submissions
239 let submit_btn = jQuery(this);
240 submit_btn.prop('disabled', true);
241
242 // start loading animation
243 VBOCore.emitEvent('vbo-tm-newtask-loading');
244
245 // get form data
246 const taskForm = new FormData(document.querySelector('#vbo-tm-task-manage-form'));
247
248 // build query parameters for the request
249 let qpRequest = new URLSearchParams(taskForm).toString();
250
251 // make the request
252 VBOCore.doAjax(
253 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=taskmanager.createTask'); ?>",
254 qpRequest,
255 (resp) => {
256 // trigger filters-changed event on success
257 VBOCore.emitEvent('vbo-tm-filters-changed', {
258 filters: vboTmFilters,
259 });
260
261 // dismiss the modal
262 VBOCore.emitEvent('vbo-tm-newtask-dismiss');
263 },
264 (error) => {
265 // display error message
266 alert(error.responseText);
267
268 // re-enable submit button
269 submit_btn.prop('disabled', false);
270
271 // stop loading
272 VBOCore.emitEvent('vbo-tm-newtask-loading');
273 }
274 );
275 });
276
277 // display modal
278 let modalBody = VBOCore.displayModal({
279 suffix: 'tm_newtask_modal',
280 title: <?php echo json_encode($taskArea->getName() . ' - ' . JText::translate('VBO_NEW_TASK')); ?>,
281 extra_class: 'vbo-modal-rounded vbo-modal-taller vbo-modal-large',
282 body_prepend: true,
283 lock_scroll: true,
284 escape_dismiss: false,
285 footer_left: cancel_btn,
286 footer_right: save_btn,
287 loading_event: 'vbo-tm-newtask-loading',
288 dismiss_event: 'vbo-tm-newtask-dismiss',
289 });
290
291 // start loading animation
292 VBOCore.emitEvent('vbo-tm-newtask-loading');
293
294 // make the request
295 VBOCore.doAjax(
296 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=taskmanager.renderLayout'); ?>",
297 {
298 type: 'tasks.managetask',
299 data: {
300 area_id: <?php echo $taskArea->getID(); ?>,
301 form_id: 'vbo-tm-task-manage-form',
302 },
303 },
304 (resp) => {
305 // stop loading
306 VBOCore.emitEvent('vbo-tm-newtask-loading');
307
308 try {
309 // decode the response (if needed), and append the content to the modal body
310 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
311 modalBody.append(obj_res['html']);
312 } catch (err) {
313 console.error('Error decoding the response', err, resp);
314 }
315 },
316 (error) => {
317 // display error message
318 alert(error.responseText);
319
320 // stop loading
321 VBOCore.emitEvent('vbo-tm-newtask-loading');
322 }
323 );
324 });
325
326 });
327 </script>
328