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