name = 'statsregistrations';
$this->tab = 'Stats';
$this->version = 1.0;
parent::__construct();
$this->displayName = $this->l('Customer accounts');
$this->description = $this->l('Display the progress of customer registration');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
}
public function getTotalRegistrations()
{
$result = Db::getInstance()->getRow('
SELECT COUNT(`id_customer`) as total
FROM `'._DB_PREFIX_.'customer`
WHERE `date_add` BETWEEN '.ModuleGraph::getDateBetween());
return isset($result['total']) ? $result['total'] : 0;
}
public function getBlockedVisitors()
{
$result = Db::getInstance()->getRow('
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.php"
AND (g.id_customer IS NULL OR g.id_customer = 0)
AND c.`date_add` BETWEEN '.ModuleGraph::getDateBetween());
return $result['blocked'];
}
public function getFirstBuyers()
{
$result = Db::getInstance()->getRow('
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().' AND o.valid = 1
AND ABS(TIMEDIFF(o.date_add, c.date_add)+0) < 120000');
return $result['buyers'];
}
public function hookAdminStatsModules($params)
{
$totalRegistrations = $this->getTotalRegistrations();
$totalBlocked = $this->getBlockedVisitors();
$totalBuyers = $this->getFirstBuyers();
$this->_html = '
';
return $this->_html;
}
protected function getData($layers)
{
$this->_query = '
SELECT `date_add`
FROM `'._DB_PREFIX_.'customer`
WHERE `date_add` BETWEEN';
$this->_titles['main'] = $this->l('Number of customer accounts created');
$this->setDateGraph($layers, true);
}
protected function setYearValues($layers)
{
$result = Db::getInstance()->ExecuteS($this->_query.$this->getDate());
foreach ($result AS $row)
$this->_values[intval(substr($row['date_add'], 5, 2))]++;
}
protected function setMonthValues($layers)
{
$result = Db::getInstance()->ExecuteS($this->_query.$this->getDate());
foreach ($result AS $row)
$this->_values[intval(substr($row['date_add'], 8, 2))]++;
}
protected function setDayValues($layers)
{
$result = Db::getInstance()->ExecuteS($this->_query.$this->getDate());
foreach ($result AS $row)
$this->_values[intval(substr($row['date_add'], 11, 2))]++;
}
}
?>