diff --git a/admin-dev/themes/default/template/controllers/modules/content.tpl b/admin-dev/themes/default/template/controllers/modules/content.tpl
index 4e58e5b6d..58546be45 100644
--- a/admin-dev/themes/default/template/controllers/modules/content.tpl
+++ b/admin-dev/themes/default/template/controllers/modules/content.tpl
@@ -24,7 +24,6 @@
*}
{if isset($module_content)}
-
{$module_content}
{else}
{if !isset($smarty.get.configure)}
diff --git a/admin-dev/themes/default/template/controllers/modules/header.tpl b/admin-dev/themes/default/template/controllers/modules/header.tpl
index dd72657af..ec446c360 100644
--- a/admin-dev/themes/default/template/controllers/modules/header.tpl
+++ b/admin-dev/themes/default/template/controllers/modules/header.tpl
@@ -23,6 +23,8 @@
* International Registered Trademark & Property of PrestaShop SA
*}
+{$kpis}
+
{l s='List of modules'}
@@ -72,4 +74,3 @@
{/if}
-
diff --git a/admin-dev/themes/default/template/controllers/modules/page.tpl b/admin-dev/themes/default/template/controllers/modules/page.tpl
index 33d5ee9ab..89b756dc2 100644
--- a/admin-dev/themes/default/template/controllers/modules/page.tpl
+++ b/admin-dev/themes/default/template/controllers/modules/page.tpl
@@ -23,7 +23,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
-
{include file='controllers/modules/header.tpl'}
{if $upgrade_available|@count}
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 45697a700..d92a8afea 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -1365,7 +1365,7 @@ class AdminControllerCore extends Controller
$this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]);
foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type)
- $this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
+ $this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
$this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php
index c7bb1feb5..d228373cb 100644
--- a/controllers/admin/AdminModulesController.php
+++ b/controllers/admin/AdminModulesController.php
@@ -975,6 +975,51 @@ class AdminModulesControllerCore extends AdminController
return false;
}
+ public function renderKpis()
+ {
+ $time = time();
+ $kpis = array();
+
+ /* The data generation is located in AdminStatsControllerCore */
+
+ $helper = new HelperKpi();
+ $helper->id = 'box-installed-modules';
+ $helper->icon = 'icon-puzzle-piece';
+ $helper->color = 'color1';
+ $helper->title = html_entity_decode($this->l('Installed Modules'));
+ if (ConfigurationKPI::get('INSTALLED_MODULES') !== false)
+ $helper->value = ConfigurationKPI::get('INSTALLED_MODULES');
+ if (ConfigurationKPI::get('INSTALLED_MODULES_EXPIRE') < $time)
+ $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=installed_modules';
+ $kpis[] = $helper->generate();
+
+ $helper = new HelperKpi();
+ $helper->id = 'box-disabled-modules';
+ $helper->icon = 'icon-off';
+ $helper->color = 'color2';
+ $helper->title = html_entity_decode($this->l('Disabled Modules'));
+ if (ConfigurationKPI::get('DISABLED_MODULES') !== false)
+ $helper->value = ConfigurationKPI::get('DISABLED_MODULES');
+ if (ConfigurationKPI::get('DISABLED_MODULES_EXPIRE') < $time)
+ $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_modules';
+ $kpis[] = $helper->generate();
+
+ $helper = new HelperKpi();
+ $helper->id = 'box-update-modules';
+ $helper->icon = 'icon-refresh';
+ $helper->color = 'color3';
+ $helper->title = html_entity_decode($this->l('Modules to update'));
+ if (ConfigurationKPI::get('UPDATE_MODULES') !== false)
+ $helper->value = ConfigurationKPI::get('UPDATE_MODULES');
+ if (ConfigurationKPI::get('UPDATE_MODULES_EXPIRE') < $time)
+ $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=update_modules';
+ $kpis[] = $helper->generate();
+
+ $helper = new HelperKpiRow();
+ $helper->kpis = $kpis;
+ return $helper->generate();
+ }
+
public function initContent()
{
// Adding Css
@@ -1003,8 +1048,8 @@ class AdminModulesControllerCore extends AdminController
$tab_modules_preferences = array();
$modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
$tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'tab_module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
-
- foreach($tab_modules_preferences_tmp as $i => $j)
+
+ foreach ($tab_modules_preferences_tmp as $i => $j)
$tab_modules_preferences[$j['module']][] = $j['id_tab'];
foreach ($modules_preferences_tmp as $k => $v)
@@ -1168,6 +1213,8 @@ class AdminModulesControllerCore extends AdminController
$tpl_vars['add_permission'] = $this->tabAccess['add'];
$tpl_vars['tab_modules_preferences'] = $tab_modules_preferences;
+ $tpl_vars['kpis'] = $this->renderKpis();
+
if ($this->logged_on_addons)
{
$tpl_vars['logged_on_addons'] = 1;
diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php
index 2040cb38b..f4ecc62c2 100644
--- a/controllers/admin/AdminStatsController.php
+++ b/controllers/admin/AdminStatsController.php
@@ -72,6 +72,38 @@ class AdminStatsControllerCore extends AdminStatsTabController
'.Shop::addSqlRestriction(Shop::SHARE_ORDER));
}
+ public static function getInstalledModules()
+ {
+ return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'module` m
+ '.Shop::addSqlAssociation('module', 'm'));
+ }
+
+ public static function getDisabledModules()
+ {
+ return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'module` m
+ '.Shop::addSqlAssociation('module', 'm').'
+ WHERE `active` = 0');
+ }
+
+ public static function getModulesToUpdate()
+ {
+ $context = Context::getContext();
+ $logged_on_addons = false;
+ if (isset($context->cookie->username_addons) && isset($context->cookie->password_addons)
+ && !empty($context->cookie->username_addons) && !empty($context->cookie->password_addons))
+ $logged_on_addons = true;
+ $modules = Module::getModulesOnDisk(true, $logged_on_addons, $context->employee->id);
+ $upgrade_available = 0;
+ foreach ($modules as $km => $module)
+ if ($module->installed && isset($module->version_addons) && (int)(string)$module->version_addons) // SimpleXMLElement
+ ++$upgrade_available;
+ return $upgrade_available;
+ }
+
public static function getPercentProductStock()
{
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
@@ -315,7 +347,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
else
$value = 0;
$value .= '%';
-
+
ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', Tools::jsonEncode($data));
ConfigurationKPI::updateValue('CONVERSION_RATE', $value);
ConfigurationKPI::updateValue('CONVERSION_RATE_EXPIRE', strtotime(date('Y-m-d 00:00:00', strtotime('+1 day'))));
@@ -327,6 +359,24 @@ class AdminStatsControllerCore extends AdminStatsTabController
ConfigurationKPI::updateValue('ABANDONED_CARTS_EXPIRE', strtotime('+10 min'));
break;
+ case 'installed_modules':
+ $value = AdminStatsController::getInstalledModules();
+ ConfigurationKPI::updateValue('INSTALLED_MODULES', $value);
+ ConfigurationKPI::updateValue('INSTALLED_MODULES_EXPIRE', strtotime('+2 min'));
+ break;
+
+ case 'disabled_modules':
+ $value = AdminStatsController::getDisabledModules();
+ ConfigurationKPI::updateValue('DISABLED_MODULES', $value);
+ ConfigurationKPI::updateValue('DISABLED_MODULES_EXPIRE', strtotime('+2 min'));
+ break;
+
+ case 'update_modules':
+ $value = AdminStatsController::getModulesToUpdate();
+ ConfigurationKPI::updateValue('UPDATE_MODULES', $value);
+ ConfigurationKPI::updateValue('UPDATE_MODULES_EXPIRE', strtotime('+2 min'));
+ break;
+
case 'percent_product_stock':
$value = AdminStatsController::getPercentProductStock();
ConfigurationKPI::updateValue('PERCENT_PRODUCT_STOCK', $value);