本文整理汇总了PHP中ConfigurationKPI::updateValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigurationKPI::updateValue方法的具体用法?PHP ConfigurationKPI::updateValue怎么用?PHP ConfigurationKPI::updateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigurationKPI
的用法示例。
在下文中一共展示了ConfigurationKPI::updateValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setMonths
public function setMonths($year)
{
$months = array();
for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1)) {
$months[$i . '_' . $year] = array('label' => Dashgoals::$month_labels[$i], 'values' => array());
}
foreach (Dashgoals::$types as $type) {
foreach ($months as $month => &$month_row) {
$key = 'dashgoals_' . $type . '_' . $month;
if (Tools::isSubmit('submitDashGoals')) {
ConfigurationKPI::updateValue(Tools::strtoupper($key), (double) Tools::getValue($key));
}
$month_row['values'][$type] = ConfigurationKPI::get(Tools::strtoupper($key));
}
}
return $months;
}
示例2: displayAjaxGetKpi
public function displayAjaxGetKpi()
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
switch (Tools::getValue('kpi')) {
case 'conversion_rate':
$visitors = AdminStatsController::getVisits(true, date('Y-m-d', strtotime('-31 day')), date('Y-m-d', strtotime('-1 day')), false);
$orders = AdminStatsController::getOrders(date('Y-m-d', strtotime('-31 day')), date('Y-m-d', strtotime('-1 day')), false);
// $data = array();
// $from = strtotime(date('Y-m-d 00:00:00', strtotime('-31 day')));
// $to = strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')));
// for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date))
// if (isset($visitors[$date]) && $visitors[$date])
// $data[$date] = round(100 * ((isset($orders[$date]) && $orders[$date]) ? $orders[$date] : 0) / $visitors[$date], 2);
// else
// $data[$date] = 0;
$visits_sum = $visitors;
//array_sum($visitors);
$orders_sum = $orders;
//array_sum($orders);
if ($visits_sum) {
$value = round(100 * $orders_sum / $visits_sum, 2);
} elseif ($orders_sum) {
$value = '∞';
} 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'))));
break;
case 'abandoned_cart':
$value = AdminStatsController::getAbandonedCarts(date('Y-m-d H:i:s', strtotime('-2 day')), date('Y-m-d H:i:s', strtotime('-1 day')));
ConfigurationKPI::updateValue('ABANDONED_CARTS', $value);
ConfigurationKPI::updateValue('ABANDONED_CARTS_EXPIRE', strtotime('+1 hour'));
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);
ConfigurationKPI::updateValue('PERCENT_PRODUCT_STOCK_EXPIRE', strtotime('+4 hour'));
break;
case 'product_avg_gross_margin':
$value = AdminStatsController::getProductAverageGrossMargin();
ConfigurationKPI::updateValue('PRODUCT_AVG_GROSS_MARGIN', $value);
ConfigurationKPI::updateValue('PRODUCT_AVG_GROSS_MARGIN_EXPIRE', strtotime('+6 hour'));
break;
case 'disabled_categories':
$value = AdminStatsController::getDisabledCategories();
ConfigurationKPI::updateValue('DISABLED_CATEGORIES', $value);
ConfigurationKPI::updateValue('DISABLED_CATEGORIES_EXPIRE', strtotime('+2 hour'));
break;
case 'disabled_products':
$value = AdminStatsController::getDisabledProducts();
ConfigurationKPI::updateValue('DISABLED_PRODUCTS', $value);
ConfigurationKPI::updateValue('DISABLED_PRODUCTS_EXPIRE', strtotime('+2 hour'));
break;
case '8020_sales_catalog':
$value = AdminStatsController::get8020SalesCatalog(date('Y-m-d', strtotime('-1 month')), date('Y-m-d'));
$value = sprintf($this->l('%d%% of your Catalog'), $value);
ConfigurationKPI::updateValue('8020_SALES_CATALOG', $value);
ConfigurationKPI::updateValue('8020_SALES_CATALOG_EXPIRE', strtotime('+12 hour'));
break;
case 'empty_categories':
$value = AdminStatsController::getEmptyCategories();
ConfigurationKPI::updateValue('EMPTY_CATEGORIES', $value);
ConfigurationKPI::updateValue('EMPTY_CATEGORIES_EXPIRE', strtotime('+2 hour'));
break;
case 'customer_main_gender':
$value = AdminStatsController::getCustomerMainGender();
if ($value === false) {
$value = $this->l('No customers', null, null, false);
} elseif ($value['type'] == 'female') {
$value = sprintf($this->l('%d%% Women Customers', null, null, false), $value['value']);
} elseif ($value['type'] == 'male') {
$value = sprintf($this->l('%d%% Men Customers', null, null, false), $value['value']);
} else {
$value = sprintf($this->l('%d%% Neutral Customers', null, null, false), $value['value']);
}
ConfigurationKPI::updateValue('CUSTOMER_MAIN_GENDER', array($this->context->language->id => $value));
ConfigurationKPI::updateValue('CUSTOMER_MAIN_GENDER_EXPIRE', array($this->context->language->id => strtotime('+1 day')));
break;
case 'avg_customer_age':
$value = sprintf($this->l('%d years', null, null, false), AdminStatsController::getAverageCustomerAge(), 1);
ConfigurationKPI::updateValue('AVG_CUSTOMER_AGE', $value);
ConfigurationKPI::updateValue('AVG_CUSTOMER_AGE_EXPIRE', strtotime('+1 day'));
//.........这里部分代码省略.........
示例3: initContent
//.........这里部分代码省略.........
continue;
}
require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
}
if ($object = new $module->name()) {
$object->runUpgradeModule();
if (count($errors_module_list = $object->getErrors())) {
$module_errors[] = array('name' => $module->displayName, 'message' => $errors_module_list);
} else {
if (count($conf_module_list = $object->getConfirmations())) {
$module_success[] = array('name' => $module->displayName, 'message' => $conf_module_list);
}
}
unset($object);
}
} elseif (Module::getUpgradeStatus($module->name)) {
// When the XML cache file is up-to-date, the module may not be loaded yet
if (!class_exists($module->name)) {
if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
$object = new $module->name();
$module_success[] = array('name' => $module->name, 'message' => array(0 => sprintf($this->l('Current version: %s'), $object->version), 1 => $this->l('No file upgrades applied (none exist).')));
} else {
continue;
}
}
unset($object);
} elseif (Tools::getValue('updated') && Tools::getValue('module_name')) {
$module_names = (string) Tools::getValue('module_name');
if (strpos($module_names, '|')) {
$module_names = explode('|', $module_names);
$dont_filter = true;
}
if (!is_array($module_names)) {
$module_names = (array) $module_names;
}
if (in_array($module->name, $module_names)) {
$module_success[] = array('name' => $module->displayName, 'message' => array(0 => sprintf($this->l('Current version: %s'), $module->version)));
}
}
// Make modules stats
$this->makeModulesStats($module);
// Assign warnings
if ($module->active && isset($module->warning) && !empty($module->warning) && !$this->ajax) {
$href = Context::getContext()->link->getAdminLink('AdminModules', true) . '&module_name=' . $module->name . '&tab_module=' . $module->tab . '&configure=' . $module->name;
$this->context->smarty->assign('text', sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning));
$this->context->smarty->assign('module_link', $href);
$this->displayWarning($this->context->smarty->fetch('controllers/modules/warning_module.tpl'));
}
// AutoComplete array
$autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', ';
// Apply filter
if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') {
unset($modules[$km]);
} else {
if (isset($modules_preferences[$modules[$km]->name])) {
$modules[$km]->preferences = $modules_preferences[$modules[$km]->name];
}
$this->fillModuleData($module, 'array');
$module->categoryName = isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name'];
}
unset($object);
if ($module->installed && isset($module->version_addons) && $module->version_addons) {
$upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->name, 'displayName' => $module->displayName);
}
if (in_array($module->name, $this->list_partners_modules)) {
$module->type = 'addonsPartner';
}
if (isset($module->description_full) && trim($module->description_full) != '') {
$module->show_quick_view = true;
}
}
// Don't display categories without modules
$cleaned_list = array();
foreach ($this->list_modules_categories as $k => $list) {
if ($list['nb'] > 0) {
$cleaned_list[$k] = $list;
}
}
// Actually used for the report of the upgraded errors
if (count($module_errors)) {
$html = $this->generateHtmlMessage($module_errors);
$this->errors[] = sprintf(Tools::displayError('The following module(s) were not upgraded successfully: %s'), $html);
}
if (count($module_success)) {
$html = $this->generateHtmlMessage($module_success);
$this->confirmations[] = sprintf($this->l('The following module(s) were upgraded successfully:') . ' %s', $html);
}
ConfigurationKPI::updateValue('UPDATE_MODULES', count($upgrade_available));
if (count($upgrade_available) == 0 && (int) Tools::getValue('check') == 1) {
$this->confirmations[] = $this->l('Everything is up-to-date');
}
// Init tpl vars for smarty
$tpl_vars = array('token' => $this->token, 'upgrade_available' => $upgrade_available, 'currentIndex' => self::$currentIndex, 'dirNameCurrentIndex' => dirname(self::$currentIndex), 'ajaxCurrentIndex' => str_replace('index', 'ajax-tab', self::$currentIndex), 'autocompleteList' => rtrim($autocompleteList, ' ,') . '];', 'showTypeModules' => $this->filter_configuration['PS_SHOW_TYPE_MODULES_' . (int) $this->id_employee], 'showCountryModules' => $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_' . (int) $this->id_employee], 'showInstalledModules' => $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_' . (int) $this->id_employee], 'showEnabledModules' => $this->filter_configuration['PS_SHOW_ENABLED_MODULES_' . (int) $this->id_employee], 'nameCountryDefault' => Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')), 'isoCountryDefault' => $this->iso_default_country, 'categoryFiltered' => $categoryFiltered, 'modules' => $modules, 'nb_modules' => $this->nb_modules_total, 'nb_modules_favorites' => count($this->context->employee->favoriteModulesList()), 'nb_modules_installed' => $this->nb_modules_installed, 'nb_modules_uninstalled' => $this->nb_modules_total - $this->nb_modules_installed, 'nb_modules_activated' => $this->nb_modules_activated, 'nb_modules_unactivated' => $this->nb_modules_installed - $this->nb_modules_activated, 'list_modules_categories' => $cleaned_list, 'list_modules_authors' => $this->modules_authors, 'add_permission' => $this->tabAccess['add'], 'tab_modules_preferences' => $tab_modules_preferences, 'kpis' => $this->renderKpis(), 'module_name' => Tools::getValue('module_name'), 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn, 'modules_uri' => __PS_BASE_URI__ . basename(_PS_MODULE_DIR_), 'dont_filter' => $dont_filter);
if ($this->logged_on_addons) {
$tpl_vars['logged_on_addons'] = 1;
$tpl_vars['username_addons'] = $this->context->cookie->username_addons;
}
$smarty->assign($tpl_vars);
}
示例4: writeTranslationFile
/**
* Read the Post var and write the translation file.
* This method overwrites the old translation file.
*
* @param bool $override_file : set true if this file is a override
*/
protected function writeTranslationFile($override_file = false)
{
$type = Tools::toCamelCase($this->type_selected, true);
$translation_informations = $this->translations_informations[$this->type_selected];
if ($override_file) {
$file_path = $translation_informations['override']['dir'] . $translation_informations['override']['file'];
} else {
$file_path = $translation_informations['dir'] . $translation_informations['file'];
}
if (!file_exists($file_path)) {
if (!file_exists(dirname($file_path)) && !mkdir(dirname($file_path), 0777, true)) {
throw new PrestaShopException(sprintf(Tools::displayError('Directory "%s" cannot be created'), dirname($file_path)));
} elseif (!touch($file_path)) {
throw new PrestaShopException(sprintf(Tools::displayError('File "%s" cannot be created'), $file_path));
}
}
$kpi_key = substr(strtoupper(Tools::getValue('theme') . '_' . Tools::getValue('lang')), 0, 16);
if ($fd = fopen($file_path, 'w')) {
// Get value of button save and stay
$save_and_stay = Tools::isSubmit('submitTranslations' . $type . 'AndStay');
// Get language
$lang = strtolower(Tools::getValue('lang'));
// Unset all POST which are not translations
unset($_POST['submitTranslations' . $type], $_POST['submitTranslations' . $type . 'AndStay'], $_POST['lang'], $_POST['token'], $_POST['theme'], $_POST['type']);
// Get all POST which aren't empty
$to_insert = array();
foreach ($_POST as $key => $value) {
if (!empty($value)) {
$to_insert[$key] = $value;
}
}
ConfigurationKPI::updateValue('FRONTOFFICE_TRANSLATIONS_EXPIRE', time());
ConfigurationKPI::updateValue('TRANSLATE_TOTAL_' . $kpi_key, count($_POST));
ConfigurationKPI::updateValue('TRANSLATE_DONE_' . $kpi_key, count($to_insert));
// translations array is ordered by key (easy merge)
ksort($to_insert);
$tab = $translation_informations['var'];
fwrite($fd, "<?php\n\nglobal \$" . $tab . ";\n\$" . $tab . " = array();\n");
foreach ($to_insert as $key => $value) {
fwrite($fd, '$' . $tab . '[\'' . pSQL($key, true) . '\'] = \'' . pSQL($value, true) . '\';' . "\n");
}
fwrite($fd, "\n?>");
fclose($fd);
// Redirect
if ($save_and_stay) {
$this->redirect(true);
} else {
$this->redirect();
}
} else {
throw new PrestaShopException(sprintf(Tools::displayError('Cannot write this file: "%s"'), $file_path));
}
}