PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / coupons / tmpl / default.php
vikappointments / admin / views / coupons / tmpl Last commit date
default.php 3 days ago index.html 3 days ago
default.php
486 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('bootstrap.tooltip', '.hasTooltip');
15 JHtml::fetch('formbehavior.chosen');
16
17 $rows = $this->rows;
18
19 $filters = $this->filters;
20
21 $vik = VAPApplication::getInstance();
22
23 $config = VAPFactory::getConfig();
24 $currency = VAPFactory::getCurrency();
25
26 $user = JFactory::getUser();
27
28 $canEdit = $user->authorise('core.edit', 'com_vikappointments');
29
30 $dt_format = $config->get('dateformat') . ' ' . $config->get('timeformat');
31
32 $now = JFactory::getDate()->toSql();
33
34 $is_searching = $this->hasFilters();
35
36 /**
37 * Trigger event to display custom HTML.
38 * In case it is needed to include any additional fields,
39 * it is possible to create a plugin and attach it to an event
40 * called "onDisplayViewCouponsList". The event method receives the
41 * view instance as argument.
42 *
43 * @since 1.7
44 */
45 $forms = $this->onDisplayListView($is_searching);
46
47 ?>
48
49 <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm">
50
51 <div class="btn-toolbar" style="height: 32px;">
52 <div class="btn-group pull-left input-append">
53 <input type="text" name="keys" id="vapkeysearch" size="32"
54 value="<?php echo $this->escape($filters['keys']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" />
55
56 <button type="submit" class="btn">
57 <i class="fas fa-search"></i>
58 </button>
59 </div>
60
61 <!-- Define role to detect the supported hook -->
62 <!-- {"rule":"customizer","event":"onDisplayViewCouponsList","type":"search","key":"search"} -->
63
64 <?php
65 // plugins can use the "search" key to introduce custom
66 // filters within the search bar
67 if (isset($forms['search']))
68 {
69 echo $forms['search'];
70 }
71 ?>
72
73 <div class="btn-group pull-left">
74 <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);">
75 <?php echo JText::translate('JSEARCH_TOOLS'); ?>&nbsp;<i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i>
76 </button>
77 </div>
78
79 <div class="btn-group pull-left">
80 <button type="button" class="btn" onclick="clearFilters();">
81 <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?>
82 </button>
83 </div>
84
85 <div class="btn-group pull-right">
86 <a href="index.php?option=com_vikappointments&amp;view=coupongroups" class="btn">
87 <?php echo JText::translate('VAPMANAGEGROUPS'); ?>
88 </a>
89 </div>
90 </div>
91
92 <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>">
93
94 <?php
95 $options = array(
96 JHtml::fetch('select.option', 0, JText::translate('VAPFILTERSELECTTYPE')),
97 JHtml::fetch('select.option', 1, JText::translate('VAPCOUPONTYPEOPTION1')),
98 JHtml::fetch('select.option', 2, JText::translate('VAPCOUPONTYPEOPTION2')),
99 );
100 ?>
101 <div class="btn-group pull-left">
102 <select name="type" id="vap-type-sel" class="<?php echo ($filters['type'] != 0 ? 'active' : ''); ?>" onchange="document.adminForm.submit();">
103 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['type']); ?>
104 </select>
105 </div>
106
107 <?php
108 $options = array(
109 JHtml::fetch('select.option', 0, JText::translate('VAPFILTERSELECTVAL')),
110 JHtml::fetch('select.option', 1, JText::translate('VAPCOUPONVALUETYPE1')),
111 JHtml::fetch('select.option', 2, JText::translate('VAPCOUPONVALUETYPE2')),
112 );
113 ?>
114 <div class="btn-group pull-left">
115 <select name="value" id="vap-value-sel" class="<?php echo ($filters['value'] != 0 ? 'active' : ''); ?>" onchange="document.adminForm.submit();">
116 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['value']); ?>
117 </select>
118 </div>
119
120 <?php
121 $options = array(
122 JHtml::fetch('select.option', 0, JText::translate('VAPFILTERSELECTSTATUS')),
123 JHtml::fetch('select.option', 1, JText::translate('VAPCOUPONVALID0')),
124 JHtml::fetch('select.option', 2, JText::translate('VAPCOUPONVALID1')),
125 JHtml::fetch('select.option', 3, JText::translate('VAPCOUPONVALID2')),
126 );
127 ?>
128 <div class="btn-group pull-left">
129 <select name="status" id="vap-status-sel" class="<?php echo ($filters['status'] != 0 ? 'active' : ''); ?>" onchange="document.adminForm.submit();">
130 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['status']); ?>
131 </select>
132 </div>
133
134 <?php
135 $options = array(
136 JHtml::fetch('select.option', -1, JText::translate('VAPFILTERSELECTGROUP')),
137 JHtml::fetch('select.option', 0, JText::translate('VAPSERVICENOGROUP')),
138 );
139
140 $options = array_merge($options, JHtml::fetch('vaphtml.admin.coupongroups'));
141 ?>
142 <div class="btn-group pull-left">
143 <select name="id_group" id="vap-group-sel" class="<?php echo ($filters['id_group'] != -1 ? 'active' : ''); ?>" onchange="document.adminForm.submit();">
144 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $filters['id_group']); ?>
145 </select>
146 </div>
147
148 <!-- Define role to detect the supported hook -->
149 <!-- {"rule":"customizer","event":"onDisplayViewCouponsList","type":"search","key":"filters"} -->
150
151 <?php
152 // plugins can use the "filters" key to introduce custom
153 // filters within the search bar
154 if (isset($forms['filters']))
155 {
156 echo $forms['filters'];
157 }
158 ?>
159
160 </div>
161
162 <?php
163 if (count($rows) == 0)
164 {
165 echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS'));
166 }
167 else
168 {
169 /**
170 * Trigger event to display custom columns.
171 *
172 * @since 1.7
173 */
174 $columns = $this->onDisplayTableColumns();
175 ?>
176
177 <!-- Define role to detect the supported hook -->
178 <!-- {"rule":"customizer","event":"onDisplayCouponsTableTH","type":"th"} -->
179
180 <!-- Define role to detect the supported hook -->
181 <!-- {"rule":"customizer","event":"onDisplayCouponsTableTD","type":"td"} -->
182
183 <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>">
184 <?php echo $vik->openTableHead(); ?>
185 <tr>
186
187 <th width="1%">
188 <?php echo $vik->getAdminToggle(count($rows)); ?>
189 </th>
190
191 <!-- ID -->
192
193 <th class="<?php echo $vik->getAdminThClass('left hidden-phone nowrap'); ?>" width="1%" style="text-align: left;">
194 <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECOUPON1', 'c.id', $this->orderDir, $this->ordering); ?>
195 </th>
196
197 <!-- CODE -->
198
199 <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;">
200 <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECOUPON2', 'c.code', $this->orderDir, $this->ordering); ?>
201 </th>
202
203 <!-- TYPE -->
204
205 <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: center;">
206 <?php echo JText::translate('VAPMANAGECOUPON3'); ?>
207 </th>
208
209 <!-- AMOUNT -->
210
211 <th class="<?php echo $vik->getAdminThClass(); ?>" width="8%" style="text-align: center;">
212 <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECOUPON5', 'c.value', $this->orderDir, $this->ordering); ?>
213 </th>
214
215 <!-- MIN COST -->
216
217 <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="8%" style="text-align: center;">
218 <?php echo JText::translate('VAPMANAGECOUPON6'); ?>
219 </th>
220
221 <!-- CUSTOM -->
222
223 <?php
224 foreach ($columns as $k => $col)
225 {
226 ?>
227 <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>">
228 <?php echo $col->th; ?>
229 </th>
230 <?php
231 }
232 ?>
233
234 <!-- PUBLISHING -->
235
236 <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="15%" style="text-align: center;">
237 <?php echo JHtml::fetch('vaphtml.admin.sort', 'JGLOBAL_FIELDSET_PUBLISHING', 'c.dstart', $this->orderDir, $this->ordering); ?>
238 </th>
239
240 <!-- LAST MINUTE -->
241
242 <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="5%" style="text-align: center;">
243 <?php echo JText::translate('VAPMANAGECOUPON10'); ?>
244 </th>
245
246 <!-- STATUS -->
247
248 <th class="<?php echo $vik->getAdminThClass(); ?>" width="10%" style="text-align: center;">
249 <?php echo JText::translate('VAPMANAGECOUPON9'); ?>
250 </th>
251
252 </tr>
253 <?php echo $vik->closeTableHead(); ?>
254
255 <?php
256 for ($i = 0, $n = count($rows); $i < $n; $i++)
257 {
258 $row = $rows[$i];
259
260 // validate coupon according to the applicable section
261 if (in_array($row['applicable'], array('', 'appointments')))
262 {
263 // validate as appointment
264 $valid = (int) VikAppointments::validateCoupon($row);
265 }
266 else if ($row['applicable'] == 'packages')
267 {
268 // validate as package
269 $valid = (int) VikAppointments::validatePackagesCoupon($row);
270 }
271 else
272 {
273 // validate as subscription
274 $valid = (int) VikAppointments::validateSubscriptionsCoupon($row);
275 }
276
277 if ($valid)
278 {
279 // coupon valid
280 $class = 'vapreservationstatusconfirmed';
281 }
282 else
283 {
284 // coupon invalid, check whether it is expired
285 if (!VAPDateHelper::isNull($row['dstart']) && $row['dstart'] > $now)
286 {
287 // coupon not yet active
288 $class = 'vapreservationstatuspending';
289 $valid = 2;
290 }
291 else
292 {
293 // coupon is expired
294 $class = 'vapreservationstatusremoved';
295 }
296 }
297
298 $tooltip = JText::sprintf('VAPCOUPONINFOTIP',
299 $row['used_quantity'],
300 ($row['type'] == 2 ? max(array(0, $row['max_quantity'] - $row['used_quantity'])) : "&infin;"),
301 (strlen($row['notes']) ? '<br /><br />' : '') . $row['notes']
302 );
303
304 if ($row['lastminute'])
305 {
306 $last_min_title = VikAppointments::formatMinutesToTime($row['lastminute'] * 60, $format = true);
307 }
308 else
309 {
310 $last_min_title = '';
311 }
312
313 ?>
314 <tr class="row<?php echo ($i % 2); ?>">
315
316 <td>
317 <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>">
318 </td>
319
320 <!-- ID -->
321
322 <td class="hidden-phone">
323 <?php echo $row['id']; ?>
324 </td>
325
326 <!-- CODE -->
327
328 <td>
329 <div class="td-primary td-pull-left">
330 <?php
331 if ($canEdit)
332 {
333 ?>
334 <a href="index.php?option=com_vikappointments&amp;task=coupon.edit&amp;cid[]=<?php echo $row['id']; ?>">
335 <?php echo $row['code']; ?>
336 </a>
337 <?php
338 }
339 else
340 {
341 echo $row['code'];
342 }
343 ?>
344 </div>
345
346 <div class="td-pull-right">
347 <a href="javascript: void(0);" class="hasTooltip" title="<?php echo $this->escape($tooltip); ?>">
348 <i class="fas fa-sticky-note big"></i>
349 </a>
350 </div>
351 </td>
352
353 <!-- TYPE -->
354
355 <td style="text-align: center;" class="hidden-phone">
356 <?php echo JText::translate('VAPCOUPONTYPEOPTION' . $row['type'] ); ?>
357 </td>
358
359 <!-- AMOUNT -->
360
361 <td style="text-align: center;">
362 <?php
363 if ($row['percentot'] == 1)
364 {
365 echo $row['value'] . JText::translate('VAPCOUPONPERCENTOTOPTION1');
366 }
367 else
368 {
369 echo $currency->format($row['value']);
370 }
371 ?>
372 </td>
373
374 <!-- MIN COST -->
375
376 <td style="text-align: center;" class="hidden-phone">
377 <?php echo $currency->format($row['mincost']); ?>
378 </td>
379
380 <!-- CUSTOM -->
381
382 <?php
383 foreach ($columns as $k => $col)
384 {
385 ?>
386 <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone">
387 <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?>
388 </td>
389 <?php
390 }
391 ?>
392
393 <!-- PUBLISHING -->
394
395 <td style="text-align: center;" class="hidden-phone">
396 <?php
397 if (!VAPDateHelper::isNull($row['dstart']) || !VAPDateHelper::isNull($row['dend']))
398 {
399 if (!VAPDateHelper::isNull($row['dstart']))
400 {
401 ?>
402 <span class="badge badge-success hasTooltip" title="<?php echo $this->escape(JText::translate('VAPMANAGEPACKAGE6')); ?>">
403 <?php echo JHtml::fetch('date', $row['dstart'], 'DATE_FORMAT_LC3'); ?>
404 </span>
405 <?php
406 }
407
408 if (!VAPDateHelper::isNull($row['dend']))
409 {
410 ?>
411 <span class="badge badge-important hasTooltip" title="<?php echo $this->escape(JText::translate('VAPMANAGEPACKAGE7')); ?>">
412 <?php echo JHtml::fetch('date', $row['dend'], 'DATE_FORMAT_LC3'); ?>
413 </span>
414 <?php
415 }
416 }
417 else
418 {
419 echo '/';
420 }
421 ?>
422 </td>
423
424 <!-- LAST MINUTE -->
425
426 <td style="text-align: center;" class="hidden-phone">
427 <?php echo JHtml::fetch('vaphtml.admin.stateaction', $row['lastminute'], $row['id'], '', false, array(), $last_min_title); ?>
428 </td>
429
430 <!-- STATUS -->
431
432 <td style="text-align: center;" class="<?php echo $class; ?>">
433 <?php echo JText::translate('VAPCOUPONVALID' . $valid); ?>
434 </td>
435
436 </tr>
437 <?php
438 }
439 ?>
440 </table>
441 <?php
442 }
443 ?>
444
445 <!-- hidden input for import tool -->
446 <input type="hidden" name="import_type" value="coupons" />
447
448 <input type="hidden" name="boxchecked" value="0" />
449 <input type="hidden" name="task" value="" />
450 <input type="hidden" name="view" value="coupons" />
451
452 <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" />
453 <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" />
454
455 <?php echo JHtml::fetch('form.token'); ?>
456 <?php echo $this->navbut; ?>
457 </form>
458
459 <script>
460
461 jQuery(function($) {
462 VikRenderer.chosen('.btn-toolbar');
463 });
464
465 function clearFilters() {
466 jQuery('#vapkeysearch').val('');
467 jQuery('#vap-type-sel').updateChosen(0);
468 jQuery('#vap-value-sel').updateChosen(0);
469 jQuery('#vap-status-sel').updateChosen(0);
470 jQuery('#vap-group-sel').updateChosen(-1);
471
472 document.adminForm.submit();
473 }
474
475 Joomla.submitbutton = function(task) {
476 if (task == 'import' || task == 'export') {
477 // populate view instead of task
478 document.adminForm.view.value = task;
479 task = '';
480 }
481
482 Joomla.submitform(task, document.adminForm);
483 }
484
485 </script>
486