* @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 StatsBestCustomers extends ModuleGrid { private $html; private $query; private $columns; private $default_sort_column; private $default_sort_direction; private $empty_message; private $paging_message; public function __construct() { $this->name = 'statsbestcustomers'; $this->tab = 'analytics_stats'; $this->version = '1.3'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->default_sort_column = 'totalMoneySpent'; $this->default_sort_direction = 'DESC'; $this->empty_message = $this->l('Empty recordset returned'); $this->paging_message = sprintf($this->l('Displaying %1$s of %2$s'), '{0} - {1}', '{2}'); $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $this->columns = array( array( 'id' => 'lastname', 'header' => $this->l('Last Name'), 'dataIndex' => 'lastname', 'align' => 'center' ), array( 'id' => 'firstname', 'header' => $this->l('First Name'), 'dataIndex' => 'firstname', 'align' => 'center' ), array( 'id' => 'email', 'header' => $this->l('Email'), 'dataIndex' => 'email', 'align' => 'center' ), array( 'id' => 'totalVisits', 'header' => $this->l('Visits'), 'dataIndex' => 'totalVisits', 'align' => 'center' ), array( 'id' => 'totalValidOrders', 'header' => $this->l('Valid orders'), 'dataIndex' => 'totalValidOrders', 'align' => 'center' ), array( 'id' => 'totalMoneySpent', 'header' => $this->l('Money spent').' ('.Tools::safeOutput($currency->iso_code).')', 'dataIndex' => 'totalMoneySpent', 'align' => 'center' ) ); $this->displayName = $this->l('Best customers'); $this->description = $this->l('Adds a list of the best customers 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_customer', '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); $this->html = '
'.$this->l('Keeping a client can be more profitable than gaining a new one. That is one of the many reasons it is necessary to cultivate customer loyalty.').'
'.$this->l('Word of mouth is also a means for getting new, satisfied clients. A dissatisfied customer can hurt your e-reputation and obstruct future sales goals.').'
'.$this->l('In order to achieve this goal, you can organize:').'