diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 607257ac1..1c19b244c 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -99,11 +99,15 @@ class CategoryControllerCore extends FrontController $dateFrom = Tools::getValue('date_from'); $dateTo = Tools::getValue('date_to'); - if ($dateFrom != '' && !Validate::isDate($dateFrom)) { + $currentTimestamp = strtotime(date('Y-m-d')); + $dateFromTimestamp = strtotime($dateFrom); + $dateToTimestamp = strtotime($dateTo); + + if ($dateFrom != '' && (!$dateFromTimestamp || ($dateFromTimestamp < $currentTimestamp))) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } - if ($dateTo != '' && !Validate::isDate($dateTo)) { + if ($dateTo != '' && (!$dateToTimestamp || ($dateToTimestamp < $currentTimestamp))) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 997053ca9..70bb30678 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -92,11 +92,15 @@ class ProductControllerCore extends FrontController $dateFrom = Tools::getValue('date_from'); $dateTo = Tools::getValue('date_to'); - if ($dateFrom != '' && !Validate::isDate($dateFrom)) { + $currentTimestamp = strtotime(date('Y-m-d')); + $dateFromTimestamp = strtotime($dateFrom); + $dateToTimestamp = strtotime($dateTo); + + if ($dateFrom != '' && (!$dateFromTimestamp || ($dateFromTimestamp < $currentTimestamp))) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } - if ($dateTo != '' && !Validate::isDate($dateTo)) { + if ($dateTo != '' && (!$dateToTimestamp || ($dateToTimestamp < $currentTimestamp))) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 9554e3d48..fc5b6c5a7 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1237,8 +1237,8 @@ var BookingForm = { var data = { id_product: parseInt($('#product_page_product_id').val()), - date_from: $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate('dd-mm-yy', $('#room_check_in').val())), - date_to: $.datepicker.formatDate('yy-mm-dd', $.datepicker.parseDate('dd-mm-yy', $('#room_check_out').val())), + date_from: $('#room_check_in').val(), + date_to: $('#room_check_out').val(), quantity: quantity, room_type_demands: JSON.stringify(getRoomsExtraDemands()), };