// Added Modules KPIs
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
*}
|
||||
|
||||
{if isset($module_content)}
|
||||
|
||||
{$module_content}
|
||||
{else}
|
||||
{if !isset($smarty.get.configure)}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{$kpis}
|
||||
|
||||
<div class="page-head">
|
||||
<h2 class="page-title">
|
||||
{l s='List of modules'}
|
||||
@@ -72,4 +74,3 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
|
||||
{include file='controllers/modules/header.tpl'}
|
||||
|
||||
{if $upgrade_available|@count}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user