[*] BO #PSFV-94 : Added AdminStatsController && AdminStatsTabController && norm of statistic modules

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10004 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-11-09 15:48:15 +00:00
parent 42bfc372da
commit dc716baa05
28 changed files with 980 additions and 891 deletions
-238
View File
@@ -1,238 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7307 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
abstract class AdminStatsTab extends AdminPreferences
{
public function postProcess()
{
$this->context = Context::getContext();
if (Tools::isSubmit('submitDatePicker'))
{
if (!Validate::isDate($from = Tools::getValue('datepickerFrom')) OR !Validate::isDate($to = Tools::getValue('datepickerTo')))
$this->_errors[] = Tools::displayError('Date specified is invalid');
}
if (Tools::isSubmit('submitDateDay'))
{
$from = date('Y-m-d');
$to = date('Y-m-d');
}
if (Tools::isSubmit('submitDateDayPrev'))
{
$yesterday = time() - 60*60*24;
$from = date('Y-m-d', $yesterday);
$to = date('Y-m-d', $yesterday);
}
if (Tools::isSubmit('submitDateMonth'))
{
$from = date('Y-m-01');
$to = date('Y-m-t');
}
if (Tools::isSubmit('submitDateMonthPrev'))
{
$m = (date('m') == 1 ? 12 : date('m') - 1);
$y = ($m == 12 ? date('Y') - 1 : date('Y'));
$from = $y.'-'.$m.'-01';
$to = $y.'-'.$m.date('-t', mktime(12, 0, 0, $m, 15, $y));
}
if (Tools::isSubmit('submitDateYear'))
{
$from = date('Y-01-01');
$to = date('Y-12-31');
}
if (Tools::isSubmit('submitDateYearPrev'))
{
$from = (date('Y') - 1).date('-01-01');
$to = (date('Y') - 1).date('-12-31');
}
if (isset($from) AND isset($to) AND !sizeof($this->_errors))
{
$this->context->employee->stats_date_from = $from;
$this->context->employee->stats_date_to = $to;
$this->context->employee->update();
Tools::redirectAdmin($_SERVER['REQUEST_URI']);
}
if (Tools::getValue('submitSettings'))
{
if ($this->tabAccess['edit'] === '1')
{
self::$currentIndex .= '&module='.Tools::getValue('module');
Configuration::updateValue('PS_STATS_RENDER', Tools::getValue('PS_STATS_RENDER', Configuration::get('PS_STATS_RENDER')));
Configuration::updateValue('PS_STATS_GRID_RENDER', Tools::getValue('PS_STATS_GRID_RENDER', Configuration::get('PS_STATS_GRID_RENDER')));
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (sizeof($this->_errors))
AdminTab::displayErrors();
}
protected function displayEngines()
{
$graphEngine = Configuration::get('PS_STATS_RENDER');
$gridEngine = Configuration::get('PS_STATS_GRID_RENDER');
$arrayGraphEngines = ModuleGraphEngine::getGraphEngines();
$arrayGridEngines = ModuleGridEngine::getGridEngines();
echo '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<fieldset style="width: 200px;"><legend><img src="../img/admin/tab-preferences.gif" />'.$this->l('Settings', 'AdminStatsTab').'</legend>';
echo '<p><strong>'.$this->l('Graph engine', 'AdminStatsTab').' </strong><br />';
if (sizeof($arrayGraphEngines))
{
echo '<select name="PS_STATS_RENDER">';
foreach ($arrayGraphEngines as $k => $value)
echo '<option value="'.$k.'"'.($k == $graphEngine ? ' selected="selected"' : '').'>'.$value[0].'</option>';
echo '</select><p>';
}
else
echo $this->l('No graph engine module installed', 'AdminStatsTab');
echo '<p><strong>'.$this->l('Grid engine', 'AdminStatsTab').' </strong><br />';
if (sizeof($arrayGridEngines))
{
echo '<select name="PS_STATS_GRID_RENDER">';
foreach ($arrayGridEngines as $k => $value)
echo '<option value="'.$k.'"'.($k == $gridEngine ? ' selected="selected"' : '').'>'.$value[0].'</option>';
echo '</select></p>';
}
else
echo $this->l('No grid engine module installed', 'AdminStatsTab');
echo '<p><input type="submit" value="'.$this->l(' Save ', 'AdminStatsTab').'" name="submitSettings" class="button" /></p>
</fieldset>
</form><div class="clear space">&nbsp;</div>';
}
protected function getDate()
{
$year = isset($this->context->cookie->stats_year) ? $this->context->cookie->stats_year : date('Y');
$month = isset($this->context->cookie->stats_month) ? sprintf('%02d', $this->context->cookie->stats_month) : '%';
$day = isset($this->context->cookie->stats_day) ? sprintf('%02d', $this->context->cookie->stats_day) : '%';
return $year.'-'.$month.'-'.$day;
}
public function displayCalendar()
{
echo '<div id="calendar">
'.self::displayCalendarStatic(array(
'Calendar' => $this->l('Calendar', 'AdminStatsTab'), 'Day' => $this->l('Day', 'AdminStatsTab'),
'Month' => $this->l('Month', 'AdminStatsTab'), 'Year' => $this->l('Year', 'AdminStatsTab'),
'From' => $this->l('From:', 'AdminStatsTab'), 'To' => $this->l('To:', 'AdminStatsTab'), 'Save' => $this->l('Save', 'AdminStatsTab')
)).'
<div class="clear space">&nbsp;</div></div>';
}
public static function displayCalendarStatic($translations)
{
$context = Context::getContext();
includeDatepicker(array('datepickerFrom', 'datepickerTo'));
return '
<fieldset style="width: 200px; font-size:13px;"><legend><img src="../img/admin/date.png" /> '.$translations['Calendar'].'</legend>
<div>
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<input type="submit" name="submitDateDay" class="button" value="'.$translations['Day'].'">
<input type="submit" name="submitDateMonth" class="button" value="'.$translations['Month'].'">
<input type="submit" name="submitDateYear" class="button" value="'.$translations['Year'].'"><br />
<input type="submit" name="submitDateDayPrev" class="button" value="'.$translations['Day'].'-1" style="margin-top:2px">
<input type="submit" name="submitDateMonthPrev" class="button" value="'.$translations['Month'].'-1" style="margin-top:2px">
<input type="submit" name="submitDateYearPrev" class="button" value="'.$translations['Year'].'-1" style="margin-top:2px">
<p>'.(isset($translations['From']) ? $translations['From'] : 'From:').' <input type="text" name="datepickerFrom" id="datepickerFrom" value="'.Tools::getValue('datepickerFrom', $context->employee->stats_date_from).'"></p>
<p>'.(isset($translations['To']) ? $translations['To'] : 'To:').' <input type="text" name="datepickerTo" id="datepickerTo" value="'.Tools::getValue('datepickerTo', $context->employee->stats_date_to).'"></p>
<input type="submit" name="submitDatePicker" class="button" value="'.(isset($translations['Save']) ? $translations['Save'] : ' Save ').'" />
</form>
</div>
</fieldset>';
}
public function displaySearch()
{
return;
echo '
<fieldset style="margin-top:20px; width: 200px;"><legend><img src="../img/admin/binoculars.png" /> '.$this->l('Search', 'AdminStatsTab').'</legend>
<input type="text" /> <input type="button" class="button" value="'.$this->l('Go', 'AdminStatsTab').'" />
</fieldset>';
}
private function getModules()
{
$sql = 'SELECT h.`name` AS hook, m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` LIKE \'AdminStatsModules\'
AND m.`active` = 1
GROUP BY hm.id_module
ORDER BY hm.`position`';
return Db::getInstance()->executeS($sql);
}
public function displayMenu()
{
$modules = $this->getModules();
echo '<fieldset style="width: 200px"><legend><img src="../img/admin/navigation.png" /> '.$this->l('Navigation', 'AdminStatsTab').'</legend>';
if (sizeof($modules))
{
foreach ($modules AS $module)
if ($moduleInstance = Module::getInstanceByName($module['name']))
echo '<h4><img src="../modules/'.$module['name'].'/logo.gif" /><a href="'.self::$currentIndex.'&token='.Tools::getValue('token').'&module='.$module['name'].'">'.$moduleInstance->displayName.'</a></h4>';
}
else
echo $this->l('No module installed', 'AdminStatsTab');
echo '</fieldset><div class="clear space">&nbsp;</div>';
}
public function display()
{
echo '<div style="float:left">';
$this->displayCalendar();
$this->displayEngines();
$this->displayMenu();
$this->displaySearch();
echo '</div>
<div style="float:left; margin-left:20px;">';
if (!($moduleName = Tools::getValue('module')) AND $moduleInstance = Module::getInstanceByName('statsforecast') AND $moduleInstance->active)
$moduleName = 'statsforecast';
if ($moduleName)
{
// Needed for the graphics display when this is the default module
$_GET['module'] = $moduleName;
if (!isset($moduleInstance))
$moduleInstance = Module::getInstanceByName($moduleName);
if ($moduleInstance AND $moduleInstance->active)
echo Hook::exec('AdminStatsModules', NULL, $moduleInstance->id);
else
echo $this->l('Module not found', 'AdminStatsTab');
}
else
echo '<h3 class="space">'.$this->l('Please select a module in the left column.').'</h3>';
echo '</div><div class="clear"></div>';
}
}
+3 -3
View File
@@ -1143,7 +1143,7 @@ class AdminControllerCore extends Controller
$img = _MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.png';
// retrocompatibility
if(!file_exists($img))
if (!file_exists($img))
$img = str_replace('png', 'gif', $img);
// tab[class_name] does not contains the "Controller" suffix
@@ -1561,7 +1561,7 @@ class AdminControllerCore extends Controller
unset($parse_query['setShopContext']);
Tools::redirectAdmin($url['path'].'?'.http_build_query($parse_query));
}
elseif (!Shop::isFeatureActive())
else if (!Shop::isFeatureActive())
$this->context->cookie->shopContext = 's-1';
$shop_id = '';
@@ -2423,7 +2423,7 @@ EOF;
<div id="languages_'.$id.'" class="language_flags">
'.$this->l('Choose language:').'<br /><br />';
foreach ($languages as $language)
if($use_vars_instead_of_ids)
if ($use_vars_instead_of_ids)
$output .= '<img src="../img/l/'.(int)($language['id_lang']).'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'" onclick="changeLanguage(\''.$id.'\', '.$ids.', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
else
$output .= '<img src="../img/l/'.(int)($language['id_lang']).'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'" onclick="changeLanguage(\''.$id.'\', \''.$ids.'\', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
+16 -15
View File
@@ -27,13 +27,13 @@
abstract class ModuleGraphEngineCore extends Module
{
protected $_type;
protected $_type;
public function __construct($type)
{
$this->_type = $type;
}
public function install()
{
if (!parent::install())
@@ -44,24 +44,25 @@ abstract class ModuleGraphEngineCore extends Module
public static function getGraphEngines()
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'GraphEngine\'');
$arrayEngines = array();
foreach ($result AS $module)
{
SELECT m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'displayAdminStatsGraphEngine\'
');
$array_engines = array();
foreach ($result as $module)
{
$instance = Module::getInstanceByName($module['name']);
if (!$instance)
continue;
$arrayEngines[$module['name']] = array($instance->displayName, $instance->description);
$array_engines[$module['name']] = array($instance->displayName, $instance->description);
}
return $arrayEngines;
return $array_engines;
}
abstract public function createValues($values);
abstract public function setSize($width, $height);
abstract public function setLegend($legend);
+18 -16
View File
@@ -27,40 +27,42 @@
abstract class ModuleGridEngineCore extends Module
{
protected $_type;
protected $_type;
public function __construct($type)
{
$this->_type = $type;
}
public function install()
{
if (!parent::install())
return false;
return Configuration::updateValue('PS_STATS_GRID_RENDER', $this->name);
}
public static function getGridEngines()
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'GridEngine\'');
$arrayEngines = array();
foreach ($result AS $module)
{
SELECT m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'displayAdminStatsGridEngine\'
');
$array_engines = array();
foreach ($result as $module)
{
$instance = Module::getInstanceByName($module['name']);
if (!$instance)
continue;
$arrayEngines[$module['name']] = array($instance->displayName, $instance->description);
}
return $arrayEngines;
$array_engines[$module['name']] = array($instance->displayName, $instance->description);
}
return $array_engines;
}
abstract public function setValues($values);
abstract public function setTitle($title);
abstract public function setSize($width, $height);
@@ -25,11 +25,6 @@
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/AdminStatsTab.php');
class AdminStats extends AdminStatsTab
class AdminStatsControllerCore extends AdminStatsTabControllerCore
{
}
}
@@ -0,0 +1,232 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7307 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCore
{
public function init()
{
parent::init();
$this->action = 'view';
$this->display = 'view';
}
public function initContent()
{
if ($this->display == 'view')
{
// Some controllers use the view action without an object
if ($this->className)
$this->loadObject(true);
$this->content .= $this->initView();
}
$this->content .= $this->displayCalendar();
$this->content .= $this->displayEngines();
$this->content .= $this->displayMenu();
$this->content .= $this->displayStats();
$this->context->smarty->assign(array(
'content' => $this->content,
'url_post' => self::$currentIndex.'&token='.$this->token,
));
}
public function displayCalendar()
{
return $this->displayCalendarForm(array(
'Calendar' => $this->l('Calendar', 'AdminStatsTab'),
'Day' => $this->l('Day', 'AdminStatsTab'),
'Month' => $this->l('Month', 'AdminStatsTab'),
'Year' => $this->l('Year', 'AdminStatsTab'),
'From' => $this->l('From:', 'AdminStatsTab'),
'To' => $this->l('To:', 'AdminStatsTab'),
'Save' => $this->l('Save', 'AdminStatsTab')
));
}
public function displayCalendarForm($translations)
{
$tpl = $this->context->smarty->createTemplate('stats/calendar.tpl');
$tpl->assign(array(
'current' => self::$currentIndex,
'token' => $this->token,
'translations' => $translations,
'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from),
'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to)
));
return $tpl->fetch();
}
protected function displayEngines()
{
$tpl = $this->context->smarty->createTemplate('stats/engines.tpl');
$tpl->assign(array(
'current' => self::$currentIndex,
'token' => $this->token,
'graph_engine' => Configuration::get('PS_STATS_RENDER'),
'grid_engine' => Configuration::get('PS_STATS_GRID_RENDER'),
'array_graph_engines' => ModuleGraphEngine::getGraphEngines(),
'array_grid_engines' => ModuleGridEngine::getGridEngines()
));
return $tpl->fetch();
}
public function displayMenu()
{
$tpl = $this->context->smarty->createTemplate('stats/menu.tpl');
$modules = $this->getModules();
$module_instance = array();
foreach ($modules as $module)
$module_instance[$module['name']] = Module::getInstanceByName($module['name']);
$tpl->assign(array(
'current' => self::$currentIndex,
'token' => $this->token,
'modules' => $modules,
'module_instance' => $module_instance
));
return $tpl->fetch();
}
private function getModules()
{
$sql = 'SELECT h.`name` AS hook, m.`name`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` LIKE \'displayAdminStatsModules\'
AND m.`active` = 1
GROUP BY hm.id_module
ORDER BY hm.`position`';
return Db::getInstance()->executeS($sql);
}
public function displayStats()
{
$tpl = $this->context->smarty->createTemplate('stats/stats.tpl');
if (!($module_name = Tools::getValue('module')) && $module_instance = Module::getInstanceByName('statsforecast') AND $module_instance->active)
$module_name = 'statsforecast';
if ($module_name)
{
$_GET['module'] = $module_name;
if (!isset($module_instance))
$module_instance = Module::getInstanceByName($module_name);
if ($module_instance && $module_instance->active)
$hook = Hook::exec('AdminStatsModules', NULL, $module_instance->id);
}
$tpl->assign(array(
'module_name' => $module_name,
'module_instance' => $module_instance,
'hook' => $hook
));
return $tpl->fetch();
}
public function postProcess()
{
$this->context = Context::getContext();
if (Tools::isSubmit('submitDatePicker'))
{
if (!Validate::isDate($from = Tools::getValue('datepickerFrom')) || !Validate::isDate($to = Tools::getValue('datepickerTo')))
$this->_errors[] = Tools::displayError('Date specified is invalid');
}
if (Tools::isSubmit('submitDateDay'))
{
$from = date('Y-m-d');
$to = date('Y-m-d');
}
if (Tools::isSubmit('submitDateDayPrev'))
{
$yesterday = time() - 60 * 60 * 24;
$from = date('Y-m-d', $yesterday);
$to = date('Y-m-d', $yesterday);
}
if (Tools::isSubmit('submitDateMonth'))
{
$from = date('Y-m-01');
$to = date('Y-m-t');
}
if (Tools::isSubmit('submitDateMonthPrev'))
{
$m = (date('m') == 1 ? 12 : date('m') - 1);
$y = ($m == 12 ? date('Y') - 1 : date('Y'));
$from = $y.'-'.$m.'-01';
$to = $y.'-'.$m.date('-t', mktime(12, 0, 0, $m, 15, $y));
}
if (Tools::isSubmit('submitDateYear'))
{
$from = date('Y-01-01');
$to = date('Y-12-31');
}
if (Tools::isSubmit('submitDateYearPrev'))
{
$from = (date('Y') - 1).date('-01-01');
$to = (date('Y') - 1).date('-12-31');
}
if (isset($from) && isset($to) && !count($this->_errors))
{
$this->context->employee->stats_date_from = $from;
$this->context->employee->stats_date_to = $to;
$this->context->employee->update();
Tools::redirectAdmin($_SERVER['REQUEST_URI']);
}
if (Tools::getValue('submitSettings'))
{
if ($this->tabAccess['edit'] === '1')
{
self::$currentIndex .= '&module='.Tools::getValue('module');
Configuration::updateValue('PS_STATS_RENDER', Tools::getValue('PS_STATS_RENDER', Configuration::get('PS_STATS_RENDER')));
Configuration::updateValue('PS_STATS_GRID_RENDER', Tools::getValue('PS_STATS_GRID_RENDER', Configuration::get('PS_STATS_GRID_RENDER')));
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (count($this->_errors))
AdminTab::displayErrors();
}
protected function getDate()
{
$year = isset($this->context->cookie->stats_year) ? $this->context->cookie->stats_year : date('Y');
$month = isset($this->context->cookie->stats_month) ? sprintf('%02d', $this->context->cookie->stats_month) : '%';
$day = isset($this->context->cookie->stats_day) ? sprintf('%02d', $this->context->cookie->stats_day) : '%';
return $year.'-'.$month.'-'.$day;
}
}
+60 -50
View File
@@ -30,43 +30,43 @@ if (!defined('_PS_VERSION_'))
class Pagesnotfound extends Module
{
private $_html = '';
private $_html = '';
function __construct()
{
$this->name = 'pagesnotfound';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'pagesnotfound';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Pages not found');
$this->description = $this->l('Display the pages requested by your visitors but not found.');
}
parent::__construct();
function install()
$this->displayName = $this->l('Pages not found');
$this->description = $this->l('Display the pages requested by your visitors but not found.');
}
public function install()
{
if (!parent::install() OR !$this->registerHook('top') OR !$this->registerHook('AdminStatsModules'))
if (!parent::install() || !$this->registerHook('top') || !$this->registerHook('AdminStatsModules'))
return false;
return Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'pagenotfound` (
id_pagenotfound INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
id_group_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
request_uri VARCHAR(256) NOT NULL,
http_referer VARCHAR(256) NOT NULL,
date_add DATETIME NOT NULL,
PRIMARY KEY(id_pagenotfound),
INDEX (`date_add`)
id_pagenotfound INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
id_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
id_group_shop INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
request_uri VARCHAR(256) NOT NULL,
http_referer VARCHAR(256) NOT NULL,
date_add DATETIME NOT NULL,
PRIMARY KEY(id_pagenotfound),
INDEX (`date_add`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;');
}
function uninstall()
{
return (parent::uninstall() AND Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'pagenotfound`'));
}
public function uninstall()
{
return (parent::uninstall() && Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'pagenotfound`'));
}
private function getPages()
{
@@ -81,7 +81,7 @@ class Pagesnotfound extends Module
foreach ($result as $row)
{
$row['http_referer'] = parse_url($row['http_referer'], PHP_URL_HOST).parse_url($row['http_referer'], PHP_URL_PATH);
if (!isset($row['http_referer']) OR empty($row['http_referer']))
if (!isset($row['http_referer']) || empty($row['http_referer']))
$row['http_referer'] = '--';
if (!isset($pages[$row['request_uri']]))
$pages[$row['request_uri']] = array('nb' => 0);
@@ -92,14 +92,14 @@ class Pagesnotfound extends Module
return $pages;
}
function hookAdminStatsModules()
{
public function hookAdminStatsModules()
{
if (Tools::isSubmit('submitTruncatePNF'))
{
Db::getInstance()->execute('TRUNCATE `'._DB_PREFIX_.'pagenotfound`');
$this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" /> '.$this->l('Pages not found has been emptied.').'</div>';
}
elseif (Tools::isSubmit('submitDeletePNF'))
else if (Tools::isSubmit('submitDeletePNF'))
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'pagenotfound`
@@ -107,12 +107,12 @@ class Pagesnotfound extends Module
$this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" /> '.$this->l('Pages not found have been deleted.').'</div>';
}
$this->_html .= '<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
$this->_html .= '<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
if (!file_exists(dirname(__FILE__).'/../../.htaccess'))
$this->_html .= '<div class="warning warn">'.$this->l('You <b>must</b> use a .htaccess file to redirect 404 errors to the page "404.php"').'</div>';
$pages = $this->getPages();
if (sizeof($pages))
if (count($pages))
{
$this->_html .= '
<table class="table" cellpadding="0" cellspacing="0">
@@ -137,42 +137,52 @@ class Pagesnotfound extends Module
$this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" /> '.$this->l('No pages registered').'</div>';
$this->_html .= '</fieldset>';
if (sizeof($pages))
if (count($pages))
$this->_html .= '<div class="clear">&nbsp;</div>
<fieldset class="width3"><legend><img src="../img/admin/delete.gif" /> '.$this->l('Empty database').'</legend>
<fieldset><legend><img src="../img/admin/delete.gif" /> '.$this->l('Empty database').'</legend>
<form action="'.Tools::htmlEntitiesUtf8($_SERVER['REQUEST_URI']).'" method="post">
<input type="submit" class="button" name="submitDeletePNF" value="'.$this->l('Empty ALL pages not found in this period').'">
<input type="submit" class="button" name="submitTruncatePNF" value="'.$this->l('Empty ALL pages not found').'">
</form>
</fieldset>';
$this->_html .= '<div class="clear">&nbsp;</div>
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
$this->_html .= '<br />
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('404 errors').'</h2>
<p>'.$this->l('A 404 error is an HTTP error code which means that the file requested by the user cannot be found. In your case it means that one of your visitors entered a wrong URL in the address bar or that you or another website has a dead link. When it is available, the referrer is shown so you can find the page which contains the dead link. If not, it means generally that it is a direct access, so someone may have bookmarked a link which doesn\'t exist anymore.').'</p>
<p>'.$this->l('A 404 error is an HTTP error code which means that the file requested by the user cannot be found.
In your case it means that one of your visitors entered a wrong URL in the address bar or that you or another website has a dead link.
When it is available, the referrer is shown so you can find the page which contains the dead link.
If not, it means generally that it is a direct access, so someone may have bookmarked a link which doesn\'t exist anymore.').'</p>
<h3>'.$this->l('How to catch these errors?').'</h3>
<p>'.$this->l('If your webhost supports the <i>.htaccess</i> file, you can create it in the root directory of PrestaShop and insert the following line inside:').' <i>ErrorDocument 404 '.__PS_BASE_URI__.'404.php</i>. '.$this->l('A user requesting a page which doesn\'t exist will be redirected to the page.').' <i>'.__PS_BASE_URI__.'404.php</i>. '.$this->l('This module logs the accesses to this page: the page requested, the referrer and the number of times that it occurred.').'</p><br />
<p>'.$this->l('If your webhost supports the <i>.htaccess</i> file, you can create it in the root directory of PrestaShop and insert the following line inside:').'
<i>ErrorDocument 404 '.__PS_BASE_URI__.'404.php</i>. '.
$this->l('A user requesting a page which doesn\'t exist will be redirected to the page.').' <i>'.__PS_BASE_URI__.'404.php</i>. '.
$this->l('This module logs the accesses to this page: the page requested, the referrer and the number of times that it occurred.').'</p><br />
</fieldset>';
return $this->_html;
}
return $this->_html;
}
function hookTop($params)
public function hookTop($params)
{
if (strstr($_SERVER['REQUEST_URI'], '404.php') AND isset($_SERVER['REDIRECT_URL']))
if (strstr($_SERVER['REQUEST_URI'], '404.php') && isset($_SERVER['REDIRECT_URL']))
$_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_URL'];
if (!Validate::isUrl($request_uri = $_SERVER['REQUEST_URI']) OR strstr($_SERVER['REQUEST_URI'], '-admin404'))
if (!Validate::isUrl($request_uri = $_SERVER['REQUEST_URI']) || strstr($_SERVER['REQUEST_URI'], '-admin404'))
return;
if (strstr($_SERVER['PHP_SELF'], '404.php') AND !strstr($_SERVER['REQUEST_URI'], '404.php'))
if (strstr($_SERVER['PHP_SELF'], '404.php') && !strstr($_SERVER['REQUEST_URI'], '404.php'))
{
$http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if (empty($http_referer) OR Validate::isAbsoluteUrl($http_referer))
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_group_shop`) VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.$this->context->shop->getID().', '.$this->context->shop->getGroupID().')');
if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer))
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_group_shop`)
VALUES (\''.pSQL($request_uri).'\', \''.pSQL($http_referer).'\', NOW(), '.$this->context->shop->getID().', '.$this->context->shop->getGroupID().')
');
}
}
}
function pnfSort($a, $b) {
if ($a['nb'] == $b['nb'])
return 0;
return ($a['nb'] > $b['nb']) ? -1 : 1;
function pnfSort($a, $b)
{
if ($a['nb'] == $b['nb'])
return 0;
return ($a['nb'] > $b['nb']) ? -1 : 1;
}
+32 -28
View File
@@ -30,19 +30,19 @@ if (!defined('_PS_VERSION_'))
class SEKeywords extends ModuleGraph
{
private $_html = '';
private $html = '';
private $_query = '';
private $_query2 = '';
public function __construct()
{
$this->name = 'sekeywords';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'sekeywords';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->_query = 'SELECT `keyword`, COUNT(TRIM(`keyword`)) as occurences
FROM `'._DB_PREFIX_.'sekeyword`
@@ -54,13 +54,13 @@ class SEKeywords extends ModuleGraph
HAVING occurences > '.(int)Configuration::get('SEK_MIN_OCCURENCES').'
ORDER BY occurences DESC';
$this->displayName = $this->l('Search engine keywords');
$this->description = $this->l('Display which keywords have led visitors to your website.');
}
$this->displayName = $this->l('Search engine keywords');
$this->description = $this->l('Display which keywords have led visitors to your website.');
}
public function install()
{
if (!parent::install() OR !$this->registerHook('top') OR !$this->registerHook('AdminStatsModules'))
if (!parent::install() || !$this->registerHook('top') || !$this->registerHook('AdminStatsModules'))
return false;
Configuration::updateValue('SEK_MIN_OCCURENCES', 1);
Configuration::updateValue('SEK_FILTER_KW', '');
@@ -75,16 +75,16 @@ class SEKeywords extends ModuleGraph
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
}
public function uninstall()
{
if (!parent::uninstall())
public function uninstall()
{
if (!parent::uninstall())
return false;
return (Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'sekeyword`'));
}
}
public function hookTop($params)
{
if (!isset($_SERVER['HTTP_REFERER']) OR strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false)))
if (!isset($_SERVER['HTTP_REFERER']) || strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false)))
return;
if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER']))
@@ -105,9 +105,9 @@ class SEKeywords extends ModuleGraph
$this->csvExport(array('type' => 'pie'));
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.ModuleGraph::getDateBetween().$this->_query2);
$total = count($result);
$this->_html = '<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
$this->html = '<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$total.' '.($total == 1 ? $this->l('keyword matches your query.') : $this->l('keywords match your query.')).'<div class="clear">&nbsp;</div>';
if ($result AND $total)
if ($result && $total)
{
$table = '
<div style="overflow-y: scroll; height: 600px;">
@@ -123,27 +123,31 @@ class SEKeywords extends ModuleGraph
$table .= '<tr><td>'.$keyword.'</td><td style="text-align: right">'.$occurences.'</td></tr>';
}
$table .= '</tbody></table></div>';
$this->_html .= '<center>'.$this->engine(array('type' => 'pie')).'</center>
$this->html .= '<div>'.$this->engine(array('type' => 'pie')).'</div>
<br class="clear" />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br class="clear" />
<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post">
'.$this->l('Filter by keyword').' <input type="text" name="SEK_FILTER_KW" value="'.Tools::htmlentitiesUTF8(Configuration::get('SEK_FILTER_KW')).'" />
'.$this->l('and min occurrences').' <input type="text" name="SEK_MIN_OCCURENCES" value="'.(int)(Configuration::get('SEK_MIN_OCCURENCES')).'" />
'.$this->l('and min occurrences').' <input type="text" name="SEK_MIN_OCCURENCES" value="'.(int)Configuration::get('SEK_MIN_OCCURENCES').'" />
<input type="submit" class="button" name="submitSEK" value="'.$this->l(' Apply ').'" />
</form>
<br class="clear" />'.$table;
}
else
$this->_html .= '<p><strong>'.$this->l('No keywords').'</strong></p>';
$this->html .= '<p><strong>'.$this->l('No keywords').'</strong></p>';
$this->_html .= '</fieldset><br class="clear" />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
$this->html .= '</fieldset><br class="clear" />
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Identify external search engines\' keywords').'</h2>
<p>'.$this->l('One of the most common ways of finding a website through a search engine. Identifying the most popular keywords entered by your new visitors allows you to see which products you should put in front if you want to attract more visitors and potential customers.').'</p><br />
<p>'.$this->l('One of the most common ways of finding a website through a search engine.
Identifying the most popular keywords entered by your new visitors allows you to see which products you should put in front if you want to attract more visitors and potential customers.').'
</p><br />
<h3>'.$this->l('How does it work?').'</h2>
<p>'.$this->l('When a visitor comes to your website, the server notes their previous location. This module parses the URL and finds the keywords in it. Currently, it manages the following search engines:').'<b> Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila</b> '.$this->l('and').' <b>Altavista</b>. '.$this->l('Soon it will be possible to dynamically add new search engines and contribute to this module.').'</p><br />
<p>'.$this->l('When a visitor comes to your website, the server notes their previous location. This module parses the URL and finds the keywords in it.
Currently, it manages the following search engines:').'<b> Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila</b> '.$this->l('and').' <b>Altavista</b>. '.
$this->l('Soon it will be possible to dynamically add new search engines and contribute to this module.').'</p><br />
</fieldset>';
return $this->_html;
return $this->html;
}
public function getKeywords($url)
@@ -166,9 +170,9 @@ class SEKeywords extends ModuleGraph
{
$kArray = array();
preg_match('/[^a-z]'.$varname.'=.+\&'.'/U', $parsedUrl['query'], $kArray);
if (!isset($kArray[0]) OR empty($kArray[0]))
if (!isset($kArray[0]) || empty($kArray[0]))
preg_match('/[^a-z]'.$varname.'=.+$'.'/', $parsedUrl['query'], $kArray);
if (!isset($kArray[0]) OR empty($kArray[0]))
if (!isset($kArray[0]) || empty($kArray[0]))
return false;
$kString = urldecode(str_replace('+', ' ', ltrim(substr(rtrim($kArray[0], '&'), strlen($varname) + 1), '=')));
return $kString;
@@ -38,7 +38,7 @@ class StatsBestCategories extends ModuleGrid
private $_emptyMessage;
private $_pagingMessage;
function __construct()
public function __construct()
{
$this->name = 'statsbestcategories';
$this->tab = 'analytics_stats';
@@ -90,7 +90,7 @@ class StatsBestCategories extends ModuleGrid
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -104,12 +104,12 @@ class StatsBestCategories extends ModuleGrid
'emptyMessage' => $this->_emptyMessage,
'pagingMessage' => $this->_pagingMessage
);
if (Tools::getValue('export'))
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<br /><a href="'.htmlentities($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a>
</fieldset>';
@@ -120,7 +120,7 @@ class StatsBestCategories extends ModuleGrid
{
$dateBetween = $this->getDate();
$id_lang = $this->getLang();
// If a shop is selected, get all children categories for the shop
$categories = array();
if ($this->context->shop->getContextType() != Shop::CONTEXT_ALL)
@@ -136,7 +136,7 @@ class StatsBestCategories extends ModuleGrid
{
$ntreeRestriction = array();
foreach ($result as $row)
$ntreeRestriction[] = '(nleft >= ' . $row['nleft'] . ' AND nright <= ' . $row['nright'] . ')';
$ntreeRestriction[] = '(nleft >= '.$row['nleft'].' AND nright <= '.$row['nright'].')';
if ($ntreeRestriction)
{
@@ -194,10 +194,10 @@ class StatsBestCategories extends ModuleGrid
if (Validate::IsName($this->_sort))
{
$this->_query .= ' ORDER BY `'.$this->_sort.'`';
if (isset($this->_direction) AND Validate::IsSortDirection($this->_direction))
if (isset($this->_direction) && Validate::IsSortDirection($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
@@ -38,7 +38,7 @@ class StatsBestCustomers extends ModuleGrid
private $_emptyMessage;
private $_pagingMessage;
function __construct()
public function __construct()
{
$this->name = 'statsbestcustomers';
$this->tab = 'analytics_stats';
@@ -92,7 +92,7 @@ class StatsBestCustomers extends ModuleGrid
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -109,19 +109,21 @@ class StatsBestCustomers extends ModuleGrid
if (Tools::getValue('export'))
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<p><a href="'.htmlentities($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2 >'.$this->l('Develop clients\' loyalty').'</h2>
<p class="space">
'.$this->l('Keeping a client is more profitable than gaining a new one. Thus, it is necessary to develop their loyalty, in other words to make them want to come back to your webshop.').' <br />
'.$this->l('Word of mouth is also a means to of getting new, satisfied clients; a dissatisfied one won\'t attract new clients.').'<br />
'.$this->l('In order to achieve this goal you can organize: ').'
<ul>
<li>'.$this->l('Punctual operations: commercial rewards (personalized special offers, product or service offered), non commercial rewards (priority handling of an order or a product), pecuniary rewards (bonds, discount coupons, payback).').'</li>
<li>'.$this->l('Sustainable operations: loyalty points or cards, which not only justify communication between merchant and client, but also offer advantages to clients (private offers, discounts).').'</li>
<li>'.$this->l('Punctual operations: commercial rewards (personalized special offers, product or service offered),
non commercial rewards (priority handling of an order or a product), pecuniary rewards (bonds, discount coupons, payback).').'</li>
<li>'.$this->l('Sustainable operations: loyalty points or cards, which not only justify communication between merchant and client,
but also offer advantages to clients (private offers, discounts).').'</li>
</ul>
'.$this->l('These operations encourage clients to buy products and visit your webshop regularly.').' <br />
</p><br />
@@ -130,7 +132,7 @@ class StatsBestCustomers extends ModuleGrid
}
public function getData()
{
{
$this->_query = '
SELECT SQL_CALC_FOUND_ROWS c.`id_customer`, c.`lastname`, c.`firstname`, c.`email`,
COUNT(co.`id_connections`) as totalVisits,
@@ -151,10 +153,10 @@ class StatsBestCustomers extends ModuleGrid
if (Validate::IsName($this->_sort))
{
$this->_query .= ' ORDER BY `'.$this->_sort.'`';
if (isset($this->_direction) AND Validate::IsSortDirection($this->_direction))
if (isset($this->_direction) && Validate::IsSortDirection($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
@@ -31,26 +31,26 @@ if (!defined('_PS_VERSION_'))
class StatsBestManufacturers extends ModuleGrid
{
private $_html = null;
private $_query = null;
private $_query = null;
private $_columns = null;
private $_defaultSortColumn = null;
private $_defaultSortDirection = null;
private $_emptyMessage = null;
private $_pagingMessage = null;
function __construct()
public function __construct()
{
$this->name = 'statsbestmanufacturers';
$this->tab = 'analytics_stats';
$this->version = '1.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->_defaultSortColumn = 'sales';
$this->_defaultSortDirection = 'DESC';
$this->_emptyMessage = $this->l('Empty recordset returned');
$this->_pagingMessage = $this->l('Displaying').' {0} - {1} '.$this->l('of').' {2}';
$this->_columns = array(
array(
'id' => 'name',
@@ -74,18 +74,18 @@ class StatsBestManufacturers extends ModuleGrid
'align' => 'right'
)
);
parent::__construct();
$this->displayName = $this->l('Best manufacturers');
$this->description = $this->l('A list of the best manufacturers');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
{
$engineParams = array(
@@ -97,18 +97,18 @@ class StatsBestManufacturers extends ModuleGrid
'emptyMessage' => $this->_emptyMessage,
'pagingMessage' => $this->_pagingMessage
);
if (Tools::getValue('export'))
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<br /><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a>
</fieldset>';
return $this->_html;
}
public function getTotalCount()
{
$sql = 'SELECT COUNT(DISTINCT(m.id_manufacturer))
@@ -122,9 +122,9 @@ class StatsBestManufacturers extends ModuleGrid
AND m.id_manufacturer IS NOT NULL';
return Db::getInstance()->getValue($sql);
}
public function getData()
{
{
$this->_totalCount = $this->getTotalCount();
$this->_query = 'SELECT m.name, SUM(od.product_quantity) as quantity, ROUND(SUM(od.product_quantity * od.product_price) / c.conversion_rate, 2) as sales
@@ -141,10 +141,10 @@ class StatsBestManufacturers extends ModuleGrid
if (Validate::IsName($this->_sort))
{
$this->_query .= ' ORDER BY `'.$this->_sort.'`';
if (isset($this->_direction) AND Validate::IsSortDirection($this->_direction))
if (isset($this->_direction) && Validate::IsSortDirection($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance()->executeS($this->_query);
}
+14 -14
View File
@@ -37,20 +37,20 @@ class StatsBestProducts extends ModuleGrid
private $_defaultSortDirection = null;
private $_emptyMessage = null;
private $_pagingMessage = null;
function __construct()
public function __construct()
{
$this->name = 'statsbestproducts';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->_defaultSortColumn = 'totalPriceSold';
$this->_defaultSortDirection = 'DESC';
$this->_emptyMessage = $this->l('Empty recordset returned');
$this->_pagingMessage = $this->l('Displaying').' {0} - {1} '.$this->l('of').' {2}';
$this->_columns = array(
array(
'id' => 'reference',
@@ -109,18 +109,18 @@ class StatsBestProducts extends ModuleGrid
'align' => 'right'
)
);
parent::__construct();
$this->displayName = $this->l('Best products');
$this->description = $this->l('A list of the best products');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
{
$engineParams = array(
@@ -135,15 +135,15 @@ class StatsBestProducts extends ModuleGrid
if (Tools::getValue('export'))
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<p><a href="'.htmlentities($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset>';
return $this->_html;
}
public function getData()
{
$dateBetween = $this->getDate();
@@ -176,11 +176,11 @@ class StatsBestProducts extends ModuleGrid
if (Validate::IsName($this->_sort))
{
$this->_query .= ' ORDER BY `'.$this->_sort.'`';
if (isset($this->_direction) AND Validate::IsSortDirection($this->_direction))
if (isset($this->_direction) && Validate::IsSortDirection($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
@@ -31,14 +31,14 @@ if (!defined('_PS_VERSION_'))
class StatsBestSuppliers extends ModuleGrid
{
private $_html = null;
private $_query = null;
private $_query = null;
private $_columns = null;
private $_defaultSortColumn = null;
private $_defaultSortDirection = null;
private $_emptyMessage = null;
private $_pagingMessage = null;
function __construct()
public function __construct()
{
$this->name = 'statsbestsuppliers';
$this->tab = 'analytics_stats';
@@ -80,10 +80,10 @@ class StatsBestSuppliers extends ModuleGrid
$this->displayName = $this->l('Best suppliers');
$this->description = $this->l('A list of the best suppliers');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -101,7 +101,7 @@ class StatsBestSuppliers extends ModuleGrid
if (Tools::getValue('export') == 1)
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset>';
@@ -126,7 +126,7 @@ class StatsBestSuppliers extends ModuleGrid
}
public function getData()
{
{
$this->_totalCount = $this->getTotalCount();
$this->_query = 'SELECT s.name, SUM(od.product_quantity) as quantity, ROUND(SUM(od.product_quantity * od.product_price) / o.conversion_rate, 2) as sales
@@ -142,11 +142,11 @@ class StatsBestSuppliers extends ModuleGrid
if (Validate::IsName($this->_sort))
{
$this->_query .= ' ORDER BY `'.$this->_sort.'`';
if (isset($this->_direction) AND Validate::IsSortDirection($this->_direction))
if (isset($this->_direction) && Validate::IsSortDirection($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
}
@@ -38,7 +38,7 @@ class StatsBestVouchers extends ModuleGrid
private $_emptyMessage;
private $_pagingMessage;
function __construct()
public function __construct()
{
$this->name = 'statsbestvouchers';
$this->tab = 'analytics_stats';
@@ -83,7 +83,7 @@ class StatsBestVouchers extends ModuleGrid
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -97,12 +97,12 @@ class StatsBestVouchers extends ModuleGrid
'emptyMessage' => $this->_emptyMessage,
'pagingMessage' => $this->_pagingMessage
);
if (Tools::getValue('export'))
$this->csvExport($engineParams);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
'.$this->engine($engineParams).'
<br /><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a>
</fieldset>';
@@ -110,7 +110,7 @@ class StatsBestVouchers extends ModuleGrid
}
public function getData()
{
{
$this->_query = 'SELECT SQL_CALC_FOUND_ROWS ocr.code, COUNT(ocr.id_cart_rule) as total, SUM(o.total_paid_real) / o.conversion_rate as ca
FROM '._DB_PREFIX_.'order_cart_rule ocr
LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = ocr.id_order
@@ -124,7 +124,7 @@ class StatsBestVouchers extends ModuleGrid
if (isset($this->_direction))
$this->_query .= ' '.$this->_direction;
}
if (($this->_start === 0 OR Validate::IsUnsignedInt($this->_start)) AND Validate::IsUnsignedInt($this->_limit))
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
+26 -22
View File
@@ -30,28 +30,28 @@ if (!defined('_PS_VERSION_'))
class StatsCarrier extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
function __construct()
{
$this->name = 'statscarrier';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statscarrier';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Carrier distribution');
$this->description = $this->l('Display the carriers distribution');
}
$this->displayName = $this->l('Carrier distribution');
$this->description = $this->l('Display the carriers distribution');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -60,38 +60,42 @@ class StatsCarrier extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.((int)(Tools::getValue('id_order_state')) ? 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)(Tools::getValue('id_order_state')) : '');
'.((int)Tools::getValue('id_order_state') ? 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)Tools::getValue('id_order_state') : '');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
$states = OrderState::getOrderStates($this->context->language->id);
if (Tools::getValue('export'))
$this->csvExport(array('type' => 'pie', 'option' => Tools::getValue('id_order_state')));
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" style="float: right;">
<select name="id_order_state">
<option value="0"'.((!Tools::getValue('id_order_state')) ? ' selected="selected"' : '').'>'.$this->l('All').'</option>';
foreach ($states AS $state)
foreach ($states as $state)
$this->_html .= '<option value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == Tools::getValue('id_order_state')) ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
$this->_html .= '</select>
<input type="submit" name="submitState" value="'.$this->l('Filter').'" class="button" />
</form>
<p><img src="../img/admin/down.gif" />'.$this->l('This graph represents the carrier distribution for your orders. You can also limit it to orders in one state.').'</p>
'.($result['total'] ? $this->engine(array('type' => 'pie', 'option' => Tools::getValue('id_order_state'))).'<br /><br /> <a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a>' : $this->l('No valid orders for this period.')).'
'.($result['total'] ? $this->engine(array('type' => 'pie', 'option' => Tools::getValue('id_order_state'))).'<br /><br /> <a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a>' : $this->l('No valid orders for this period.')).'
</fieldset>';
return $this->_html;
}
public function setOption($option, $layers = 1)
{
$this->_option = (int)($option);
$this->_option = (int)$option;
}
protected function getData($layers)
{
$stateQuery = '';
if ((int)($this->_option))
$stateQuery = 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)($this->_option);
if ((int)$this->_option)
$stateQuery = 'AND (
SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh
WHERE o.id_order = oh.id_order
ORDER BY oh.date_add DESC, oh.id_order_history DESC
LIMIT 1) = '.(int)$this->_option;
$this->_titles['main'] = $this->l('Percentage of orders by carrier');
$sql = 'SELECT c.name, COUNT(DISTINCT o.`id_order`) as total
@@ -104,8 +108,8 @@ class StatsCarrier extends ModuleGraph
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
}
}
}
+33 -31
View File
@@ -33,23 +33,23 @@ class StatsCatalog extends Module
private $_join = '';
private $_where = '';
function __construct()
{
$this->name = 'statscatalog';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statscatalog';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Catalog statistics');
$this->description = $this->l('General statistics about your catalog.');
}
parent::__construct();
$this->displayName = $this->l('Catalog statistics');
$this->description = $this->l('General statistics about your catalog.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function getQuery1()
@@ -119,14 +119,15 @@ class StatsCatalog extends Module
$precalc2 = array();
foreach ($precalc as $array)
$precalc2[] = (int)($array['id_product']);
$precalc2[] = (int)$array['id_product'];
$sql = 'SELECT p.id_product, pl.name, pl.link_rewrite
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
'.$this->_join.'
WHERE p.`active` = 1
'.(sizeof($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').'
'.(count($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').'
'.$this->_where;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return array('total' => Db::getInstance(_PS_USE_SQL_SLAVE_)->NumRows(), 'result' => $result);
@@ -134,11 +135,10 @@ class StatsCatalog extends Module
public function hookAdminStatsModules($params)
{
$categories = Category::getCategories($this->context->language->id, true, false);
$productToken = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id);
$irow = 0;
if ($id_category = (int)(Tools::getValue('id_category')))
{
$this->_join = ' LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)';
@@ -169,7 +169,7 @@ class StatsCatalog extends Module
$html = '
<script type="text/javascript" language="javascript">$(\'#calendar\').slideToggle();</script>
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<label>
'.$this->l('Choose a category').'
</label>
@@ -178,23 +178,25 @@ class StatsCatalog extends Module
<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
<option value="0">'.$this->l('All').'</option>';
foreach ($categories as $category)
$html .= '<option value="'.$category['id_category'].'"'.($id_category == $category['id_category'] ? ' selected="selected"' : '').'>'.$category['name'].'</option>';
$html .= '<option value="'.$category['id_category'].'"'.($id_category == $category['id_category'] ? ' selected="selected"' : '').'>'.
$category['name'].'
</option>';
$html .= '
</select>
</form>
</div>
<div class="clear space"></div>
<table>
'.$this->returnLine($this->l('Products available:'), (int)($total)).'
'.$this->returnLine($this->l('Products available:'), (int)$total).'
'.$this->returnLine($this->l('Average price (base price):'), Tools::displayPrice($averagePrice, $this->context->currency)).'
'.$this->returnLine($this->l('Product pages viewed:'), (int)($totalPageViewed)).'
'.$this->returnLine($this->l('Products bought:'), (int)($totalBought)).'
'.$this->returnLine($this->l('Average number of page visits:'), number_format((float)($averageViewed), 2, '.', '')).'
'.$this->returnLine($this->l('Average number of purchases:'), number_format((float)($averagePurchase), 2, '.', '')).'
'.$this->returnLine($this->l('Images available:'), (int)($totalPictures)).'
'.$this->returnLine($this->l('Average number of images:'), number_format((float)($averagePictures), 2, '.', '')).'
'.$this->returnLine($this->l('Products never viewed:'), (int)($totalNV).' / '.(int)($total)).'
'.$this->returnLine('<a style="cursor : pointer" onclick="$(\'#pnb\').slideToggle();">'.$this->l('Products never purchased:').'</a>', (int)($totalNB).' / '.(int)($total)).'
'.$this->returnLine($this->l('Product pages viewed:'), (int)$totalPageViewed).'
'.$this->returnLine($this->l('Products bought:'), (int)$totalBought).'
'.$this->returnLine($this->l('Average number of page visits:'), number_format((float)$averageViewed, 2, '.', '')).'
'.$this->returnLine($this->l('Average number of purchases:'), number_format((float)$averagePurchase, 2, '.', '')).'
'.$this->returnLine($this->l('Images available:'), (int)$totalPictures).'
'.$this->returnLine($this->l('Average number of images:'), number_format((float)$averagePictures, 2, '.', '')).'
'.$this->returnLine($this->l('Products never viewed:'), (int)$totalNV.' / '.(int)$total).'
'.$this->returnLine('<a style="cursor : pointer" onclick="$(\'#pnb\').slideToggle();">'.$this->l('Products never purchased:').'</a>', (int)$totalNB.' / '.(int)$total).'
'.$this->returnLine($this->l('Conversion rate*:'), $conversion).'
</table>
<div style="margin-top: 20px;">
@@ -203,10 +205,10 @@ class StatsCatalog extends Module
</div>
</fieldset>';
if (sizeof($productsNB) AND sizeof($productsNB) < 50)
if (count($productsNB) && count($productsNB) < 50)
{
$html .= '
<fieldset class="width3 space"><legend><img src="../modules/'.$this->name.'/basket_delete.png" /> '.$this->l('Products never purchased').'</legend>
$html .= '<br />
<fieldset><legend><img src="../modules/'.$this->name.'/basket_delete.png" /> '.$this->l('Products never purchased').'</legend>
<table cellpadding="0" cellspacing="0" class="table">
<tr><th>'.$this->l('ID').'</th><th>'.$this->l('Name').'</th><th>'.$this->l('Edit / View').'</th></tr>';
foreach ($productsNB as $product)
+83 -49
View File
@@ -30,33 +30,55 @@ if (!defined('_PS_VERSION_'))
class StatsCheckUp extends Module
{
function __construct()
{
$this->name = 'statscheckup';
$this->tab = 'analytics_stats';
$this->version = 1.0;
private $html = '';
public function __construct()
{
$this->name = 'statscheckup';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Catalog evaluation');
$this->description = $this->l('Quick evaluation of your catalog quality.');
}
$this->displayName = $this->l('Catalog evaluation');
$this->description = $this->l('Quick evaluation of your catalog quality.');
}
public function install()
{
foreach (array('CHECKUP_DESCRIPTIONS_LT'=>100,'CHECKUP_DESCRIPTIONS_GT'=>400,'CHECKUP_IMAGES_LT'=>1,'CHECKUP_IMAGES_GT'=>2,'CHECKUP_SALES_LT'=>1,'CHECKUP_SALES_GT'=>2,'CHECKUP_STOCK_LT'=>1,'CHECKUP_STOCK_GT'=>3) as $confname => $confdefault)
$confs = array(
'CHECKUP_DESCRIPTIONS_LT'=>100,
'CHECKUP_DESCRIPTIONS_GT'=>400,
'CHECKUP_IMAGES_LT'=>1,
'CHECKUP_IMAGES_GT'=>2,
'CHECKUP_SALES_LT'=>1,
'CHECKUP_SALES_GT'=>2,
'CHECKUP_STOCK_LT'=>1,
'CHECKUP_STOCK_GT'=>3
);
foreach ($confs as $confname => $confdefault)
if (!Configuration::get($confname))
Configuration::updateValue($confname, (int)$confdefault);
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
function hookAdminStatsModules()
{
public function hookAdminStatsModules()
{
if (Tools::isSubmit('submitCheckup'))
{
foreach (array('CHECKUP_DESCRIPTIONS_LT','CHECKUP_DESCRIPTIONS_GT','CHECKUP_IMAGES_LT','CHECKUP_IMAGES_GT','CHECKUP_SALES_LT','CHECKUP_SALES_GT','CHECKUP_STOCK_LT','CHECKUP_STOCK_GT') as $confname)
$confs = array(
'CHECKUP_DESCRIPTIONS_LT',
'CHECKUP_DESCRIPTIONS_GT',
'CHECKUP_IMAGES_LT',
'CHECKUP_IMAGES_GT',
'CHECKUP_SALES_LT',
'CHECKUP_SALES_GT',
'CHECKUP_STOCK_LT',
'CHECKUP_STOCK_GT'
);
foreach ($confs as $confname)
Configuration::updateValue($confname, (int)Tools::getValue($confname));
echo '<div class="conf confirm"><img src="../img/admin/ok.gif"> '.$this->l('Configuration updated').'</div>';
}
@@ -100,7 +122,7 @@ class StatsCheckUp extends Module
$orderBy = 'p.id_product';
if ($this->context->cookie->checkup_order == 2)
$orderBy = 'pl.name';
elseif ($this->context->cookie->checkup_order == 3)
else if ($this->context->cookie->checkup_order == 3)
$orderBy = 'nbSales DESC';
// Get products stats
@@ -122,7 +144,8 @@ class StatsCheckUp extends Module
WHERE pa.id_product = p.id_product
), p.quantity) as stock
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
'.$this->context->shop->addSqlAssociation('product', 'p').'
ORDER BY '.$orderBy;
$result = $db->executeS($sql);
@@ -137,29 +160,38 @@ class StatsCheckUp extends Module
'STOCK' => array('name' => $this->l('Stock'), 'text' => $this->l('items'))
);
$html = '
$this->html = '
<style type="text/css">
form.checkup input[type=text] {width:30px}
table.checkup {float:left}
form.checkup div {float:left;margin-left:20px}
form.checkup div {margin-top:20px}
table.checkup th {text-align:center}
table.checkup td {padding:5px 10px}
table.checkup2 td {text-align:right}
</style>
<form action="'.AdminTab::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'" method="post" class="checkup">
<table class="table checkup" border="0" cellspacing="0" cellspacing="0">
<tr><th></th><th>'.$arrayColors[0].' '.$this->l('Not enough').'</th><th>'.$arrayColors[2].' '.$this->l('Alright').'</th></tr>';
foreach ($arrayConf as $conf => $translations)
$html .= '<tr>
<th>'.$translations['name'].'</th>
<td>'.$this->l('lower than').' <input type="text" name="CHECKUP_'.$conf.'_LT" value="'.Tools::safeOutput(Tools::getValue('CHECKUP_'.$conf.'_LT', Configuration::get('CHECKUP_'.$conf.'_LT'))).'" /> '.$translations['text'].'
<td>'.$this->l('greater than').' <input type="text" name="CHECKUP_'.$conf.'_GT" value="'.Tools::safeOutput(Tools::getValue('CHECKUP_'.$conf.'_GT', Configuration::get('CHECKUP_'.$conf.'_GT'))).'" /> '.$translations['text'].'
</tr>';
$html .= '</table>
<form action="'.AdminController::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'" method="post" class="checkup">
<table class="table checkup" border="0" cellspacing="0" cellspacing="0">
<tr>
<th></th>
<th>'.$arrayColors[0].' '.$this->l('Not enough').'</th>
<th>'.$arrayColors[2].' '.$this->l('Alright').'</th>
</tr>';
foreach ($arrayConf as $conf => $translations)
$this->html .= '<tr>
<th>'.$translations['name'].'</th>
<td>'.$this->l('lower than').'
<input type="text" name="CHECKUP_'.$conf.'_LT"
value="'.Tools::safeOutput(Tools::getValue('CHECKUP_'.$conf.'_LT', Configuration::get('CHECKUP_'.$conf.'_LT'))).'" /> '.$translations['text'].'
</td>
<td>'.$this->l('greater than').'
<input type="text" name="CHECKUP_'.$conf.'_GT"
value="'.Tools::safeOutput(Tools::getValue('CHECKUP_'.$conf.'_GT', Configuration::get('CHECKUP_'.$conf.'_GT'))).'" /> '.$translations['text'].'
</td>
</tr>';
$this->html .= '</table>
<div><input type="submit" name="submitCheckup" class="button" value="'.$this->l(' Save ').'" /></div>
</form>
<div class="clear">&nbsp;</div>
<form action="'.AdminTab::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'" method="post">
<br />
<form action="'.AdminController::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'" method="post">
'.$this->l('Order by').'
<select name="submitCheckupOrder" onchange="this.form.submit();" style="width:100px">
<option value="1">'.$this->l('ID').'</option>
@@ -167,15 +199,15 @@ class StatsCheckUp extends Module
<option value="3" '.($this->context->cookie->checkup_order == 3 ? 'selected="selected"' : '').'>'.$this->l('Sales').'</option>
</select>
</form>
<div class="clear">&nbsp;</div>
<br />
<table class="table checkup2" border="0" cellspacing="0" cellspacing="0">
<tr>
<th>'.$this->l('ID').'</th>
<th>'.$this->l('Item').'</th>
<th>'.$this->l('Active').'</th>';
foreach ($languages as $language)
$html .= '<th>'.$this->l('Desc.').' ('.strtoupper($language['iso_code']).')</th>';
$html .= '
$this->html .= '<th>'.$this->l('Desc.').' ('.strtoupper($language['iso_code']).')</th>';
$this->html .= '
<th>'.$this->l('Images').'</th>
<th>'.$this->l('Sales').'</th>
<th>'.$this->l('Stock').'</th>
@@ -194,7 +226,12 @@ class StatsCheckUp extends Module
$totals['images'] += (int)$scores['images'];
$totals['sales'] += (int)$scores['sales'];
$totals['stock'] += (int)$scores['stock'];
$descriptions = $db->executeS('SELECT l.iso_code, pl.description FROM '._DB_PREFIX_.'product_lang pl LEFT JOIN '._DB_PREFIX_.'lang l ON pl.id_lang = l.id_lang WHERE id_product = '.(int)$row['id_product'].$this->context->shop->addSqlRestrictionOnLang('pl'));
$descriptions = $db->executeS('
SELECT l.iso_code, pl.description
FROM '._DB_PREFIX_.'product_lang pl
LEFT JOIN '._DB_PREFIX_.'lang l
ON pl.id_lang = l.id_lang
WHERE id_product = '.(int)$row['id_product'].$this->context->shop->addSqlRestrictionOnLang('pl'));
foreach ($descriptions as $description)
{
$row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description']));
@@ -204,16 +241,16 @@ class StatsCheckUp extends Module
$scores['average'] = array_sum($scores) / $divisor;
$scores['average'] = ($scores['average'] < 1 ? 0 : ($scores['average'] > 1.5 ? 2 : 1));
$html .= '<tr>
$this->html .= '<tr>
<td>'.$row['id_product'].'</td>
<td style="text-align:left"><a href="index.php?tab=AdminCatalog&updateproduct&id_product='.$row['id_product'].'&token='.$tokenProducts.'">'.Tools::substr($row['name'], 0, 42).'</a></td>
<td>'.$arrayColors[$scores['active']].'</td>';
foreach ($languages as $language)
if (isset($row['desclength_'.$language['iso_code']]))
$html .= '<td>'.(int)$row['desclength_'.$language['iso_code']].' '.$arrayColors[$scores['description_'.$language['iso_code']]].'</td>';
$this->html .= '<td>'.(int)$row['desclength_'.$language['iso_code']].' '.$arrayColors[$scores['description_'.$language['iso_code']]].'</td>';
else
$html .= '<td>0 '.$arrayColors[0].'</td>';
$html .= '
$this->html .= '<td>0 '.$arrayColors[0].'</td>';
$this->html .= '
<td>'.(int)$row['nbImages'].' '.$arrayColors[$scores['images']].'</td>
<td>'.(int)$row['nbSales'].' '.$arrayColors[$scores['sales']].'</td>
<td>'.(int)$row['stock'].' '.$arrayColors[$scores['stock']].'</td>
@@ -237,13 +274,13 @@ class StatsCheckUp extends Module
$totals['average'] = array_sum($totals) / $divisor;
$totals['average'] = ($totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1));
$html .= '
$this->html .= '
<tr>
<th colspan="2"></th>
<th>'.$this->l('Active').'</th>';
foreach ($languages as $language)
$html .= '<th>'.$this->l('Desc.').' ('.strtoupper($language['iso_code']).')</th>';
$html .= '
$this->html .= '<th>'.$this->l('Desc.').' ('.strtoupper($language['iso_code']).')</th>';
$this->html .= '
<th>'.$this->l('Images').'</th>
<th>'.$this->l('Sales').'</th>
<th>'.$this->l('Stock').'</th>
@@ -253,19 +290,16 @@ class StatsCheckUp extends Module
<td colspan="2"></td>
<td>'.$arrayColors[$totals['active']].'</td>';
foreach ($languages as $language)
$html .= '<td>'.$arrayColors[$totals['description_'.$language['iso_code']]].'</td>';
$html .= '
$this->html .= '<td>'.$arrayColors[$totals['description_'.$language['iso_code']]].'</td>';
$this->html .= '
<td>'.$arrayColors[$totals['images']].'</td>
<td>'.$arrayColors[$totals['sales']].'</td>
<td>'.$arrayColors[$totals['stock']].'</td>
<td>'.$arrayColors[$totals['average']].'</td>
</tr>
</table>
<div class="clear">&nbsp;</div>
<script type="text/javascript">
$(document).ready(function(){$("#container").css("width", "1200px");});
</script>';
<div class="clear">&nbsp;</div>';
return $html;
}
return $this->html;
}
}
+67 -50
View File
@@ -30,29 +30,29 @@ if (!defined('_PS_VERSION_'))
class StatsEquipment extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $_query2 = '';
private $html = '';
private $_query = '';
private $_query2 = '';
function __construct()
{
$this->name = 'statsequipment';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statsequipment';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Software');
$this->description = $this->l('Display the software used by your visitors.');
$this->displayName = $this->l('Software');
$this->description = $this->l('Display the software used by your visitors.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
/**
* @return array Get list of browser "plugins" (javascript, media player, etc.)
*/
@@ -64,8 +64,23 @@ class StatsEquipment extends ModuleGraph
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(false, 'c');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, false);
$calcArray = array('jsOK' => 0, 'jsKO' => 0, 'javaOK' => 0, 'javaKO' => 0, 'wmpOK' => 0, 'wmpKO' => 0, 'qtOK' => 0, 'qtKO' => 0, 'realOK' => 0, 'realKO' => 0, 'flashOK' => 0, 'flashKO' => 0, 'directorOK' => 0, 'directorKO' => 0);
$calcArray = array(
'jsOK' => 0,
'jsKO' => 0,
'javaOK' => 0,
'javaKO' => 0,
'wmpOK' => 0,
'wmpKO' => 0,
'qtOK' => 0,
'qtKO' => 0,
'realOK' => 0,
'realKO' => 0,
'flashOK' => 0,
'flashKO' => 0,
'directorOK' => 0,
'directorKO' => 0
);
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
{
if (!$row['javascript'])
@@ -81,10 +96,10 @@ class StatsEquipment extends ModuleGraph
($row['sun_java']) ? ++$calcArray['javaOK'] : ++$calcArray['javaKO'];
($row['apple_quicktime']) ? ++$calcArray['qtOK'] : ++$calcArray['qtKO'];
}
if (!$calcArray['jsOK'])
return false;
$equip = array(
'Windows Media Player' => $calcArray['wmpOK'] / ($calcArray['wmpOK'] + $calcArray['wmpKO']),
'Real Player' => $calcArray['realOK'] / ($calcArray['realOK'] + $calcArray['realKO']),
@@ -96,50 +111,52 @@ class StatsEquipment extends ModuleGraph
arsort($equip);
return $equip;
}
public function hookAdminStatsModules($params)
{
if (Tools::getValue('export'))
if (Tools::getValue('exportType') == 'browser')
$this->csvExport(array('type' => 'pie', 'option' => 'wb'));
elseif (Tools::getValue('exportType') == 'os')
else if (Tools::getValue('exportType') == 'os')
$this->csvExport(array('type' => 'pie', 'option' => 'os'));
$equipment = $this->getEquipment();
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<center>
<p><img src="../img/admin/down.gif" />'.$this->l('Determine the percentage of web browsers used by your customers.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'wb')).'<br /><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=browser"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
<p><img src="../img/admin/down.gif" />'.$this->l('Determine the percentage of operating systems used by your customers.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'os')).'
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=os"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>';
if ($equipment)
{
$this->_html .= '<table class="table space" border="0" cellspacing="0" cellpadding="0">
<tr><th style="width: 200px">'.$this->l('Plug-ins').'</th><th></th></tr>';
foreach ($equipment as $name => $value)
$this->_html .= '<tr><td>'.$name.'</td><td>'.number_format(100 * $value, 2).'%</td></tr>';
$this->_html .= '</table>';
}
$this->_html .= '
</center>
</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
$this->html = '
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<p><img src="../img/admin/down.gif" />'.$this->l('Determine the percentage of web browsers used by your customers.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'wb')).'<br /><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=browser"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
<p><img src="../img/admin/down.gif" />'.$this->l('Determine the percentage of operating systems used by your customers.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'os')).'
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=os"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>';
if ($equipment)
{
$this->html .= '<table class="table space" border="0" cellspacing="0" cellpadding="0">
<tr><th style="width: 200px">'.$this->l('Plug-ins').'</th><th></th></tr>';
foreach ($equipment as $name => $value)
$this->html .= '<tr><td>'.$name.'</td><td>'.number_format(100 * $value, 2).'%</td></tr>';
$this->html .= '</table>';
}
$this->html .= '
</fieldset>
<br />
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Ensure that your website is accessible to all.').'</h2>
<p>
'.$this->l('When managing Websites, it is important to keep track of software used by visitors in order to be sure that the site displays the same way for everyone. PrestaShop was built in order to be compatible with most recent Web browsers and computer operating systems (OS). However, because you may end up adding advanced features to your Website or even modify the core PrestaShop code, these additions may not be accessible by everyone. That is why it is a good idea to keep tabs on the percentage of users for each type of software before adding or changing something that only a limited number of users will be able to access.').'
'.$this->l('When managing Websites, it is important to keep track of software used by visitors in order to be sure that the site displays the same way for everyone.
PrestaShop was built in order to be compatible with most recent Web browsers and computer operating systems (OS).
However, because you may end up adding advanced features to your Website or even modify the core PrestaShop code, these additions may not be accessible by everyone.
That is why it is a good idea to keep tabs on the percentage of users for each type of software before adding or changing something that only a limited number of users will be able to access.').'
</p><br />
</fieldset>';
return $this->_html;
return $this->html;
}
public function setOption($option, $layers = 1)
{
switch($option)
switch ($option)
{
case 'wb':
$this->_titles['main'] = $this->l('Web browser use');
@@ -166,7 +183,7 @@ class StatsEquipment extends ModuleGraph
break;
}
}
protected function getData($layers)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate().$this->_query2);
@@ -174,8 +191,8 @@ class StatsEquipment extends ModuleGraph
$i = 0;
foreach ($result as $row)
{
$this->_values[$i] = $row['total'];
$this->_legend[$i++] = $row['name'];
$this->_values[$i] = $row['total'];
$this->_legend[$i++] = $row['name'];
}
}
}
+23 -23
View File
@@ -40,19 +40,19 @@ class StatsForecast extends Module
private $t7 = 0;
private $t8 = 0;
public function __construct()
{
$this->name = 'statsforecast';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statsforecast';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Stats Dashboard');
$this->description = '';
}
$this->displayName = $this->l('Stats Dashboard');
$this->description = '';
}
public function install()
{
@@ -61,7 +61,7 @@ class StatsForecast extends Module
public function getContent()
{
Tools::redirectAdmin('index.php?tab=AdminStats&module=statsforecast&token='.Tools::getAdminTokenLite('AdminStats'));
Tools::redirectAdmin('index.php?controller=AdminStats&module=statsforecast&token='.Tools::getAdminTokenLite('AdminStats'));
}
public function hookAdminStatsModules()
@@ -98,7 +98,7 @@ class StatsForecast extends Module
$intervalAvg = $interval2;
if ($this->context->cookie->stats_granularity == 42)
$intervalAvg = $interval2 / 7;
// @todo : to remove
if (!defined('PS_BASE_URI'))
define('PS_BASE_URI', '/');
@@ -133,14 +133,14 @@ class StatsForecast extends Module
{
$dateEnd = strtotime($employee->stats_date_to.' 23:59:59');
$dateToday = time();
for ($i = strtotime($employee->stats_date_from.' 00:00:00'); $i <= $dateEnd AND $i <= $dateToday; $i += 86400)
for ($i = strtotime($employee->stats_date_from.' 00:00:00'); $i <= $dateEnd && $i <= $dateToday; $i += 86400)
$dataTable[$i] = array('fix_date' => date('Y-m-d', $i), 'countOrders' => 0, 'countProducts' => 0, 'totalProducts' => 0);
}
while ($row = $db->nextRow($result))
$dataTable[strtotime($row['fix_date'])] = $row;
$this->_html .= '<div style="float:left;width:660px">
$this->_html .= '<div>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<p style="float:left">'.$this->l('All amounts are without taxes.').'</p>
<form id="granularity" action="'.$ru.'#granularity" method="post" style="float:right">
@@ -176,7 +176,7 @@ class StatsForecast extends Module
while ($row = $db->nextRow($visits))
$visitArray[$row['fix_date']] = $row['visits'];
$discountArray = array();
/*$discountArray = array();
$sql = 'SELECT '.$dateFromGInvoice.' as fix_date, SUM(od.value) as total
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_discount od ON o.id_order = od.id_order
@@ -187,12 +187,12 @@ class StatsForecast extends Module
GROUP BY '.$dateFromGInvoice;
$discounts = Db::getInstance()->executeS($sql, false);
while ($row = $db->nextRow($discounts))
$discountArray[$row['fix_date']] = $row['total'];
$discountArray[$row['fix_date']] = $row['total'];*/
$today = date('Y-m-d');
foreach ($dataTable as $row)
{
$discountToday = (isset($discountArray[$row['fix_date']]) ? $discountArray[$row['fix_date']] : 0);
$discountToday = 0;//(isset($discountArray[$row['fix_date']]) ? $discountArray[$row['fix_date']] : 0);
$visitsToday = (int)(isset($visitArray[$row['fix_date']]) ? $visitArray[$row['fix_date']] : 0);
$dateFromGReg = ($this->context->cookie->stats_granularity != 42
@@ -316,7 +316,7 @@ class StatsForecast extends Module
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o');
$orders = Db::getInstance()->getValue($sql);
$this->_html .= '<div class="clear">&nbsp;</div>
$this->_html .= '<br />
<fieldset><legend><img src="../modules/'.$this->name.'/funnel.png" /> '.$this->l('Conversion').'</legend>
<span style="float:left;text-align:center;margin-right:10px;padding-top:15px">'.$this->l('Visitors').'<br />'.$visitors.'</span>
<span style="float:left;text-align:center;margin-right:10px">
@@ -358,7 +358,7 @@ class StatsForecast extends Module
$prop5000 = 5000 / 30 * $interval;
$this->_html .= '
<div class="clear">&nbsp;</div>';
<br />';
$this->_html .= '<fieldset><legend id="payment"><img src="../img/t/AdminPayment.gif" />'.$this->l('Payment distibution').'</legend>
<form id="cat" action="'.$ru.'#payment" method="post" style="float:right">
<input type="hidden" name="submitIdZone" value="1" />
@@ -381,7 +381,7 @@ class StatsForecast extends Module
$this->_html .= '
</table>
</fieldset>
<div class="clear">&nbsp;</div>
<br />
<fieldset><legend><img src="../img/t/AdminCatalog.gif" /> '.$this->l('Category distribution').'</legend>
<form id="cat" action="'.$ru.'#cat" method="post" style="float:right">
<input type="hidden" name="submitIdZone" value="1" />
@@ -406,7 +406,7 @@ class StatsForecast extends Module
$this->_html .= '
</table>
</fieldset>
<div class="clear">&nbsp;</div>
<br />
<fieldset><legend><img src="../img/t/AdminLanguages.gif" /> '.$this->l('Language distribution').'</legend>
<table class="table" border="0" cellspacing="0" cellspacing="0">
<tr><th>'.$this->l('Customers').'</th><th>'.$this->l('Sales').'</th><th>'.$this->l('%').'</th><th colspan="2">'.$this->l('Growth').'</th></tr>';
@@ -425,7 +425,7 @@ class StatsForecast extends Module
$this->_html .= '
</table>
</fieldset>
<div class="clear">&nbsp;</div>
<br />
<fieldset><legend><img src="../img/t/AdminLanguages.gif" />'.$this->l('Zone distribution').'</legend>
<table class="table" border="0" cellspacing="0" cellspacing="0">
<tr><th>'.$this->l('Zone').'</th><th>'.$this->l('Count').'</th><th>'.$this->l('Total').'</th><th>'.$this->l('% Count').'</th><th>'.$this->l('% Sales').'</th></tr>';
@@ -441,7 +441,7 @@ class StatsForecast extends Module
$this->_html .= '
</table>
</fieldset>
<div class="clear">&nbsp;</div>
<br />
<fieldset><legend id="currencies"><img src="../img/t/AdminCurrencies.gif" />'.$this->l('Currency distribution').'</legend>
<form id="cat" action="'.$ru.'#currencies" method="post" style="float:right">
<input type="hidden" name="submitIdZone" value="1" />
@@ -465,7 +465,7 @@ class StatsForecast extends Module
$this->_html .= '
</table>
</fieldset>
<div class="clear">&nbsp;</div>
<br />
<fieldset><legend><img src="../img/t/AdminCatalog.gif" />'.$this->l('Attribute distribution').'</legend>
<table class="table" border="0" cellspacing="0" cellspacing="0">
<tr><th>'.$this->l('Group').'</th><th>'.$this->l('Attribute').'</th><th>'.$this->l('Count').'</th></tr>';
+34 -26
View File
@@ -30,23 +30,25 @@ if (!defined('_PS_VERSION_'))
class StatsLive extends Module
{
function __construct()
{
$this->name = 'statslive';
$this->tab = 'analytics_stats';
$this->version = 1.0;
private $html = '';
public function __construct()
{
$this->name = 'statslive';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Visitors online');
$this->description = $this->l('Display the list of customers and visitors currently online.');
}
$this->displayName = $this->l('Visitors online');
$this->description = $this->l('Display the list of customers and visitors currently online.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return parent::install() && $this->registerHook('AdminStatsModules');
}
/**
@@ -115,56 +117,62 @@ class StatsLive extends Module
list($visitors, $totalVisitors) = $this->getVisitorsOnline();
$irow = 0;
echo '<script type="text/javascript" language="javascript">
$this->html .= '<script type="text/javascript" language="javascript">
$("#calendar").next().remove();
$("#calendar").remove();
</script>';
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
echo '<div class="warn width3">'.$this->l('You must activate the option "pages views for each customer" in the "Stats datamining" module in order to see the pages currently viewed by your customers.').'</div>';
echo '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Customers online').'</legend>';
$this->html .= '<div class="warn">'.
$this->l('You must activate the option "pages views for each customer" in the "Stats datamining" module in order to see the pages currently viewed by your customers.').'
</div>';
$this->html .= '
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Customers online').'</legend>';
if ($totalCustomers)
{
echo $this->l('Total:').' '.(int)($totalCustomers).'
$this->html .= $this->l('Total:').' '.(int)$totalCustomers.'
<table cellpadding="0" cellspacing="0" class="table space">
<tr><th>'.$this->l('ID').'</th><th>'.$this->l('Name').'</th><th>'.$this->l('Current Page').'</th><th>'.$this->l('View').'</th></tr>';
foreach ($customers as $customer)
echo '
$this->html .= '
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
<td>'.$customer['id_customer'].'</td>
<td style="width: 200px;">'.$customer['firstname'].' '.$customer['lastname'].'</td>
<td style="width: 200px;">'.$customer['page'].'</td>
<td style="text-align: right; width: 25px;">
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id).'" target="_blank">
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)Tab::getIdFromClassName('AdminCustomers').(int)$this->context->employee->id).'"
target="_blank">
<img src="../modules/'.$this->name.'/logo.gif" />
</a>
</td>
</tr>';
echo '</table>';
$this->html .= '</table>';
}
else
echo $this->l('There are no customers online.');
echo '</fieldset>
<fieldset class="width3 space"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Visitors online').'</legend>';
$this->html .= $this->l('There are no customers online.');
$this->html .= '</fieldset>
<br />
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Visitors online').'</legend>';
if ($totalVisitors)
{
echo $this->l('Total:').' '.(int)($totalVisitors).'
$this->html .= $this->l('Total:').' '.(int)($totalVisitors).'
<div style="overflow-y: scroll; height: 600px;">
<table cellpadding="0" cellspacing="0" class="table space">
<tr><th>'.$this->l('Guest').'</th><th>'.$this->l('IP').'</th><th>'.$this->l('Since').'</th><th>'.$this->l('Current page').'</th><th>'.$this->l('Referrer').'</th></tr>';
foreach ($visitors as $visitor)
echo '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
$this->html .= '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
<td>'.$visitor['id_guest'].'</td>
<td style="width: 80px;">'.long2ip($visitor['ip_address']).'</td>
<td style="width: 100px;">'.substr($visitor['date_add'], 11).'</td>
<td style="width: 200px;">'.(isset($visitor['page']) ? $visitor['page'] : $this->l('Undefined')).'</td>
<td style="width: 200px;">'.(empty($visitor['http_referer']) ? $this->l('none') : parse_url($visitor['http_referer'], PHP_URL_HOST)).'</td>
</tr>';
echo '</table></div>';
$this->html .= '</table></div>';
}
else
echo $this->l('There are no visitors online.');
echo '</fieldset>';
$this->html .= $this->l('There are no visitors online.');
$this->html .= '</fieldset>';
return $this->html;
}
}
+34 -34
View File
@@ -30,28 +30,28 @@ if (!defined('_PS_VERSION_'))
class StatsNewsletter extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
function __construct()
{
$this->name = 'statsnewsletter';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statsnewsletter';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Newsletter');
$this->description = $this->l('Display the newsletter registrations');
}
$this->displayName = $this->l('Newsletter');
$this->description = $this->l('Display the newsletter registrations');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
@@ -62,11 +62,11 @@ class StatsNewsletter extends ModuleGraph
if (Tools::getValue('export'))
$this->csvExport(array('type' => 'line', 'layers' => 3));
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<p>'.$this->l('Registrations from customers:').' '.(int)($totals['customers']).'</p>
<p>'.$this->l('Registrations from visitors:').' '.(int)($totals['visitors']).'</p>
<p>'.$this->l('Both:').' '.(int)($totals['both']).'</p>
<center>'.$this->engine(array('type' => 'line', 'layers' => 3)).'</center>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<p>'.$this->l('Registrations from customers:').' '.(int)$totals['customers'].'</p>
<p>'.$this->l('Registrations from visitors:').' '.(int)$totals['visitors'].'</p>
<p>'.$this->l('Both:').' '.(int)$totals['both'].'</p>
<div>'.$this->engine(array('type' => 'line', 'layers' => 3)).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset>';
}
@@ -119,11 +119,11 @@ class StatsNewsletter extends ModuleGraph
{
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query2.$this->getDate());
foreach ($result1 AS $row)
$this->_values[0][(int)(substr($row['newsletter_date_add'], 0, 4))] += 1;
foreach ($result1 as $row)
$this->_values[0][(int)substr($row['newsletter_date_add'], 0, 4)] += 1;
if ($result2)
foreach ($result2 AS $row)
$this->_values[1][(int)(substr($row['newsletter_date_add'], 0, 4))] += 1;
foreach ($result2 as $row)
$this->_values[1][(int)substr($row['newsletter_date_add'], 0, 4)] += 1;
foreach ($this->_values[2] as $key => $zerofill)
$this->_values[2][$key] = $this->_values[0][$key] + $this->_values[1][$key];
}
@@ -132,11 +132,11 @@ class StatsNewsletter extends ModuleGraph
{
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query2.$this->getDate());
foreach ($result1 AS $row)
$this->_values[0][(int)(substr($row['newsletter_date_add'], 5, 2))] += 1;
foreach ($result1 as $row)
$this->_values[0][(int)substr($row['newsletter_date_add'], 5, 2)] += 1;
if ($result2)
foreach ($result2 AS $row)
$this->_values[1][(int)(substr($row['newsletter_date_add'], 5, 2))] += 1;
foreach ($result2 as $row)
$this->_values[1][(int)substr($row['newsletter_date_add'], 5, 2)] += 1;
foreach ($this->_values[2] as $key => $zerofill)
$this->_values[2][$key] = $this->_values[0][$key] + $this->_values[1][$key];
}
@@ -145,11 +145,11 @@ class StatsNewsletter extends ModuleGraph
{
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query2.$this->getDate());
foreach ($result1 AS $row)
$this->_values[0][(int)(substr($row['newsletter_date_add'], 8, 2))] += 1;
foreach ($result1 as $row)
$this->_values[0][(int)substr($row['newsletter_date_add'], 8, 2)] += 1;
if ($result2)
foreach ($result2 AS $row)
$this->_values[1][(int)(substr($row['newsletter_date_add'], 8, 2))] += 1;
foreach ($result2 as $row)
$this->_values[1][(int)substr($row['newsletter_date_add'], 8, 2)] += 1;
foreach ($this->_values[2] as $key => $zerofill)
$this->_values[2][$key] = $this->_values[0][$key] + $this->_values[1][$key];
}
@@ -158,11 +158,11 @@ class StatsNewsletter extends ModuleGraph
{
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query2.$this->getDate());
foreach ($result1 AS $row)
$this->_values[0][(int)(substr($row['newsletter_date_add'], 11, 2))] += 1;
foreach ($result1 as $row)
$this->_values[0][(int)substr($row['newsletter_date_add'], 11, 2)] += 1;
if ($result2)
foreach ($result2 AS $row)
$this->_values[1][(int)(substr($row['newsletter_date_add'], 11, 2))] += 1;
foreach ($result2 as $row)
$this->_values[1][(int)substr($row['newsletter_date_add'], 11, 2)] += 1;
foreach ($this->_values[2] as $key => $zerofill)
$this->_values[2][$key] = $this->_values[0][$key] + $this->_values[1][$key];
}
+30 -28
View File
@@ -31,24 +31,24 @@ if (!defined('_PS_VERSION_'))
class StatsOrigin extends ModuleGraph
{
private $_html;
function __construct()
{
$this->name = 'statsorigin';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statsorigin';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Visitors origin');
$this->description = $this->l('Display the websites your visitors come from.');
}
function install()
parent::__construct();
$this->displayName = $this->l('Visitors origin');
$this->description = $this->l('Display the websites your visitors come from.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
private function getOrigins($dateBetween)
@@ -63,7 +63,7 @@ class StatsOrigin extends ModuleGraph
$websites = array($directLink => 0);
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
{
if (!isset($row['http_referer']) OR empty($row['http_referer']))
if (!isset($row['http_referer']) || empty($row['http_referer']))
++$websites[$directLink];
else
{
@@ -78,48 +78,50 @@ class StatsOrigin extends ModuleGraph
return $websites;
}
function hookAdminStatsModules()
public function hookAdminStatsModules()
{
$websites = $this->getOrigins(ModuleGraph::getDateBetween());
if (Tools::getValue('export'))
if (Tools::getValue('exportType') == 'top')
$this->csvExport(array('type' => 'pie'));
$this->_html = '<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Origin').'</legend>';
if (sizeof($websites))
$this->_html = '<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Origin').'</legend>';
if (count($websites))
{
$this->_html .= '
<center><p><img src="../img/admin/down.gif" />'. $this->l('Here is the percentage of the 10 most popular referrer websites by which visitors went through to get to your shop.').'</p>
'.$this->engine(array('type' => 'pie')).'</center>
<p><img src="../img/admin/down.gif" />'.$this->l('Here is the percentage of the 10 most popular referrer websites by which visitors went through to get to your shop.').'</p>
<div>'.$this->engine(array('type' => 'pie')).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=top"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br /><br />
<div style="overflow-y: scroll; height: 600px;">
<center>
<table class="table " border="0" cellspacing="0" cellspacing="0">
<tr>
<th style="width:400px;">'.$this->l('Origin').'</th>
<th style="width:50px; text-align: right">'.$this->l('Total').'</th>
</tr>';
foreach ($websites as $website => $total)
$this->_html .= '<tr><td>'.(!strstr($website, ' ') ? '<a href="'.Tools::getProtocol().$website.'">' : '').$website.(!strstr($website, ' ') ? '</a>' : '').'</td><td style="text-align: right">'.$total.'</td></tr>';
$this->_html .= '</table></center></div>';
$this->_html .= '<tr>
<td>'.(!strstr($website, ' ') ? '<a href="'.Tools::getProtocol().$website.'">' : '').$website.(!strstr($website, ' ') ? '</a>' : '').'</td><td style="text-align: right">'.$total.'</td>
</tr>';
$this->_html .= '</table></div>';
}
else
$this->_html .= '<p><strong>'.$this->l('Direct links only').'</strong></p>';
$this->_html .= '</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('What is a referrer website?').'</h2>
<p>
'.$this->l('When visiting a webpage, the referrer is the URL of the previous webpage from which a link was followed.').'<br />
'.$this->l('A referrer enables you to know which keywords are entered by visitors in search engines when getting to your shop and allows you to optimize web promotion.').'<br /><br />
'. $this->l('A referrer can be:').'
'.$this->l('A referrer can be:').'
<ul>
<li class="bullet">'. $this->l('Someone who put a link on their website for your shop').'</li>
<li class="bullet">'. $this->l('A partner with whom you made a link exchange in order to bring in sales or attract new customers').'</li>
<li class="bullet">'.$this->l('Someone who put a link on their website for your shop').'</li>
<li class="bullet">'.$this->l('A partner with whom you made a link exchange in order to bring in sales or attract new customers').'</li>
</ul>
</p>
</fieldset>';
return $this->_html;
}
protected function getData($layers)
{
$this->_titles['main'] = $this->l('First 10 websites');
@@ -30,71 +30,70 @@ if (!defined('_PS_VERSION_'))
class StatsPersonalInfos extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $html = '';
private $_query = '';
private $_option;
function __construct()
{
$this->name = 'statspersonalinfos';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statspersonalinfos';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Registered Customer Info');
$this->description = $this->l('Display characteristics such as gender and age.');
$this->displayName = $this->l('Registered Customer Info');
$this->description = $this->l('Display characteristics such as gender and age.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function hookAdminStatsModules($params)
{
$this->_html = '<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
if (sizeof(Customer::getCustomers()))
$this->html = '<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
if (count(Customer::getCustomers()))
{
if (Tools::getValue('export'))
if (Tools::getValue('exportType') =='gender')
if (Tools::getValue('exportType') == 'gender')
$this->csvExport(array('type' => 'pie', 'option' => 'gender'));
elseif (Tools::getValue('exportType') =='age')
else if (Tools::getValue('exportType') == 'age')
$this->csvExport(array('type' => 'pie', 'option' => 'age'));
elseif (Tools::getValue('exportType') =='country')
else if (Tools::getValue('exportType') == 'country')
$this->csvExport(array('type' => 'pie', 'option' => 'country'));
elseif (Tools::getValue('exportType') =='currency')
else if (Tools::getValue('exportType') == 'currency')
$this->csvExport(array('type' => 'pie', 'option' => 'currency'));
elseif (Tools::getValue('exportType') =='language')
else if (Tools::getValue('exportType') == 'language')
$this->csvExport(array('type' => 'pie', 'option' => 'language'));
$this->_html .= '
<center><p><img src="../img/admin/down.gif" />'.$this->l('Gender distribution allows you to determine the percentage of men and women among your customers.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'gender')).'<br /></center>
$this->html .= '
<p><img src="../img/admin/down.gif" />'.$this->l('Gender distribution allows you to determine the percentage of men and women among your customers.').'</p>
<div>'.$this->engine(array('type' => 'pie', 'option' => 'gender')).'</div><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=gender"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
<br class="clear" /><br />
<center><p><img src="../img/admin/down.gif" />'.$this->l('Age ranges allows you to determine in which age range your customers are.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'age')).'<br /></center>
<p><img src="../img/admin/down.gif" />'.$this->l('Age ranges allows you to determine in which age range your customers are.').'</p>
<div>'.$this->engine(array('type' => 'pie', 'option' => 'age')).'</div><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=age"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br /><br />
<center><p><img src="../img/admin/down.gif" />'.$this->l('Country distribution allows you to determine in which part of the world your customers are shopping from.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'country')).'<br /></center>
<p><img src="../img/admin/down.gif" />'.$this->l('Country distribution allows you to determine in which part of the world your customers are shopping from.').'</p>
<div>'.$this->engine(array('type' => 'pie', 'option' => 'country')).'</div><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=country"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br /><br />
<center><p><img src="../img/admin/down.gif" />'.$this->l('Currency ranges allows you to determine which currencies your customers are using.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'currency')).'<br /></center>
<p><img src="../img/admin/down.gif" />'.$this->l('Currency ranges allows you to determine which currencies your customers are using.').'</p>
<div>'.$this->engine(array('type' => 'pie', 'option' => 'currency')).'</div><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=currency"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br /><br />
<center><p><img src="../img/admin/down.gif" />'.$this->l('Language distribution allows you to determine the general languages your customers are using on your shop.').'</p>
'.$this->engine(array('type' => 'pie', 'option' => 'language')).'<br /></center>
<p><img src="../img/admin/down.gif" />'.$this->l('Language distribution allows you to determine the general languages your customers are using on your shop.').'</p>
<div>'.$this->engine(array('type' => 'pie', 'option' => 'language')).'</div><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</center>';
}
else
$this->_html .= '<p>'.$this->l('No customers registered yet.').'</p>';
$this->_html .= '
$this->html .= '<p>'.$this->l('No customers registered yet.').'</p>';
$this->html .= '
</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Target your audience').'</h2>
<p>
'.$this->l('In order for each message to have an impact, you need to know to whom it should be addressed.').'
@@ -110,7 +109,7 @@ class StatsPersonalInfos extends ModuleGraph
</ul>
</p><br />
</fieldset>';
return $this->_html;
return $this->html;
}
public function setOption($option, $layers = 1)
@@ -164,7 +163,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('0-18 years old');
@@ -178,7 +177,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('18-24 years old');
@@ -192,7 +191,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('25-34 years old');
@@ -206,7 +205,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('35-49 years old');
@@ -220,7 +219,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('50-59 years old');
@@ -233,7 +232,7 @@ class StatsPersonalInfos extends ModuleGraph
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('60 years old and more');
@@ -245,7 +244,7 @@ class StatsPersonalInfos extends ModuleGraph
WHERE `birthday` IS NULL
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) AND $result['total'])
if (isset($result['total']) && $result['total'])
{
$this->_values[] = $result['total'];
$this->_legend[] = $this->l('Unknown');
@@ -265,8 +264,8 @@ class StatsPersonalInfos extends ModuleGraph
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
}
break;
@@ -281,8 +280,8 @@ class StatsPersonalInfos extends ModuleGraph
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
}
break;
@@ -297,8 +296,8 @@ class StatsPersonalInfos extends ModuleGraph
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
}
break;
}
+76 -68
View File
@@ -30,28 +30,28 @@ if (!defined('_PS_VERSION_'))
class StatsProduct extends ModuleGraph
{
private $_html = '';
private $html = '';
private $_query = '';
private $_option = 0;
private $_id_product = 0;
function __construct()
{
$this->name = 'statsproduct';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statsproduct';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Product details');
$this->description = $this->l('Get detailed statistics for each product.');
}
$this->displayName = $this->l('Product details');
$this->description = $this->l('Get detailed statistics for each product.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return (parent::install() && $this->registerHook('AdminStatsModules'));
}
public function getTotalBought($id_product)
@@ -73,7 +73,7 @@ class StatsProduct extends ModuleGraph
$sql = 'SELECT SUM(od.`product_quantity` * od.`product_price`) AS total
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)($id_product).'
WHERE od.`product_id` = '.(int)$id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween;
@@ -90,7 +90,7 @@ class StatsProduct extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
WHERE pt.`name` = \'product\'
'.$this->sqlShopRestriction(false, 'pv').'
AND p.`id_object` = '.(int)($id_product).'
AND p.`id_object` = '.(int)$id_product.'
AND dr.`time_start` BETWEEN '.$dateBetween.'
AND dr.`time_end` BETWEEN '.$dateBetween;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -105,8 +105,8 @@ class StatsProduct extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.$this->context->shop->addSqlRestrictionOnLang('pl').'
'.$this->context->shop->addSqlAssociation('product', 'p').'
'.(Tools::getValue('id_category') ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`' : '').'
WHERE pl.`id_lang` = '.(int)($id_lang).'
'.(Tools::getValue('id_category') ? 'AND cp.id_category = '.(int)(Tools::getValue('id_category')) : '').'
WHERE pl.`id_lang` = '.(int)$id_lang.'
'.(Tools::getValue('id_category') ? 'AND cp.id_category = '.(int)Tools::getValue('id_category') : '').'
ORDER BY pl.`name`';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
@@ -119,7 +119,7 @@ class StatsProduct extends ModuleGraph
WHERE o.date_add BETWEEN '.$this->getDate().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND od.product_id = '.(int)($id_product);
AND od.product_id = '.(int)$id_product;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
@@ -148,26 +148,26 @@ class StatsProduct extends ModuleGraph
public function hookAdminStatsModules($params)
{
$id_category = (int)(Tools::getValue('id_category'));
$id_category = (int)Tools::getValue('id_category');
$currency = Context::getContext()->currency;
if (Tools::getValue('export'))
if (!Tools::getValue('exportType'))
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
$this->_html = '<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
if ($id_product = (int)(Tools::getValue('id_product')))
$this->html = '<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
if ($id_product = (int)Tools::getValue('id_product'))
{
if (Tools::getValue('export'))
if (Tools::getValue('exportType') == 1)
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-'.$id_product));
elseif (Tools::getValue('exportType') == 2)
else if (Tools::getValue('exportType') == 2)
$this->csvExport(array('type' => 'pie', 'option' => '3-'.$id_product));
$product = new Product($id_product, false, $this->context->language->id);
$totalBought = $this->getTotalBought($product->id);
$totalSales = $this->getTotalSales($product->id);
$totalViewed = $this->getTotalViewed($product->id);
$this->_html .= '<h3>'.$product->name.' - '.$this->l('Details').'</h3>
$this->html .= '<h3>'.$product->name.' - '.$this->l('Details').'</h3>
<p>'.$this->l('Total bought:').' '.$totalBought.'</p>
<p>'.$this->l('Sales (-Tx):').' '.Tools::displayprice($totalSales, $currency).'</p>
<p>'.$this->l('Total viewed:').' '.$totalViewed.'</p>
@@ -175,15 +175,15 @@ class StatsProduct extends ModuleGraph
<center>'.$this->engine(array('layers' => 2, 'type' => 'line', 'option' => '1-'.$id_product)).'</center>
<br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>';
if ($hasAttribute = $product->hasAttributes() AND $totalBought)
$this->_html .= '<h3 class="space">'.$this->l('Attribute sales distribution').'</h3><center>'.$this->engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'</center><br />
if ($hasAttribute = $product->hasAttributes() && $totalBought)
$this->html .= '<h3 class="space">'.$this->l('Attribute sales distribution').'</h3><center>'.$this->engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'</center><br />
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br />';
if ($totalBought)
{
$sales = $this->getSales($id_product, $this->context->language->id);
$this->_html .= '<br class="clear" />
$this->html .= '<br class="clear" />
<h3>'.$this->l('Sales').'</h3>
<div style="overflow-y: scroll; height: '.min(400, (count($sales)+1)*32).'px;">
<div style="overflow-y: scroll; height: '.min(400, (count($sales) + 1) * 32).'px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
<tr>
@@ -195,24 +195,24 @@ class StatsProduct extends ModuleGraph
<th>'.$this->l('Price').'</th>
</tr>
</thead><tbody>';
$tokenOrder = Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($this->context->employee->id));
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($this->context->employee->id));
$tokenOrder = Tools::getAdminToken('AdminOrders'.(int)Tab::getIdFromClassName('AdminOrders').(int)$this->context->employee->id);
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)Tab::getIdFromClassName('AdminCustomers').(int)$this->context->employee->id);
foreach ($sales as $sale)
$this->_html .= '
$this->html .= '
<tr>
<td>'.Tools::displayDate($sale['date_add'], (int)($this->context->language->id), false).'</td>
<td>'.Tools::displayDate($sale['date_add'], (int)$this->context->language->id, false).'</td>
<td align="center"><a href="?tab=AdminOrders&id_order='.$sale['id_order'].'&vieworder&token='.$tokenOrder.'">'.(int)($sale['id_order']).'</a></td>
<td align="center"><a href="?tab=AdminCustomers&id_customer='.$sale['id_customer'].'&viewcustomer&token='.$tokenCustomer.'">'.(int)($sale['id_customer']).'</a></td>
'.($hasAttribute ? '<td>'.$sale['product_name'].'</td>' : '').'
<td>'.(int)($sale['product_quantity']).'</td>
<td>'.(int)$sale['product_quantity'].'</td>
<td>'.Tools::displayprice($sale['total'], $currency).'</td>
</tr>';
$this->_html .= '</tbody></table></div>';
$this->html .= '</tbody></table></div>';
$crossSelling = $this->getCrossSales($id_product, $this->context->language->id);
if (count($crossSelling))
{
$this->_html .= '<br class="clear" />
$this->html .= '<br class="clear" />
<h3>'.$this->l('Cross Selling').'</h3>
<div style="overflow-y: scroll; height: 200px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
@@ -223,30 +223,30 @@ class StatsProduct extends ModuleGraph
<th>'.$this->l('Average price').'</th>
</tr>
</thead><tbody>';
$tokenProducts = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($this->context->employee->id));
$tokenProducts = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog').(int)$this->context->employee->id);
foreach ($crossSelling as $selling)
$this->_html .= '
$this->html .= '
<tr>
<td ><a href="?tab=AdminCatalog&id_product='.(int)($selling['id_product']).'&addproduct&token='.$tokenProducts.'">'.$selling['pname'].'</a></td>
<td align="center">'.(int)($selling['pqty']).'</td>
<td ><a href="?tab=AdminCatalog&id_product='.(int)$selling['id_product'].'&addproduct&token='.$tokenProducts.'">'.$selling['pname'].'</a></td>
<td align="center">'.(int)$selling['pqty'].'</td>
<td align="right">'.Tools::displayprice($selling['pprice'], $currency).'</td>
</tr>';
$this->_html .= '</tbody></table></div>';
$this->html .= '</tbody></table></div>';
}
}
}
else
{
$categories = Category::getCategories((int)$this->context->language->id, true, false);
$this->_html .= '
$this->html .= '
<label>'.$this->l('Choose a category').'</label>
<div class="margin-form">
<form action="" method="post" id="categoriesForm">
<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
<option value="0">'.$this->l('All').'</option>';
foreach ($categories as $category)
$this->_html .= '<option value="'.$category['id_category'].'"'.($id_category == $category['id_category'] ? ' selected="selected"' : '').'>'.$category['name'].'</option>';
$this->_html .= '
$this->html .= '<option value="'.$category['id_category'].'"'.($id_category == $category['id_category'] ? ' selected="selected"' : '').'>'.$category['name'].'</option>';
$this->html .= '
</select>
</form>
</div>
@@ -265,25 +265,33 @@ class StatsProduct extends ModuleGraph
</thead><tbody>';
foreach ($this->getProducts($this->context->language->id) as $product)
$this->_html .= '<tr><td>'.$product['reference'].'</td><td><a href="'.AdminTab::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'&id_product='.$product['id_product'].'">'.$product['name'].'</a></td><td>'.$product['quantity'].'</td></tr>';
$this->html .= '
<tr>
<td>'.$product['reference'].'</td>
<td>
<a href="'.AdminTab::$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'&id_product='.$product['id_product'].'">'.$product['name'].'</a>
</td>
<td>'.$product['quantity'].'</td>
</tr>';
$this->_html .= '</tbody></table><br /></div><br />
$this->html .= '</tbody></table><br /></div><br />
<a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a><br />';
}
$this->_html .= '</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
$this->html .= '</fieldset><br />
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Number of purchases compared to number of viewings').'</h2>
<p>
'.$this->l('After choosing a category and selecting a product, informational graphs will appear. Then, you will be able to analyze them.').'
<ul>
<li class="bullet">'.$this->l('If you notice that a product is successful and often purchased, but viewed infrequently, you should put it more prominently on your webshop front-office.').'</li>
<li class="bullet">'.$this->l('On the other hand, if a product has many viewings but is not often purchased, we advise you to check or modify this product\'s information, description and photography again.').'
<li class="bullet">'.$this->l('On the other hand, if a product has many viewings but is not often purchased,
we advise you to check or modify this product\'s information, description and photography again.').'
</li>
</ul>
</p>
</fieldset>';
return $this->_html;
return $this->html;
}
public function setOption($option, $layers = 1)
@@ -303,7 +311,7 @@ class StatsProduct extends ModuleGraph
$this->_query[0] = 'SELECT o.`date_add`, SUM(od.`product_quantity`) AS total
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)($this->_id_product).'
WHERE od.`product_id` = '.(int)$this->_id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween.'
@@ -316,7 +324,7 @@ class StatsProduct extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
WHERE pt.`name` = \'product\'
'.$this->sqlShopRestriction(false, 'pv').'
AND p.`id_object` = '.(int)($this->_id_product).'
AND p.`id_object` = '.(int)$this->_id_product.'
AND dr.`time_start` BETWEEN '.$dateBetween.'
AND dr.`time_end` BETWEEN '.$dateBetween.'
GROUP BY dr.`time_start`';
@@ -347,29 +355,29 @@ class StatsProduct extends ModuleGraph
if ($this->_option == 42)
{
$products = $this->getProducts($this->context->language->id);
foreach ($products AS $product)
foreach ($products as $product)
{
$this->_values[0][] = $product['reference'];
$this->_values[1][] = $product['name'];
$this->_values[2][] = $product['quantity'];
$this->_values[0][] = $product['reference'];
$this->_values[1][] = $product['name'];
$this->_values[2][] = $product['quantity'];
$this->_legend[] = $product['id_product'];
}
}
elseif ($this->_option != 3)
else if ($this->_option != 3)
$this->setDateGraph($layers, true);
else
{
$product = new Product($this->_id_product, false, (int)($this->getLang()));
$product = new Product($this->_id_product, false, (int)$this->getLang());
$combArray = array();
$assocNames = array();
$combinaisons = $product->getAttributeCombinaisons((int)($this->getLang()));
foreach ($combinaisons AS $k => $combinaison)
$combinaisons = $product->getAttributeCombinaisons((int)$this->getLang());
foreach ($combinaisons as $k => $combinaison)
$combArray[$combinaison['id_product_attribute']][] = array('group' => $combinaison['group_name'], 'attr' => $combinaison['attribute_name']);
foreach ($combArray AS $id_product_attribute => $product_attribute)
foreach ($combArray as $id_product_attribute => $product_attribute)
{
$list = '';
foreach ($product_attribute AS $attribute)
foreach ($product_attribute as $attribute)
$list .= trim($attribute['group']).' - '.trim($attribute['attr']).', ';
$list = rtrim($list, ', ');
$assocNames[$id_product_attribute] = $list;
@@ -378,8 +386,8 @@ class StatsProduct extends ModuleGraph
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = @$assocNames[$row['product_attribute_id']];
$this->_values[] = $row['total'];
$this->_legend[] = @$assocNames[$row['product_attribute_id']];
}
}
}
@@ -389,8 +397,8 @@ class StatsProduct extends ModuleGraph
for ($i = 0; $i < $layers; $i++)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query[$i]);
foreach ($result AS $row)
$this->_values[$i][(int)(substr($row['date_add'], 0, 4))] += $row['total'];
foreach ($result as $row)
$this->_values[$i][(int)(substr($row['date_add'], 0, 4))] += $row['total'];
}
}
@@ -399,8 +407,8 @@ class StatsProduct extends ModuleGraph
for ($i = 0; $i < $layers; $i++)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query[$i]);
foreach ($result AS $row)
$this->_values[$i][(int)(substr($row['date_add'], 5, 2))] += $row['total'];
foreach ($result as $row)
$this->_values[$i][(int)(substr($row['date_add'], 5, 2))] += $row['total'];
}
}
@@ -409,8 +417,8 @@ class StatsProduct extends ModuleGraph
for ($i = 0; $i < $layers; $i++)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query[$i]);
foreach ($result AS $row)
$this->_values[$i][(int)(substr($row['date_add'], 8, 2))] += $row['total'];
foreach ($result as $row)
$this->_values[$i][(int)(substr($row['date_add'], 8, 2))] += $row['total'];
}
}
@@ -419,8 +427,8 @@ class StatsProduct extends ModuleGraph
for ($i = 0; $i < $layers; $i++)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query[$i]);
foreach ($result AS $row)
$this->_values[$i][(int)(substr($row['date_add'], 11, 2))] += $row['total'];
foreach ($result as $row)
$this->_values[$i][(int)(substr($row['date_add'], 11, 2))] += $row['total'];
}
}
}
@@ -30,26 +30,26 @@ if (!defined('_PS_VERSION_'))
class StatsRegistrations extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $_html = '';
private $_query = '';
function __construct()
{
$this->name = 'statsregistrations';
$this->tab = 'analytics_stats';
$this->version = 1.0;
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.');
}
$this->displayName = $this->l('Customer accounts');
$this->description = $this->l('Display the progress of customer registration.');
}
/**
* Called during module installation
*/
/**
* Called during module installation
*/
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
@@ -109,16 +109,16 @@ class StatsRegistrations extends ModuleGraph
if (Tools::getValue('export'))
$this->csvExport(array('layers' => 0, 'type' => 'line'));
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<p>
'.$this->l('Visitors who have stopped at the registering step:').' '.(int)($totalBlocked).($totalRegistrations ? ' ('.number_format(100*$totalBlocked/($totalRegistrations+$totalBlocked), 2).'%)' : '').'<br />
'.$this->l('Visitors who have placed an order directly after registration:').' '.(int)($totalBuyers).($totalRegistrations ? ' ('.number_format(100*$totalBuyers/($totalRegistrations), 2).'%)' : '').'
</p>
<p>'.$this->l('Total customer accounts:').' '.$totalRegistrations.'</p>
<center>'.$this->engine(array('type' => 'line')).'</center>
<div>'.$this->engine(array('type' => 'line')).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Number of customer accounts created').'</h2>
<p>'.$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.').'</p>
<br /><h3>'.$this->l('How to act on the registrations\' evolution?').'</h3>
@@ -152,7 +152,7 @@ class StatsRegistrations extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
foreach ($result AS $row)
$this->_values[(int)(substr($row['date_add'], 0, 4))]++;
$this->_values[(int)(substr($row['date_add'], 0, 4))]++;
}
protected function setYearValues($layers)
@@ -178,7 +178,7 @@ class StatsRegistrations extends ModuleGraph
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.$this->getDate());
foreach ($result AS $row)
$this->_values[(int)(substr($row['date_add'], 11, 2))]++;
$this->_values[(int)(substr($row['date_add'], 11, 2))]++;
}
}
+22 -22
View File
@@ -30,25 +30,25 @@ if (!defined('_PS_VERSION_'))
class StatsSales extends ModuleGraph
{
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
private $id_country = '';
private $_html = '';
private $_query = '';
private $_query2 = '';
private $_option = '';
private $id_country = '';
function __construct()
{
$this->name = 'statssales';
$this->tab = 'analytics_stats';
$this->version = 1.0;
function __construct()
{
$this->name = 'statssales';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Sales and orders');
$this->description = $this->l('Display the sales evolution and orders by statuses');
}
$this->displayName = $this->l('Sales and orders');
$this->description = $this->l('Display the sales evolution and orders by statuses');
}
public function install()
{
@@ -67,7 +67,7 @@ class StatsSales extends ModuleGraph
$this->csvExport(array('type' => 'pie', 'option' => '3-'.(int)Tools::getValue('id_country')));
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" style="float: right; margin-left: 10px;">
<select name="id_country">
<option value="0"'.((!Tools::getValue('id_order_state')) ? ' selected="selected"' : '').'>'.$this->l('All').'</option>';
@@ -76,15 +76,15 @@ class StatsSales extends ModuleGraph
$this->_html .= '</select>
<input type="submit" name="submitCountry" value="'.$this->l('Filter').'" class="button" />
</form>
<p><center><img src="../img/admin/down.gif" />
<p><img src="../img/admin/down.gif" />
'.$this->l('These graphs represent the evolution of your orders and sales turnover for a given period. This tool allows for quick overview of the viability of your shop. You can also keep watch on the difference between time periods (like the holiday season). Only valid orders are included in these two graphs.').'
</center></p>
</p>
<p>'.$this->l('Orders placed:').' '.(int)($totals['orderCount']).'</p>
<p>'.$this->l('Products bought:').' '.(int)($totals['products']).'</p>
<center>'.$this->engine(array('type' => 'line', 'option' => '1-'.(int)Tools::getValue('id_country'), 'layers' => 2)).'</center>
<div>'.$this->engine(array('type' => 'line', 'option' => '1-'.(int)Tools::getValue('id_country'), 'layers' => 2)).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" alt="" />'.$this->l('CSV Export').'</a></p>
<p>'.$this->l('Sales:').' '.Tools::displayPrice($totals['orderSum'], $currency).'</p>
<center>'.$this->engine(array('type' => 'line', 'option' => '2-'.(int)Tools::getValue('id_country'))).'</center></p>
<div>'.$this->engine(array('type' => 'line', 'option' => '2-'.(int)Tools::getValue('id_country'))).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=2"><img src="../img/admin/asterisk.gif" alt="" />'.$this->l('CSV Export').'</a></p>
<p class="space"><img src="../img/admin/down.gif" />
'.$this->l('You can see the order state distribution below.').'
@@ -92,8 +92,8 @@ class StatsSales extends ModuleGraph
'.($totals['orderCount'] ? $this->engine(array('type' => 'pie', 'option' => '3-'.(int)Tools::getValue('id_country'))) : $this->l('No orders for this period.')).'</center>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=3"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
</fieldset>
<br class="clear" />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<br />
<fieldset><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Various order statuses').'</h2>
<p>
'.$this->l('In your back-office, you can find the following order statuses : Awaiting check payment, Payment accepted, Preparation in progress, Shipping, Delivered, Cancelled, Refund, Payment error, Out of stock, and Awaiting bank wire payment.').'<br />
@@ -248,8 +248,8 @@ class StatsSales extends ModuleGraph
GROUP BY oh.`id_order_state`');
foreach ($result as $row)
{
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
$this->_values[] = $row['total'];
$this->_legend[] = $row['name'];
}
}
}
+23 -23
View File
@@ -30,15 +30,15 @@ if (!defined('_PS_VERSION_'))
class StatsSearch extends ModuleGraph
{
private $_html = '';
private $_html = '';
private $_query = '';
private $_query2 = '';
function __construct()
{
$this->name = 'statssearch';
$this->tab = 'analytics_stats';
$this->version = 1.0;
public function __construct()
{
$this->name = 'statssearch';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -54,13 +54,13 @@ class StatsSearch extends ModuleGraph
HAVING occurences > 1
ORDER BY occurences DESC';
$this->displayName = $this->l('Shop search');
$this->description = $this->l('Display which keywords have been searched by your visitors.');
}
$this->displayName = $this->l('Shop search');
$this->description = $this->l('Display which keywords have been searched by your visitors.');
}
function install()
public function install()
{
if (!parent::install() OR !$this->registerHook('search') OR !$this->registerHook('AdminStatsModules'))
if (!parent::install() || !$this->registerHook('search') || !$this->registerHook('AdminStatsModules'))
return false;
return Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'statssearch` (
@@ -74,31 +74,31 @@ class StatsSearch extends ModuleGraph
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
}
function uninstall()
{
if (!parent::uninstall())
public function uninstall()
{
if (!parent::uninstall())
return false;
return (Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'statssearch`'));
}
}
/**
* Insert keywords in statssearch table when a search is launched on FO
*/
function hookSearch($params)
/**
* Insert keywords in statssearch table when a search is launched on FO
*/
public function hookSearch($params)
{
$sql = 'INSERT INTO `'._DB_PREFIX_.'statssearch` (`id_shop`, `id_group_shop`, `keywords`, `results`, `date_add`)
VALUES ('.$this->context->shop->getID(true).', '.$this->context->shop->getGroupID().', \''.pSQL($params['expr']).'\', '.(int)$params['total'].', NOW())';
Db::getInstance()->execute($sql);
}
function hookAdminStatsModules()
public function hookAdminStatsModules()
{
if (Tools::getValue('export'))
$this->csvExport(array('type' => 'pie'));
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query.ModuleGraph::getDateBetween().$this->_query2);
$this->_html = '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->displayName.'</legend>';
$table = '<div style="overflow-y: scroll; height: 600px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
@@ -120,8 +120,8 @@ class StatsSearch extends ModuleGraph
}
$table .= '</tbody></table></div>';
if (sizeof($result))
$this->_html .= '<center>'.$this->engine(array('type' => 'pie')).'</center>
if (count($result))
$this->_html .= '<div>'.$this->engine(array('type' => 'pie')).'</div>
<p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p>
<br class="clear" />'.$table;
else
+36 -29
View File
@@ -24,40 +24,42 @@
* @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 StatsStock extends Module
{
function __construct()
{
$this->name = 'statsstock';
$this->tab = 'analytics_stats';
$this->version = 1.0;
private $html = '';
public function __construct()
{
$this->name = 'statsstock';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Stock stats');
$this->description = '';
}
$this->displayName = $this->l('Stock stats');
$this->description = '';
}
public function install()
{
return (parent::install() && $this->registerHook('AdminStatsModules'));
return parent::install() && $this->registerHook('AdminStatsModules');
}
function hookAdminStatsModules()
{
public function hookAdminStatsModules()
{
if (Tools::isSubmit('submitCategory'))
$this->context->cookie->statsstock_id_category = Tools::getValue('statsstock_id_category');
$ru = AdminTab::$currentIndex.'&module='.$this->name.'&token='.Tools::getValue('token');
$ru = AdminController::$currentIndex.'&module='.$this->name.'&token='.Tools::getValue('token');
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$filter = ((int)$this->context->cookie->statsstock_id_category ? ' AND p.id_product IN (SELECT cp.id_product FROM '._DB_PREFIX_.'category_product cp WHERE cp.id_category = '.(int)$this->context->cookie->statsstock_id_category.')' : '');
$sql = 'SELECT p.id_product, p.reference, pl.name,
IFNULL((
SELECT AVG(pa.wholesale_price)
@@ -74,30 +76,33 @@ class StatsStock extends Module
), p.wholesale_price * p.quantity) as stockvalue
FROM '._DB_PREFIX_.'product p
'.$this->context->shop->addSqlAssociation('product', 'p').'
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
INNER JOIN '._DB_PREFIX_.'product_lang pl
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
WHERE 1 = 1
'.$filter;
$products = Db::getInstance()->executeS($sql);
echo '
$this->html .= '
<script type="text/javascript">$(\'#calendar\').slideToggle();</script>
<h2 style="float:left">'.$this->l('Stock value').'</h2>
<form action="'.$ru.'" method="post" style="float:right">
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Stock value').'</legend>
<form action="'.$ru.'" method="post">
<input type="hidden" name="submitCategory" value="1" />
'.$this->l('Category').' : <select name="statsstock_id_category" onchange="this.form.submit();">
<option value="0">-- '.$this->l('All').' --</option>';
foreach (Category::getSimpleCategories($this->context->language->id) as $category)
echo '<option value="'.(int)$category['id_category'].'" '.($this->context->cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '').'>'.$category['name'].'</option>';
echo ' </select>
</form>
<div style="clear:both">&nbsp;</div>';
$this->html .= '<option value="'.(int)$category['id_category'].'" '.
($this->context->cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '').'>'.
$category['name'].'
</option>';
$this->html .= '</select>
</form><br />';
if (!count($products))
echo $this->l('Your catalog is empty.');
$this->html .= $this->l('Your catalog is empty.');
else
{
$rollup = array('quantity' => 0, 'wholesale_price' => 0, 'stockvalue' => 0);
echo '<table class="table" cellspacing="0" cellpadding="0">
$this->html .= '<table class="table" cellspacing="0" cellpadding="0">
<tr>
<th>'.$this->l('ID').'</th>
<th>'.$this->l('Ref.').'</th>
@@ -111,7 +116,7 @@ class StatsStock extends Module
$rollup['quantity'] += $product['quantity'];
$rollup['wholesale_price'] += $product['wholesale_price'];
$rollup['stockvalue'] += $product['stockvalue'];
echo '<tr>
$this->html .= '<tr>
<td>'.$product['id_product'].'</td>
<td>'.$product['reference'].'</td>
<td>'.$product['name'].'</td>
@@ -120,7 +125,7 @@ class StatsStock extends Module
<td>'.Tools::displayPrice($product['stockvalue'], $currency).'</td>
</tr>';
}
echo '
$this->html .= '
<tr>
<th colspan="3"></th>
<th>'.$this->l('Total stock').'</th>
@@ -134,7 +139,9 @@ class StatsStock extends Module
<td>'.Tools::displayPrice($rollup['stockvalue'], $currency).'</td>
</tr>
</table>
<p>* '.$this->l('Average price when the product has attributes.').'</p>';
<p>* '.$this->l('Average price when the product has attributes.').'</p></fieldset>';
return $this->html;
}
}
}
}