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 / site / views / order / tmpl / default_countdown.php
vikappointments / site / views / order / tmpl Last commit date
default.php 2 days ago default.xml 2 days ago default_appointment.php 2 days ago default_attendees.php 2 days ago default_backbutton.php 2 days ago default_countdown.php 2 days ago default_locations.php 2 days ago default_orderdetails.php 2 days ago default_service.php 2 days ago default_usernote.php 2 days ago default_usernote_block.php 2 days ago index.html 2 days ago track.php 2 days ago
default_countdown.php
77 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 $vik = VAPApplication::getInstance();
15
16 // calculate remaining minutes
17 $remaining = ceil(($this->order->locked_until - time()) / 60);
18
19 /**
20 * Do not display the countdown in case the remaining time is expired.
21 *
22 * @since 1.7.9
23 */
24 if ($remaining <= 0) {
25 return;
26 }
27
28 // format remaining seconds in a readable text
29 $remaining = VikAppointments::formatMinutesToTime($remaining, $apply = true);
30
31 ?>
32
33 <div class="vap-order-countdown">
34
35 <?php
36 // display countdown message
37 echo JText::sprintf('VAPORDERCOUNTDOWN', $remaining);
38 ?>
39
40 </div>
41
42 <script>
43
44 (function($) {
45 let COUNTDOWN_TIMER = setInterval(() => {
46 UIAjax.do(
47 '<?php echo $vik->ajaxUrl('index.php?option=com_vikappointments&task=order.countdown'); ?>',
48 {
49 id: <?php echo $this->order->id; ?>,
50 locked_until: <?php echo $this->order->locked_until; ?>,
51 },
52 (resp) => {
53 if (resp.status) {
54 // refresh time
55 $('.vap-order-countdown').html(resp.text);
56 } else {
57 // expired time, remove countdown block
58 $('.vap-order-countdown').remove();
59
60 // stop timer
61 clearInterval(COUNTDOWN_TIMER);
62
63 // still offer other 60 seconds to complete the payment
64 setTimeout(() => {
65 document.orderform.submit();
66 }, 60000);
67 }
68 },
69 (err) => {
70 // do nothing on error, we probably faced a downtime
71 }
72 );
73 }, 30000);
74 })(jQuery);
75
76 </script>
77