default.php
551 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('formbehavior.chosen'); |
| 15 | |
| 16 | $rows = $this->rows; |
| 17 | |
| 18 | $filters = $this->filters; |
| 19 | |
| 20 | $vik = VAPApplication::getInstance(); |
| 21 | |
| 22 | $multi_lang = VikAppointments::isMultilanguage(); |
| 23 | |
| 24 | $user = JFactory::getUser(); |
| 25 | |
| 26 | $currency = VAPFactory::getCurrency(); |
| 27 | |
| 28 | $canEdit = $user->authorise('core.edit', 'com_vikappointments'); |
| 29 | $canEditState = $user->authorise('core.edit.state', 'com_vikappointments'); |
| 30 | $canOrder = $this->ordering == 'f.ordering'; |
| 31 | |
| 32 | if ($canOrder && $canEditState) |
| 33 | { |
| 34 | $saveOrderingUrl = 'index.php?option=com_vikappointments&task=customf.saveOrderAjax&tmpl=component'; |
| 35 | JHtml::fetch('vaphtml.scripts.sortablelist', 'customFieldsList', 'adminForm', $this->orderDir, $saveOrderingUrl, array('group' => $this->filters['group'])); |
| 36 | } |
| 37 | |
| 38 | $is_searching = $this->hasFilters(); |
| 39 | |
| 40 | /** |
| 41 | * Trigger event to display custom HTML. |
| 42 | * In case it is needed to include any additional fields, |
| 43 | * it is possible to create a plugin and attach it to an event |
| 44 | * called "onDisplayViewCustomfList". The event method receives the |
| 45 | * view instance as argument. |
| 46 | * |
| 47 | * @since 1.7 |
| 48 | */ |
| 49 | $forms = $this->onDisplayListView($is_searching); |
| 50 | |
| 51 | ?> |
| 52 | |
| 53 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 54 | |
| 55 | <div class="btn-toolbar" style="height: 32px;"> |
| 56 | |
| 57 | <div class="btn-group pull-left input-append"> |
| 58 | <input type="text" name="keys" id="vapkeysearch" size="32" |
| 59 | value="<?php echo $this->escape($filters['keys']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 60 | |
| 61 | <button type="submit" class="btn"> |
| 62 | <i class="fas fa-search"></i> |
| 63 | </button> |
| 64 | </div> |
| 65 | |
| 66 | <!-- Define role to detect the supported hook --> |
| 67 | <!-- {"rule":"customizer","event":"onDisplayViewOptionsList","type":"search","key":"search"} --> |
| 68 | |
| 69 | <?php |
| 70 | // plugins can use the "search" key to introduce custom |
| 71 | // filters within the search bar |
| 72 | if (isset($forms['search'])) |
| 73 | { |
| 74 | echo $forms['search']; |
| 75 | } |
| 76 | ?> |
| 77 | |
| 78 | <div class="btn-group pull-left"> |
| 79 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 80 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 81 | </button> |
| 82 | </div> |
| 83 | |
| 84 | <div class="btn-group pull-left"> |
| 85 | <button type="button" class="btn" onclick="clearFilters();"> |
| 86 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 87 | </button> |
| 88 | </div> |
| 89 | |
| 90 | <?php |
| 91 | $options = array(); |
| 92 | $options[] = JHtml::fetch('select.option', 0, JText::translate('VAPMENUCUSTOMERS')); |
| 93 | $options[] = JHtml::fetch('select.option', 1, JText::translate('VAPMENUEMPLOYEES')); |
| 94 | ?> |
| 95 | <div class="btn-group pull-right"> |
| 96 | <select name="group" id="vap-group-sel" onchange="document.adminForm.submit();"> |
| 97 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['group']); ?> |
| 98 | </select> |
| 99 | </div> |
| 100 | |
| 101 | </div> |
| 102 | |
| 103 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 104 | |
| 105 | <?php |
| 106 | $options = array(); |
| 107 | $options[] = JHtml::fetch('select.option', '', JText::translate('VAPFILTERSELECTTYPE')); |
| 108 | |
| 109 | // get list of supported types |
| 110 | $types = VAPCustomFieldsFactory::getSupportedTypes(); |
| 111 | |
| 112 | foreach ($types as $k => $type) |
| 113 | { |
| 114 | $options[] = JHtml::fetch('select.option', $k, $type); |
| 115 | } |
| 116 | ?> |
| 117 | <div class="btn-group pull-left"> |
| 118 | <select name="type" id="vap-type-sel" class="<?php echo (!empty($filters['type']) ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 119 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['type']); ?> |
| 120 | </select> |
| 121 | </div> |
| 122 | |
| 123 | <?php |
| 124 | if ($filters['group'] == 0) |
| 125 | { |
| 126 | $options = array(); |
| 127 | $options[] = JHtml::fetch('select.option', -1, JText::translate('VAPFILTERSELECTRULE')); |
| 128 | |
| 129 | // get list of supported rules |
| 130 | $rules = VAPCustomFieldsFactory::getSupportedRules(); |
| 131 | |
| 132 | foreach ($rules as $k => $rule) |
| 133 | { |
| 134 | $options[] = JHtml::fetch('select.option', $k, $rule); |
| 135 | } |
| 136 | ?> |
| 137 | <div class="btn-group pull-left"> |
| 138 | <select name="rule" id="vap-rule-sel" class="<?php echo ($filters['rule'] != -1 ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 139 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['rule']); ?> |
| 140 | </select> |
| 141 | </div> |
| 142 | |
| 143 | <?php |
| 144 | $options = array(); |
| 145 | $options[] = JHtml::fetch('select.option', -1, JText::translate('VAPFILTERSELECTOWNER')); |
| 146 | $options[] = JHtml::fetch('select.option', 0, JText::translate('VAPMENUTITLEHEADER3')); |
| 147 | $options[] = JHtml::fetch('select.option', 1, JText::translate('VAPMENUEMPLOYEES')); |
| 148 | $options[] = JHtml::fetch('select.option', 2, JText::translate('VAPMENUSERVICES')); |
| 149 | ?> |
| 150 | <div class="btn-group pull-left"> |
| 151 | <select name="owner" id="vap-owner-sel" class="<?php echo ($filters['owner'] != -1 ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 152 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['owner']); ?> |
| 153 | </select> |
| 154 | </div> |
| 155 | |
| 156 | <?php } ?> |
| 157 | |
| 158 | <?php |
| 159 | $options = array(); |
| 160 | $options[] = JHtml::fetch('select.option', '', JText::translate('VAPFILTERSELECTSTATUS')); |
| 161 | $options[] = JHtml::fetch('select.option', 1, JText::translate('VAPREQUIRED')); |
| 162 | $options[] = JHtml::fetch('select.option', 0, JText::translate('VAPOPTIONAL')); |
| 163 | $options[] = JHtml::fetch('select.option', 2, JText::translate('VAPMANAGECUSTOMF14')); |
| 164 | ?> |
| 165 | <div class="btn-group pull-left"> |
| 166 | <select name="status" id="vap-status-sel" class="<?php echo (strlen($filters['status']) ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 167 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['status']); ?> |
| 168 | </select> |
| 169 | </div> |
| 170 | |
| 171 | <!-- Define role to detect the supported hook --> |
| 172 | <!-- {"rule":"customizer","event":"onDisplayViewOptionsList","type":"search","key":"filters"} --> |
| 173 | |
| 174 | <?php |
| 175 | // plugins can use the "filters" key to introduce custom |
| 176 | // filters within the search bar |
| 177 | if (isset($forms['filters'])) |
| 178 | { |
| 179 | echo $forms['filters']; |
| 180 | } |
| 181 | ?> |
| 182 | |
| 183 | </div> |
| 184 | |
| 185 | <?php |
| 186 | if (count($rows) == 0) |
| 187 | { |
| 188 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | /** |
| 193 | * Trigger event to display custom columns. |
| 194 | * |
| 195 | * @since 1.7 |
| 196 | */ |
| 197 | $columns = $this->onDisplayTableColumns(); |
| 198 | ?> |
| 199 | |
| 200 | <!-- Define role to detect the supported hook --> |
| 201 | <!-- {"rule":"customizer","event":"onDisplayCustomfTableTH","type":"th"} --> |
| 202 | |
| 203 | <!-- Define role to detect the supported hook --> |
| 204 | <!-- {"rule":"customizer","event":"onDisplayCustomfTableTD","type":"td"} --> |
| 205 | |
| 206 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>" id="customFieldsList"> |
| 207 | <?php echo $vik->openTableHead(); ?> |
| 208 | <tr> |
| 209 | |
| 210 | <th width="1%"> |
| 211 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 212 | </th> |
| 213 | |
| 214 | <!-- ID --> |
| 215 | |
| 216 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone nowrap'); ?>" width="1%" style="text-align: left;"> |
| 217 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEOPTION1', 'f.id', $this->orderDir, $this->ordering); ?> |
| 218 | </th> |
| 219 | |
| 220 | <!-- NAME --> |
| 221 | |
| 222 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 223 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECUSTOMF1', 'f.name', $this->orderDir, $this->ordering); ?> |
| 224 | </th> |
| 225 | |
| 226 | <!-- TYPE --> |
| 227 | |
| 228 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="10%" style="text-align: left;"> |
| 229 | <?php echo JText::translate('VAPMANAGECUSTOMF2'); ?> |
| 230 | </th> |
| 231 | |
| 232 | <!-- RULE --> |
| 233 | |
| 234 | <?php |
| 235 | if ($filters['group'] == 0) |
| 236 | { |
| 237 | ?> |
| 238 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="10%" style="text-align: left;"> |
| 239 | <?php echo JText::translate('VAPMANAGECUSTOMF12'); ?> |
| 240 | </th> |
| 241 | <?php |
| 242 | } |
| 243 | ?> |
| 244 | |
| 245 | <!-- REQUIRED --> |
| 246 | |
| 247 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="5%" style="text-align: center;"> |
| 248 | <?php echo JText::translate('VAPMANAGECUSTOMF3'); ?> |
| 249 | </th> |
| 250 | |
| 251 | <!-- CUSTOM --> |
| 252 | |
| 253 | <?php |
| 254 | foreach ($columns as $k => $col) |
| 255 | { |
| 256 | ?> |
| 257 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 258 | <?php echo $col->th; ?> |
| 259 | </th> |
| 260 | <?php |
| 261 | } |
| 262 | ?> |
| 263 | |
| 264 | <?php |
| 265 | if ($filters['group'] == 0) |
| 266 | { |
| 267 | ?> |
| 268 | <!-- EMPLOYEE --> |
| 269 | |
| 270 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: center;"> |
| 271 | <?php echo JText::translate('VAPMANAGECUSTOMF10'); ?> |
| 272 | </th> |
| 273 | |
| 274 | <!-- SERVICES --> |
| 275 | |
| 276 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="8%" style="text-align: center;"> |
| 277 | <?php echo JText::translate('VAPMENUSERVICES'); ?> |
| 278 | </th> |
| 279 | <?php |
| 280 | } |
| 281 | ?> |
| 282 | |
| 283 | <!-- LANGUAGES --> |
| 284 | |
| 285 | <?php |
| 286 | if ($multi_lang && $canEdit) |
| 287 | { |
| 288 | ?> |
| 289 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 290 | <?php echo JText::translate('VAPLANGUAGES');?> |
| 291 | </th> |
| 292 | <?php |
| 293 | } |
| 294 | ?> |
| 295 | |
| 296 | <!-- ORDERING --> |
| 297 | |
| 298 | <th class="<?php echo $vik->getAdminThClass('hidden-phone nowrap'); ?>" width="1%" style="text-align: center;"> |
| 299 | <?php echo JHtml::fetch('vaphtml.admin.sort', '<i class="fas fa-sort"></i>', 'f.ordering', $this->orderDir, $this->ordering); ?> |
| 300 | </th> |
| 301 | |
| 302 | </tr> |
| 303 | <?php echo $vik->closeTableHead(); ?> |
| 304 | |
| 305 | <?php |
| 306 | for ($i = 0, $n = count($rows); $i < $n; $i++) |
| 307 | { |
| 308 | $row = $rows[$i]; |
| 309 | |
| 310 | ?> |
| 311 | <tr class="row<?php echo ($i % 2); ?>"> |
| 312 | <td> |
| 313 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 314 | </td> |
| 315 | |
| 316 | <!-- ID --> |
| 317 | |
| 318 | <td class="hidden-phone"> |
| 319 | <?php echo $row['id']; ?> |
| 320 | </td> |
| 321 | |
| 322 | <!-- NAME --> |
| 323 | |
| 324 | <td> |
| 325 | <div class="td-primary"> |
| 326 | <?php |
| 327 | if ($canEdit) |
| 328 | { |
| 329 | ?> |
| 330 | <a href="index.php?option=com_vikappointments&task=customf.edit&cid[]=<?php echo $row['id']; ?>"> |
| 331 | <?php echo JText::translate($row['name']); ?> |
| 332 | </a> |
| 333 | <?php |
| 334 | } |
| 335 | else |
| 336 | { |
| 337 | echo JText::translate($row['name']); |
| 338 | } |
| 339 | ?> |
| 340 | </div> |
| 341 | </td> |
| 342 | |
| 343 | <!-- TYPE --> |
| 344 | |
| 345 | <td> |
| 346 | <?php |
| 347 | if (isset($types[$row['type']])) |
| 348 | { |
| 349 | echo $types[$row['type']]; |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | ?> |
| 354 | <span class="badge badge-warning"><?php echo $row['type']; ?></span> |
| 355 | <?php |
| 356 | } |
| 357 | ?> |
| 358 | </td> |
| 359 | |
| 360 | <!-- RULE --> |
| 361 | |
| 362 | <?php |
| 363 | if ($filters['group'] == 0) |
| 364 | { |
| 365 | ?> |
| 366 | <td class="hidden-phone"> |
| 367 | <?php |
| 368 | if ($row['rule']) |
| 369 | { |
| 370 | switch ($row['rule']) |
| 371 | { |
| 372 | case 'nominative': |
| 373 | $clazz = 'male'; |
| 374 | break; |
| 375 | |
| 376 | case 'email': |
| 377 | $clazz = 'envelope'; |
| 378 | break; |
| 379 | |
| 380 | case 'phone': |
| 381 | $clazz = 'mobile-alt'; |
| 382 | break; |
| 383 | |
| 384 | case 'country': |
| 385 | $clazz = 'globe-americas'; |
| 386 | break; |
| 387 | |
| 388 | case 'state': |
| 389 | $clazz = 'map'; |
| 390 | break; |
| 391 | |
| 392 | case 'city': |
| 393 | $clazz = 'map-signs'; |
| 394 | break; |
| 395 | |
| 396 | case 'address': |
| 397 | $clazz = 'road'; |
| 398 | break; |
| 399 | |
| 400 | case 'zip': |
| 401 | $clazz = 'map-marker-alt'; |
| 402 | break; |
| 403 | |
| 404 | case 'company': |
| 405 | $clazz = 'building'; |
| 406 | break; |
| 407 | |
| 408 | case 'vatnum': |
| 409 | $clazz = 'briefcase'; |
| 410 | break; |
| 411 | |
| 412 | case 'ssn': |
| 413 | $clazz = 'id-card'; |
| 414 | break; |
| 415 | |
| 416 | case 'pec': |
| 417 | $clazz = 'envelope-circle-check'; |
| 418 | break; |
| 419 | |
| 420 | default: |
| 421 | $clazz = 'plug'; |
| 422 | } |
| 423 | |
| 424 | ?> |
| 425 | <span class="td-pull-left"> |
| 426 | <?php |
| 427 | if (isset($rules[$row['rule']])) |
| 428 | { |
| 429 | echo $rules[$row['rule']]; |
| 430 | } |
| 431 | else |
| 432 | { |
| 433 | ?> |
| 434 | <span class="badge badge-warning"><?php echo $row['rule']; ?></span> |
| 435 | <?php |
| 436 | } |
| 437 | ?> |
| 438 | </span> |
| 439 | |
| 440 | <span class="td-pull-right"> |
| 441 | <i class="fas fa-<?php echo $clazz; ?> big" style="width:32px;text-align:center;"></i> |
| 442 | </span> |
| 443 | <?php |
| 444 | } |
| 445 | ?> |
| 446 | </td> |
| 447 | <?php |
| 448 | } |
| 449 | ?> |
| 450 | |
| 451 | <!-- REQUIRED --> |
| 452 | |
| 453 | <td style="text-align: center;"> |
| 454 | <?php echo JHtml::fetch('vaphtml.admin.stateaction', $row['required'], $row['id'], 'customf.required', $canEditState && $row['type'] != 'separator'); ?> |
| 455 | </td> |
| 456 | |
| 457 | <!-- CUSTOM --> |
| 458 | |
| 459 | <?php |
| 460 | foreach ($columns as $k => $col) |
| 461 | { |
| 462 | ?> |
| 463 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 464 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 465 | </td> |
| 466 | <?php |
| 467 | } |
| 468 | |
| 469 | if ($filters['group'] == 0) |
| 470 | { |
| 471 | ?> |
| 472 | <!-- EMPLOYEE --> |
| 473 | |
| 474 | <td style="text-align: center;" class="hidden-phone"> |
| 475 | <?php echo $row['ename'] ? $row['ename'] : JText::translate('VAPMANAGECUSTOMF11'); ?> |
| 476 | </td> |
| 477 | |
| 478 | <!-- SERVICE --> |
| 479 | |
| 480 | <td style="text-align: center;" class="hidden-phone"> |
| 481 | <?php echo !empty($row['services_count']) ? $row['services_count'] : JText::translate('VAPMANAGECUSTOMF11'); ?> |
| 482 | </td> |
| 483 | <?php |
| 484 | } |
| 485 | ?> |
| 486 | |
| 487 | <!-- LANGUAGES --> |
| 488 | |
| 489 | <?php |
| 490 | if ($multi_lang && $canEdit) |
| 491 | { |
| 492 | ?> |
| 493 | <td style="text-align: center;"> |
| 494 | <a href="index.php?option=com_vikappointments&view=langcustomf&id_customf=<?php echo $row['id']; ?>"> |
| 495 | <?php |
| 496 | foreach ($row['languages'] as $lang) |
| 497 | { |
| 498 | echo ' ' . JHtml::fetch('vaphtml.site.flag', $lang) . ' '; |
| 499 | } |
| 500 | ?> |
| 501 | </a> |
| 502 | </td> |
| 503 | <?php |
| 504 | } |
| 505 | ?> |
| 506 | |
| 507 | <!-- ORDERING --> |
| 508 | |
| 509 | <td class="order nowrap center hidden-phone"> |
| 510 | <?php echo JHtml::fetch('vaphtml.admin.sorthandle', $row['ordering'], $canEditState, $canOrder); ?> |
| 511 | </td> |
| 512 | |
| 513 | </tr> |
| 514 | <?php |
| 515 | } |
| 516 | ?> |
| 517 | </table> |
| 518 | <?php |
| 519 | } |
| 520 | ?> |
| 521 | |
| 522 | <input type="hidden" name="boxchecked" value="0" /> |
| 523 | <input type="hidden" name="task" value="" /> |
| 524 | <input type="hidden" name="view" value="customf" /> |
| 525 | |
| 526 | <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" /> |
| 527 | <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" /> |
| 528 | |
| 529 | <?php echo JHtml::fetch('form.token'); ?> |
| 530 | <?php echo $this->navbut; ?> |
| 531 | </form> |
| 532 | |
| 533 | <script> |
| 534 | |
| 535 | jQuery(function($) { |
| 536 | VikRenderer.chosen('.btn-toolbar'); |
| 537 | }); |
| 538 | |
| 539 | function clearFilters() { |
| 540 | jQuery('#vapkeysearch').val(''); |
| 541 | // jQuery('#vap-group-sel').updateChosen(0); |
| 542 | jQuery('#vap-type-sel').updateChosen(''); |
| 543 | jQuery('#vap-rule-sel').updateChosen(-1); |
| 544 | jQuery('#vap-owner-sel').updateChosen(-1); |
| 545 | jQuery('#vap-status-sel').updateChosen(''); |
| 546 | |
| 547 | document.adminForm.submit(); |
| 548 | } |
| 549 | |
| 550 | </script> |
| 551 |