diff --git a/admin-dev/tabs/AdminStatsTab.php b/admin-dev/tabs/AdminStatsTab.php
deleted file mode 100644
index 3ad6c27f5..000000000
--- a/admin-dev/tabs/AdminStatsTab.php
+++ /dev/null
@@ -1,238 +0,0 @@
-
-* @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 '
-
';
- }
-
- 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 '
- '.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')
- )).'
-
';
- }
-
- public static function displayCalendarStatic($translations)
- {
- $context = Context::getContext();
- includeDatepicker(array('datepickerFrom', 'datepickerTo'));
- return '
- '.$translations['Calendar'].'
-
- ';
- }
-
- public function displaySearch()
- {
- return;
- echo '
- '.$this->l('Search', 'AdminStatsTab').'
-
- ';
- }
-
- 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 ' '.$this->l('Navigation', 'AdminStatsTab').' ';
- if (sizeof($modules))
- {
- foreach ($modules AS $module)
- if ($moduleInstance = Module::getInstanceByName($module['name']))
- echo '';
- }
- else
- echo $this->l('No module installed', 'AdminStatsTab');
- echo '
';
- }
-
- public function display()
- {
- echo '';
- $this->displayCalendar();
- $this->displayEngines();
- $this->displayMenu();
- $this->displaySearch();
- echo '
- ';
-
- 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 '
'.$this->l('Please select a module in the left column.').' ';
- echo '
';
- }
-}
-
-
diff --git a/classes/AdminController.php b/classes/AdminController.php
index 97c9db315..60102b4c5 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -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;
'.$this->l('Choose language:').'
';
foreach ($languages as $language)
- if($use_vars_instead_of_ids)
+ if ($use_vars_instead_of_ids)
$output .= '
';
else
$output .= '
';
diff --git a/classes/ModuleGraphEngine.php b/classes/ModuleGraphEngine.php
index 274deff68..5eb593a63 100644
--- a/classes/ModuleGraphEngine.php
+++ b/classes/ModuleGraphEngine.php
@@ -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);
diff --git a/classes/ModuleGridEngine.php b/classes/ModuleGridEngine.php
index 18932c0e6..81ef96ee8 100644
--- a/classes/ModuleGridEngine.php
+++ b/classes/ModuleGridEngine.php
@@ -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);
diff --git a/admin-dev/tabs/AdminStats.php b/controllers/admin/AdminStatsController.php
similarity index 91%
rename from admin-dev/tabs/AdminStats.php
rename to controllers/admin/AdminStatsController.php
index 518816a9d..e1d566036 100644
--- a/admin-dev/tabs/AdminStats.php
+++ b/controllers/admin/AdminStatsController.php
@@ -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
{
-}
-
-
+}
\ No newline at end of file
diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php
new file mode 100644
index 000000000..1e14a723b
--- /dev/null
+++ b/controllers/admin/AdminStatsTabController.php
@@ -0,0 +1,232 @@
+
+* @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;
+ }
+}
\ No newline at end of file
diff --git a/modules/pagesnotfound/pagesnotfound.php b/modules/pagesnotfound/pagesnotfound.php
index 22d08312a..1652107c5 100644
--- a/modules/pagesnotfound/pagesnotfound.php
+++ b/modules/pagesnotfound/pagesnotfound.php
@@ -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 .= '
'.$this->l('Pages not found has been emptied.').'
';
}
- 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 .= '
'.$this->l('Pages not found have been deleted.').'
';
}
- $this->_html .= '
'.$this->displayName.' ';
+ $this->_html .= ' '.$this->displayName.' ';
if (!file_exists(dirname(__FILE__).'/../../.htaccess'))
$this->_html .= ''.$this->l('You must use a .htaccess file to redirect 404 errors to the page "404.php"').'
';
-
+
$pages = $this->getPages();
- if (sizeof($pages))
+ if (count($pages))
{
$this->_html .= '
@@ -137,42 +137,52 @@ class Pagesnotfound extends Module
$this->_html .= ' '.$this->l('No pages registered').'
';
$this->_html .= '';
- if (sizeof($pages))
+ if (count($pages))
$this->_html .= '
- '.$this->l('Empty database').'
+ '.$this->l('Empty database').'
';
- $this->_html .= '
- '.$this->l('Guide').'
+ $this->_html .= '
+ '.$this->l('Guide').'
'.$this->l('404 errors').'
- '.$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.').'
+ '.$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.').'
'.$this->l('How to catch these errors?').'
- '.$this->l('If your webhost supports the .htaccess file, you can create it in the root directory of PrestaShop and insert the following line inside:').' ErrorDocument 404 '.__PS_BASE_URI__.'404.php . '.$this->l('A user requesting a page which doesn\'t exist will be redirected to the page.').' '.__PS_BASE_URI__.'404.php . '.$this->l('This module logs the accesses to this page: the page requested, the referrer and the number of times that it occurred.').'
+ '.$this->l('If your webhost supports the .htaccess file, you can create it in the root directory of PrestaShop and insert the following line inside:').'
+ ErrorDocument 404 '.__PS_BASE_URI__.'404.php . '.
+ $this->l('A user requesting a page which doesn\'t exist will be redirected to the page.').' '.__PS_BASE_URI__.'404.php . '.
+ $this->l('This module logs the accesses to this page: the page requested, the referrer and the number of times that it occurred.').'
';
- 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;
}
\ No newline at end of file
diff --git a/modules/sekeywords/sekeywords.php b/modules/sekeywords/sekeywords.php
index f9f386fa5..a701d774e 100644
--- a/modules/sekeywords/sekeywords.php
+++ b/modules/sekeywords/sekeywords.php
@@ -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 = ' '.$this->displayName.'
+ $this->html = ' '.$this->displayName.'
'.$total.' '.($total == 1 ? $this->l('keyword matches your query.') : $this->l('keywords match your query.')).'
';
- if ($result AND $total)
+ if ($result && $total)
{
$table = '
@@ -123,27 +123,31 @@ class SEKeywords extends ModuleGraph
$table .= '
'.$keyword.' '.$occurences.' ';
}
$table .= '
';
- $this->_html .= ''.$this->engine(array('type' => 'pie')).'
+ $this->html .= ''.$this->engine(array('type' => 'pie')).'
'.$this->l('CSV Export').'
'.$table;
}
else
- $this->_html .= ''.$this->l('No keywords').'
';
+ $this->html .= ''.$this->l('No keywords').'
';
- $this->_html .= '
- '.$this->l('Guide').'
+ $this->html .= '
+ '.$this->l('Guide').'
'.$this->l('Identify external search engines\' keywords').'
- '.$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.').'
+ '.$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.').'
+
'.$this->l('How does it work?').'
- '.$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:').' Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila '.$this->l('and').' Altavista . '.$this->l('Soon it will be possible to dynamically add new search engines and contribute to this module.').'
+ '.$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:').' Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila '.$this->l('and').' Altavista . '.
+ $this->l('Soon it will be possible to dynamically add new search engines and contribute to this module.').'
';
- 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;
diff --git a/modules/statsbestcategories/statsbestcategories.php b/modules/statsbestcategories/statsbestcategories.php
index 8199212e4..8b95662fc 100644
--- a/modules/statsbestcategories/statsbestcategories.php
+++ b/modules/statsbestcategories/statsbestcategories.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
';
@@ -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()');
diff --git a/modules/statsbestcustomers/statsbestcustomers.php b/modules/statsbestcustomers/statsbestcustomers.php
index e4480a42c..99d8be6ee 100644
--- a/modules/statsbestcustomers/statsbestcustomers.php
+++ b/modules/statsbestcustomers/statsbestcustomers.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
- '.$this->l('Guide').'
+ '.$this->l('Guide').'
'.$this->l('Develop clients\' loyalty').'
'.$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.').'
'.$this->l('Word of mouth is also a means to of getting new, satisfied clients; a dissatisfied one won\'t attract new clients.').'
'.$this->l('In order to achieve this goal you can organize: ').'
- '.$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).').'
- '.$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).').'
+ '.$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).').'
+ '.$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).').'
'.$this->l('These operations encourage clients to buy products and visit your webshop regularly.').'
@@ -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()');
diff --git a/modules/statsbestmanufacturers/statsbestmanufacturers.php b/modules/statsbestmanufacturers/statsbestmanufacturers.php
index aee265202..771df0f89 100755
--- a/modules/statsbestmanufacturers/statsbestmanufacturers.php
+++ b/modules/statsbestmanufacturers/statsbestmanufacturers.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
';
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);
}
diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php
index 6933c50a3..5db4e40fb 100644
--- a/modules/statsbestproducts/statsbestproducts.php
+++ b/modules/statsbestproducts/statsbestproducts.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
';
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()');
diff --git a/modules/statsbestsuppliers/statsbestsuppliers.php b/modules/statsbestsuppliers/statsbestsuppliers.php
index da9e119bc..08288d7c5 100644
--- a/modules/statsbestsuppliers/statsbestsuppliers.php
+++ b/modules/statsbestsuppliers/statsbestsuppliers.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
';
@@ -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);
}
diff --git a/modules/statsbestvouchers/statsbestvouchers.php b/modules/statsbestvouchers/statsbestvouchers.php
index f869345ee..8eccbecd9 100644
--- a/modules/statsbestvouchers/statsbestvouchers.php
+++ b/modules/statsbestvouchers/statsbestvouchers.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->engine($engineParams).'
'.$this->l('CSV Export').'
';
@@ -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()');
diff --git a/modules/statscarrier/statscarrier.php b/modules/statscarrier/statscarrier.php
index 481d8e8ba..9e186d973 100644
--- a/modules/statscarrier/statscarrier.php
+++ b/modules/statscarrier/statscarrier.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->l('This graph represents the carrier distribution for your orders. You can also limit it to orders in one state.').'
- '.($result['total'] ? $this->engine(array('type' => 'pie', 'option' => Tools::getValue('id_order_state'))).' '.$this->l('CSV Export').' ' : $this->l('No valid orders for this period.')).'
+ '.($result['total'] ? $this->engine(array('type' => 'pie', 'option' => Tools::getValue('id_order_state'))).' '.$this->l('CSV Export').' ' : $this->l('No valid orders for this period.')).'
';
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'];
}
}
}
diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php
index 827774bd0..cb2eb9da6 100644
--- a/modules/statscatalog/statscatalog.php
+++ b/modules/statscatalog/statscatalog.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->l('Choose a category').'
@@ -178,23 +178,25 @@ class StatsCatalog extends Module
'.$this->l('All').' ';
foreach ($categories as $category)
- $html .= ''.$category['name'].' ';
+ $html .= ''.
+ $category['name'].'
+ ';
$html .= '
- '.$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(''.$this->l('Products never purchased:').' ', (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(''.$this->l('Products never purchased:').' ', (int)$totalNB.' / '.(int)$total).'
'.$this->returnLine($this->l('Conversion rate*:'), $conversion).'
@@ -203,10 +205,10 @@ class StatsCatalog extends Module
';
- if (sizeof($productsNB) AND sizeof($productsNB) < 50)
+ if (count($productsNB) && count($productsNB) < 50)
{
- $html .= '
- '.$this->l('Products never purchased').'
+ $html .= '
+ '.$this->l('Products never purchased').'
'.$this->l('ID').' '.$this->l('Name').' '.$this->l('Edit / View').' ';
foreach ($productsNB as $product)
diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php
index c9ff411c9..79989554c 100644
--- a/modules/statscheckup/statscheckup.php
+++ b/modules/statscheckup/statscheckup.php
@@ -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 ' '.$this->l('Configuration updated').'
';
}
@@ -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 = '
-
-
-
-
+
'.$this->l('ID').'
'.$this->l('Item').'
'.$this->l('Active').' ';
foreach ($languages as $language)
- $html .= ''.$this->l('Desc.').' ('.strtoupper($language['iso_code']).') ';
- $html .= '
+ $this->html .= ''.$this->l('Desc.').' ('.strtoupper($language['iso_code']).') ';
+ $this->html .= '
'.$this->l('Images').'
'.$this->l('Sales').'
'.$this->l('Stock').'
@@ -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 .= '
+ $this->html .= '
'.$row['id_product'].'
'.Tools::substr($row['name'], 0, 42).'
'.$arrayColors[$scores['active']].' ';
foreach ($languages as $language)
if (isset($row['desclength_'.$language['iso_code']]))
- $html .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$arrayColors[$scores['description_'.$language['iso_code']]].' ';
+ $this->html .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$arrayColors[$scores['description_'.$language['iso_code']]].' ';
else
- $html .= '0 '.$arrayColors[0].' ';
- $html .= '
+ $this->html .= '0 '.$arrayColors[0].' ';
+ $this->html .= '
'.(int)$row['nbImages'].' '.$arrayColors[$scores['images']].'
'.(int)$row['nbSales'].' '.$arrayColors[$scores['sales']].'
'.(int)$row['stock'].' '.$arrayColors[$scores['stock']].'
@@ -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 .= '
'.$this->l('Active').' ';
foreach ($languages as $language)
- $html .= ''.$this->l('Desc.').' ('.strtoupper($language['iso_code']).') ';
- $html .= '
+ $this->html .= ''.$this->l('Desc.').' ('.strtoupper($language['iso_code']).') ';
+ $this->html .= '
'.$this->l('Images').'
'.$this->l('Sales').'
'.$this->l('Stock').'
@@ -253,19 +290,16 @@ class StatsCheckUp extends Module
'.$arrayColors[$totals['active']].' ';
foreach ($languages as $language)
- $html .= ''.$arrayColors[$totals['description_'.$language['iso_code']]].' ';
- $html .= '
+ $this->html .= ''.$arrayColors[$totals['description_'.$language['iso_code']]].' ';
+ $this->html .= '
'.$arrayColors[$totals['images']].'
'.$arrayColors[$totals['sales']].'
'.$arrayColors[$totals['stock']].'
'.$arrayColors[$totals['average']].'
-
- ';
+
';
- return $html;
- }
+ return $this->html;
+ }
}
\ No newline at end of file
diff --git a/modules/statsequipment/statsequipment.php b/modules/statsequipment/statsequipment.php
index c417a91da..f3715375b 100644
--- a/modules/statsequipment/statsequipment.php
+++ b/modules/statsequipment/statsequipment.php
@@ -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 = '
- '.$this->displayName.'
-
- '.$this->l('Determine the percentage of web browsers used by your customers.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'wb')).'
- '.$this->l('CSV Export').'
- '.$this->l('Determine the percentage of operating systems used by your customers.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'os')).'
- '.$this->l('CSV Export').'
';
-
- if ($equipment)
- {
- $this->_html .= '
- '.$this->l('Plug-ins').' ';
- foreach ($equipment as $name => $value)
- $this->_html .= ''.$name.' '.number_format(100 * $value, 2).'% ';
- $this->_html .= '
';
- }
- $this->_html .= '
-
-
- '.$this->l('Guide').'
+ $this->html = '
+ '.$this->displayName.'
+ '.$this->l('Determine the percentage of web browsers used by your customers.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'wb')).'
+ '.$this->l('CSV Export').'
+ '.$this->l('Determine the percentage of operating systems used by your customers.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'os')).'
+ '.$this->l('CSV Export').'
';
+
+ if ($equipment)
+ {
+ $this->html .= '
+ '.$this->l('Plug-ins').' ';
+ foreach ($equipment as $name => $value)
+ $this->html .= ''.$name.' '.number_format(100 * $value, 2).'% ';
+ $this->html .= '
';
+ }
+ $this->html .= '
+
+
+ '.$this->l('Guide').'
'.$this->l('Ensure that your website is accessible to all.').'
- '.$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.').'
';
- 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'];
}
}
}
diff --git a/modules/statsforecast/statsforecast.php b/modules/statsforecast/statsforecast.php
index f0ae33a0a..e92f4ab2d 100644
--- a/modules/statsforecast/statsforecast.php
+++ b/modules/statsforecast/statsforecast.php
@@ -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 .= '
+ $this->_html .= '
'.$this->displayName.'
'.$this->l('All amounts are without taxes.').'
-
+
'.$this->l('Category distribution').'
@@ -406,7 +406,7 @@ class StatsForecast extends Module
$this->_html .= '
-
+
'.$this->l('Language distribution').'
'.$this->l('Customers').' '.$this->l('Sales').' '.$this->l('%').' '.$this->l('Growth').' ';
@@ -425,7 +425,7 @@ class StatsForecast extends Module
$this->_html .= '
-
+
'.$this->l('Zone distribution').'
'.$this->l('Zone').' '.$this->l('Count').' '.$this->l('Total').' '.$this->l('% Count').' '.$this->l('% Sales').' ';
@@ -441,7 +441,7 @@ class StatsForecast extends Module
$this->_html .= '
-
+
'.$this->l('Currency distribution').'
@@ -465,7 +465,7 @@ class StatsForecast extends Module
$this->_html .= '
-
+
'.$this->l('Attribute distribution').'
'.$this->l('Group').' '.$this->l('Attribute').' '.$this->l('Count').' ';
diff --git a/modules/statslive/statslive.php b/modules/statslive/statslive.php
index 22af37685..bada7efaa 100644
--- a/modules/statslive/statslive.php
+++ b/modules/statslive/statslive.php
@@ -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 '';
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
- echo ''.$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.').'
';
- echo '
- '.$this->l('Customers online').' ';
+ $this->html .= ''.
+ $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.').'
+
';
+ $this->html .= '
+ '.$this->l('Customers online').' ';
if ($totalCustomers)
{
- echo $this->l('Total:').' '.(int)($totalCustomers).'
+ $this->html .= $this->l('Total:').' '.(int)$totalCustomers.'
'.$this->l('ID').' '.$this->l('Name').' '.$this->l('Current Page').' '.$this->l('View').' ';
foreach ($customers as $customer)
- echo '
+ $this->html .= '
'.$customer['id_customer'].'
'.$customer['firstname'].' '.$customer['lastname'].'
'.$customer['page'].'
-
+
';
- echo '
';
+ $this->html .= '
';
}
else
- echo $this->l('There are no customers online.');
- echo '
- '.$this->l('Visitors online').' ';
+ $this->html .= $this->l('There are no customers online.');
+ $this->html .= '
+
+ '.$this->l('Visitors online').' ';
if ($totalVisitors)
{
- echo $this->l('Total:').' '.(int)($totalVisitors).'
+ $this->html .= $this->l('Total:').' '.(int)($totalVisitors).'
'.$this->l('Guest').' '.$this->l('IP').' '.$this->l('Since').' '.$this->l('Current page').' '.$this->l('Referrer').' ';
foreach ($visitors as $visitor)
- echo '
+ $this->html .= '
'.$visitor['id_guest'].'
'.long2ip($visitor['ip_address']).'
'.substr($visitor['date_add'], 11).'
'.(isset($visitor['page']) ? $visitor['page'] : $this->l('Undefined')).'
'.(empty($visitor['http_referer']) ? $this->l('none') : parse_url($visitor['http_referer'], PHP_URL_HOST)).'
';
- echo '
';
+ $this->html .= '';
}
else
- echo $this->l('There are no visitors online.');
- echo ' ';
+ $this->html .= $this->l('There are no visitors online.');
+ $this->html .= ' ';
+
+ return $this->html;
}
}
diff --git a/modules/statsnewsletter/statsnewsletter.php b/modules/statsnewsletter/statsnewsletter.php
index d6f41999e..99465d2d6 100644
--- a/modules/statsnewsletter/statsnewsletter.php
+++ b/modules/statsnewsletter/statsnewsletter.php
@@ -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 = '
- '.$this->displayName.'
- '.$this->l('Registrations from customers:').' '.(int)($totals['customers']).'
- '.$this->l('Registrations from visitors:').' '.(int)($totals['visitors']).'
- '.$this->l('Both:').' '.(int)($totals['both']).'
- '.$this->engine(array('type' => 'line', 'layers' => 3)).'
+ '.$this->displayName.'
+ '.$this->l('Registrations from customers:').' '.(int)$totals['customers'].'
+ '.$this->l('Registrations from visitors:').' '.(int)$totals['visitors'].'
+ '.$this->l('Both:').' '.(int)$totals['both'].'
+ '.$this->engine(array('type' => 'line', 'layers' => 3)).'
'.$this->l('CSV Export').'
';
}
@@ -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];
}
diff --git a/modules/statsorigin/statsorigin.php b/modules/statsorigin/statsorigin.php
index ed5354299..0333748bd 100644
--- a/modules/statsorigin/statsorigin.php
+++ b/modules/statsorigin/statsorigin.php
@@ -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 = ' '.$this->l('Origin').' ';
- if (sizeof($websites))
+ $this->_html = ' '.$this->l('Origin').' ';
+ if (count($websites))
{
$this->_html .= '
- '. $this->l('Here is the percentage of the 10 most popular referrer websites by which visitors went through to get to your shop.').'
- '.$this->engine(array('type' => 'pie')).'
+ '.$this->l('Here is the percentage of the 10 most popular referrer websites by which visitors went through to get to your shop.').'
+ '.$this->engine(array('type' => 'pie')).'
'.$this->l('CSV Export').'
-
+
'.$this->l('Origin').'
'.$this->l('Total').'
';
foreach ($websites as $website => $total)
- $this->_html .= ''.(!strstr($website, ' ') ? '' : '').$website.(!strstr($website, ' ') ? ' ' : '').' '.$total.' ';
- $this->_html .= '
';
+ $this->_html .= '
+ '.(!strstr($website, ' ') ? '' : '').$website.(!strstr($website, ' ') ? ' ' : '').' '.$total.'
+ ';
+ $this->_html .= '';
}
else
$this->_html .= ''.$this->l('Direct links only').'
';
$this->_html .= '
- '.$this->l('Guide').'
+ '.$this->l('Guide').'
'.$this->l('What is a referrer website?').'
'.$this->l('When visiting a webpage, the referrer is the URL of the previous webpage from which a link was followed.').'
'.$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.').'
- '. $this->l('A referrer can be:').'
+ '.$this->l('A referrer can be:').'
- '. $this->l('Someone who put a link on their website for your shop').'
- '. $this->l('A partner with whom you made a link exchange in order to bring in sales or attract new customers').'
+ '.$this->l('Someone who put a link on their website for your shop').'
+ '.$this->l('A partner with whom you made a link exchange in order to bring in sales or attract new customers').'
';
return $this->_html;
}
-
+
protected function getData($layers)
{
$this->_titles['main'] = $this->l('First 10 websites');
diff --git a/modules/statspersonalinfos/statspersonalinfos.php b/modules/statspersonalinfos/statspersonalinfos.php
index df5c4ff80..59efc62b2 100644
--- a/modules/statspersonalinfos/statspersonalinfos.php
+++ b/modules/statspersonalinfos/statspersonalinfos.php
@@ -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 = ' '.$this->displayName.' ';
- if (sizeof(Customer::getCustomers()))
+ $this->html = ' '.$this->displayName.' ';
+ 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 .= '
-
- '.$this->l('Gender distribution allows you to determine the percentage of men and women among your customers.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'gender')).'
+ $this->html .= '
+ '.$this->l('Gender distribution allows you to determine the percentage of men and women among your customers.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'gender')).'
'.$this->l('CSV Export').'
- '.$this->l('Age ranges allows you to determine in which age range your customers are.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'age')).'
+ '.$this->l('Age ranges allows you to determine in which age range your customers are.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'age')).'
'.$this->l('CSV Export').'
- '.$this->l('Country distribution allows you to determine in which part of the world your customers are shopping from.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'country')).'
+ '.$this->l('Country distribution allows you to determine in which part of the world your customers are shopping from.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'country')).'
'.$this->l('CSV Export').'
- '.$this->l('Currency ranges allows you to determine which currencies your customers are using.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'currency')).'
+ '.$this->l('Currency ranges allows you to determine which currencies your customers are using.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'currency')).'
'.$this->l('CSV Export').'
- '.$this->l('Language distribution allows you to determine the general languages your customers are using on your shop.').'
- '.$this->engine(array('type' => 'pie', 'option' => 'language')).'
+ '.$this->l('Language distribution allows you to determine the general languages your customers are using on your shop.').'
+ '.$this->engine(array('type' => 'pie', 'option' => 'language')).'
'.$this->l('CSV Export').'
';
}
else
- $this->_html .= ''.$this->l('No customers registered yet.').'
';
- $this->_html .= '
+ $this->html .= ''.$this->l('No customers registered yet.').'
';
+ $this->html .= '
- '.$this->l('Guide').'
+ '.$this->l('Guide').'
'.$this->l('Target your audience').'
'.$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
';
- 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;
}
diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php
index 4d1000f9d..6663bf41a 100644
--- a/modules/statsproduct/statsproduct.php
+++ b/modules/statsproduct/statsproduct.php
@@ -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 = ' '.$this->displayName.' ';
- if ($id_product = (int)(Tools::getValue('id_product')))
+ $this->html = ' '.$this->displayName.' ';
+ 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 .= ''.$product->name.' - '.$this->l('Details').'
+ $this->html .= ''.$product->name.' - '.$this->l('Details').'
'.$this->l('Total bought:').' '.$totalBought.'
'.$this->l('Sales (-Tx):').' '.Tools::displayprice($totalSales, $currency).'
'.$this->l('Total viewed:').' '.$totalViewed.'
@@ -175,15 +175,15 @@ class StatsProduct extends ModuleGraph
'.$this->engine(array('layers' => 2, 'type' => 'line', 'option' => '1-'.$id_product)).'
'.$this->l('CSV Export').'
';
- if ($hasAttribute = $product->hasAttributes() AND $totalBought)
- $this->_html .= ''.$this->l('Attribute sales distribution').' '.$this->engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'
+ if ($hasAttribute = $product->hasAttributes() && $totalBought)
+ $this->html .= ''.$this->l('Attribute sales distribution').' '.$this->engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'
'.$this->l('CSV Export').'
';
if ($totalBought)
{
$sales = $this->getSales($id_product, $this->context->language->id);
- $this->_html .= '
+ $this->html .= '
'.$this->l('Sales').'
-
+
@@ -195,24 +195,24 @@ class StatsProduct extends ModuleGraph
'.$this->l('Price').'
';
- $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 .= '
- '.Tools::displayDate($sale['date_add'], (int)($this->context->language->id), false).'
+ '.Tools::displayDate($sale['date_add'], (int)$this->context->language->id, false).'
'.(int)($sale['id_order']).'
'.(int)($sale['id_customer']).'
'.($hasAttribute ? ''.$sale['product_name'].' ' : '').'
- '.(int)($sale['product_quantity']).'
+ '.(int)$sale['product_quantity'].'
'.Tools::displayprice($sale['total'], $currency).'
';
- $this->_html .= '
';
+ $this->html .= '
';
$crossSelling = $this->getCrossSales($id_product, $this->context->language->id);
if (count($crossSelling))
{
- $this->_html .= '
+ $this->html .= '
'.$this->l('Cross Selling').'
@@ -223,30 +223,30 @@ class StatsProduct extends ModuleGraph
'.$this->l('Average price').'
';
- $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 .= '
- '.$selling['pname'].'
- '.(int)($selling['pqty']).'
+ '.$selling['pname'].'
+ '.(int)$selling['pqty'].'
'.Tools::displayprice($selling['pprice'], $currency).'
';
- $this->_html .= '
';
+ $this->html .= '';
}
}
}
else
{
$categories = Category::getCategories((int)$this->context->language->id, true, false);
- $this->_html .= '
+ $this->html .= '
'.$this->l('Choose a category').'
'.$this->l('All').' ';
foreach ($categories as $category)
- $this->_html .= ''.$category['name'].' ';
- $this->_html .= '
+ $this->html .= ''.$category['name'].' ';
+ $this->html .= '
@@ -265,25 +265,33 @@ class StatsProduct extends ModuleGraph
';
foreach ($this->getProducts($this->context->language->id) as $product)
- $this->_html .= ''.$product['reference'].' '.$product['name'].' '.$product['quantity'].' ';
+ $this->html .= '
+
+ '.$product['reference'].'
+
+ '.$product['name'].'
+
+ '.$product['quantity'].'
+ ';
- $this->_html .= '
+ $this->html .= '
'.$this->l('CSV Export').' ';
}
- $this->_html .= '
- '.$this->l('Guide').'
+ $this->html .= '
+ '.$this->l('Guide').'
'.$this->l('Number of purchases compared to number of viewings').'
'.$this->l('After choosing a category and selecting a product, informational graphs will appear. Then, you will be able to analyze them.').'
'.$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.').'
- '.$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.').'
+ '.$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.').'
';
- 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'];
}
}
}
\ No newline at end of file
diff --git a/modules/statsregistrations/statsregistrations.php b/modules/statsregistrations/statsregistrations.php
index 535914a95..1f5713b6a 100644
--- a/modules/statsregistrations/statsregistrations.php
+++ b/modules/statsregistrations/statsregistrations.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->l('Visitors who have stopped at the registering step:').' '.(int)($totalBlocked).($totalRegistrations ? ' ('.number_format(100*$totalBlocked/($totalRegistrations+$totalBlocked), 2).'%)' : '').'
'.$this->l('Visitors who have placed an order directly after registration:').' '.(int)($totalBuyers).($totalRegistrations ? ' ('.number_format(100*$totalBuyers/($totalRegistrations), 2).'%)' : '').'
'.$this->l('Total customer accounts:').' '.$totalRegistrations.'
- '.$this->engine(array('type' => 'line')).'
+ '.$this->engine(array('type' => 'line')).'
'.$this->l('CSV Export').'
- '.$this->l('Guide').'
+ '.$this->l('Guide').'
'.$this->l('Number of customer accounts created').'
'.$this->l('The total number of accounts created is not in itself important information. However, it is beneficial to analyze the number created over time. This will indicate whether or not things are on the right track.').'
'.$this->l('How to act on the registrations\' evolution?').'
@@ -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))]++;
}
}
diff --git a/modules/statssales/statssales.php b/modules/statssales/statssales.php
index 76e227870..da50613ff 100644
--- a/modules/statssales/statssales.php
+++ b/modules/statssales/statssales.php
@@ -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 = '
- '.$this->displayName.'
+ '.$this->displayName.'
'.$this->l('All').' ';
@@ -76,15 +76,15 @@ class StatsSales extends ModuleGraph
$this->_html .= '
-
+
'.$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.').'
-
+
'.$this->l('Orders placed:').' '.(int)($totals['orderCount']).'
'.$this->l('Products bought:').' '.(int)($totals['products']).'
- '.$this->engine(array('type' => 'line', 'option' => '1-'.(int)Tools::getValue('id_country'), 'layers' => 2)).'
+ '.$this->engine(array('type' => 'line', 'option' => '1-'.(int)Tools::getValue('id_country'), 'layers' => 2)).'
'.$this->l('CSV Export').'
'.$this->l('Sales:').' '.Tools::displayPrice($totals['orderSum'], $currency).'
- '.$this->engine(array('type' => 'line', 'option' => '2-'.(int)Tools::getValue('id_country'))).'
+ '.$this->engine(array('type' => 'line', 'option' => '2-'.(int)Tools::getValue('id_country'))).'
'.$this->l('CSV Export').'
'.$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.')).'
'.$this->l('CSV Export').'
-
- '.$this->l('Guide').'
+
+ '.$this->l('Guide').'
'.$this->l('Various order statuses').'
'.$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.').'
@@ -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'];
}
}
}
diff --git a/modules/statssearch/statssearch.php b/modules/statssearch/statssearch.php
index 6fc4e9b4c..bb05b08f4 100644
--- a/modules/statssearch/statssearch.php
+++ b/modules/statssearch/statssearch.php
@@ -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 = '
-
'.$this->displayName.' ';
+ '.$this->displayName.' ';
$table = '
@@ -120,8 +120,8 @@ class StatsSearch extends ModuleGraph
}
$table .= '
';
- if (sizeof($result))
- $this->_html .= ''.$this->engine(array('type' => 'pie')).'
+ if (count($result))
+ $this->_html .= ''.$this->engine(array('type' => 'pie')).'
'.$this->l('CSV Export').'
'.$table;
else
diff --git a/modules/statsstock/statsstock.php b/modules/statsstock/statsstock.php
index 3dc818492..592985b6e 100644
--- a/modules/statsstock/statsstock.php
+++ b/modules/statsstock/statsstock.php
@@ -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 .= '
- '.$this->l('Stock value').'
-
+ '.$this->l('Stock value').'
+
'.$this->l('Category').' :
-- '.$this->l('All').' -- ';
foreach (Category::getSimpleCategories($this->context->language->id) as $category)
- echo 'context->cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '').'>'.$category['name'].' ';
- echo '
-
-
';
+ $this->html .= 'context->cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '').'>'.
+ $category['name'].'
+ ';
+ $this->html .= '
+ ';
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 '
+ $this->html .= '
'.$this->l('ID').'
'.$this->l('Ref.').'
@@ -111,7 +116,7 @@ class StatsStock extends Module
$rollup['quantity'] += $product['quantity'];
$rollup['wholesale_price'] += $product['wholesale_price'];
$rollup['stockvalue'] += $product['stockvalue'];
- echo '
+ $this->html .= '
'.$product['id_product'].'
'.$product['reference'].'
'.$product['name'].'
@@ -120,7 +125,7 @@ class StatsStock extends Module
'.Tools::displayPrice($product['stockvalue'], $currency).'
';
}
- echo '
+ $this->html .= '
'.$this->l('Total stock').'
@@ -134,7 +139,9 @@ class StatsStock extends Module
'.Tools::displayPrice($rollup['stockvalue'], $currency).'
- * '.$this->l('Average price when the product has attributes.').'
';
+ * '.$this->l('Average price when the product has attributes.').'
';
+
+ return $this->html;
}
- }
+ }
}
\ No newline at end of file