';
- $('#category_data_cont').html(html);
+ filter_ajax = $.ajax({
+ url: cat_link,
+ type: 'POST',
+ dataType: 'JSON',
+ data: data,
+ success: function (response) {
+ if (response.status == 'ok') {
+ $('#category_data_cont').html(response.html_room_type_list);
}
}
});
diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl
new file mode 100644
index 000000000..708a46fb9
--- /dev/null
+++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl
@@ -0,0 +1,126 @@
+{*
+* 2010-2022 Webkul.
+*
+* NOTICE OF LICENSE
+*
+* All right is reserved,
+* Please go through LICENSE.txt file inside our module
+*
+* 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 CustomizationPolicy.txt file inside our module for more information.
+*
+* @author Webkul IN
+* @copyright 2010-2022 Webkul IN
+* @license LICENSE.txt
+*}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js
index 0e6fb787c..f4c04381c 100644
--- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js
+++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js
@@ -507,11 +507,6 @@ var ajaxCart = {
var date_checkIn = $('#room_check_in').val();
var date_checkOut = $('#room_check_out').val();
var product_page_id_product = $('#product_page_product_id').val();
- console.log(idProduct == product_page_id_product);
- console.log(dateFrom);
- console.log(date_checkOut);
- console.log(dateTo);
- console.log(date_checkIn);
if (idProduct == product_page_id_product && dateFrom < date_checkOut && dateTo >= date_checkIn) {
if (jsonData.avail_rooms <= room_warning_num) {
$('.num_quantity_alert').show();
@@ -528,6 +523,7 @@ var ajaxCart = {
$('.unvail_rooms_cond_display').hide();
}
}
+ BookingForm.refresh();
}
if (pagename == 'category') {
diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js
index 01ecd1ec4..880716b28 100644
--- a/themes/hotel-reservation-theme/js/product.js
+++ b/themes/hotel-reservation-theme/js/product.js
@@ -1096,130 +1096,23 @@ $(document).ready(function() {
}
}
- $("#room_check_in").datepicker({
- showOtherMonths: true,
- dateFormat: 'dd-mm-yy',
- minDate: 0,
- beforeShow: function (input, instance) {
- // So that on translating page date is translated to NaN-NaN-NaN
- $('.ui-datepicker').addClass('notranslate');
- },
- beforeShowDay: function (date) {
- // highlight dates of the selected date range
- return highlightSelectedDateRange(date, $("#room_check_in").val(), $("#room_check_out").val());
- },
- onClose: function() {
- var checkOut = $("#room_check_out").val();
- var selectedDate = $("#room_check_in").val();
-
- var date_from_format = selectedDate.split("-");
- var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_from_format[2], date_from_format[1] - 1, date_from_format[0])));
- var date_in = $.datepicker.formatDate('yy-mm-dd', selectedDate);
-
- var date_to_format = $('#room_check_out').val().split("-");
- var selectedDateTo = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_to_format[2], date_to_format[1] - 1, date_to_format[0])));
-
- var date_out = $.datepicker.formatDate('yy-mm-dd', selectedDateTo);
-
- if (date_in >= date_out) {
- selectedDate.setDate(selectedDate.getDate() + 1);
- $("#room_check_out").datepicker("option", "minDate", selectedDate);
- $("#room_check_out").val($.datepicker.formatDate('dd-mm-yy', selectedDate));
- var date_out = $.datepicker.formatDate('yy-mm-dd', selectedDate);
- }
-
- /* open datepicker of chechout date only if
- checkout date is empty or checkin selected is equal or more than check out date */
- if (checkOut == '') {
- $("#room_check_out").datepicker( "show" );
- } else {
- // Lets make the date in the required format
- var currentDate = selectedDate.getDate();
- var currentMonth = selectedDate.getMonth() + 1;
- if (currentMonth < 10) {
- currentMonth = '0' + currentMonth;
- }
- if (currentDate < 10) {
- currentDate = '0' + currentDate;
- }
-
- dmy = selectedDate.getFullYear() + "-" + currentMonth + "-" + currentDate;
- checkOut = checkOut.split("-");
- checkOut = (checkOut[2]) + '-' + (checkOut[1]) + '-' + (checkOut[0]);
-
- if (checkOut <= dmy) {
- $("#room_check_out").datepicker('show');
- }
- }
-
- changeRoomDate(date_in, date_out);
- }
- });
-
- $("#room_check_out").datepicker({
- showOtherMonths: true,
- dateFormat: 'dd-mm-yy',
- beforeShow: function (input, instance) {
- // So that on translating page date is translated to NaN-NaN-NaN
- $('.ui-datepicker').addClass('notranslate');
-
- var date_to = $('#room_check_in').val();
- if (typeof date_to != 'undefined' && date_to != '') {
- var date_format = date_to.split("-");
- var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0])));
- selectedDate.setDate(selectedDate.getDate()+1);
- $("#room_check_out").datepicker("option", "minDate", selectedDate);
- } else {
- var date_format = new Date();
- var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date()));
- selectedDate.setDate(selectedDate.getDate()+1);
- $("#room_check_out").datepicker("option", "minDate", selectedDate);
- }
- },
- beforeShowDay: function (date) {
- // highlight dates of the selected date range
- return highlightSelectedDateRange(date, $("#room_check_in").val(), $("#room_check_out").val());
- },
- onSelect: function(dateText, inst) {
- var date_from_format = $('#room_check_in').val().split("-");
- var selectedDateFrom = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_from_format[2], date_from_format[1] - 1, date_from_format[0])));
- var date_in = $.datepicker.formatDate('yy-mm-dd', selectedDateFrom);
- var date_to_format = $('#room_check_out').val().split("-");
- var selectedDateTo = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_to_format[2], date_to_format[1] - 1, date_to_format[0])));
- var date_out = $.datepicker.formatDate('yy-mm-dd', selectedDateTo);
-
- if (date_in >= date_out) {
- $(this).val(inst.lastVal);
- $('.room_unavailability_date_error_div').text(correct_date_cond);
- $('.room_unavailability_date_error_div').css('display', 'block');
-
- setTimeout(function() {
- $('.room_unavailability_date_error_div').css('display', 'none');
- },
- 3000);
- } else {
- changeRoomDate(date_in, date_out);
- }
- }
- });
-
+ BookingForm.initDatepicker();
$(document).on('focusout', '#quantity_wanted', function(e) {
- changeRoomTypeDemands();
+ BookingForm.refresh();
});
$('.id_room_type_demand').on('click', function() {
- changeRoomTypeDemands();
+ BookingForm.refresh();
});
$(document).on('change', '.room_demand_block .id_option', function(e) {
- var option_selected = $(this).find('option:selected');
- var extra_demand_price = option_selected.attr("optionPrice")
- extra_demand_price = parseFloat(extra_demand_price);
- extra_demand_price = formatCurrency(extra_demand_price, currency_format, currency_sign, currency_blank);
-
- $(this).closest('.room_demand_block').find('.extra_demand_option_price').text(extra_demand_price);
- changeRoomTypeDemands();
+ var optionSelected = $(this).find('option:selected');
+ var extraDemandPrice = optionSelected.attr("optionPrice")
+ extraDemandPrice = parseFloat(extraDemandPrice);
+ extraDemandPrice = formatCurrency(extraDemandPrice, currency_format, currency_sign, currency_blank);
+ $(this).closest('.room_demand_block').find('.extra_demand_option_price').text(extraDemandPrice);
+ BookingForm.refresh();
});
/*Set maxDate for Order resrict date*/
@@ -1265,169 +1158,115 @@ $(document).ready(function() {
});
});
-function changeRoomTypeDemands() {
- var qty_wntd = $('#quantity_wanted').val();
- if (qty_wntd == '' || !$.isNumeric(qty_wntd)) {
- $('#quantity_wanted').val(1);
- qty_wntd = $('#quantity_wanted').val();
- }
- $('#quantity_wanted').val(parseInt(qty_wntd));
- if ((parseInt(qty_wntd) < 1 || parseInt(qty_wntd) > $('#max_avail_type_qty').val())
- && $('#max_avail_type_qty').val() > 0
- ) {
- $('#quantity_wanted').val($('#max_avail_type_qty').val());
- setTimeout(function() {
- $('.room_unavailability_qty_error_div').hide();
- },
- 2000);
- } else if (qty_wntd <= $('#max_avail_type_qty').val() && qty_wntd >= 1) {
- // get the selected extra demands by customer
- var roomDemands = getRoomsExtraDemands();
- $.ajax({
- type: 'POST',
- headers: {
- "cache-control": "no-cache"
+var BookingForm = {
+ init: function() {
+ BookingForm.initDatepicker();
+ },
+ initDatepicker: function() {
+ // date from
+ $("#room_check_in").datepicker({
+ showOtherMonths: true,
+ dateFormat: 'dd-mm-yy',
+ minDate: 0,
+ beforeShow: function (input, instance) {
+ // So that on translating page date is translated to NaN-NaN-NaN
+ $('.ui-datepicker').addClass('notranslate');
},
- url: product_controller_url,
- dataType: 'JSON',
- cache: false,
- data: {
- date_from: $('#room_check_in').val(),
- date_to: $('#room_check_out').val(),
- product_quantity_down: 1,
- qty: qty_wntd,
- id_product: $('#product_page_product_id').val(),
- room_demands: JSON.stringify(roomDemands),
- action: 'checkRoomAvailabilityAndRate',
- ajax: true
+ beforeShowDay: function (date) {
+ // highlight dates of the selected date range
+ return highlightSelectedDateRange(date, $("#room_check_in").val(), $("#room_check_out").val());
},
- success: function(result) {
- if (result.msg == 'success') {
- total_price = result.total_price;
- total_price = parseFloat(total_price);
- total_price = formatCurrency(total_price, currency_format, currency_sign, currency_blank);
- $('.total_price_block p').text(total_price);
- total_room_price = result.total_room_price;
- total_room_price = parseFloat(total_room_price);
- total_room_price = formatCurrency(total_room_price, currency_format, currency_sign, currency_blank);
- $('.total_rooms_price_block').text(total_room_price);
- extra_demand_price = result.extra_demand_price;
- extra_demand_price = parseFloat(extra_demand_price);
- extra_demand_price = formatCurrency(extra_demand_price, currency_format, currency_sign, currency_blank);
- $('.extra_demands_price_block').text(extra_demand_price);
+ onClose: function() {
+ var selectedDate = $("#room_check_in").val();
- $('#num_days').val(result.num_days);
- $("#max_avail_type_qty").val(result.avail_rooms);
- } else if (result.msg == 'unavailable_quantity') {
- $('#quantity_wanted').val(result.avail_rooms);
- $('.room_unavailability_qty_error_div').text(unavail_qty_text);
- $('.room_unavailability_qty_error_div').show();
+ var date_from_format = selectedDate.split("-");
+ var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_from_format[2], date_from_format[1] - 1, date_from_format[0])));
+ var date_in = $.datepicker.formatDate('yy-mm-dd', selectedDate);
- setTimeout(function() {
- $('.room_unavailability_qty_error_div').hide();
- },
- 2000);
+ var date_to_format = $('#room_check_out').val().split("-");
+ var selectedDateTo = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_to_format[2], date_to_format[1] - 1, date_to_format[0])));
+
+ var date_out = $.datepicker.formatDate('yy-mm-dd', selectedDateTo);
+
+ if (date_in >= date_out) {
+ selectedDate.setDate(selectedDate.getDate() + 1);
+ $("#room_check_out").datepicker("option", "minDate", selectedDate);
+ $("#room_check_out").val($.datepicker.formatDate('dd-mm-yy', selectedDate));
+ }
+ BookingForm.refresh();
+ }
+ });
+
+ // date to
+ $("#room_check_out").datepicker({
+ showOtherMonths: true,
+ dateFormat: 'dd-mm-yy',
+ beforeShow: function (input, instance) {
+ // So that on translating page date is translated to NaN-NaN-NaN
+ $('.ui-datepicker').addClass('notranslate');
+
+ var date_to = $('#room_check_in').val();
+ if (typeof date_to != 'undefined' && date_to != '') {
+ var date_format = date_to.split("-");
+ var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0])));
+ selectedDate.setDate(selectedDate.getDate()+1);
+ $("#room_check_out").datepicker("option", "minDate", selectedDate);
} else {
- alert(some_error_cond);
+ var date_format = new Date();
+ var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date()));
+ selectedDate.setDate(selectedDate.getDate()+1);
+ $("#room_check_out").datepicker("option", "minDate", selectedDate);
+ }
+ },
+ beforeShowDay: function (date) {
+ // highlight dates of the selected date range
+ return highlightSelectedDateRange(date, $("#room_check_in").val(), $("#room_check_out").val());
+ },
+ onSelect: function(dateText, instance) {
+ var date_from_format = $('#room_check_in').val().split("-");
+ var selectedDateFrom = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_from_format[2], date_from_format[1] - 1, date_from_format[0])));
+ var date_in = $.datepicker.formatDate('yy-mm-dd', selectedDateFrom);
+ var date_to_format = $('#room_check_out').val().split("-");
+ var selectedDateTo = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_to_format[2], date_to_format[1] - 1, date_to_format[0])));
+ var date_out = $.datepicker.formatDate('yy-mm-dd', selectedDateTo);
+
+ if (date_out > date_in) {
+ BookingForm.refresh();
}
}
});
- }
-}
-
-function changeRoomDate(date_in, date_out){
- // get the selected extra demands by customer
- var roomDemands = getRoomsExtraDemands();
-
- /*by webkul to manage quantity of rooms*/
- $.ajax({
- type: 'POST',
- headers: {
- "cache-control": "no-cache"
- },
- url: product_controller_url,
- cache: false,
- dataType: 'JSON',
- data: {
- date_from: date_in,
- date_to: date_out,
- change_date: 1,
- qty: $('#quantity_wanted').val(),
- id_product: $('#product_page_product_id').val(),
- room_demands: JSON.stringify(roomDemands),
- action: 'checkRoomAvailabilityAndRate',
- ajax: true
- },
- success: function(result) {
- if (result.msg == 'success') {
- if (result.avail_rooms <= room_warning_num) {
- $('.num_quantity_alert').show();
- } else {
- $('.num_quantity_alert').hide();
- }
-
- $('.num_searched_avail_rooms').text(result.avail_rooms);
- $("#max_avail_type_qty").val(result.avail_rooms);
- $('.room_unavailability_date_error_div').hide();
- $('.unvail_rooms_cond_display').show();
- $('.sold_out_alert').hide();
- disableRoomTypeDemands(0);
-
- total_price = result.total_price;
- total_price = parseFloat(total_price);
- total_price = formatCurrency(total_price, currency_format, currency_sign, currency_blank);
- total_room_price = result.total_room_price;
- total_room_price = parseFloat(total_room_price);
- total_room_price = formatCurrency(total_room_price, currency_format, currency_sign, currency_blank);
- $('.total_price_block p').text(total_price);
- $('.total_rooms_price_block').text(total_room_price);
-
- extra_demand_price = parseFloat(result.extra_demand_price);
- extra_demand_price = formatCurrency(extra_demand_price, currency_format, currency_sign, currency_blank);
- $('.extra_demands_price_block').text(extra_demand_price);
-
- feature_price = parseFloat(result.feature_price);
- original_product_price = parseFloat(result.original_product_price);
- feature_price_diff = parseFloat(result.feature_price_diff);
- if (feature_price_diff > 0) {
- $('.room_type_current_price').text(formatCurrency(feature_price, currency_format, currency_sign, currency_blank));
- $('.room_type_current_price').show();
- $('.product_original_price').addClass('room_type_old_price');
- } else if (feature_price_diff < 0) {
- $('.room_type_current_price').text(formatCurrency(feature_price, currency_format, currency_sign, currency_blank));
- $('.room_type_current_price').show();
- $('.product_original_price').hide();
- } else {
- $('.room_type_current_price').hide();
- $('.product_original_price').removeClass('room_type_old_price');
- $('.product_original_price').show();
- }
-
- $('#num_days').val(result.num_days);
- } else if (result.msg == 'unavailable_quantity') {
- if (result.avail_rooms > 0) {
- $('.room_unavailability_date_error_div').text(unavail_qty_text);
- $('.num_searched_avail_rooms').text(result.avail_rooms);
- $("#max_avail_type_qty").val(result.avail_rooms);
- $('.room_unavailability_date_error_div').show();
- $('#quantity_wanted').val(result.avail_rooms);
- $('.unvail_rooms_cond_display').show();
- $('.sold_out_alert').hide();
- disableRoomTypeDemands(0);
-
- setTimeout(function() {
- $('.room_unavailability_date_error_div').css('display', 'none');
- },
- 3000);
- } else {
- $('.num_quantity_alert').hide();
- $('.unvail_rooms_cond_display').hide();
- $('.sold_out_alert').show();
- disableRoomTypeDemands(1);
- }
- } else {
- alert(some_error_cond);
- }
- }
- });
+ },
+ getFormData: function () {
+ var data = {
+ id_product: parseInt($('#product_page_product_id').val()),
+ date_from: $('#room_check_in').val(),
+ date_to: $('#room_check_out').val(),
+ quantity: parseInt($('#quantity_wanted').val()),
+ room_type_demands: JSON.stringify(getRoomsExtraDemands()),
+ };
+ return data;
+ },
+ refresh: function() {
+ $.ajax({
+ url: product_controller_url,
+ type: 'POST',
+ headers: { 'cache-control': 'no-cache' },
+ dataType: 'JSON',
+ cache: false,
+ data: $.extend({
+ ajax: true,
+ action: 'refreshBookingForm',
+ }, BookingForm.getFormData()),
+ success: function(response) {
+ if (response.status == 'ok') {
+ $('.booking-form').animate({opacity: 0}, 250, 'linear', function() {
+ $('.booking-form').replaceWith(response.html_booking_form);
+ $('.booking-form').animate({opacity: 1}, 250, 'linear', function() {
+ BookingForm.init();
+ });
+ })
+ }
+ }
+ });
+ },
}
diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl
index c7b91d609..9b24bbf7b 100644
--- a/themes/hotel-reservation-theme/product.tpl
+++ b/themes/hotel-reservation-theme/product.tpl
@@ -289,106 +289,8 @@
-
-
-
-
-
+ {include file='./_partials/booking-form.tpl'}
{* extra room type demands *}
{if isset($room_type_demands) && $room_type_demands}