Accept all valid date formats

This commit is contained in:
Abhishek Kumar
2023-01-18 19:52:39 +05:30
parent 3e49492af7
commit 2ec01dbc49
3 changed files with 14 additions and 6 deletions

View File

@@ -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'));
}

View File

@@ -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'));
}

View File

@@ -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()),
};