default.php
370 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 | $canEdit = $user->authorise('core.edit', 'com_vikappointments'); |
| 27 | $canEditState = $user->authorise('core.edit.state', 'com_vikappointments'); |
| 28 | $canOrder = $this->ordering == 's.ordering'; |
| 29 | |
| 30 | if ($canOrder && $canEditState) |
| 31 | { |
| 32 | $saveOrderingUrl = 'index.php?option=com_vikappointments&task=statuscode.saveOrderAjax&tmpl=component'; |
| 33 | JHtml::fetch('vaphtml.scripts.sortablelist', 'statuscodesList', 'adminForm', $this->orderDir, $saveOrderingUrl); |
| 34 | } |
| 35 | |
| 36 | $is_searching = $this->hasFilters(); |
| 37 | |
| 38 | /** |
| 39 | * Trigger event to display custom HTML. |
| 40 | * In case it is needed to include any additional fields, |
| 41 | * it is possible to create a plugin and attach it to an event |
| 42 | * called "onDisplayViewStatuscodesList". The event method receives the |
| 43 | * view instance as argument. |
| 44 | * |
| 45 | * @since 1.7 |
| 46 | */ |
| 47 | $forms = $this->onDisplayListView($is_searching); |
| 48 | |
| 49 | ?> |
| 50 | |
| 51 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 52 | |
| 53 | <div class="btn-toolbar" style="height: 32px;"> |
| 54 | |
| 55 | <div class="btn-group pull-left input-append"> |
| 56 | <input type="text" name="keys" id="vapkeysearch" size="32" |
| 57 | value="<?php echo $this->escape($filters['keys']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 58 | |
| 59 | <button type="submit" class="btn"> |
| 60 | <i class="fas fa-search"></i> |
| 61 | </button> |
| 62 | </div> |
| 63 | |
| 64 | <!-- Define role to detect the supported hook --> |
| 65 | <!-- {"rule":"customizer","event":"onDisplayViewStatuscodesList","type":"search","key":"search"} --> |
| 66 | |
| 67 | <?php |
| 68 | // plugins can use the "search" key to introduce custom |
| 69 | // filters within the search bar |
| 70 | if (isset($forms['search'])) |
| 71 | { |
| 72 | echo $forms['search']; |
| 73 | } |
| 74 | ?> |
| 75 | |
| 76 | <div class="btn-group pull-left"> |
| 77 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 78 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 79 | </button> |
| 80 | </div> |
| 81 | |
| 82 | <div class="btn-group pull-left"> |
| 83 | <button type="button" class="btn" onclick="clearFilters();"> |
| 84 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 85 | </button> |
| 86 | </div> |
| 87 | |
| 88 | </div> |
| 89 | |
| 90 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 91 | |
| 92 | <?php |
| 93 | $options = array( |
| 94 | JHtml::fetch('select.option', '', 'VAPFILTERSELECTGROUP'), |
| 95 | JHtml::fetch('select.option', 'appointments', 'VAPMENUTITLEHEADER2'), |
| 96 | JHtml::fetch('select.option', 'packages', 'VAPMENUPACKAGES'), |
| 97 | JHtml::fetch('select.option', 'subscriptions', 'VAPMENUSUBSCRIPTIONS'), |
| 98 | ); |
| 99 | ?> |
| 100 | <div class="btn-group pull-left"> |
| 101 | <select name="group" id="vap-group-sel" class="<?php echo ($filters['group'] ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 102 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['group'], true); ?> |
| 103 | </select> |
| 104 | </div> |
| 105 | |
| 106 | <!-- Define role to detect the supported hook --> |
| 107 | <!-- {"rule":"customizer","event":"onDisplayViewStatuscodesList","type":"search","key":"filters"} --> |
| 108 | |
| 109 | <?php |
| 110 | // plugins can use the "filters" key to introduce custom |
| 111 | // filters within the search bar |
| 112 | if (isset($forms['filters'])) |
| 113 | { |
| 114 | echo $forms['filters']; |
| 115 | } |
| 116 | ?> |
| 117 | |
| 118 | </div> |
| 119 | |
| 120 | <?php |
| 121 | if (count($rows) == 0) |
| 122 | { |
| 123 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | /** |
| 128 | * Trigger event to display custom columns. |
| 129 | * |
| 130 | * @since 1.7 |
| 131 | */ |
| 132 | $columns = $this->onDisplayTableColumns(); |
| 133 | ?> |
| 134 | |
| 135 | <!-- Define role to detect the supported hook --> |
| 136 | <!-- {"rule":"customizer","event":"onDisplayStatuscodesTableTH","type":"th"} --> |
| 137 | |
| 138 | <!-- Define role to detect the supported hook --> |
| 139 | <!-- {"rule":"customizer","event":"onDisplayStatuscodesTableTD","type":"td"} --> |
| 140 | |
| 141 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>" id="statuscodesList"> |
| 142 | <?php echo $vik->openTableHead(); ?> |
| 143 | <tr> |
| 144 | |
| 145 | <th width="1%"> |
| 146 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 147 | </th> |
| 148 | |
| 149 | <!-- ID --> |
| 150 | |
| 151 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone nowrap'); ?>" width="1%" style="text-align: left;"> |
| 152 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEOPTION1', 's.id', $this->orderDir, $this->ordering); ?> |
| 153 | </th> |
| 154 | |
| 155 | <!-- NAME --> |
| 156 | |
| 157 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 158 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEOPTION2', 's.name', $this->orderDir, $this->ordering); ?> |
| 159 | </th> |
| 160 | |
| 161 | <!-- DESCRIPTION --> |
| 162 | |
| 163 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="30%" style="text-align: left;"> |
| 164 | <?php echo JText::translate('VAPMANAGEOPTION3'); ?> |
| 165 | </th> |
| 166 | |
| 167 | <!-- CODE --> |
| 168 | |
| 169 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 170 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECOUPON2', 's.code', $this->orderDir, $this->ordering); ?> |
| 171 | </th> |
| 172 | |
| 173 | <!-- COLOR --> |
| 174 | |
| 175 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 176 | <?php echo JText::translate('VAPCOLOR'); ?> |
| 177 | </th> |
| 178 | |
| 179 | <!-- CUSTOM --> |
| 180 | |
| 181 | <?php |
| 182 | foreach ($columns as $k => $col) |
| 183 | { |
| 184 | ?> |
| 185 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 186 | <?php echo $col->th; ?> |
| 187 | </th> |
| 188 | <?php |
| 189 | } |
| 190 | ?> |
| 191 | |
| 192 | <!-- LANGUAGES --> |
| 193 | |
| 194 | <?php |
| 195 | if ($multi_lang && $canEdit) |
| 196 | { |
| 197 | ?> |
| 198 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;"> |
| 199 | <?php echo JText::translate('VAPLANGUAGES');?> |
| 200 | </th> |
| 201 | <?php |
| 202 | } |
| 203 | ?> |
| 204 | |
| 205 | <!-- ORDERING --> |
| 206 | |
| 207 | <th class="<?php echo $vik->getAdminThClass('hidden-phone nowrap'); ?>" width="1%" style="text-align: center;"> |
| 208 | <?php echo JHtml::fetch('vaphtml.admin.sort', '<i class="fas fa-sort"></i>', 's.ordering', $this->orderDir, $this->ordering); ?> |
| 209 | </th> |
| 210 | |
| 211 | </tr> |
| 212 | <?php echo $vik->closeTableHead(); ?> |
| 213 | |
| 214 | <?php |
| 215 | for ($i = 0, $n = count($rows); $i < $n; $i++) |
| 216 | { |
| 217 | $row = $rows[$i]; |
| 218 | |
| 219 | $desc = strip_tags((string) $row['description']); |
| 220 | |
| 221 | if (strlen($desc) > 300) |
| 222 | { |
| 223 | $desc = trim(mb_substr($desc, 0, 256, 'UTF-8'), ' .') . '...'; |
| 224 | } |
| 225 | ?> |
| 226 | <tr class="row<?php echo ($i % 2); ?>"> |
| 227 | |
| 228 | <td> |
| 229 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 230 | </td> |
| 231 | |
| 232 | <!-- ID --> |
| 233 | |
| 234 | <td class="hidden-phone"> |
| 235 | <?php echo $row['id']; ?> |
| 236 | </td> |
| 237 | |
| 238 | <!-- NAME --> |
| 239 | |
| 240 | <td> |
| 241 | <div class="td-primary"> |
| 242 | <?php |
| 243 | if ($canEdit) |
| 244 | { |
| 245 | ?> |
| 246 | <a href="index.php?option=com_vikappointments&task=statuscode.edit&cid[]=<?php echo $row['id']; ?>"> |
| 247 | <?php echo $row['name']; ?> |
| 248 | </a> |
| 249 | <?php |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | echo $row['name']; |
| 254 | } |
| 255 | ?> |
| 256 | </div> |
| 257 | </td> |
| 258 | |
| 259 | <!-- DESCRIPTION --> |
| 260 | |
| 261 | <td class="hidden-phone"> |
| 262 | <?php echo $desc; ?> |
| 263 | </td> |
| 264 | |
| 265 | <!-- CODE --> |
| 266 | |
| 267 | <td style="text-align: center;"> |
| 268 | <?php echo $row['code']; ?> |
| 269 | </td> |
| 270 | |
| 271 | <!-- COLOR --> |
| 272 | |
| 273 | <td style="text-align: center;"> |
| 274 | <span style="background: #<?php echo $row['color']; ?>;display: inline-block;width: 16px;height: 16px;border-radius: 4px;"></span> |
| 275 | </td> |
| 276 | |
| 277 | <!-- CUSTOM --> |
| 278 | |
| 279 | <?php |
| 280 | foreach ($columns as $k => $col) |
| 281 | { |
| 282 | ?> |
| 283 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 284 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 285 | </td> |
| 286 | <?php |
| 287 | } |
| 288 | ?> |
| 289 | |
| 290 | <!-- LANGUAGES --> |
| 291 | |
| 292 | <?php |
| 293 | if ($multi_lang && $canEdit) |
| 294 | { |
| 295 | ?> |
| 296 | <td style="text-align: center;"> |
| 297 | <a href="index.php?option=com_vikappointments&view=langstatuscodes&id_status_code=<?php echo $row['id']; ?>"> |
| 298 | <?php |
| 299 | foreach ($row['languages'] as $lang) |
| 300 | { |
| 301 | echo ' ' . JHtml::fetch('vaphtml.site.flag', $lang) . ' '; |
| 302 | } |
| 303 | ?> |
| 304 | </a> |
| 305 | </td> |
| 306 | <?php |
| 307 | } |
| 308 | ?> |
| 309 | |
| 310 | <!-- ORDERING --> |
| 311 | |
| 312 | <td class="order nowrap center hidden-phone"> |
| 313 | <?php echo JHtml::fetch('vaphtml.admin.sorthandle', $row['ordering'], $canEditState, $canOrder); ?> |
| 314 | </td> |
| 315 | |
| 316 | </tr> |
| 317 | <?php |
| 318 | } |
| 319 | ?> |
| 320 | </table> |
| 321 | <?php |
| 322 | } |
| 323 | ?> |
| 324 | |
| 325 | <input type="hidden" name="boxchecked" value="0" /> |
| 326 | <input type="hidden" name="task" value="" /> |
| 327 | <input type="hidden" name="view" value="statuscodes" /> |
| 328 | |
| 329 | <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" /> |
| 330 | <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" /> |
| 331 | |
| 332 | <?php echo JHtml::fetch('form.token'); ?> |
| 333 | <?php echo $this->navbut; ?> |
| 334 | </form> |
| 335 | |
| 336 | <?php |
| 337 | JText::script('VAP_STATUS_CODES_FACTORY_RESET_CONFIRM'); |
| 338 | ?> |
| 339 | |
| 340 | <script> |
| 341 | |
| 342 | (function($) { |
| 343 | 'use strict'; |
| 344 | |
| 345 | window['clearFilters'] = () => { |
| 346 | $('#vapkeysearch').val(''); |
| 347 | $('#vap-group-sel').updateChosen(''); |
| 348 | |
| 349 | document.adminForm.submit(); |
| 350 | } |
| 351 | |
| 352 | // override the Joomla submit button |
| 353 | Joomla.submitbutton = (task) => { |
| 354 | const msg = Joomla.JText._('VAP_STATUS_CODES_FACTORY_RESET_CONFIRM'); |
| 355 | |
| 356 | // ask for a manual confirmation before applying the factory reset |
| 357 | if (task == 'statuscode.restore' && !confirm(msg)) { |
| 358 | return false; |
| 359 | } |
| 360 | |
| 361 | Joomla.submitform(task, document.adminForm); |
| 362 | } |
| 363 | |
| 364 | $(function() { |
| 365 | VikRenderer.chosen('.btn-toolbar'); |
| 366 | }); |
| 367 | })(jQuery); |
| 368 | |
| 369 | </script> |
| 370 |