public function renderView() { if (Tools::isSubmit('profitability_conf')) { return parent::renderOptions(); } // $translations = array( // 'Calendar' => $this->trans('Calendar', array(),'Admin.Global'), // 'Day' => $this->trans('Day', array(), 'Admin.Global'), // 'Month' => $this->trans('Month', array(), 'Admin.Global'), // 'Year' => $this->trans('Year', array(), 'Admin.Global'), // 'From' => $this->trans('From:', array(), 'Admin.Global'), // 'To' => $this->trans('To:', array(), 'Admin.Global'), // 'Save' => $this->trans('Save', array(), 'Admin.Global') // ); if ($this->context->cookie->__get('stats_date_update') < strtotime(date('Y-m-d'))) { switch ($this->context->employee->preselect_date_range) { case 'day': $date_from = date('Y-m-d'); $date_to = date('Y-m-d'); break; case 'prev-day': $date_from = date('Y-m-d', strtotime('-1 day')); $date_to = date('Y-m-d', strtotime('-1 day')); break; case 'month': default: $date_from = date('Y-m-01'); $date_to = date('Y-m-d'); break; case 'prev-month': $date_from = date('Y-m-01', strtotime('-1 month')); $date_to = date('Y-m-t', strtotime('-1 month')); break; case 'year': $date_from = date('Y-01-01'); $date_to = date('Y-m-d'); break; case 'prev-year': $date_from = date('Y-m-01', strtotime('-1 year')); $date_to = date('Y-12-t', strtotime('-1 year')); break; } $this->context->employee->stats_date_from = $date_from; $this->context->employee->stats_date_to = $date_to; $this->context->employee->update(); $this->context->cookie->__set('stats_date_update', strtotime(date('Y-m-d'))); $this->context->cookie->write(); } $calendar_helper = new HelperCalendar(); $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from)); $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to)); $stats_compare_from = $this->context->employee->stats_compare_from; $stats_compare_to = $this->context->employee->stats_compare_to; if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') { $stats_compare_from = null; } if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') { $stats_compare_to = null; } $calendar_helper->setCompareDateFrom($stats_compare_from); $calendar_helper->setCompareDateTo($stats_compare_to); $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option)); $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to); $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); $moduleManager = $moduleManagerBuilder->build(); $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), 'action' => '#', 'warning' => $this->getWarningDomainName(), 'new_version_url' => Tools::getCurrentUrlProtocolPrefix() . _PS_API_DOMAIN_ . '/version/check_version.php?v=' . _PS_VERSION_ . '&lang=' . $this->context->language->iso_code . '&autoupgrade=' . (int) ($moduleManager->isInstalled('autoupgrade') && $moduleManager->isEnabled('autoupgrade')) . '&hosted_mode=' . (int) defined('_PS_HOST_MODE_'), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range)); return parent::renderView(); }
public function renderView() { 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') // ); if ($this->context->cookie->__get('stats_date_update') < strtotime(date('Y-m-d'))) { switch ($this->context->employee->preselect_date_range) { case 'day': $date_from = date('Y-m-d'); $date_to = date('Y-m-d'); break; case 'prev-day': $date_from = date('Y-m-d', strtotime('-1 day')); $date_to = date('Y-m-d', strtotime('-1 day')); break; case 'month': default: $date_from = date('Y-m-01'); $date_to = date('Y-m-d'); break; case 'prev-month': $date_from = date('Y-m-01', strtotime('-1 month')); $date_to = date('Y-m-t', strtotime('-1 month')); break; case 'year': $date_from = date('Y-01-01'); $date_to = date('Y-m-d'); break; case 'prev-year': $date_from = date('Y-m-01', strtotime('-1 year')); $date_to = date('Y-12-t', strtotime('-1 year')); break; } $this->context->employee->stats_date_from = $date_from; $this->context->employee->stats_date_to = $date_to; $this->context->employee->update(); $this->context->cookie->__set('stats_date_update', strtotime(date('Y-m-d'))); $this->context->cookie->write(); } $calendar_helper = new HelperCalendar(); $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from)); $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to)); $stats_compare_from = $this->context->employee->stats_compare_from; $stats_compare_to = $this->context->employee->stats_compare_to; if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') { $stats_compare_from = null; } if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') { $stats_compare_to = null; } $calendar_helper->setCompareDateFrom($stats_compare_from); $calendar_helper->setCompareDateTo($stats_compare_to); $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option)); $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to); $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), 'action' => '#', 'warning' => $this->getWarningDomainName(), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range)); return parent::renderView(); }
public function renderView() { 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') // ); $calendar_helper = new HelperCalendar(); $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from)); $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to)); $stats_compare_from = $this->context->employee->stats_compare_from; $stats_compare_to = $this->context->employee->stats_compare_to; if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') { $stats_compare_from = null; } if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') { $stats_compare_to = null; } $calendar_helper->setCompareDateFrom($stats_compare_from); $calendar_helper->setCompareDateTo($stats_compare_to); $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option)); $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to); $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), '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 . '&autoupgrade=' . (int) (Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')) . '&hosted_mode=' . (int) defined('_PS_HOST_MODE_'), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range)); return parent::renderView(); }