From 892516342e68783b8ba8176564c182de51e77de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Nadaud?= Date: Sun, 13 Oct 2013 11:47:29 +0200 Subject: [PATCH] // Fix when date is null --- classes/helper/HelperCalendar.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/classes/helper/HelperCalendar.php b/classes/helper/HelperCalendar.php index 4d74173ea..c84f0ba26 100644 --- a/classes/helper/HelperCalendar.php +++ b/classes/helper/HelperCalendar.php @@ -61,8 +61,11 @@ class HelperCalendarCore extends Helper public function setCompareDateFrom($value) { + if (!isset($value) || $value == ''); + $value = date('d-m-Y', strtotime("-31 days")); + if (!is_string($value)) - throw new PrestaShopException('Date format must be string'); + throw new PrestaShopException('Date must be string'); $this->_compare_date_from = $value; return $this; @@ -78,8 +81,11 @@ class HelperCalendarCore extends Helper public function setCompareDateTo($value) { + if (!isset($value) || $value == '') + $value = date('Y-m-d'); + if (!is_string($value)) - throw new PrestaShopException('Date format must be string'); + throw new PrestaShopException('Date must be string'); $this->_compare_date_to = $value; return $this; @@ -112,8 +118,11 @@ class HelperCalendarCore extends Helper public function setDateFrom($value) { + if (!isset($value) || $value == '') + $value = date('d-m-Y', strtotime("-31 days")); + if (!is_string($value)) - throw new PrestaShopException('Date format must be string'); + throw new PrestaShopException('Date must be string'); $this->_date_from = $value; return $this; @@ -129,8 +138,11 @@ class HelperCalendarCore extends Helper public function setDateTo($value) { + if (!isset($value) || $value == '') + $value = date('Y-m-d'); + if (!is_string($value)) - throw new PrestaShopException('Date format must be string'); + throw new PrestaShopException('Date must be string'); $this->_date_to = $value; return $this;