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 / finance / rog.php
vikappointments / admin / layouts / statistics / widgets / finance Last commit date
coupons 5 days ago payments 5 days ago revenue 5 days ago index.html 5 days ago overall.php 5 days ago rog.php 5 days ago
rog.php
130 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 */
19 extract($displayData);
20
21 ?>
22
23 <style>
24
25 .canvas-align-center .rog {
26 text-align: center;
27 }
28 .canvas-align-center .rog .rog-earning {
29 font-size: 40px;
30 margin-bottom: 20px;
31 color: #476799;
32 font-weight: bold;
33 }
34 .canvas-align-center .rog .rog-percent {
35 font-size: 26px;
36 color: #002243;
37 font-weight: bold;
38 }
39 .canvas-align-center .rog .rog-percent > .down {
40 color: #ec4d56;
41 }
42 .canvas-align-center .rog .rog-percent > .up {
43 color: #29a449;
44 }
45 .canvas-align-center .rog .rog-percent i {
46 margin-left: 5px;
47 }
48
49 </style>
50
51 <div class="canvas-align-center">
52
53 <div class="rog">
54 <div class="rog-earning"></div>
55 <div class="rog-percent"></div>
56 </div>
57
58 </div>
59
60 <div class="no-results" style="display:none;">
61 <?php echo VAPApplication::getInstance()->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); ?>
62 </div>
63
64 <div class="widget-floating-box">
65
66 <span class="badge badge-info pull-left month1" style="margin-right:4px;"></span>
67 <span class="badge badge-important pull-left month2"></span>
68
69 </div>
70
71 <script>
72
73 (function($) {
74 'use strict';
75
76 /**
77 * Register callback to be executed after
78 * completing the update request.
79 *
80 * @param mixed widget The widget selector.
81 * @param mixed data The AJAX response.
82 * @param object config The widget configuration.
83 *
84 * @return void
85 */
86 WIDGET_CALLBACKS[<?php echo $widget->getID(); ?>] = (widget, data, config) => {
87 if (data.nodata) {
88 // hide rog information
89 $(widget).find('.canvas-align-center').hide();
90 // show "no results" box
91 $(widget).find('.no-results').show();
92 } else {
93 // hide "no results" box
94 $(widget).find('.no-results').hide();
95 // show rog information
96 $(widget).find('.canvas-align-center').show();
97
98 // fetch rog
99 var rog = parseFloat(data.rogPercent);
100 var rogIcon = '';
101 var sfx = 'equals';
102
103 if (rog > 0) {
104 rogIcon = '<i class="fas fa-arrow-up"></i>';
105 sfx = 'up';
106 } else if (rog < 0) {
107 rogIcon = '<i class="fas fa-arrow-down"></i>';
108 sfx = 'down';
109 }
110
111 // strip decimals in case the rog is higher than 10 or lower than -10
112 if (Math.abs(rog) > 10) {
113 rog = Math.round(rog);
114 }
115
116 var rogHtml = '<span class="' + sfx + '">' + rog + '%' + rogIcon + '</span>';
117
118 // update total earning
119 $(widget).find('.rog-earning').text(VAPCurrency.getInstance().format(data[data.month1].total));
120 $(widget).find('.rog-percent').html(rogHtml);
121 }
122
123 // update badges
124 $(widget).find('.badge.month1').text(data[data.month1].date);
125 $(widget).find('.badge.month2').text(data[data.month2].date);
126 }
127 })(jQuery);
128
129 </script>
130