//dashboard range date choice in ajax 👍

This commit is contained in:
Vincent Augagneur
2013-09-05 15:25:41 +02:00
parent f09347a8be
commit c34dbcf43a
4 changed files with 77 additions and 41 deletions
@@ -66,6 +66,7 @@ class AdminDashboardControllerCore extends AdminController
'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo'),
'translations' => $translations,
'action' => '#',
'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'),
'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from),
'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to)
);
@@ -76,12 +77,16 @@ class AdminDashboardControllerCore extends AdminController
{
$id_module = null;
if ($module = Tools::getValue('module'))
$id_module = Module::getInstanceByName($module)->id;
{
$module_obj = Module::getInstanceByName($module);
if (Validate::isLoadedObject($module_obj))
$id_module = $module_obj->id;
}
$params = array(
'date_from' => $this->context->employee->stats_date_from,
'date_to' => $this->context->employee->stats_date_to,
'use_push' => (int)Tools::getValue('use_push')
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
);
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true)));
+32 -9
View File
@@ -194,6 +194,25 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
public function postProcess()
{
$this->context = Context::getContext();
$this->ajaxProcessSetDashboardDateRange();
if (Tools::getValue('submitSettings'))
{
if ($this->tabAccess['edit'] === '1')
{
self::$currentIndex .= '&module='.Tools::getValue('module');
Configuration::updateValue('PS_STATS_RENDER', Tools::getValue('PS_STATS_RENDER', Configuration::get('PS_STATS_RENDER')));
Configuration::updateValue('PS_STATS_GRID_RENDER', Tools::getValue('PS_STATS_GRID_RENDER', Configuration::get('PS_STATS_GRID_RENDER')));
Configuration::updateValue('PS_STATS_OLD_CONNECT_AUTO_CLEAN', Tools::getValue('PS_STATS_OLD_CONNECT_AUTO_CLEAN', Configuration::get('PS_STATS_OLD_CONNECT_AUTO_CLEAN')));
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
public function ajaxProcessSetDashboardDateRange()
{
if (Tools::isSubmit('submitDatePicker'))
{
if (!Validate::isDate($from = Tools::getValue('datepickerFrom')) || !Validate::isDate($to = Tools::getValue('datepickerTo')))
@@ -239,17 +258,21 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
$this->context->employee->update();
Tools::redirectAdmin($_SERVER['REQUEST_URI']);
}
if (Tools::getValue('submitSettings'))
if ($this->isXmlHttpRequest())
{
if ($this->tabAccess['edit'] === '1')
{
self::$currentIndex .= '&module='.Tools::getValue('module');
Configuration::updateValue('PS_STATS_RENDER', Tools::getValue('PS_STATS_RENDER', Configuration::get('PS_STATS_RENDER')));
Configuration::updateValue('PS_STATS_GRID_RENDER', Tools::getValue('PS_STATS_GRID_RENDER', Configuration::get('PS_STATS_GRID_RENDER')));
Configuration::updateValue('PS_STATS_OLD_CONNECT_AUTO_CLEAN', Tools::getValue('PS_STATS_OLD_CONNECT_AUTO_CLEAN', Configuration::get('PS_STATS_OLD_CONNECT_AUTO_CLEAN')));
}
if (is_array($this->errors) && count($this->errors))
die(Tools::jsonEncode(array(
'has_errors' => true,
'errors' => array($this->errors),
'date_from' => $this->context->employee->stats_date_from,
'date_to' => $this->context->employee->stats_date_to)
));
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
die(Tools::jsonEncode(array(
'has_errors' => false,
'date_from' => $this->context->employee->stats_date_from,
'date_to' => $this->context->employee->stats_date_to)
));
}
}