File manager - Edit - /home/verseaumee/ptitsanes/plugins/solidres/statistics/statistics.php
Back
<?php /*------------------------------------------------------------------------ Solidres - Hotel booking extension for Joomla ------------------------------------------------------------------------ @Author Solidres Team @Website http://www.solidres.com @Copyright Copyright (C) 2013 - 2020 Solidres. All Rights Reserved. @License GNU General Public License version 3, or later ------------------------------------------------------------------------*/ defined('_JEXEC') or die; /** * Solidres Statistics * * @package Solidres * @subpackage Statistics * @since 0.5.0 */ use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\MVC\View\HtmlView; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory as CMSFactory; class plgSolidresStatistics extends SRPlugin { protected static $plgVersion = '1.5.0'; protected $addIncludePath = false; public static function framework($plugins = array()) { static $loaded = false; if (!$loaded) { SRHtml::_('jquery.ui'); HTMLHelper::_('stylesheet', 'plg_solidres_statistics/assets/statistics.min.css', array('version' => self::getHashVersion(), 'relative' => true)); HTMLHelper::_('stylesheet', 'plg_solidres_statistics/assets/jquery.jqplot.min.css', array('relative' => true)); HTMLHelper::_('stylesheet', 'plg_solidres_statistics/assets/jvectormaps/jquery-jvectormap-2.0.3.css', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/statistics.min.js', array('version' => self::getHashVersion(), 'relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/jquery.scrollTo-min.js', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/jquery.ui.touch-punch.min.js', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/statistics/jquery.jqplot.min.js', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/jvectormaps/jquery-jvectormap-2.0.3.min.js', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/jvectormaps/jquery-jvectormap-randata.js', array('relative' => true)); HTMLHelper::_('script', 'plg_solidres_statistics/assets/jvectormaps/jquery-jvectormap-world-mill.js', array('relative' => true)); $loaded = true; } if (!empty($plugins)) { foreach ($plugins as $plugin) { HTMLHelper::_('script', 'plg_solidres_statistics/assets/statistics/jqplot.' . $plugin . '.min.js', array('relative' => true)); } } } public function onReservationAfterSave($data, $table, $isNew, $model) { $config = ComponentHelper::getParams('com_solidres'); if (!$config->get('enable_geocoding', 1)) { return; } $db = CMSFactory::getDbo(); $query = $db->getQuery(true) ->select('a.customer_city, a2.name AS customer_country_name') ->from($db->quoteName('#__sr_reservations', 'a')) ->innerJoin($db->quoteName('#__sr_countries', 'a2') . ' ON a2.id = a.customer_country_id') ->where('a.id = ' . (int) $table->id); $db->setQuery($query); if (!($row = $db->loadObject())) { return; } $mapAPI = 'https://maps.googleapis.com/maps/api/geocode/json?key=' . $config->get('google_map_api_key', '') . '&address='; $location = trim($row->customer_country_name); if (!empty($row->customer_city)) { $location = trim($row->customer_city) . ',' . $location; } if ($json = file_get_contents($mapAPI . urlencode($location))) { $table->set('customer_coordinates', $json); $table->store(); } } public function onSolidresPluginRegister() { parent::onSolidresPluginRegister(); SRControllerLegacy::addIncludePath($this->_getAdminPath()); } public function onSolidresWidgetsRegister(&$widgets = []) { $widgets = array_merge( [ 'total.reservations' => 'SR_STATISTICS_TOTAL_RESERVATION', 'total.rooms' => 'SR_STATISTICS_TOTAL_ROOMS', 'lifetimes' => 'SR_STATISTICS_LIFE_TIME_SALES', 'total.assets' => 'SR_STATISTICS_TOTAL_RESERVATION_ASSETS', 'total.roomtypes' => 'SR_STATISTICS_TOTAL_ROOM_TYPES', 'total.customers' => 'SR_STATISTICS_TOTAL_CUSTOMERS', 'assets' => 'SR_STATISTICS_ASSETS_DROPDOWN', 'dashboard' => 'SR_STATISTICS_DASHBOARD_TITLE', 'maps' => 'SR_STATISTICS_MAPS', 'latestBookings' => 'SR_STATISTICS_LATEST_BOOKINGS', 'upcomingCheckin' => 'SR_STATISTICS_UPCOMING_CHECKIN', 'upcomingCheckout' => 'SR_STATISTICS_UPCOMING_CHECKOUT', //'revpar' => Text::_('SR_STATISTICS_REVPAR'), 'origins' => 'SR_STATISTICS_ORIGINS', ], $widgets ); } public function onSolidresWidgetPrepare(stdClass $widget, HtmlView $statisticsView) { $widgets = []; $this->onSolidresWidgetsRegister($widgets); if (!isset($widgets[$widget->id])) { return; } $statisticsModel = $statisticsView->getModel(); $colors = $statisticsModel->getStateColors(); $baseLinks = $statisticsModel->getBaseLinks(); $displayData = [ 'view' => $statisticsView, 'colors' => $colors, 'baseLinks' => $baseLinks, 'dateFormat' => ComponentHelper::getParams('com_solidres')->get('date_format', 'd-m-Y'), ]; switch ($widget->id) { case 'total.reservations': $widget->title = Text::_('SR_STATISTICS_TOTAL_RESERVATION'); $widget->content = $statisticsModel->getTotalReservations() ?: Text::_('SR_STATISTICS_NO_DATA_FOUND'); $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-calendar'; break; case 'total.rooms': $widget->title = Text::_('SR_STATISTICS_TOTAL_ROOMS'); $widget->content = $statisticsModel->getTotalRooms() ?: Text::_('SR_STATISTICS_NO_DATA_FOUND'); $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-key'; break; case 'total.assets': $widget->title = Text::_('SR_STATISTICS_TOTAL_RESERVATION_ASSETS'); $widget->content = count($statisticsModel->getReservationAssets()) ?: Text::_('SR_STATISTICS_NO_DATA_FOUND'); $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-building'; break; case 'total.roomtypes': $widget->title = Text::_('SR_STATISTICS_TOTAL_ROOM_TYPES'); $widget->content = $statisticsModel->getTotalRoomTypes() ?: Text::_('SR_STATISTICS_NO_DATA_FOUND'); $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-object-group'; break; case 'total.customers': $widget->title = Text::_('SR_STATISTICS_TOTAL_CUSTOMERS'); $widget->content = $statisticsModel->getTotalCustomers() ?: Text::_('SR_STATISTICS_NO_DATA_FOUND'); $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-bar-chart'; break; case 'lifetimes': if ($lifeTimeSale = $statisticsModel->getLifeTimeSale()) { $currency = new SRCurrency($lifeTimeSale, $statisticsView->get('currencyId')); $lifeTimeSale = $currency->format(); } else { $lifeTimeSale = Text::_('SR_STATISTICS_NO_DATA_FOUND'); } $widget->title = Text::_('SR_STATISTICS_LIFE_TIME_SALES'); $widget->content = $lifeTimeSale; $widget->layoutId = 'widgets.card'; $widget->icon = 'fa fa-users'; break; case 'assets': $widget->title = Text::_('SR_STATISTICS_TOTAL_CUSTOMERS'); $widget->content = SRLayoutHelper::render('widgets.content.assets', $displayData); $widget->layoutId = 'widgets.blank'; break; case 'dashboard': $widget->title = Text::_('SR_STATISTICS_DASHBOARD_TITLE'); $widget->content = SRLayoutHelper::render('widgets.content.dashboard', $displayData); $widget->layoutId = 'widgets.blank'; break; case 'maps': $widget->title = Text::_('SR_STATISTICS_MAPS'); $widget->content = SRLayoutHelper::render('widgets.content.maps', $displayData); $widget->layoutId = 'widgets.blank'; break; case 'latestBookings': case 'upcomingCheckin': case 'upcomingCheckout': $textMaps = [ 'latestBookings' => Text::_('SR_STATISTICS_LATEST_BOOKINGS'), 'upcomingCheckin' => Text::_('SR_STATISTICS_UPCOMING_CHECKIN'), 'upcomingCheckout' => Text::_('SR_STATISTICS_UPCOMING_CHECKOUT'), ]; $widget->title = $textMaps[$widget->id]; $widget->content = SRLayoutHelper::render('widgets.content.bookings', array_merge($displayData, [ 'bookings' => call_user_func_array([$statisticsModel, 'get' . $widget->id], [5]), ])); $widget->layoutId = 'widgets.box'; break; /*case 'revpar': $displayData['assetId'] = $statisticsModel->get('reservationAssetId', 0); $roomTypesModel = BaseDatabaseModel::getInstance('RoomTypes', 'SolidresModel', ['ignore_request' => true]); $roomTypesModel->setState('filter.state', 1); $roomTypesModel->setState('filter.reservation_asset_id', $displayData['assetId']); $roomTypesModel->setState('filter.partner_id', $statisticsModel->getState('filter.partner_id')); $roomTypesModel->setState('list.select', 'r.id, r.name'); $roomTypesModel->setState('list.start', 0); $roomTypesModel->setState('list.limit', 0); $displayData['roomTypes'] = $roomTypesModel->getItems(); $widget->title = Text::_('SR_STATISTICS_REVPAR'); $widget->content = SRLayoutHelper::render('widgets.content.revpar', $displayData); $widget->layoutId = 'widgets.box'; break;*/ case 'origins': $displayData['origins'] = $statisticsModel->getOriginsData(); $widget->title = Text::_('SR_STATISTICS_ORIGINS'); $widget->content = SRLayoutHelper::render('widgets.content.origins', $displayData); $widget->layoutId = 'widgets.box'; break; } } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings