Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Done button in the occupancy popup in the front office. #966

Merged
merged 6 commits into from
Jul 4, 2024
Merged
8 changes: 7 additions & 1 deletion modules/wkroomsearchblock/views/css/wk-global-search.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@
text-transform: uppercase;
border: none;
border-radius: 4px;}
.submit_occupancy_btn {
background-color: #1292FF;
font-size: 13px;
border: none;
padding: 5px 20px;
border-radius: 4px;}


/* occupancy */
Expand All @@ -223,7 +229,7 @@
overflow: auto;
box-shadow: 0 8px 25px -4px rgba(0,0,0,0.39);
left: 0px;
padding: 20px;}
padding: 12px 20px;}
#search_occupancy_wrapper.top {
top: unset;
bottom: 100%; }
Expand Down
9 changes: 9 additions & 0 deletions modules/wkroomsearchblock/views/js/wk-room-search-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,15 @@ $(document).ready(function() {
}
});

$(document).on('click', '#search_occupancy_wrapper .submit_occupancy_btn', function(e) {
e.preventDefault();
if ($('#search_occupancy_wrapper').length) {
if ($('#search_occupancy_wrapper').css('display') !== 'none') {
return validateOccupancies();
}
}
});

var isEnterKeyHeldOnLocation = false;
$('body').on('keydown', function(e) {
let preventDefault = false;
Expand Down
28 changes: 26 additions & 2 deletions modules/wkroomsearchblock/views/templates/hook/searchForm.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
{*
* Copyright since 2010 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <[email protected]>
* @copyright since 2010 Webkul IN
* @license https://store.webkul.com/license.html
*}

<form method="POST" id="search_hotel_block_form" class="grid">
{if isset($location_enabled) && $location_enabled}
<div class="form-group area-{$column_widths['location']}">
Expand Down Expand Up @@ -191,8 +210,13 @@
</div>
{/if}
</div>
<div id="add_new_occupancy">
<a class="add_new_occupancy_btn" href="#"><i class="icon-plus"></i> <span>{l s='Add Room' mod='wkroomsearchblock'}</span></a>
<div>
<span id="add_new_occupancy">
<a class="add_new_occupancy_btn" href="#"><i class="icon-plus"></i> <span>{l s='Add Room' mod='wkroomsearchblock'}</span></a>
</span>
<span>
<button class="submit_occupancy_btn btn btn btn-primary pull-right">{l s='Done' mod='wkroomsearchblock'}</button>
</span>
</div>
</div>
</div>
Expand Down
15 changes: 10 additions & 5 deletions themes/hotel-reservation-theme/_partials/occupancy_field.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,16 @@
</div>
{/if}
</div>
<div class="add_occupancy_block">
<a class="add_new_occupancy_btn{if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies)} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<i class="icon-plus"></i>
<span>{l s='Add Room'}</span>
</a>
<div>
<span class="add_occupancy_block">
<a class="add_new_occupancy_btn{if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies)} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<i class="icon-plus"></i>
<span>{l s='Add Room'}</span>
</a>
</span>
<span>
<button type="submit" class="submit_occupancy_btn btn btn btn-primary pull-right">{l s='Done'}</button>
</span>
</div>
</div>
</div>
106 changes: 60 additions & 46 deletions themes/hotel-reservation-theme/js/occupancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,64 +160,78 @@ $(document).ready(function(){
}
});

$(document).on('click', '.booking_occupancy_wrapper .submit_occupancy_btn', function(e) {
e.preventDefault();
if ($('.booking_occupancy_wrapper:visible').length) {
return validateBookingOccupancies(e);
}
});

$(document).on('click', function(e) {
if ($('.booking_occupancy_wrapper:visible').length) {
var occupancy_wrapper = $('.booking_occupancy_wrapper:visible');
$(occupancy_wrapper).find(".occupancy_info_block").addClass('selected');
setRoomTypeGuestOccupancy(occupancy_wrapper);
if (!($(e.target).closest(".booking_occupancy_wrapper").length
|| $(e.target).closest(".booking_guest_occupancy").length
|| $(e.target).closest(".remove-room-link").length
)) {
let hasErrors = 0;
return validateBookingOccupancies(e);
}
}
});

let adults = $(occupancy_wrapper).find(".num_adults").map(function(){return $(this).val();}).get();
let children = $(occupancy_wrapper).find(".num_children").map(function(){return $(this).val();}).get();
let child_ages = $(occupancy_wrapper).find(".guest_child_age").map(function(){return $(this).val();}).get();
function validateBookingOccupancies(e) {
var occupancy_wrapper = $('.booking_occupancy_wrapper:visible');
$(occupancy_wrapper).find(".occupancy_info_block").addClass('selected');
setRoomTypeGuestOccupancy(occupancy_wrapper);
let hasErrors = 0;
let adults = $(occupancy_wrapper).find(".num_adults").map(function(){return $(this).val();}).get();
let children = $(occupancy_wrapper).find(".num_children").map(function(){return $(this).val();}).get();
let child_ages = $(occupancy_wrapper).find(".guest_child_age").map(function(){return $(this).val();}).get();

// start validating above values
if (!adults.length || (adults.length != children.length)) {
hasErrors = 1;
showErrorMessage(invalid_occupancy_txt);
} else {
$(occupancy_wrapper).find('.occupancy_count').removeClass('error_border');

// start validating above values
if (!adults.length || (adults.length != children.length)) {
// validate values of adults and children
adults.forEach(function (item, index) {
if (isNaN(item) || parseInt(item) < 1) {
hasErrors = 1;
showErrorMessage(invalid_occupancy_txt);
} else {
$(occupancy_wrapper).find('.occupancy_count').removeClass('error_border');

// validate values of adults and children
adults.forEach(function (item, index) {
if (isNaN(item) || parseInt(item) < 1) {
hasErrors = 1;
$(occupancy_wrapper).find(".num_adults").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
}
if (isNaN(children[index])) {
hasErrors = 1;
$(occupancy_wrapper).find(".num_children").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
}
});

// validate values of selected child ages
$(occupancy_wrapper).find('.guest_child_age').removeClass('error_border');
child_ages.forEach(function (age, index) {
age = parseInt(age);
if (isNaN(age) || (age < 0) || (age >= parseInt(max_child_age))) {
hasErrors = 1;
$(occupancy_wrapper).find(".guest_child_age").eq(index).addClass('error_border');
}
});
$(occupancy_wrapper).find(".num_adults").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
}
if (hasErrors == 0) {
if (!($(e.target).closest(".ajax_add_to_cart_button").length
|| $(e.target).closest(".exclusive.book_now_submit").length
)) {
$(occupancy_wrapper).parent().removeClass('open');
$(occupancy_wrapper).siblings(".booking_guest_occupancy").removeClass('error_border');
$(document).trigger( "QloApps:updateRoomOccupancy", [occupancy_wrapper]);
}
} else {
$(occupancy_wrapper).siblings(".booking_guest_occupancy").addClass('error_border');
if (isNaN(children[index])) {
hasErrors = 1;
$(occupancy_wrapper).find(".num_children").eq(index).closest('.occupancy_count_block').find('.occupancy_count').addClass('error_border');
}
}
});

// validate values of selected child ages
$(occupancy_wrapper).find('.guest_child_age').removeClass('error_border');
child_ages.forEach(function (age, index) {
age = parseInt(age);
if (isNaN(age) || (age < 0) || (age >= parseInt(max_child_age))) {
hasErrors = 1;
$(occupancy_wrapper).find(".guest_child_age").eq(index).addClass('error_border');
}
});
}
});
if (hasErrors == 0) {
if (!($(e.target).closest(".ajax_add_to_cart_button").length
|| $(e.target).closest(".exclusive.book_now_submit").length
)) {
$(occupancy_wrapper).parent().removeClass('open');
$(occupancy_wrapper).siblings(".booking_guest_occupancy").removeClass('error_border');
$(document).trigger( "QloApps:updateRoomOccupancy", [occupancy_wrapper]);
}
} else {
$(occupancy_wrapper).siblings(".booking_guest_occupancy").addClass('error_border');

return false;
}

return true;
}

$(document).on('click', '.booking_occupancy_wrapper .add_new_occupancy_btn', function(e) {
e.preventDefault();
Expand Down