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 / reportsser / tmpl / default.php
vikappointments / admin / views / reportsser / tmpl Last commit date
default.php 5 days ago index.html 5 days ago
default.php
236 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('formbehavior.chosen');
15 JHtml::fetch('vaphtml.assets.chartjs');
16
17 $vik = VAPApplication::getInstance();
18
19 ?>
20
21 <style>
22 /**
23 * Hide summary badges from pie chart.
24 */
25 .widget-floating-box {
26 display: none;
27 }
28 </style>
29
30 <script>
31
32 /**
33 * A lookup of preflights to be used before refreshing
34 * the contents of the widgets.
35 *
36 * If needed, a widget can register its own callback
37 * to be executed before the AJAX request is started.
38 *
39 * The property name MUST BE equals to the ID of
40 * the widget that is registering its callback.
41 *
42 * @var object
43 */
44 var WIDGET_PREFLIGHTS = {};
45
46 /**
47 * A lookup of callbacks to be used when refreshing
48 * the contents of the widgets.
49 *
50 * If needed, a widget can register its own callback
51 * to be executed once the AJAX request is completed.
52 *
53 * The property name MUST BE equals to the ID of
54 * the widget that is registering its callback.
55 *
56 * @var object
57 */
58 var WIDGET_CALLBACKS = {};
59
60 </script>
61
62 <form action="index.php" method="POST" name="adminForm" id="adminForm">
63
64 <?php echo $vik->openCard(); ?>
65
66 <div class="btn-toolbar" style="height: 32px;">
67
68 <div class="btn-group pull-left">
69 <?php echo $vik->calendar($this->filters['datefrom'], 'datefrom', 'vapstartdate'); ?>
70 </div>
71
72 <div class="btn-group pull-left">
73 <?php echo $vik->calendar($this->filters['dateto'], 'dateto', 'vapenddate'); ?>
74 </div>
75
76 <?php
77 $options = array(
78 JHtml::fetch('select.option', 'total', JText::translate('VAPREPORTSVALUETYPEOPT1')),
79 JHtml::fetch('select.option', 'count', JText::translate('VAPREPORTSVALUETYPEOPT2')),
80 );
81 ?>
82
83 <div class="btn-group pull-left">
84 <select name="valuetype" id="vap-valuetype-sel">
85 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $this->filters['valuetype'])?>
86 </select>
87 </div>
88
89 <?php
90 $options = array(
91 JHtml::fetch('select.option', 1, JText::translate('VAPDOWNLOADREPORTOPT1')),
92 JHtml::fetch('select.option', 0, JText::translate('VAPDOWNLOADREPORTOPT2')),
93 );
94 ?>
95
96 <div class="btn-group pull-left">
97 <select name="checkin" id="vap-checkin-sel">
98 <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $this->filters['checkin'])?>
99 </select>
100 </div>
101
102 <div class="btn-group pull-left">
103 <button type="button" class="btn" id="submit-search">
104 <?php echo JText::translate('VAPRESERVATIONBUTTONFILTER'); ?>
105 </button>
106 </div>
107
108 </div>
109
110 <div class="vap-charts-pool">
111
112 <?php
113 foreach ($this->services as $service)
114 {
115 echo $vik->openFieldset($service->name); ?>
116
117 <div class="vap-empchart-box">
118
119 <div class="vap-linechart-container">
120 <div class="vap-linechart-wrapper" id="widget-<?php echo $service->lineChart->getID(); ?>" data-widget="<?php echo $this->escape($service->lineChart->getName()); ?>">
121 <?php echo $service->lineChart->display(array('legend' => true)); ?>
122 </div>
123 </div>
124
125 <div class="vap-piechart-container">
126 <div class="vap-piechart-wrapper" id="widget-<?php echo $service->pieChart->getID(); ?>" data-widget="<?php echo $this->escape($service->pieChart->getName()); ?>">
127 <?php echo $service->pieChart->display(); ?>
128 </div>
129 </div>
130
131 <input type="hidden" name="cid[]" value="<?php echo $service->id; ?>" />
132
133 </div>
134
135 <?php
136 echo $vik->closeFieldset();
137 }
138 ?>
139
140 </div>
141
142 <?php echo $vik->closeCard(); ?>
143
144 <input type="hidden" name="option" value="com_vikappointments" />
145 <input type="hidden" name="view" value="reportsser" />
146 <input type="hidden" name="task" value="" />
147
148 </form>
149
150 <script>
151
152 (function($) {
153 'use strict';
154
155 /**
156 * Prepare any chart to be responsive.
157 */
158 Chart.defaults.global.responsive = true;
159
160 /**
161 * Updates the configuration of the last edited widget.
162 *
163 * @param integer id The widget ID.
164 * @param object config The widget configuration.
165 *
166 * @return void
167 */
168 const updateWidgetContents = (id, config) => {
169 // keep a reference to the widget
170 var box = $('#widget-' + id);
171
172 // get widget class
173 var widget = box.data('widget');
174
175 // prepare request data
176 Object.assign(config, {
177 id: id,
178 widget: widget,
179 tmp: true,
180 });
181
182 if (WIDGET_PREFLIGHTS.hasOwnProperty(id)) {
183 // let the widget prepares the contents without
184 // waiting for the request completion
185 WIDGET_PREFLIGHTS[id](box, config);
186 }
187
188 // make request to load widget dataset
189 UIAjax.do(
190 '<?php echo $vik->ajaxUrl('index.php?option=com_vikappointments&task=analytics.loadwidgetdata'); ?>',
191 config,
192 (resp) => {
193 // check if the widget registered its own update method
194 if (WIDGET_CALLBACKS.hasOwnProperty(id)) {
195 // let the widget callback finalizes the update
196 WIDGET_CALLBACKS[id](box, resp, config);
197 } else {
198 if (typeof resp === 'string') {
199 // replace widget body with returned string/HTML
200 $(box).html(resp);
201 }
202 }
203 },
204 (error) => {
205 // do nothing on error
206 }
207 );
208 }
209
210 $('#submit-search').on('click', () => {
211 // manually clear task for a correct refresh
212 document.adminForm.task.value = '';
213 // refresh form on button click
214 Joomla.submitbutton('');
215 });
216
217 $(function() {
218 VikRenderer.chosen('.btn-toolbar');
219
220 <?php
221 // iterate dashboard widgets
222 foreach ($this->services as $service)
223 {
224 ?>
225 // load line chart
226 updateWidgetContents('<?php echo $service->lineChart->getID(); ?>', <?php echo json_encode($service->lineChart->getOptions()); ?>);
227 // load pie chart
228 updateWidgetContents('<?php echo $service->pieChart->getID(); ?>', <?php echo json_encode($service->pieChart->getOptions()); ?>);
229 <?php
230 }
231 ?>
232 });
233 })(jQuery);
234
235 </script>
236