* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php'); abstract class AdminStatsTab extends AdminPreferences { public function __construct() { $this->_fieldsSettings = array( 'PS_STATS_RENDER' => array('title' => $this->l('Graph engine'), 'validation' => 'isGenericName'), 'PS_STATS_GRID_RENDER' => array('title' => $this->l('Grid engine'), 'validation' => 'isGenericName') ); parent::__construct(); } public function postProcess() { global $cookie, $currentIndex; if (Tools::isSubmit('submitDatePicker')) { if (!Validate::isDate($from = Tools::getValue('datepickerFrom')) OR !Validate::isDate($to = Tools::getValue('datepickerTo'))) $this->_errors[] = Tools::displayError('Date specified is invalid'); } if (Tools::isSubmit('submitDateDay')) { $from = date('Y-m-d'); $to = date('Y-m-d'); } if (Tools::isSubmit('submitDateDayPrev')) { $yesterday = time() - 60*60*24; $from = date('Y-m-d', $yesterday); $to = date('Y-m-d', $yesterday); } if (Tools::isSubmit('submitDateMonth')) { $from = date('Y-m-01'); $to = date('Y-m-t'); } if (Tools::isSubmit('submitDateMonthPrev')) { $m = (date('m') == 1 ? 12 : date('m') - 1); $y = ($m == 12 ? date('Y') - 1 : date('Y')); $from = $y.'-'.$m.'-01'; $to = $y.'-'.$m.date('-t', mktime(12, 0, 0, $m, 15, $y)); } if (Tools::isSubmit('submitDateYear')) { $from = date('Y-01-01'); $to = date('Y-12-31'); } if (Tools::isSubmit('submitDateYearPrev')) { $from = (date('Y') - 1).date('-01-01'); $to = (date('Y') - 1).date('-12-31'); } if (isset($from) AND isset($to) AND !sizeof($this->_errors)) { $employee = new Employee($cookie->id_employee); $employee->stats_date_from = $from; $employee->stats_date_to = $to; $employee->update(); Tools::redirectAdmin($_SERVER['REQUEST_URI']); } if (Tools::getValue('submitSettings')) { if ($this->tabAccess['edit'] === '1') { $currentIndex .= '&module='.Tools::getValue('module'); $this->_postConfig($this->_fieldsSettings); } else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } if (sizeof($this->_errors)) AdminTab::displayErrors(); } protected function displayEngines() { global $currentIndex, $cookie; $graphEngine = Configuration::get('PS_STATS_RENDER'); $gridEngine = Configuration::get('PS_STATS_GRID_RENDER'); $arrayGraphEngines = ModuleGraphEngine::getGraphEngines(); $arrayGridEngines = ModuleGridEngine::getGridEngines(); echo '