default.php
| 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 | $config = VAPFactory::getConfig(); |
| 25 | $user = JFactory::getUser(); |
| 26 | |
| 27 | $canEdit = $user->authorise('core.edit', 'com_vikappointments'); |
| 28 | |
| 29 | $is_searching = $this->hasFilters(); |
| 30 | |
| 31 | /** |
| 32 | * Trigger event to display custom HTML. |
| 33 | * In case it is needed to include any additional fields, |
| 34 | * it is possible to create a plugin and attach it to an event |
| 35 | * called "onDisplayViewTaxesList". The event method receives the |
| 36 | * view instance as argument. |
| 37 | * |
| 38 | * @since 1.7 |
| 39 | */ |
| 40 | $forms = $this->onDisplayListView($is_searching); |
| 41 | |
| 42 | ?> |
| 43 | |
| 44 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 45 | |
| 46 | <div class="btn-toolbar" style="height: 32px;"> |
| 47 | |
| 48 | <div class="btn-group pull-left input-append"> |
| 49 | <input type="text" name="keys" id="vapkeysearch" size="32" |
| 50 | value="<?php echo $this->escape($filters['keys']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 51 | |
| 52 | <button type="submit" class="btn"> |
| 53 | <i class="fas fa-search"></i> |
| 54 | </button> |
| 55 | </div> |
| 56 | |
| 57 | <!-- Define role to detect the supported hook --> |
| 58 | <!-- {"rule":"customizer","event":"onDisplayViewTaxesList","type":"search","key":"search"} --> |
| 59 | |
| 60 | <?php |
| 61 | // plugins can use the "search" key to introduce custom |
| 62 | // filters within the search bar |
| 63 | if (isset($forms['search'])) |
| 64 | { |
| 65 | echo $forms['search']; |
| 66 | } |
| 67 | ?> |
| 68 | |
| 69 | <?php |
| 70 | // in case a plugin needs to use the filter bar, display the button |
| 71 | if (isset($forms['filters'])) |
| 72 | { |
| 73 | ?> |
| 74 | <div class="btn-group pull-left"> |
| 75 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 76 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 77 | </button> |
| 78 | </div> |
| 79 | <?php |
| 80 | } |
| 81 | ?> |
| 82 | |
| 83 | <div class="btn-group pull-left"> |
| 84 | <button type="button" class="btn" onclick="clearFilters();"> |
| 85 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 86 | </button> |
| 87 | </div> |
| 88 | |
| 89 | <div class="btn-group pull-right"> |
| 90 | <button type="button" class="btn" onclick="vapOpenJModal('taxestest', null, true);"> |
| 91 | <?php echo JText::translate('VAPTESTTAXES'); ?> |
| 92 | </button> |
| 93 | </div> |
| 94 | |
| 95 | </div> |
| 96 | |
| 97 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 98 | |
| 99 | <!-- Define role to detect the supported hook --> |
| 100 | <!-- {"rule":"customizer","event":"onDisplayViewTaxesList","type":"search","key":"filters"} --> |
| 101 | |
| 102 | <?php |
| 103 | // plugins can use the "filters" key to introduce custom |
| 104 | // filters within the search bar |
| 105 | if (isset($forms['filters'])) |
| 106 | { |
| 107 | echo $forms['filters']; |
| 108 | } |
| 109 | ?> |
| 110 | |
| 111 | </div> |
| 112 | |
| 113 | <?php |
| 114 | if (count($rows) == 0) |
| 115 | { |
| 116 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | /** |
| 121 | * Trigger event to display custom columns. |
| 122 | * |
| 123 | * @since 1.7 |
| 124 | */ |
| 125 | $columns = $this->onDisplayTableColumns(); |
| 126 | ?> |
| 127 | |
| 128 | <!-- Define role to detect the supported hook --> |
| 129 | <!-- {"rule":"customizer","event":"onDisplayTaxesTableTH","type":"th"} --> |
| 130 | |
| 131 | <!-- Define role to detect the supported hook --> |
| 132 | <!-- {"rule":"customizer","event":"onDisplayTaxesTableTD","type":"td"} --> |
| 133 | |
| 134 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>"> |
| 135 | <?php echo $vik->openTableHead(); ?> |
| 136 | <tr> |
| 137 | |
| 138 | <th width="1%"> |
| 139 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 140 | </th> |
| 141 | |
| 142 | <!-- ID --> |
| 143 | |
| 144 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone nowrap'); ?>" width="1%" style="text-align: left;"> |
| 145 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEOPTION1', 't.id', $this->orderDir, $this->ordering); ?> |
| 146 | </th> |
| 147 | |
| 148 | <!-- NAME --> |
| 149 | |
| 150 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 151 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEOPTION2', 't.name', $this->orderDir, $this->ordering); ?> |
| 152 | </th> |
| 153 | |
| 154 | <!-- DESCRIPTION --> |
| 155 | |
| 156 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="30%" style="text-align: left;"> |
| 157 | <?php echo JText::translate('VAPMANAGEOPTION3'); ?> |
| 158 | </th> |
| 159 | |
| 160 | <!-- CUSTOM --> |
| 161 | |
| 162 | <?php |
| 163 | foreach ($columns as $k => $col) |
| 164 | { |
| 165 | ?> |
| 166 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 167 | <?php echo $col->th; ?> |
| 168 | </th> |
| 169 | <?php |
| 170 | } |
| 171 | ?> |
| 172 | |
| 173 | <!-- DATE --> |
| 174 | |
| 175 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="10%" style="text-align: left;"> |
| 176 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEREVIEW4', 't.createdon', $this->orderDir, $this->ordering); ?> |
| 177 | </th> |
| 178 | |
| 179 | <!-- LANGUAGES --> |
| 180 | |
| 181 | <?php |
| 182 | if ($multi_lang && $canEdit) |
| 183 | { |
| 184 | ?> |
| 185 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="5%" style="text-align: center;"> |
| 186 | <?php echo JText::translate('VAPLANGUAGES');?> |
| 187 | </th> |
| 188 | <?php |
| 189 | } |
| 190 | ?> |
| 191 | |
| 192 | </tr> |
| 193 | <?php echo $vik->closeTableHead(); ?> |
| 194 | |
| 195 | <?php |
| 196 | for ($i = 0, $n = count($rows); $i < $n; $i++) |
| 197 | { |
| 198 | $row = $rows[$i]; |
| 199 | |
| 200 | $desc = strip_tags((string) $row['description']); |
| 201 | |
| 202 | if (strlen($desc) > 300) |
| 203 | { |
| 204 | $desc = trim(mb_substr($desc, 0, 256, 'UTF-8'), ' .') . '...'; |
| 205 | } |
| 206 | ?> |
| 207 | <tr class="row<?php echo ($i % 2); ?>"> |
| 208 | |
| 209 | <td> |
| 210 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 211 | </td> |
| 212 | |
| 213 | <!-- ID --> |
| 214 | |
| 215 | <td class="hidden-phone"> |
| 216 | <?php echo $row['id']; ?> |
| 217 | </td> |
| 218 | |
| 219 | <!-- NAME --> |
| 220 | |
| 221 | <td> |
| 222 | <div class="td-primary"> |
| 223 | <?php |
| 224 | if ($canEdit) |
| 225 | { |
| 226 | ?> |
| 227 | <a href="index.php?option=com_vikappointments&task=tax.edit&cid[]=<?php echo $row['id']; ?>"> |
| 228 | <?php echo $row['name']; ?> |
| 229 | </a> |
| 230 | <?php |
| 231 | } |
| 232 | else |
| 233 | { |
| 234 | echo $row['name']; |
| 235 | } |
| 236 | ?> |
| 237 | </div> |
| 238 | </td> |
| 239 | |
| 240 | <!-- DESCRIPTION --> |
| 241 | |
| 242 | <td class="hidden-phone"> |
| 243 | <?php echo $desc; ?> |
| 244 | </td> |
| 245 | |
| 246 | <!-- CUSTOM --> |
| 247 | |
| 248 | <?php |
| 249 | foreach ($columns as $k => $col) |
| 250 | { |
| 251 | ?> |
| 252 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 253 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 254 | </td> |
| 255 | <?php |
| 256 | } |
| 257 | ?> |
| 258 | |
| 259 | <!-- DATE --> |
| 260 | |
| 261 | <td class="hidden-phone"> |
| 262 | <?php echo JHtml::fetch('date', $row['createdon'], JText::translate('DATE_FORMAT_LC3') . ' ' . $config->get('timeformat')); ?> |
| 263 | </td> |
| 264 | |
| 265 | <!-- LANGUAGES --> |
| 266 | |
| 267 | <?php |
| 268 | if ($multi_lang && $canEdit) |
| 269 | { |
| 270 | ?> |
| 271 | <td style="text-align: center;"> |
| 272 | <a href="index.php?option=com_vikappointments&view=langtaxes&id_tax=<?php echo $row['id']; ?>"> |
| 273 | <?php |
| 274 | foreach ($row['languages'] as $lang) |
| 275 | { |
| 276 | echo ' ' . JHtml::fetch('vaphtml.site.flag', $lang) . ' '; |
| 277 | } |
| 278 | ?> |
| 279 | </a> |
| 280 | </td> |
| 281 | <?php |
| 282 | } |
| 283 | ?> |
| 284 | |
| 285 | </tr> |
| 286 | <?php |
| 287 | } |
| 288 | ?> |
| 289 | </table> |
| 290 | <?php |
| 291 | } |
| 292 | ?> |
| 293 | |
| 294 | <input type="hidden" name="boxchecked" value="0" /> |
| 295 | <input type="hidden" name="task" value="" /> |
| 296 | <input type="hidden" name="view" value="taxes" /> |
| 297 | |
| 298 | <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" /> |
| 299 | <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" /> |
| 300 | |
| 301 | <?php echo JHtml::fetch('form.token'); ?> |
| 302 | <?php echo $this->navbut; ?> |
| 303 | </form> |
| 304 | |
| 305 | <?php |
| 306 | echo JHtml::fetch( |
| 307 | 'bootstrap.renderModal', |
| 308 | 'jmodal-taxestest', |
| 309 | array( |
| 310 | 'title' => JText::translate('VAPTESTTAXES'), |
| 311 | 'closeButton' => true, |
| 312 | 'keyboard' => false, |
| 313 | 'bodyHeight' => 80, |
| 314 | 'url' => 'index.php?option=com_vikappointments&view=taxestest&tmpl=component', |
| 315 | ) |
| 316 | ); |
| 317 | ?> |
| 318 | |
| 319 | <script> |
| 320 | |
| 321 | jQuery(function($) { |
| 322 | VikRenderer.chosen('.btn-toolbar'); |
| 323 | }); |
| 324 | |
| 325 | function clearFilters() { |
| 326 | jQuery('#vapkeysearch').val(''); |
| 327 | |
| 328 | document.adminForm.submit(); |
| 329 | } |
| 330 | |
| 331 | function vapOpenJModal(id, url, jqmodal) { |
| 332 | <?php echo $vik->bootOpenModalJS(); ?> |
| 333 | } |
| 334 | |
| 335 | </script> |
| 336 |