2026-06-28 11:51:04 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package MokoSuiteCross
|
|
|
|
|
* @subpackage com_mokosuitecross
|
|
|
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
|
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Joomla\Component\MokoSuiteCross\Administrator\View\Analytics;
|
|
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
|
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
|
|
|
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
|
|
|
|
|
|
|
|
|
class HtmlView extends BaseHtmlView
|
|
|
|
|
{
|
2026-06-28 12:02:51 -05:00
|
|
|
public $heatmap;
|
|
|
|
|
public $bestTimes;
|
|
|
|
|
public $hourlyDistribution;
|
|
|
|
|
public $dayDistribution;
|
|
|
|
|
public $services;
|
|
|
|
|
public $serviceId;
|
|
|
|
|
public $period;
|
2026-06-28 11:51:04 -05:00
|
|
|
|
|
|
|
|
public function display($tpl = null): void
|
|
|
|
|
{
|
2026-06-28 12:02:51 -05:00
|
|
|
/** @var \Joomla\Component\MokoSuiteCross\Administrator\Model\AnalyticsModel $model */
|
|
|
|
|
$model = $this->getModel();
|
|
|
|
|
|
2026-06-28 11:51:04 -05:00
|
|
|
$input = Factory::getApplication()->input;
|
2026-06-28 12:02:51 -05:00
|
|
|
$this->period = $input->getInt('period', 90);
|
|
|
|
|
$this->serviceId = $input->getInt('service_id', 0);
|
|
|
|
|
|
|
|
|
|
$validPeriods = [7, 30, 90, 180, 365];
|
|
|
|
|
|
|
|
|
|
if (!\in_array($this->period, $validPeriods, true)) {
|
|
|
|
|
$this->period = 90;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sid = $this->serviceId > 0 ? $this->serviceId : null;
|
2026-06-28 11:51:04 -05:00
|
|
|
|
2026-06-28 12:02:51 -05:00
|
|
|
$this->heatmap = $model->getHeatmap($this->period, $sid);
|
|
|
|
|
$this->bestTimes = $model->getBestTimes($this->period, $sid);
|
|
|
|
|
$this->hourlyDistribution = $model->getHourlyDistribution($this->period, $sid);
|
|
|
|
|
$this->dayDistribution = $model->getDayOfWeekDistribution($this->period, $sid);
|
|
|
|
|
$this->services = $model->getServices();
|
2026-06-28 11:51:04 -05:00
|
|
|
|
|
|
|
|
$this->addToolbar();
|
|
|
|
|
|
|
|
|
|
MokoSuiteCrossHelper::addSubmenu('analytics');
|
|
|
|
|
|
|
|
|
|
parent::display($tpl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function addToolbar(): void
|
|
|
|
|
{
|
2026-06-28 12:02:51 -05:00
|
|
|
ToolbarHelper::title('MokoSuiteCross -- Analytics', 'chart');
|
2026-06-28 11:51:04 -05:00
|
|
|
}
|
|
|
|
|
}
|