Update the validation

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
aradhana kumari
2026-05-01 19:22:05 +05:30
parent ce01edfbf8
commit 685f37c4da
15 changed files with 55 additions and 26 deletions

View File

@@ -2450,6 +2450,7 @@
</form>
{strip}
{addJsDef max_child_age=$max_child_age}
{addJsDef max_child_in_room=$max_child_in_room}
{addJsDefL name='select_age_txt'}{l s='Select age' js=1}{/addJsDefL}
{addJsDefL name='under_1_age'}{l s='Under 1' js=1}{/addJsDefL}
{addJsDefL name='room_txt'}{l s='Room' js=1}{/addJsDefL}

View File

@@ -1335,6 +1335,7 @@
{addJsDefL name='invalid_occupancy_txt'}{l s='Invalid occupancy(adults/children) found.' js=1}{/addJsDefL}
{addJsDefL name='select_room_txt'}{l s='Select room' js=1}{/addJsDefL}
{addJsDef max_child_age=$max_child_age|escape:'quotes':'UTF-8'}
{addJsDef max_child_in_room=$max_child_in_room|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_CHECKED_IN=$ROOM_STATUS_CHECKED_IN|escape:'quotes':'UTF-8'}
{addJsDef ROOM_STATUS_CHECKED_OUT=$ROOM_STATUS_CHECKED_OUT|escape:'quotes':'UTF-8'}
{addJsDef ALLOTMENT_MANUAL=$ALLOTMENT_MANUAL|escape:'quotes':'UTF-8'}

View File

@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

View File

@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

View File

@@ -498,6 +498,7 @@ class FrontControllerCore extends Controller
'is_occupancy_wise_search' => $isOccupancyWiseSearch,
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'show_full_date' => $this->show_full_date
));

View File

@@ -492,6 +492,7 @@ class AdminOrdersControllerCore extends AdminController
'payment_types' => $paymentTypes,
'PAYMENT_TYPE_PAY_AT_HOTEL' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
'currency' => new Currency((int)$cart->id_currency),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
));
@@ -3626,6 +3627,7 @@ class AdminOrdersControllerCore extends AdminController
'htl_booking_order_data' => $bookingOrderInfo,
'hotel_order_status' => $htlOrderStatus,
'order_detail_data' => $order_detail_data,
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'hotel_service_products' => $orderHotelServiceProducts,
'standalone_service_products' => $orderStandaloneServiceProducts,

View File

@@ -3407,6 +3407,10 @@ class AdminProductsControllerCore extends AdminController
}
if ($baseChildren == '' || !Validate::isUnsignedInt($baseChildren)) {
$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 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');
@@ -3421,6 +3425,10 @@ class AdminProductsControllerCore extends AdminController
$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');

View File

@@ -353,4 +353,4 @@ class AdminSlipControllerCore extends AdminController
$this->addJS(_PS_JS_DIR_.'admin/slips.js');
}
}
}

View File

@@ -1063,7 +1063,7 @@ class HotelHelper
Configuration::updateValue('WK_ADVANCED_PAYMENT_INC_TAX', 1);
Configuration::updateValue('WK_GLOBAL_CHILD_MAX_AGE', 15);
Configuration::updateValue('QLO_GLOBAL_MAX_INFANT_AGE', 1);
Configuration::updateValue('WK_GLOBAL_MAX_CHILD_IN_ROOM', 0);
Configuration::updateValue('PS_MAX_CHECKOUT_OFFSET', 365);
Configuration::updateValue('PS_MIN_BOOKING_OFFSET', 0);

View File

@@ -384,6 +384,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'date_to' => $this->date_to,
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'link' => $this->context->link,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
));
@@ -980,6 +981,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'SELLING_PREFERENCE_WITH_ROOM_TYPE' => Product::SELLING_PREFERENCE_WITH_ROOM_TYPE,
'SELLING_PREFERENCE_STANDALONE' => Product::SELLING_PREFERENCE_STANDALONE,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'rooms_reallocation_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'),
'rooms_booking_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'),

View File

