* @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class StatsBestProducts extends ModuleGrid { private $_html = null; private $_query = null; private $_columns = null; private $_defaultSortColumn = null; private $_defaultSortDirection = null; private $_emptyMessage = null; private $_pagingMessage = null; public function __construct() { $this->name = 'statsbestproducts'; $this->tab = 'analytics_stats'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->_defaultSortColumn = 'totalPriceSold'; $this->_defaultSortDirection = 'DESC'; $this->_emptyMessage = $this->l('An empty record-set was returned.'); $this->_pagingMessage = sprintf($this->l('Displaying %1$s of %2$s'), '{0} - {1}', '{2}'); $this->_columns = array( array( 'id' => 'reference', 'header' => $this->l('Ref.'), 'dataIndex' => 'reference', 'align' => 'left', 'width' => 50 ), array( 'id' => 'name', 'header' => $this->l('Name'), 'dataIndex' => 'name', 'align' => 'left', 'width' => 100 ), array( 'id' => 'totalQuantitySold', 'header' => $this->l('Quantity sold'), 'dataIndex' => 'totalQuantitySold', 'width' => 50, 'align' => 'right' ), array( 'id' => 'avgPriceSold', 'header' => $this->l('Price sold'), 'dataIndex' => 'avgPriceSold', 'width' => 50, 'align' => 'right' ), array( 'id' => 'totalPriceSold', 'header' => $this->l('Sales'), 'dataIndex' => 'totalPriceSold', 'width' => 50, 'align' => 'right' ), array( 'id' => 'averageQuantitySold', 'header' => $this->l('Quantity sold in a day.'), 'dataIndex' => 'averageQuantitySold', 'width' => 60, 'align' => 'right' ), array( 'id' => 'totalPageViewed', 'header' => $this->l('Page views'), 'dataIndex' => 'totalPageViewed', 'width' => 60, 'align' => 'right' ), array( 'id' => 'quantity', 'header' => $this->l('Available quantity for sale.'), 'dataIndex' => 'quantity', 'width' => 150, 'align' => 'right' ) ); $this->displayName = $this->l('Best-selling products.'); $this->description = $this->l('A list of the best-selling products.'); } public function install() { return (parent::install() && $this->registerHook('AdminStatsModules')); } public function hookAdminStatsModules($params) { $engineParams = array( 'id' => 'id_product', 'title' => $this->displayName, 'columns' => $this->_columns, 'defaultSortColumn' => $this->_defaultSortColumn, 'defaultSortDirection' => $this->_defaultSortDirection, 'emptyMessage' => $this->_emptyMessage, 'pagingMessage' => $this->_pagingMessage ); if (Tools::getValue('export')) $this->csvExport($engineParams); $this->_html = '