widget.php
198 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments - Libraries |
| 4 | * @subpackage html.wpdash |
| 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 JRegistry $config The configuration registry |
| 18 | * @var JDashboardWidget $widget The widget instance. |
| 19 | * @var JUser $user The current user instance. |
| 20 | * @var array $monthtotal An array holding the total earning of the month (total, tax and net). |
| 21 | * @var mixed $chart The analytics widget used to generate a revenue chart. |
| 22 | * @var integer $pending The total count of pending appointments. |
| 23 | * @var integer $needpay The total count of appointments that require a payment. |
| 24 | */ |
| 25 | extract($displayData); |
| 26 | |
| 27 | JHtml::fetch('vaphtml.assets.currency'); |
| 28 | |
| 29 | $currency = VAPFactory::getCurrency(); |
| 30 | |
| 31 | ?> |
| 32 | |
| 33 | <style> |
| 34 | #vik_appointments_overview .inside { |
| 35 | padding: 0; |
| 36 | margin: 0; |
| 37 | } |
| 38 | |
| 39 | .vap-overview-widget .overview-row { |
| 40 | padding: 9px 12px; |
| 41 | border-top: 1px solid #ececec; |
| 42 | } |
| 43 | .vap-overview-widget .overview-row:first-child { |
| 44 | border-top: 0; |
| 45 | } |
| 46 | .vap-overview-widget .overview-row.overview-row-container { |
| 47 | padding: 0; |
| 48 | display: flex; |
| 49 | justify-content: space-between; |
| 50 | } |
| 51 | .vap-overview-widget .overview-row.overview-row-container .row-child { |
| 52 | flex: 1; |
| 53 | border-left: 1px solid #ececec; |
| 54 | padding: 9px 12px; |
| 55 | } |
| 56 | .vap-overview-widget .overview-row.overview-row-container .row-child:first-child { |
| 57 | border-left: 0; |
| 58 | } |
| 59 | |
| 60 | .vap-overview-widget .month-total-row { |
| 61 | display: flex; |
| 62 | justify-content: space-between; |
| 63 | align-items: center; |
| 64 | } |
| 65 | .vap-overview-widget .month-total-row .total-earning { |
| 66 | flex: 1; |
| 67 | } |
| 68 | .vap-overview-widget .month-total-row .total-earning:before { |
| 69 | content: "\f185"; |
| 70 | } |
| 71 | .vap-overview-widget .overview-row .row-main:before { |
| 72 | font-family: dashicons; |
| 73 | font-size: 2em; |
| 74 | line-height: 1.2em; |
| 75 | color: #464646; |
| 76 | float: left; |
| 77 | margin-right: 12px; |
| 78 | } |
| 79 | .vap-overview-widget .overview-row .row-main > * { |
| 80 | display: block; |
| 81 | width: 100%; |
| 82 | } |
| 83 | .vap-overview-widget .overview-row .row-main small { |
| 84 | color: #999; |
| 85 | } |
| 86 | .vap-overview-widget .month-total-row .rog .dashicons { |
| 87 | font-size: 16px; |
| 88 | } |
| 89 | .vap-overview-widget .month-total-row .rog.up { |
| 90 | color: #090; |
| 91 | } |
| 92 | .vap-overview-widget .month-total-row .rog.up .dashicons { |
| 93 | transform: rotate(45deg); |
| 94 | } |
| 95 | .vap-overview-widget .month-total-row .rog.down { |
| 96 | color: #900; |
| 97 | } |
| 98 | .vap-overview-widget .month-total-row .rog.down .dashicons { |
| 99 | transform: rotate(135deg); |
| 100 | } |
| 101 | .vap-overview-widget .month-total-row .rog.nodata { |
| 102 | color: #999; |
| 103 | } |
| 104 | .vap-overview-widget .appointments-stat .pending-count:before { |
| 105 | content: "\f14f"; |
| 106 | color: #FF7000; |
| 107 | } |
| 108 | .vap-overview-widget .appointments-stat .needpay-count:before { |
| 109 | content: "\f533"; |
| 110 | color: #339CCC; |
| 111 | } |
| 112 | </style> |
| 113 | |
| 114 | <div class="vap-overview-widget"> |
| 115 | |
| 116 | <?php |
| 117 | if ($user->authorise('core.access.analytics.finance', 'com_vikappointments')) |
| 118 | { |
| 119 | ?> |
| 120 | <div class="month-total-row overview-row"> |
| 121 | |
| 122 | <div class="row-main total-earning"> |
| 123 | <strong><?php echo $currency->format($monthtotal['total']); ?></strong> |
| 124 | <small><?php _e('sales this month', 'vikappointments'); ?></small> |
| 125 | </div> |
| 126 | |
| 127 | <?php |
| 128 | if (!empty($rog['rog'])) |
| 129 | { |
| 130 | ?> |
| 131 | <div class="rog <?php echo $rog['rog'] > 0 ? 'up' : 'down'; ?>"> |
| 132 | <span class="dashicons dashicons-arrow-up-alt"></span> |
| 133 | |
| 134 | <?php |
| 135 | // strip decimals in case the rog is higher than 10 or lower than -10 |
| 136 | if (abs($rog['rogPercent']) > 10) |
| 137 | { |
| 138 | $rog['rogPercent'] = round($rog['rogPercent']); |
| 139 | } |
| 140 | |
| 141 | echo ($rog['rogPercent'] > 0 ? '+' : '') . $rog['rogPercent'] . '%'; |
| 142 | ?> |
| 143 | </div> |
| 144 | <?php |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | ?> |
| 149 | <div class="rog nodata"> |
| 150 | <span class="dashicons dashicons-minus"></span> |
| 151 | </div> |
| 152 | <?php |
| 153 | } |
| 154 | ?> |
| 155 | |
| 156 | </div> |
| 157 | <?php |
| 158 | } |
| 159 | |
| 160 | if ($user->authorise('core.access.reservations', 'com_vikappointments')) |
| 161 | { |
| 162 | ?> |
| 163 | <div class="appointments-stat overview-row overview-row-container"> |
| 164 | |
| 165 | <div class="pending-orders row-child"> |
| 166 | |
| 167 | <div class="row-main pending-count"> |
| 168 | <strong><?php echo JText::plural('VAP_N_RESERVATIONS', $pending); ?></strong> |
| 169 | <small><?php _e('awaiting confirmation', 'vikappointments'); ?></small> |
| 170 | </div> |
| 171 | |
| 172 | </div> |
| 173 | |
| 174 | <div class="needpay-orders row-child"> |
| 175 | |
| 176 | <div class="row-main needpay-count"> |
| 177 | <strong><?php echo JText::plural('VAP_N_RESERVATIONS', $needpay); ?></strong> |
| 178 | <small><?php _e('requiring payment', 'vikappointments'); ?></small> |
| 179 | </div> |
| 180 | |
| 181 | </div> |
| 182 | |
| 183 | </div> |
| 184 | <?php |
| 185 | } |
| 186 | ?> |
| 187 | |
| 188 | <div class="weekly-chart overview-row"> |
| 189 | <?php |
| 190 | // display widget |
| 191 | echo $chart->display([ |
| 192 | 'data' => $chart->getData(), |
| 193 | ]); |
| 194 | ?> |
| 195 | </div> |
| 196 | |
| 197 | </div> |
| 198 |