diff --git a/admin-dev/themes/default/js/date-range-picker.js b/admin-dev/themes/default/js/date-range-picker.js
index a9af1ae76..f3bafdcd3 100644
--- a/admin-dev/themes/default/js/date-range-picker.js
+++ b/admin-dev/themes/default/js/date-range-picker.js
@@ -17,14 +17,6 @@
* limitations under the License.
* ========================================================= */
-$(function() {
- var currentMonth = new Date(Date.now());
- var previousMonth = new Date(new Date(currentMonth).setMonth(currentMonth.getMonth()-1));
- $('.datepicker1').datepicker("setValue",previousMonth);
- $('.datepicker2').datepicker("setValue",currentMonth);
- $("#date-start").focus().addClass("input-selected");
-});
-
//click action
!function( $ ) {
var click, switched, val, start, end, over;
diff --git a/admin-dev/themes/default/template/form_date_range_picker.tpl b/admin-dev/themes/default/template/form_date_range_picker.tpl
index 2922effde..02466d355 100644
--- a/admin-dev/themes/default/template/form_date_range_picker.tpl
+++ b/admin-dev/themes/default/template/form_date_range_picker.tpl
@@ -35,6 +35,11 @@
+
\ No newline at end of file
diff --git a/classes/helper/HelperCalendar.php b/classes/helper/HelperCalendar.php
new file mode 100644
index 000000000..f0c6f41ff
--- /dev/null
+++ b/classes/helper/HelperCalendar.php
@@ -0,0 +1,154 @@
+
+* @copyright 2007-2013 PrestaShop SA
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+class HelperCalendarCore extends Helper
+{
+ const DEFAULT_DATE_FORMAT = 'dd-mm-yyyy';
+
+ private $_actions;
+ private $_date_format;
+ private $_from_date;
+ private $_to_date;
+
+ public function __construct()
+ {
+ $this->base_folder = 'helpers/calendar/';
+ $this->base_tpl = 'calendar.tpl';
+ parent::__construct();
+ }
+
+ public function setActions($value)
+ {
+ if (!is_array($value) && !$value instanceof Traversable)
+ throw new PrestaShopException('Actions value must be an traversable array');
+
+ $this->_actions = $value;
+ return $this;
+ }
+
+ public function getActions()
+ {
+ if (!isset($this->_actions))
+ $this->_actions = array();
+
+ return $this->_actions;
+ }
+
+ public function setDateFormat($value)
+ {
+ if (!is_string($value))
+ throw new PrestaShopException('Date format must be string');
+
+ $this->_date_format = $value;
+ return $this;
+ }
+
+ public function getDateFormat()
+ {
+ if (!isset($this->_date_format))
+ $this->_date_format = self::DEFAULT_DATE_FORMAT;
+
+ return $this->_date_format;
+ }
+
+ public function setFromDate($value)
+ {
+ if (!is_string($value))
+ throw new PrestaShopException('Date format must be string');
+
+ $this->_from_date = $value;
+ return $this;
+ }
+
+ public function getFromDate()
+ {
+ if (!isset($this->_from_date))
+ $this->_from_date = date('d-m-Y', strtotime("-31 days"));
+
+ return $this->_from_date;
+ }
+
+ public function setToDate($value)
+ {
+ if (!is_string($value))
+ throw new PrestaShopException('Date format must be string');
+
+ $this->_to_date = $value;
+ return $this;
+ }
+
+ public function getToDate()
+ {
+ if (!isset($this->_to_date))
+ $this->_to_date = date('d-m-Y');
+
+ return $this->_to_date;
+ }
+
+ public function addAction($action)
+ {
+ if (!isset($this->_actions))
+ $this->_actions = array();
+
+ $this->_actions[] = $action;
+
+ return $this;
+ }
+
+ public function generate()
+ {
+ $context = Context::getContext();
+ $admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
+ $admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
+ $bo_theme = ((Validate::isLoadedObject($context->employee)
+ && $context->employee->bo_theme) ? $context->employee->bo_theme : 'default');
+
+ if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$bo_theme.DIRECTORY_SEPARATOR
+ .'template'))
+ $bo_theme = 'default';
+
+ if ($context->controller->ajax)
+ $html = '';
+ else
+ {
+ $html = '';
+ $context->controller->addJs(__PS_BASE_URI__.$admin_webpath
+ .'/themes/'.$bo_theme.'/js/date-range-picker.js');
+ }
+
+ $this->tpl = $this->createTemplate($this->base_tpl);
+ $this->tpl->assign(array(
+ 'date_format' => $this->getDateFormat(),
+ 'from_date' => $this->getFromDate(),
+ 'to_date' => $this->getToDate(),
+ 'actions' => $this->getActions()
+ ));
+
+ $html .= parent::generate();
+ return $html;
+ }
+}
diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php
index 417398c40..2aedd77e1 100644
--- a/controllers/admin/AdminDashboardController.php
+++ b/controllers/admin/AdminDashboardController.php
@@ -42,7 +42,7 @@ class AdminDashboardControllerCore extends AdminController
$admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
parent::setMedia();
- $this->addJqueryUI('ui.datepicker');
+ //$this->addJqueryUI('ui.datepicker');
$this->addJS(array(
_PS_JS_DIR_.'/vendor/d3.js',
__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->bo_theme.'/js/vendor/nv.d3.js',
@@ -150,6 +150,8 @@ class AdminDashboardControllerCore extends AdminController
'To' => $this->l('To:', 'AdminStatsTab'),
'Save' => $this->l('Save', 'AdminStatsTab')
);
+
+ $calendar_helper = new HelperCalendar();
$this->tpl_view_vars = array(
'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne'),
@@ -159,6 +161,7 @@ class AdminDashboardControllerCore extends AdminController
'warning' => $this->getWarningDomainName(),
'new_version_url' => Tools::getCurrentUrlProtocolPrefix().'api.prestashop.com/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code,
'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'),
+ 'calendar' => $calendar_helper->generate(),
'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from),
'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to)
);