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

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