Skip to content

Commit

Permalink
Merge pull request #966 from vishal-singh-webkul/gli-1702
Browse files Browse the repository at this point in the history
Added: Done button in the occupancy popup in the front office.
  • Loading branch information
rohit053 authored Jul 4, 2024
2 parents fa19ec3 + e57b18b commit 8b098f8
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 54 deletions.
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 @@ -830,6 +830,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

0 comments on commit 8b098f8

Please sign in to comment.