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 / layouts / statistics / widgets / dashboard / users / table.php
vikappointments / admin / layouts / statistics / widgets / dashboard / users Last commit date
table 5 days ago index.html 5 days ago table.php 5 days ago
table.php
196 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 /**
15 * Layout variables
16 * -----------------
17 * @var VAPStatisticsWidget $widget The instance of the widget to be displayed.
18 * @var mixed $data The table rows data.
19 */
20 extract($displayData);
21
22 // get active tab
23 $active = JFactory::getApplication()->input->cookie->get('vap_widget_' . $widget->getName() . '_active_' . $widget->getID(), 'latest');
24
25 ?>
26
27 <div class="canvas-align-top">
28
29 <!-- widget container -->
30
31 <div class="vapdash-container">
32
33 <!-- widget tabs -->
34
35 <div class="vapdash-tab-head">
36 <div class="vapdash-tab-button">
37 <a href="javascript:void(0)" data-pane="latest" class="<?php echo ($active == 'latest' ? 'active' : ''); ?>">
38 <?php echo JText::translate('VAPDASHLATESTCUSTOMERS'); ?>
39 </a>
40 </div>
41
42 <div class="vapdash-tab-button">
43 <a href="javascript:void(0)" data-pane="current" class="<?php echo ($active == 'current' ? 'active' : ''); ?>">
44 <?php echo JText::translate('VAPDASHLOGGEDCUSTOMERS'); ?>
45 </a>
46 </div>
47 </div>
48
49 <!-- widget latest users pane -->
50
51 <div class="vapdash-tab-pane" data-pane="latest" style="<?php echo $active == 'latest' ? '' : 'display:none'; ?>">
52
53 </div>
54
55 <!-- widget current users pane -->
56
57 <div class="vapdash-tab-pane" data-pane="current" style="<?php echo $active == 'current' ? '' : 'display:none'; ?>">
58
59 </div>
60
61 </div>
62
63 </div>
64
65 <script>
66
67 (function($) {
68 'use strict';
69
70 /**
71 * Register callback to be executed before
72 * launching the update request.
73 *
74 * @param mixed widget The widget selector.
75 * @param object config The widget configuration.
76 *
77 * @return void
78 */
79 WIDGET_PREFLIGHTS[<?php echo $widget->getID(); ?>] = (widget, config) => {
80 // count disabled panes
81 var disabled = 0;
82 // reference to first enabled tab
83 var firstEnabled = null;
84 // flag to check if the current active pane is disabled
85 var activeDisabled = false;
86
87 var id = $(widget).attr('id');
88
89 // iterate panes and toggle them according to the widget config
90 $(widget).find('.vapdash-tab-head a').each(function() {
91 var pane = $(this).data('pane');
92
93 if (config[pane]) {
94 $(this).show()
95 .parent()
96 .show();
97
98 // register tab as first available, only
99 // if the flag is still empty
100 if (!firstEnabled) {
101 firstEnabled = this;
102 }
103 } else {
104 $(this).hide()
105 .parent()
106 .hide();
107
108 // increase disabled counter
109 disabled++;
110 // inform the caller that the active pane is disabled
111 activeDisabled = activeDisabled || $(this).hasClass('active');
112 }
113 });
114
115 // hide all tabs in case only one is enabled
116 if (disabled < 1) {
117 $(widget).find('.vapdash-tab-head').show();
118 } else {
119 $(widget).find('.vapdash-tab-head').hide();
120 }
121
122 // in case the active pane was disabled, we should display the first one available
123 if (activeDisabled && firstEnabled) {
124 $(firstEnabled).trigger('click');
125 }
126 }
127
128 /**
129 * Register callback to be executed after
130 * completing the update request.
131 *
132 * @param mixed widget The widget selector.
133 * @param string data The JSON response.
134 * @param object config The widget configuration.
135 *
136 * @return void
137 */
138 WIDGET_CALLBACKS[<?php echo $widget->getID(); ?>] = (widget, data, config) => {
139 var id = $(widget).attr('id');
140
141 $(widget).find('.vapdash-tab-pane').each(function() {
142 // get pane id
143 var pane = $(this).data('pane');
144
145 if (data[pane] !== undefined) {
146 // fill body with returned HTML
147 $(this).html(data[pane]);
148 } else {
149 // set empty string
150 $(this).html('');
151 }
152 });
153 }
154
155 $(function() {
156 // get widget element
157 const widget = $('#widget-<?php echo $widget->getID(); ?>');
158
159 // register click event for tab buttons
160 $(widget).find('.vapdash-tab-head a').on('click', function() {
161 // get button pane
162 var pane = $(this).data('pane');
163
164 // deactivate all buttons
165 $(widget).find('.vapdash-tab-head a').removeClass('active');
166 // active clicked button
167 $(this).addClass('active');
168
169 // hide all panes
170 $(widget).find('.vapdash-tab-pane').hide();
171 // show selected pane
172 $(widget).find('.vapdash-tab-pane[data-pane="' + pane + '"]').show();
173
174 // register selected button in cookie
175 document.cookie = 'vap.widget.<?php echo $widget->getName(); ?>.active.<?php echo $widget->getID(); ?>=' + pane + '; path=/';
176 });
177
178 // display customer details in a modal box
179 $(document).on('click', '#widget-<?php echo $widget->getID(); ?> a[data-customer-id]', function() {
180 // get customer ID
181 const user_id = $(this).data('customer-id');
182
183 // update href to access the management page of the customer
184 let href = $('#custinfo-edit-btn').attr('href');
185 $('#custinfo-edit-btn').attr('href', href.replace(/cid\[\]=[\d]*$/, 'cid[]=' + user_id));
186
187 // create URL
188 const url = 'index.php?option=com_vikappointments&view=customerinfo&tmpl=component&cid[]=' + user_id;
189 // open modal
190 $('#jmodal-custinfo').vapJModal('open', url);
191 });
192 });
193 })(jQuery);
194
195 </script>
196