* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ if (!defined('_PS_VERSION_')) { exit; } class statscarrier extends ModuleGraph { private $html = ''; private $option = ''; public function __construct() { $this->name = 'statscarrier'; $this->tab = 'analytics_stats'; $this->version = '2.0.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->trans('Carrier distribution', array(), 'Modules.Statscarrier.Admin'); $this->description = $this->trans('Enrich your stats, add a pie chart illustrating your carriers’ distribution.', array(), 'Modules.Statscarrier.Admin'); $this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_); } public function install() { return (parent::install() && $this->registerHook('displayAdminStatsModules')); } public function hookDisplayAdminStatsModules($params) { $sql = 'SELECT COUNT(o.`id_order`) as total FROM `'._DB_PREFIX_.'orders` o WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().' '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').' '.((int)Tools::getValue('id_order_state') ? 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)Tools::getValue('id_order_state') : ''); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $states = OrderState::getOrderStates($this->context->language->id); if (Tools::getValue('export')) { $this->csvExport(array('type' => 'pie', 'option' => Tools::getValue('id_order_state'))); } $this->html = '