@@ -74,7 +74,7 @@
</div>
<div class="form-group col-xs-6 occupancy_count_block">
<label>{l s='Children' mod='hotelreservationsystem'} <span class="label-desc-txt"></span></label>
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0" data-max="{if isset($book_v)}{$book_v['max_children']|escape:'html':'UTF-8'}{/if}">
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0" data-max="{if isset($book_v)}{$book_v['max_children']|escape:'html':'UTF-8'}{else}{$max_child_in_room}{/if}">
({l s='Below' mod='hotelreservationsystem'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
</div>
</div>
@@ -163,7 +163,7 @@
</div>
<div class="form-group col-xs-6 occupancy_count_block">
<label>{l s='Children' mod='hotelreservationsystem'} <span class="label-desc-txt"></span></label>
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0" data-max="{if isset($book_v)}{$book_v['max_children']|escape:'html':'UTF-8'}{/if}">
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0" data-max="{if isset($book_v)}{$book_v['max_children']|escape:'html':'UTF-8'}{else}{$max_child_in_room}{/if}">
({l s='Below'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
</div>
</div>

View File

@@ -84,7 +84,7 @@
</div>
<div class="form-group col-xs-6 occupancy_count_block">
<label>{l s='Children' mod='hotelreservationsystem'} <span class="label-desc-txt"></span></label>
<input type="number" class="form-control num_occupancy num_children" name="occupancy[{$key|escape:'htmlall':'UTF-8'}][children]" value="{$room_occupancy['children']|escape:'htmlall':'UTF-8'}" min="0">
<input type="number" class="form-control num_occupancy num_children" name="occupancy[{$key|escape:'htmlall':'UTF-8'}][children]" value="{$room_occupancy['children']|escape:'htmlall':'UTF-8'}" min="0" {if $max_child_in_room}max="{$max_child_in_room}"{/if}>
({l s='Below' mod='hotelreservationsystem'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
</div>
</div>
@@ -126,7 +126,7 @@
</div>
<div class="form-group col-xs-6 occupancy_count_block">
<label>{l s='Children' mod='hotelreservationsystem'} <span class="label-desc-txt"></span></label>
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0">
<input type="number" class="form-control num_occupancy num_children" name="occupancy[0][children]" value="0" min="0" {if $max_child_in_room}max="{$max_child_in_room}"{/if}>
({l s='Below' mod='hotelreservationsystem'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
</div>
</div>

View File

@@ -696,26 +696,37 @@ $(document).ready(function() {
if (childElement) {
var totalChilds = $(this).closest('.occupancy_info_block').find('.guest_child_age').length;
element.val(elementVal);
$(this).closest('.occupancy_info_block').find('.children_age_info_block').show();
if (max_child_in_room == 0 || totalChilds < max_child_in_room) {
element.val(elementVal);
$(this).closest('.occupancy_info_block').find('.children_age_info_block').show();
var roomBlockIndex = parseInt($(this).closest('.occupancy_info_block').attr('occ_block_index'));
var roomBlockIndex = parseInt($(this).closest('.occupancy_info_block').attr('occ_block_index'));
var childAgeSelect = '<div>';
childAgeSelect += '<select class="guest_child_age room_occupancies" name="occupancy[' +roomBlockIndex+ '][child_ages][]">';
childAgeSelect += '<option value="-1">' + select_age_txt + '</option>';
childAgeSelect += '<option value="0">' + under_1_age + '</option>';
for (let age = 1; age < max_child_age; age++) {
childAgeSelect += '<option value="'+age+'">'+age+'</option>';
var childAgeSelect = '<div>';
childAgeSelect += '<select class="guest_child_age room_occupancies" name="occupancy[' +roomBlockIndex+ '][child_ages][]">';
childAgeSelect += '<option value="-1">' + select_age_txt + '</option>';
childAgeSelect += '<option value="0">' + under_1_age + '</option>';
for (let age = 1; age < max_child_age; age++) {
childAgeSelect += '<option value="'+age+'">'+age+'</option>';
}
childAgeSelect += '</select>';
childAgeSelect += '</div>';
$(this).closest('.occupancy_info_block').find('.children_ages').append(childAgeSelect);
// set input field value
$(this).closest('.occupancy_count_block').find('.occupancy_count > span').text(elementVal);
} else {
if (elementVal >= max_child_in_room) {
if (elementVal == 0) {
showOccupancyError(no_children_allowed_txt, $(this).closest(".occupancy_info_block"));
} else {
showOccupancyError(max_children_txt, $(this).closest(".occupancy_info_block"));
}
childAgeSelect += '</select>';
childAgeSelect += '</div>';
$(this).closest('.occupancy_info_block').find('.children_ages').append(childAgeSelect);
// set input field value
$(this).closest('.occupancy_count_block').find('.occupancy_count > span').text(elementVal);
} else {
showOccupancyError(max_occupancy_reached_txt, $(this).closest(".occupancy_info_block"));
}
}
} else {
element.val(elementVal);
@@ -923,7 +934,7 @@ $(document).ready(function() {
// set positions of popups when required
if (page_name == 'index') {
$('#hotel_location, #id_hotel_button_chosen, #guest_occupancy').focus(function () {
$('#hotel_location, #id_hotel_button, #guest_occupancy').focus(function () {
setBookingSearchPositions();
});

View File

@@ -62,6 +62,7 @@
{addJsDef is_occupancy_wise_search=$is_occupancy_wise_search|boolval}
{addJsDef occupancy_required_for_booking=$occupancy_required_for_booking|boolval}
{addJsDef max_child_age=$max_child_age}
{addJsDef max_child_in_room=$max_child_in_room}
{addJsDefL name='max_occupancy_reached_txt'}{l s='Maximum room occupancy reached' js=1}{/addJsDefL}
{addJsDefL name='max_adults_txt'}{l s='Maximum adult occupancy reached' js=1}{/addJsDefL}

View File

@@ -58,6 +58,8 @@ $(document).ready(function(){
let max_child_in_room;
if ($(this).closest(".booking_occupancy_wrapper").find('.max_children').val()) {
max_child_in_room = $(this).closest(".booking_occupancy_wrapper").find('.max_children').val();
} else {
max_child_in_room = window.max_child_in_room;
}
if (elementVal < max_child_in_room && elementVal < max_allowed_for_current) {
element.val(elementVal + 1);