default.php
534 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 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 | JHtml::fetch('behavior.modal'); |
| 15 | JHtml::fetch('bootstrap.tooltip', '.hasTooltip'); |
| 16 | JHtml::fetch('formbehavior.chosen'); |
| 17 | |
| 18 | $rows = $this->rows; |
| 19 | |
| 20 | $filters = $this->filters; |
| 21 | |
| 22 | $vik = VAPApplication::getInstance(); |
| 23 | |
| 24 | $multi_lang = VikAppointments::isMultilanguage(); |
| 25 | |
| 26 | $user = JFactory::getUser(); |
| 27 | |
| 28 | $currency = VAPFactory::getCurrency(); |
| 29 | |
| 30 | $canEdit = $user->authorise('core.edit', 'com_vikappointments'); |
| 31 | $canEditState = $user->authorise('core.edit.state', 'com_vikappointments'); |
| 32 | $canOrder = $this->ordering == 's.ordering'; |
| 33 | |
| 34 | if ($canOrder && $canEditState) |
| 35 | { |
| 36 | $saveOrderingUrl = 'index.php?option=com_vikappointments&task=service.saveOrderAjax&tmpl=component'; |
| 37 | JHtml::fetch('vaphtml.scripts.sortablelist', 'servicesList', 'adminForm', $this->orderDir, $saveOrderingUrl); |
| 38 | } |
| 39 | |
| 40 | $is_searching = $this->hasFilters(); |
| 41 | |
| 42 | /** |
| 43 | * Trigger event to display custom HTML. |
| 44 | * In case it is needed to include any additional fields, |
| 45 | * it is possible to create a plugin and attach it to an event |
| 46 | * called "onDisplayViewServicesList". The event method receives the |
| 47 | * view instance as argument. |
| 48 | * |
| 49 | * @since 1.6.6 |
| 50 | */ |
| 51 | $forms = $this->onDisplayListView($is_searching); |
| 52 | |
| 53 | ?> |
| 54 | |
| 55 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 56 | |
| 57 | <div class="btn-toolbar" style="height: 32px;"> |
| 58 | |
| 59 | <div class="btn-group pull-left input-append"> |
| 60 | <input type="text" name="keys" id="vapkeysearch" size="32" |
| 61 | value="<?php echo $this->escape($filters['keys']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 62 | |
| 63 | <button type="submit" class="btn"> |
| 64 | <i class="fas fa-search"></i> |
| 65 | </button> |
| 66 | </div> |
| 67 | |
| 68 | <!-- Define role to detect the supported hook --> |
| 69 | <!-- {"rule":"customizer","event":"onDisplayViewServicesList","type":"search","key":"search"} --> |
| 70 | |
| 71 | <?php |
| 72 | // plugins can use the "search" key to introduce custom |
| 73 | // filters within the search bar |
| 74 | if (isset($forms['search'])) |
| 75 | { |
| 76 | echo $forms['search']; |
| 77 | } |
| 78 | ?> |
| 79 | |
| 80 | <div class="btn-group pull-left"> |
| 81 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 82 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 83 | </button> |
| 84 | </div> |
| 85 | |
| 86 | <div class="btn-group pull-left"> |
| 87 | <button type="button" class="btn" onclick="clearFilters();"> |
| 88 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 89 | </button> |
| 90 | </div> |
| 91 | |
| 92 | <div class="btn-group pull-right"> |
| 93 | <a href="index.php?option=com_vikappointments&view=restrictions" class="btn"> |
| 94 | <i class="fas fa-calendar-times"></i> |
| 95 | <?php echo JText::translate('VAPMANAGESPECIALRESTR'); ?> |
| 96 | </a> |
| 97 | |
| 98 | <a href="index.php?option=com_vikappointments&view=rates" class="btn"> |
| 99 | <i class="fas fa-dollar-sign"></i> |
| 100 | <?php echo JText::translate('VAPMANAGESPECIALRATES'); ?> |
| 101 | </a> |
| 102 | </div> |
| 103 | |
| 104 | </div> |
| 105 | |
| 106 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 107 | |
| 108 | <?php |
| 109 | $options = array( |
| 110 | JHtml::fetch('select.option', '', JText::translate('VAPFILTERSELECTSTATUS')), |
| 111 | JHtml::fetch('select.option', 1, JText::translate('JPUBLISHED')), |
| 112 | JHtml::fetch('select.option', 0, JText::translate('JUNPUBLISHED')), |
| 113 | ); |
| 114 | ?> |
| 115 | <div class="btn-group pull-left"> |
| 116 | <select name="status" id="vap-status-sel" class="<?php echo (strlen($filters['status']) ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 117 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['status']); ?> |
| 118 | </select> |
| 119 | </div> |
| 120 | |
| 121 | <?php |
| 122 | $options = array( |
| 123 | JHtml::fetch('select.option', -1, JText::translate('VAPFILTERSELECTGROUP')), |
| 124 | JHtml::fetch('select.option', 0, JText::translate('VAPSERVICENOGROUP')), |
| 125 | ); |
| 126 | |
| 127 | $options = array_merge($options, JHtml::fetch('vaphtml.admin.groups', 1)); |
| 128 | ?> |
| 129 | <div class="btn-group pull-left"> |
| 130 | <select name="id_group" id="vap-group-sel" class="<?php echo ($filters['id_group'] != -1 ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 131 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['id_group']); ?> |
| 132 | </select> |
| 133 | </div> |
| 134 | |
| 135 | <!-- Define role to detect the supported hook --> |
| 136 | <!-- {"rule":"customizer","event":"onDisplayViewServicesList","type":"search","key":"filters"} --> |
| 137 | |
| 138 | <?php |
| 139 | // plugins can use the "filters" key to introduce custom |
| 140 | // filters within the search bar |
| 141 | if (isset($forms['filters'])) |
| 142 | { |
| 143 | echo $forms['filters']; |
| 144 | } |
| 145 | ?> |
| 146 | |
| 147 | </div> |
| 148 | |
| 149 | <?php |
| 150 | if (count($rows) == 0) |
| 151 | { |
| 152 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | /** |
| 157 | * Trigger event to display custom columns. |
| 158 | * |
| 159 | * @since 1.7 |
| 160 | */ |
| 161 | $columns = $this->onDisplayTableColumns(); |
| 162 | ?> |
| 163 | |
| 164 | <!-- Define role to detect the supported hook --> |
| 165 | <!-- {"rule":"customizer","event":"onDisplayServicesTableTH","type":"th"} --> |
| 166 | |
| 167 | <!-- Define role to detect the supported hook --> |
| 168 | <!-- {"rule":"customizer","event":"onDisplayServicesTableTD","type":"td"} --> |
| 169 | |
| 170 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>" id="servicesList"> |
| 171 | |
| 172 | <?php echo $vik->openTableHead(); ?> |
| 173 | <tr> |
| 174 | |
| 175 | <th width="1%"> |
| 176 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 177 | </th> |
| 178 | |
| 179 | <!-- ID --> |
| 180 | |
| 181 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone nowrap'); ?>" width="1%" style="text-align: left;"> |
| 182 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGESERVICE1', 's.id', $this->orderDir, $this->ordering); ?> |
| 183 | </th> |
| 184 | |
| 185 | <!-- NAME --> |
| 186 | |
| 187 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 188 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGESERVICE2', 's.name', $this->orderDir, $this->ordering); ?> |
| 189 | </th> |
| 190 | |
| 191 | <!-- DURATION --> |
| 192 | |
| 193 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 194 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGESERVICE4', 's.duration', $this->orderDir, $this->ordering); ?> |
| 195 | </th> |
| 196 | |
| 197 | <!-- PRICE --> |
| 198 | |
| 199 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 200 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGESERVICE5', 's.price', $this->orderDir, $this->ordering); ?> |
| 201 | </th> |
| 202 | |
| 203 | <!-- CAPACITY --> |
| 204 | |
| 205 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="8%" style="text-align: center;"> |
| 206 | <?php echo JText::translate('VAPCAPACITY'); ?> |
| 207 | </th> |
| 208 | |
| 209 | <!-- STATUS --> |
| 210 | |
| 211 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="8%" style="text-align: center;"> |
| 212 | <?php echo JText::translate('VAPMANAGESERVICE6'); ?> |
| 213 | </th> |
| 214 | |
| 215 | <!-- CUSTOM --> |
| 216 | |
| 217 | <?php |
| 218 | foreach ($columns as $k => $col) |
| 219 | { |
| 220 | ?> |
| 221 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 222 | <?php echo $col->th; ?> |
| 223 | </th> |
| 224 | <?php |
| 225 | } |
| 226 | ?> |
| 227 | |
| 228 | <!-- GROUP --> |
| 229 | |
| 230 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: center;"> |
| 231 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGESERVICE10', 'g.name', $this->orderDir, $this->ordering); ?> |
| 232 | </th> |
| 233 | |
| 234 | <!-- INFO --> |
| 235 | |
| 236 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="5%" style="text-align: center;"> |
| 237 | <?php echo JText::translate('VAPMANAGESERVICE15'); ?> |
| 238 | </th> |
| 239 | |
| 240 | <!-- WORKING TIMES --> |
| 241 | |
| 242 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="5%" style="text-align: center;"> |
| 243 | <?php echo JText::translate('VAPMANAGESERVICE25'); ?> |
| 244 | </th> |
| 245 | |
| 246 | <!-- LANGUAGES --> |
| 247 | |
| 248 | <?php |
| 249 | if ($multi_lang && $canEdit) |
| 250 | { |
| 251 | ?> |
| 252 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="6%" style="text-align: center;"> |
| 253 | <?php echo JText::translate('VAPLANGUAGES');?> |
| 254 | </th> |
| 255 | <?php |
| 256 | } |
| 257 | ?> |
| 258 | |
| 259 | <!-- IMAGE --> |
| 260 | |
| 261 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="6%" style="text-align: center;"> |
| 262 | <?php echo JText::translate('VAPMANAGESERVICE9'); ?> |
| 263 | </th> |
| 264 | |
| 265 | <!-- ORDERING --> |
| 266 | |
| 267 | <th class="<?php echo $vik->getAdminThClass('hidden-phone nowrap'); ?>" width="1%" style="text-align: center;"> |
| 268 | <?php echo JHtml::fetch('vaphtml.admin.sort', '<i class="fas fa-sort"></i>', 's.ordering', $this->orderDir, $this->ordering); ?> |
| 269 | </th> |
| 270 | |
| 271 | </tr> |
| 272 | <?php echo $vik->closeTableHead(); ?> |
| 273 | |
| 274 | <?php |
| 275 | for ($i = 0, $n = count($rows); $i < $n; $i++) |
| 276 | { |
| 277 | $row = $rows[$i]; |
| 278 | ?> |
| 279 | <tr class="row<?php echo ($i % 2); ?>"> |
| 280 | |
| 281 | <td> |
| 282 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 283 | </td> |
| 284 | |
| 285 | <!-- ID --> |
| 286 | |
| 287 | <td class="hidden-phone"> |
| 288 | <?php echo $row['id']; ?> |
| 289 | </td> |
| 290 | |
| 291 | <!-- NAME --> |
| 292 | |
| 293 | <td> |
| 294 | <span class="td-primary"> |
| 295 | <?php |
| 296 | if ($canEdit) |
| 297 | { |
| 298 | ?> |
| 299 | <a href="index.php?option=com_vikappointments&task=service.edit&cid[]=<?php echo $row['id']; ?>"> |
| 300 | <?php echo $row['name']; ?> |
| 301 | </a> |
| 302 | <?php |
| 303 | } |
| 304 | else |
| 305 | { |
| 306 | echo $row['name']; |
| 307 | } |
| 308 | ?> |
| 309 | </span> |
| 310 | </td> |
| 311 | |
| 312 | <!-- DURATION --> |
| 313 | |
| 314 | <td style="text-align: center;"> |
| 315 | <?php |
| 316 | echo VikAppointments::formatMinutesToTime($row['duration']); |
| 317 | |
| 318 | if ($row['sleep'] != 0) |
| 319 | { |
| 320 | $sleep = VikAppointments::formatMinutesToTime($row['sleep']); |
| 321 | ?> |
| 322 | <div class="td-secondary"> |
| 323 | <?php echo ($row['sleep'] > 0 ? '+' : '') . $sleep; ?> |
| 324 | </div> |
| 325 | <?php |
| 326 | } |
| 327 | ?> |
| 328 | </td> |
| 329 | |
| 330 | <!-- PRICE --> |
| 331 | |
| 332 | <td style="text-align: center;"> |
| 333 | <?php echo $currency->format($row['price']); ?> |
| 334 | </td> |
| 335 | |
| 336 | <!-- CAPACITY --> |
| 337 | |
| 338 | <td style="text-align: center;" class="hidden-phone"> |
| 339 | <?php |
| 340 | if ($row['max_capacity'] > 1) |
| 341 | { |
| 342 | ?> |
| 343 | <strong> <?php echo $row['max_capacity']; ?></strong> |
| 344 | <?php |
| 345 | echo '(' . $row['min_per_res'] . '-' . $row['max_per_res'] . ')'; |
| 346 | } |
| 347 | else |
| 348 | { |
| 349 | echo '/'; |
| 350 | } |
| 351 | ?> |
| 352 | </td> |
| 353 | |
| 354 | <!-- STATUS --> |
| 355 | |
| 356 | <td style="text-align: center;" class="hidden-phone"> |
| 357 | <?php |
| 358 | $state = array( |
| 359 | 'state' => $row['published'], |
| 360 | 'start' => $row['start_publishing'], |
| 361 | 'end' => $row['end_publishing'], |
| 362 | ); |
| 363 | |
| 364 | echo JHtml::fetch('vaphtml.admin.stateaction', $state, $row['id'], 'service.publish', $canEditState); |
| 365 | ?> |
| 366 | </td> |
| 367 | |
| 368 | <!-- CUSTOM --> |
| 369 | |
| 370 | <?php |
| 371 | foreach ($columns as $k => $col) |
| 372 | { |
| 373 | ?> |
| 374 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 375 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 376 | </td> |
| 377 | <?php |
| 378 | } |
| 379 | ?> |
| 380 | |
| 381 | <!-- GROUP --> |
| 382 | |
| 383 | <td style="text-align: center;" class="hidden-phone"> |
| 384 | <?php |
| 385 | if ($row['id_group'] > 0) |
| 386 | { |
| 387 | if ($canEdit && $user->authorise('core.access.groups', 'com_vikappointments')) |
| 388 | { |
| 389 | ?> |
| 390 | <a href="index.php?option=com_vikappointments&task=group.edit&type=1&cid[]=<?php echo $row['id_group']; ?>"> |
| 391 | <?php echo $row['group_name']; ?> |
| 392 | </a> |
| 393 | <?php |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | echo $row['group_name']; |
| 398 | } |
| 399 | } |
| 400 | else |
| 401 | { |
| 402 | echo '/'; |
| 403 | } |
| 404 | ?> |
| 405 | </td> |
| 406 | |
| 407 | <!-- INFO --> |
| 408 | |
| 409 | <td style="text-align: center;" class="hidden-phone"> |
| 410 | <a href="javascript:void(0)" onclick="vapOpenServiceInfoModal(<?php echo $row['id']; ?>,'<?php echo addslashes($row['name']); ?>'); return false;"> |
| 411 | <i class="fas fa-search big"></i> |
| 412 | </a> |
| 413 | </td> |
| 414 | |
| 415 | <!-- WORKING TIMES --> |
| 416 | |
| 417 | <td style="text-align: center;"> |
| 418 | <a href="index.php?option=com_vikappointments&view=serworkdays&id_service=<?php echo $row['id']; ?>"> |
| 419 | <i class="fas fa-calendar-day big"></i> |
| 420 | </a> |
| 421 | </td> |
| 422 | |
| 423 | <!-- LANGUAGES --> |
| 424 | |
| 425 | <?php |
| 426 | if ($multi_lang && $canEdit) |
| 427 | { |
| 428 | ?> |
| 429 | <td style="text-align: center;"> |
| 430 | <a href="index.php?option=com_vikappointments&view=langservices&id_service=<?php echo $row['id']; ?>"> |
| 431 | <?php |
| 432 | foreach ($row['languages'] as $lang) |
| 433 | { |
| 434 | echo ' ' . JHtml::fetch('vaphtml.site.flag', $lang) . ' '; |
| 435 | } |
| 436 | ?> |
| 437 | </a> |
| 438 | </td> |
| 439 | <?php |
| 440 | } |
| 441 | ?> |
| 442 | |
| 443 | <!-- IMAGE --> |
| 444 | |
| 445 | <td style="text-align: center;" class="hidden-phone"> |
| 446 | <?php echo JHtml::fetch('vaphtml.admin.imagestatus', $row['image']); ?> |
| 447 | </td> |
| 448 | |
| 449 | <!-- ORDERING --> |
| 450 | |
| 451 | <td class="order nowrap center hidden-phone"> |
| 452 | <?php echo JHtml::fetch('vaphtml.admin.sorthandle', $row['ordering'], $canEditState, $canOrder); ?> |
| 453 | </td> |
| 454 | |
| 455 | </tr> |
| 456 | <?php |
| 457 | } |
| 458 | ?> |
| 459 | </table> |
| 460 | <?php |
| 461 | } |
| 462 | ?> |
| 463 | <!-- hidden input for import tool --> |
| 464 | <input type="hidden" name="import_type" value="services" /> |
| 465 | |
| 466 | <input type="hidden" name="boxchecked" value="0" /> |
| 467 | <input type="hidden" name="task" value="" /> |
| 468 | <input type="hidden" name="view" value="services" /> |
| 469 | |
| 470 | <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" /> |
| 471 | <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" /> |
| 472 | |
| 473 | <?php echo JHtml::fetch('form.token'); ?> |
| 474 | <?php echo $this->navbut; ?> |
| 475 | </form> |
| 476 | |
| 477 | <?php |
| 478 | echo JHtml::fetch( |
| 479 | 'bootstrap.renderModal', |
| 480 | 'jmodal-serviceinfo', |
| 481 | array( |
| 482 | 'title' => '', |
| 483 | 'closeButton' => true, |
| 484 | 'keyboard' => false, |
| 485 | 'bodyHeight' => 80, |
| 486 | 'url' => '', |
| 487 | ) |
| 488 | ); |
| 489 | ?> |
| 490 | |
| 491 | <script> |
| 492 | |
| 493 | (function($) { |
| 494 | 'use strict'; |
| 495 | |
| 496 | window['clearFilters'] = () => { |
| 497 | $('#vapkeysearch').val(''); |
| 498 | $('#vap-status-sel').updateChosen(''); |
| 499 | $('#vap-group-sel').updateChosen(-1); |
| 500 | |
| 501 | document.adminForm.submit(); |
| 502 | } |
| 503 | |
| 504 | // modal |
| 505 | |
| 506 | window['vapOpenServiceInfoModal'] = (id, name) => { |
| 507 | let url = 'index.php?option=com_vikappointments&view=serviceinfo&tmpl=component&cid[]=' + id; |
| 508 | |
| 509 | $('#jmodal-serviceinfo .modal-header h3').html(name); |
| 510 | |
| 511 | vapOpenJModal('serviceinfo', url, true); |
| 512 | } |
| 513 | |
| 514 | window['vapOpenJModal'] = (id, url, jqmodal) => { |
| 515 | <?php echo $vik->bootOpenModalJS(); ?> |
| 516 | } |
| 517 | |
| 518 | $(function() { |
| 519 | VikRenderer.chosen('.btn-toolbar'); |
| 520 | |
| 521 | Joomla.submitbutton = function(task) { |
| 522 | if (task == 'reportsser' || task == 'import' || task == 'export') { |
| 523 | // populate view instead of task |
| 524 | document.adminForm.view.value = task; |
| 525 | task = ''; |
| 526 | } |
| 527 | |
| 528 | Joomla.submitform(task, document.adminForm); |
| 529 | } |
| 530 | }); |
| 531 | })(jQuery); |
| 532 | |
| 533 | </script> |
| 534 |