// Added Modules KPIs
This commit is contained in:
1 parent
797a6c121a
commit
d9b40b8f35
6 files changed
+103
-7
No files matched your search
@@ -24,7 +24,6 @@
|
|||||||
*}
|
*}
|
||||||
|
|
||||||
{if isset($module_content)}
|
{if isset($module_content)}
|
||||||
|
|
||||||
{$module_content}
|
{$module_content}
|
||||||
{else}
|
{else}
|
||||||
{if !isset($smarty.get.configure)}
|
{if !isset($smarty.get.configure)}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
|
{$kpis}
|
||||||
|
|
||||||
<div class="page-head">
|
<div class="page-head">
|
||||||
<h2 class="page-title">
|
<h2 class="page-title">
|
||||||
{l s='List of modules'}
|
{l s='List of modules'}
|
||||||
@@ -72,4 +74,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
|
|
||||||
{include file='controllers/modules/header.tpl'}
|
{include file='controllers/modules/header.tpl'}
|
||||||
|
|
||||||
{if $upgrade_available|@count}
|
{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]);
|
$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)
|
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);
|
$this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
|
||||||
|
|
||||||
|
|||||||
@@ -975,6 +975,51 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
return false;
|
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()
|
public function initContent()
|
||||||
{
|
{
|
||||||
// Adding Css
|
// Adding Css
|
||||||
@@ -1003,8 +1048,8 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$tab_modules_preferences = array();
|
$tab_modules_preferences = array();
|
||||||
$modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module_preference` WHERE `id_employee` = '.(int)$this->id_employee);
|
$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);
|
$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'];
|
$tab_modules_preferences[$j['module']][] = $j['id_tab'];
|
||||||
|
|
||||||
foreach ($modules_preferences_tmp as $k => $v)
|
foreach ($modules_preferences_tmp as $k => $v)
|
||||||
@@ -1168,6 +1213,8 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$tpl_vars['add_permission'] = $this->tabAccess['add'];
|
$tpl_vars['add_permission'] = $this->tabAccess['add'];
|
||||||
$tpl_vars['tab_modules_preferences'] = $tab_modules_preferences;
|
$tpl_vars['tab_modules_preferences'] = $tab_modules_preferences;
|
||||||
|
|
||||||
|
$tpl_vars['kpis'] = $this->renderKpis();
|
||||||
|
|
||||||
if ($this->logged_on_addons)
|
if ($this->logged_on_addons)
|
||||||
{
|
{
|
||||||
$tpl_vars['logged_on_addons'] = 1;
|
$tpl_vars['logged_on_addons'] = 1;
|
||||||
|
|||||||
@@ -72,6 +72,38 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
|||||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER));
|
'.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()
|
public static function getPercentProductStock()
|
||||||
{
|
{
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||||
@@ -315,7 +347,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
|||||||
else
|
else
|
||||||
$value = 0;
|
$value = 0;
|
||||||
$value .= '%';
|
$value .= '%';
|
||||||
|
|
||||||
ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', Tools::jsonEncode($data));
|
ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', Tools::jsonEncode($data));
|
||||||
ConfigurationKPI::updateValue('CONVERSION_RATE', $value);
|
ConfigurationKPI::updateValue('CONVERSION_RATE', $value);
|
||||||
ConfigurationKPI::updateValue('CONVERSION_RATE_EXPIRE', strtotime(date('Y-m-d 00:00:00', strtotime('+1 day'))));
|
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'));
|
ConfigurationKPI::updateValue('ABANDONED_CARTS_EXPIRE', strtotime('+10 min'));
|
||||||
break;
|
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':
|
case 'percent_product_stock':
|
||||||
$value = AdminStatsController::getPercentProductStock();
|
$value = AdminStatsController::getPercentProductStock();
|
||||||
ConfigurationKPI::updateValue('PERCENT_PRODUCT_STOCK', $value);
|
ConfigurationKPI::updateValue('PERCENT_PRODUCT_STOCK', $value);
|
||||||
|
|||||||
Reference in new issue
Block a user