Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap
This commit is contained in:
@@ -37,6 +37,7 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
$this->lang = true;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->_select = 'IFNULL(virtual.products, 0) as products';
|
||||
@@ -76,6 +77,16 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
if (($obj = $this->loadObject(true)) && Validate::isLoadedObject($obj))
|
||||
{
|
||||
$link = $this->context->link->getPageLink('attachment', true, NULL, 'id_attachment='.$obj->id);
|
||||
Tools::redirectLink($link);
|
||||
}
|
||||
return $this->displayWarning($this->l('File not found'));
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if (($obj = $this->loadObject(true)) && Validate::isLoadedObject($obj))
|
||||
|
||||
@@ -368,6 +368,29 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
if (ConfigurationKPI::get('EMPTY_CATEGORIES_EXPIRE') < $time)
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=empty_categories';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-top-category';
|
||||
$helper->icon = 'icon-money';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Top Category');
|
||||
$helper->subtitle = $this->l('30 days');
|
||||
if (ConfigurationKPI::get('TOP_CATEGORY', $this->context->employee->id_lang) !== false)
|
||||
$helper->value = ConfigurationKPI::get('TOP_CATEGORY', $this->context->employee->id_lang);
|
||||
if (ConfigurationKPI::get('TOP_CATEGORY_EXPIRE', $this->context->employee->id_lang) < $time)
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=top_category';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-products-per-category';
|
||||
$helper->icon = 'icon-search';
|
||||
$helper->color = 'color4';
|
||||
$helper->title = $this->l('Average number of products per category');
|
||||
if (ConfigurationKPI::get('PRODUCTS_PER_CATEGORY') !== false)
|
||||
$helper->value = ConfigurationKPI::get('PRODUCTS_PER_CATEGORY');
|
||||
if (ConfigurationKPI::get('PRODUCTS_PER_CATEGORY_EXPIRE') < $time)
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=products_per_category';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpiRow();
|
||||
$helper->kpis = $kpis;
|
||||
|
||||
@@ -194,15 +194,15 @@ class AdminDashboardControllerCore extends AdminController
|
||||
if (Tools::isSubmit('profitability_conf'))
|
||||
return parent::renderOptions();
|
||||
|
||||
$translations = 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')
|
||||
);
|
||||
// $translations = 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')
|
||||
// );
|
||||
|
||||
$calendar_helper = new HelperCalendar();
|
||||
|
||||
@@ -230,7 +230,7 @@ class AdminDashboardControllerCore extends AdminController
|
||||
$this->tpl_view_vars = array(
|
||||
'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params),
|
||||
'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params),
|
||||
'translations' => $translations,
|
||||
//'translations' => $translations,
|
||||
'action' => '#',
|
||||
'warning' => $this->getWarningDomainName(),
|
||||
'new_version_url' => Tools::getCurrentUrlProtocolPrefix().'api.prestashop.com/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code,
|
||||
|
||||
@@ -1285,14 +1285,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
if ($this->display == 'edit' || $this->display == 'add')
|
||||
{
|
||||
$this->addjQueryPlugin(array(
|
||||
'autocomplete',
|
||||
'tablednd',
|
||||
'thickbox',
|
||||
'ajaxfileupload',
|
||||
'date'
|
||||
));
|
||||
|
||||
$this->addJqueryUI(array(
|
||||
'ui.core',
|
||||
'ui.widget',
|
||||
@@ -1301,6 +1293,15 @@ class AdminProductsControllerCore extends AdminController
|
||||
'ui.datepicker'
|
||||
));
|
||||
|
||||
$this->addjQueryPlugin(array(
|
||||
'autocomplete',
|
||||
'tablednd',
|
||||
'thickbox',
|
||||
'ajaxfileupload',
|
||||
'date',
|
||||
'tagify'
|
||||
));
|
||||
|
||||
$this->addJS(array(
|
||||
_PS_JS_DIR_.'productTabsManager.js',
|
||||
_PS_JS_DIR_.'admin-products.js',
|
||||
|
||||
@@ -153,6 +153,14 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
WHERE c.active = 0');
|
||||
}
|
||||
|
||||
public static function getTotalCategories()
|
||||
{
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
'.Shop::addSqlAssociation('category', 'c'));
|
||||
}
|
||||
|
||||
public static function getDisabledProducts()
|
||||
{
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
@@ -162,6 +170,14 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
WHERE product_shop.active = 0');
|
||||
}
|
||||
|
||||
public static function getTotalProducts()
|
||||
{
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p'));
|
||||
}
|
||||
|
||||
public static function getTotalSales($date_from, $date_to, $granularity = false)
|
||||
{
|
||||
if ($granularity == 'day')
|
||||
@@ -232,6 +248,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
if ($products_sales > $total_sales)
|
||||
break;
|
||||
}
|
||||
|
||||
return round(100 * $products / $total_products).'%';
|
||||
}
|
||||
|
||||
@@ -307,6 +324,31 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return array('type' => 'neutral', 'value' => round(100 * $row['neutral'] / $row['total']));
|
||||
}
|
||||
|
||||
public static function getBestCategory($date_from, $date_to)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT ca.`id_category`
|
||||
FROM `'._DB_PREFIX_.'category` ca
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` capr ON ca.`id_category` = capr.`id_category`
|
||||
LEFT JOIN (
|
||||
SELECT pr.`id_product`, t.`totalPriceSold`
|
||||
FROM `'._DB_PREFIX_.'product` pr
|
||||
LEFT JOIN (
|
||||
SELECT pr.`id_product`,
|
||||
IFNULL(SUM(cp.`product_quantity`), 0) AS totalQuantitySold,
|
||||
IFNULL(SUM(cp.`product_price` * cp.`product_quantity`), 0) / o.conversion_rate AS totalPriceSold
|
||||
FROM `'._DB_PREFIX_.'product` pr
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'order_detail` cp ON pr.`id_product` = cp.`product_id`
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = cp.`id_order`
|
||||
WHERE o.invoice_date BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
|
||||
GROUP BY pr.`id_product`
|
||||
) t ON t.`id_product` = pr.`id_product`
|
||||
) t ON t.`id_product` = capr.`id_product`
|
||||
WHERE ca.`level_depth` > 1
|
||||
GROUP BY ca.`id_category`
|
||||
ORDER BY SUM(t.`totalPriceSold`) DESC');
|
||||
}
|
||||
|
||||
public static function getMainCountry($date_from, $date_to)
|
||||
{
|
||||
$total_orders = AdminStatsController::getOrders($date_from, $date_to);
|
||||
@@ -581,8 +623,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case '8020_sales_catalog':
|
||||
$value = AdminStatsController::get8020SalesCatalog(date('Y-m-d', strtotime('-31 day')), date('Y-m-d', strtotime('-1 day')));
|
||||
$value .= ' '.$this->l('of your 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;
|
||||
@@ -742,6 +784,27 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
ConfigurationKPI::updateValue('NETPROFIT_VISITOR', $value);
|
||||
ConfigurationKPI::updateValue('NETPROFIT_VISITOR_EXPIRE', strtotime(date('Y-m-d 00:00:00', strtotime('+1 day'))));
|
||||
break;
|
||||
|
||||
case 'products_per_category':
|
||||
$products = AdminStatsController::getTotalProducts();
|
||||
$categories = AdminStatsController::getTotalCategories();
|
||||
$value = round($products / $categories);
|
||||
ConfigurationKPI::updateValue('PRODUCTS_PER_CATEGORY', $value);
|
||||
ConfigurationKPI::updateValue('PRODUCTS_PER_CATEGORY_EXPIRE', strtotime('+1 hour'));
|
||||
break;
|
||||
|
||||
case 'top_category':
|
||||
if (!($id_category = AdminStatsController::getBestCategory(date('Y-m-d', strtotime('-1 month')), date('Y-m-d'))))
|
||||
$value = $this->l('No category');
|
||||
else
|
||||
{
|
||||
$category = new Category($id_category, $this->context->language->id);
|
||||
$value = $category->name;
|
||||
}
|
||||
|
||||
ConfigurationKPI::updateValue('TOP_CATEGORY', array($this->context->language->id => $value));
|
||||
ConfigurationKPI::updateValue('TOP_CATEGORY_EXPIRE', array($this->context->language->id => strtotime('+1 day')));
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = false;
|
||||
|
||||
@@ -103,7 +103,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
|
||||
$action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : '');
|
||||
$module = Tools::getValue('module');
|
||||
$action .= ($module ? '&module='.Tools::safeOutput($module) : '');
|
||||
$action .= ($id_product = Tools::getValue('id_product') ? '&id_product='.Tools::safeOutput($id_product) : '');
|
||||
$action .= (($id_product = Tools::getValue('id_product')) ? '&id_product='.Tools::safeOutput($id_product) : '');
|
||||
$tpl->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $token,
|
||||
@@ -166,7 +166,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
|
||||
|
||||
$tpl->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'current_module_name' => Tools::getValue('module'),
|
||||
'current_module_name' => Tools::getValue('module', 'statsforecast'),
|
||||
'token' => $this->token,
|
||||
'modules' => $modules,
|
||||
'module_instance' => $module_instance
|
||||
|
||||
@@ -154,6 +154,28 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
return $this->{$method_name}();
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
|
||||
if (Tools::getValue('lang'))
|
||||
{
|
||||
$this->page_header_toolbar_btn['save-and-stay'] = array(
|
||||
'short' => 'SaveAndStay',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
);
|
||||
$this->page_header_toolbar_btn['save'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Update translations')
|
||||
);
|
||||
$this->page_header_toolbar_btn['cancel'] = array(
|
||||
'href' => self::$currentIndex.'&token='.$this->token,
|
||||
'desc' => $this->l('Cancel')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::initToolbar() override
|
||||
* @see AdminController::initToolbar()
|
||||
|
||||
Reference in New Issue
Block a user