From 700a871776b690756550ce2750a20ca225f0b14f Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Thu, 30 May 2024 17:51:02 +0530 Subject: [PATCH 1/2] Updated: Validations for the occupancy of the room type --- .../template/controllers/products/occupancy.tpl | 1 + controllers/admin/AdminProductsController.php | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/admin/themes/default/template/controllers/products/occupancy.tpl b/admin/themes/default/template/controllers/products/occupancy.tpl index 1d61e478f..00cabb60d 100644 --- a/admin/themes/default/template/controllers/products/occupancy.tpl +++ b/admin/themes/default/template/controllers/products/occupancy.tpl @@ -25,6 +25,7 @@
{l s='Below, enter the base occupancy of this room type.'} +

{l s='Note'}: {l s='Minimum 1 adult is madatory in the base occupancy of the room type'}

diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 21bba9ce7..799be06a7 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3272,22 +3272,26 @@ class AdminProductsControllerCore extends AdminController $this->errors[] = Tools::displayError('Invalid base children'); } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { if ($baseChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - $this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); + $this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); } } if (!$maxAdults || !Validate::isUnsignedInt($maxAdults)) { $this->errors[] = Tools::displayError('Invalid maximum number of adults'); } elseif ($maxAdults < $baseAdults) { $this->errors[] = Tools::displayError('Maximum number of adults cannot be less than base adults'); + } elseif ($maxAdults > $maxGuests) { + $this->errors[] = Tools::displayError('Maximum number of adults cannot be more than maximum number of guests'); } if ($maxChildren == '' || !Validate::isUnsignedInt($maxChildren)) { $this->errors[] = Tools::displayError('Invalid maximum number of children'); - } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - $this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); - } } elseif ($maxChildren < $baseChildren) { $this->errors[] = Tools::displayError('Maximum number of children cannot be less than base children'); + } elseif ($maxChildren >= $maxGuests) { + $this->errors[] = Tools::displayError('Maximum number of children cannot be more or equal than maximum number of guests.(1 adult is mandatory in a room)'); + } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { + if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { + $this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); + } } if (!$maxGuests || !Validate::isUnsignedInt($maxGuests)) { $this->errors[] = Tools::displayError('Invalid maximum number of guests'); From 1124240d78764ee56e6fa9bcc037774a49116859 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Fri, 7 Jun 2024 10:34:24 +0530 Subject: [PATCH 2/2] Fixed: Post data does not persist after submiting the occupancy form --- .../template/controllers/products/occupancy.tpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/themes/default/template/controllers/products/occupancy.tpl b/admin/themes/default/template/controllers/products/occupancy.tpl index 00cabb60d..d497ec305 100644 --- a/admin/themes/default/template/controllers/products/occupancy.tpl +++ b/admin/themes/default/template/controllers/products/occupancy.tpl @@ -36,7 +36,7 @@
- +
@@ -47,7 +47,7 @@
- +
@@ -68,7 +68,7 @@
- +
@@ -79,7 +79,7 @@
- +
@@ -90,7 +90,7 @@
- +