* @copyright 2007-2014 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 $default_sort_column = null; private $default_sort_direction = null; private $empty_message = null; private $paging_message = null; public function __construct() { $this->name = 'statsbestproducts'; $this->tab = 'analytics_stats'; $this->version = '1.4.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->default_sort_column = 'totalPriceSold'; $this->default_sort_direction = 'DESC'; $this->empty_message = $this->l('An empty record-set was returned.'); $this->paging_message = sprintf($this->l('Displaying %1$s of %2$s'), '{0} - {1}', '{2}'); $this->columns = array( array( 'id' => 'reference', 'header' => $this->l('Reference'), 'dataIndex' => 'reference', 'align' => 'left' ), array( 'id' => 'name', 'header' => $this->l('Name'), 'dataIndex' => 'name', 'align' => 'left' ), array( 'id' => 'totalQuantitySold', 'header' => $this->l('Quantity sold'), 'dataIndex' => 'totalQuantitySold', 'align' => 'center' ), array( 'id' => 'avgPriceSold', 'header' => $this->l('Price sold'), 'dataIndex' => 'avgPriceSold', 'align' => 'right' ), array( 'id' => 'totalPriceSold', 'header' => $this->l('Sales'), 'dataIndex' => 'totalPriceSold', 'align' => 'right' ), array( 'id' => 'averageQuantitySold', 'header' => $this->l('Quantity sold in a day'), 'dataIndex' => 'averageQuantitySold', 'align' => 'center' ), array( 'id' => 'totalPageViewed', 'header' => $this->l('Page views'), 'dataIndex' => 'totalPageViewed', 'align' => 'center' ), array( 'id' => 'quantity', 'header' => $this->l('Available quantity for sale'), 'dataIndex' => 'quantity', 'align' => 'center' ), array( 'id' => 'active', 'header' => $this->l('Active'), 'dataIndex' => 'active', 'align' => 'center' ) ); $this->displayName = $this->l('Best-selling products'); $this->description = $this->l('Adds a list of the best-selling products to the Stats dashboard.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } public function install() { return (parent::install() && $this->registerHook('AdminStatsModules')); } public function hookAdminStatsModules($params) { $engine_params = array( 'id' => 'id_product', 'title' => $this->displayName, 'columns' => $this->columns, 'defaultSortColumn' => $this->default_sort_column, 'defaultSortDirection' => $this->default_sort_direction, 'emptyMessage' => $this->empty_message, 'pagingMessage' => $this->paging_message ); if (Tools::getValue('export')) $this->csvExport($engine_params); return '