* @copyright 2007-2012 PrestaShop SA * @version Release: $Revision: 7307 $ * @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 StatsRegistrations extends ModuleGraph { private $_html = ''; private $_query = ''; function __construct() { $this->name = 'statsregistrations'; $this->tab = 'analytics_stats'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Customer accounts'); $this->description = $this->l('Display the progress of customer registration.'); } /** * Called during module installation */ public function install() { return (parent::install() AND $this->registerHook('AdminStatsModules')); } /** * @return int Get total of registration in date range */ public function getTotalRegistrations() { $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` WHERE `date_add` BETWEEN '.ModuleGraph::getDateBetween().' '.Shop::addSqlRestriction(Shop::SHARE_ORDER); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return isset($result['total']) ? $result['total'] : 0; } /** * @return int Get total of blocked visitors during registration process */ public function getBlockedVisitors() { $sql = 'SELECT COUNT(DISTINCT c.`id_guest`) as blocked FROM `'._DB_PREFIX_.'page_type` pt LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page_type = pt.id_page_type LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON p.id_page = cp.id_page LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_connections = cp.id_connections LEFT JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest WHERE pt.name = "authentication" '.Shop::addSqlRestriction(false, 'c').' AND (g.id_customer IS NULL OR g.id_customer = 0) AND c.`date_add` BETWEEN '.ModuleGraph::getDateBetween(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return $result['blocked']; } public function getFirstBuyers() { $sql = 'SELECT COUNT(DISTINCT o.`id_customer`) as buyers FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'guest` g ON o.id_customer = g.id_customer LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_guest = g.id_guest WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().' '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND ABS(TIMEDIFF(o.date_add, c.date_add)+0) < 120000'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return $result['buyers']; } public function hookAdminStatsModules($params) { $totalRegistrations = $this->getTotalRegistrations(); $totalBlocked = $this->getBlockedVisitors(); $totalBuyers = $this->getFirstBuyers(); if (Tools::getValue('export')) $this->csvExport(array('layers' => 0, 'type' => 'line')); $this->_html = '
'.$this->l('The total number of accounts created is not in itself important information. However, it is beneficial to analyze the number created over time. This will indicate whether or not things are on the right track.').'
'.$this->l('If you let your shop run without changing anything, the number of customer registrations should stay stable or may slightly decline.').'
'.$this->l('A significant increase or decrease shows that there has probably been a change to your shop.Therefore, you have to identify it in order to backtrack if this change makes the number of registrations decrease, or continue with it if it increases registration.').'
'.$this->l('Here is summary of what may affect the creation of customer accounts:').'