Change booking form update using tpl on room type detail page
This commit is contained in:
@@ -218,6 +218,8 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
public function displayAjaxFilterResults()
|
||||
{
|
||||
$response = array('status' => 'ko');
|
||||
|
||||
$this->display_header = false;
|
||||
$this->display_footer = false;
|
||||
|
||||
@@ -286,9 +288,13 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
array_multisort($indi_arr, $direction, $booking_data['rm_data']);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array('booking_data' => $booking_data));
|
||||
$html = $this->context->smarty->fetch('_partials/room_type_list.tpl');
|
||||
$response['status'] = 'ok';
|
||||
$response['html_room_type_list'] = $html;
|
||||
}
|
||||
die($this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/room_type_list.tpl'));
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -304,19 +304,6 @@ class ProductControllerCore extends FrontController
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_from)));
|
||||
}
|
||||
|
||||
$obj_htl_cart_booking_data = new HotelCartBookingData();
|
||||
$obj_booking_detail = new HotelBookingDetail();
|
||||
$num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
|
||||
//$price_tax_incl = Product::getPriceStatic($this->product->id, HotelBookingDetail::useTax());
|
||||
//$total_price = $price_tax_incl * $num_days;
|
||||
//// By webkul New way to calculate product prices with feature Prices
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($this->product->id, $date_from, $date_to);
|
||||
if ($useTax) {
|
||||
$total_price = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$total_price = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
}
|
||||
//END
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
$hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1);
|
||||
|
||||
@@ -324,12 +311,6 @@ class ProductControllerCore extends FrontController
|
||||
$total_available_rooms = $hotel_room_data['stats']['num_avail'];
|
||||
}
|
||||
$hotel_branch_obj = new HotelBranchInformation($hotel_id);
|
||||
if (isset($this->context->cart->id)) {
|
||||
$num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to);
|
||||
if ($num_cart_rooms) {
|
||||
$total_available_rooms = $total_available_rooms - $num_cart_rooms;
|
||||
}
|
||||
}
|
||||
/*Max date of ordering for order restrict*/
|
||||
$order_date_restrict = false;
|
||||
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($hotel_id);
|
||||
@@ -362,9 +343,7 @@ class ProductControllerCore extends FrontController
|
||||
'warning_num' => Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'),
|
||||
'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png',
|
||||
'total_available_rooms' => $total_available_rooms,
|
||||
'total_price' => $total_price,
|
||||
'product_controller_url' => $this->context->link->getPageLink('product'),
|
||||
'num_days' => $num_days,
|
||||
'date_from' => $date_from,
|
||||
'date_to' => $date_to,
|
||||
'hotel_check_in' => date('h:i a', strtotime($hotel_branch_obj->check_in)),
|
||||
@@ -377,6 +356,9 @@ class ProductControllerCore extends FrontController
|
||||
'order_date_restrict' => $order_date_restrict
|
||||
)
|
||||
);
|
||||
|
||||
$this->assignBookingFormVars($this->product->id, $date_from, $date_to);
|
||||
|
||||
// product price after imposing feature prices...
|
||||
if ($useTax) {
|
||||
$priceProduct = Product::getPriceStatic($this->product->id, true);
|
||||
@@ -457,6 +439,138 @@ class ProductControllerCore extends FrontController
|
||||
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
|
||||
}
|
||||
|
||||
public function assignBookingFormVars(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$quantity = 1,
|
||||
$jsonDemands = ''
|
||||
) {
|
||||
$objProduct = new Product($idProduct, true, $this->context->language->id, $this->context->shop->id);
|
||||
if (!Validate::isLoadedObject($objProduct)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$smartyVars = array();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$objHotel = new HotelBranchInformation();
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$objHRTDemand = new HotelRoomTypeDemand();
|
||||
$objHRTDemandPrice = new HotelRoomTypeDemandPrice();
|
||||
|
||||
$idCart = (int) $this->context->cart->id;
|
||||
$idGuest = (int) $this->context->cart->id_guest;
|
||||
$warningCount = (int) Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER');
|
||||
|
||||
$roomType = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
$idHotel = $roomType['id_hotel'];
|
||||
$hotel = $objHotel->hotelBranchesInfo(false, 2, 1, $idHotel);
|
||||
$hotelLocation = $hotel['city'].', '.(isset($hotel['state_name']) ? ' '.$hotel['state_name'].', ' : '').
|
||||
' '.$hotel['country_name'];
|
||||
|
||||
$orderDateRestrict = false;
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
|
||||
if ($maxOrderDate) {
|
||||
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
|
||||
if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($dateFrom)
|
||||
|| strtotime($maxOrderDate) < strtotime($dateTo)
|
||||
) {
|
||||
$orderDateRestrict = true;
|
||||
}
|
||||
}
|
||||
|
||||
$numDays = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo);
|
||||
|
||||
$hotelRoomData = $objBookingDetail->DataForFrontSearch(
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idHotel,
|
||||
$idProduct,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
$idCart,
|
||||
$idGuest
|
||||
);
|
||||
|
||||
if ($hotelRoomData) {
|
||||
$totalAvailableRooms = $hotelRoomData['stats']['num_avail'];
|
||||
$quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity;
|
||||
}
|
||||
|
||||
// calculate room type price first
|
||||
$useTax = HotelBookingDetail::useTax();
|
||||
$totalPrice = 0;
|
||||
$productPriceWithoutReduction = $objProduct->getPriceWithoutReduct(!$useTax);
|
||||
$roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
);
|
||||
|
||||
$featurePrice = 0;
|
||||
if ($useTax) {
|
||||
$featurePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
true
|
||||
);
|
||||
$roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_incl'];
|
||||
} else {
|
||||
$featurePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
false
|
||||
);
|
||||
$roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
}
|
||||
$featurePriceDiff = (float) ($productPriceWithoutReduction - $featurePrice);
|
||||
|
||||
$totalRoomPrice = $roomTypeDateRangePrice * $quantity;
|
||||
|
||||
// calculate demand price now
|
||||
$demandsPrice = 0;
|
||||
$roomTypeDemands = $objHRTDemand->getRoomTypeDemands($idProduct);
|
||||
if ($jsonDemands !== '') {
|
||||
$cartDemands = json_decode($jsonDemands, true);
|
||||
$demandsPrice = $objHRTDemandPrice->getRoomTypeDemandsTotalPrice(
|
||||
$idProduct,
|
||||
$cartDemands,
|
||||
$useTax,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
);
|
||||
|
||||
$demandsPrice *= $quantity;
|
||||
}
|
||||
|
||||
// calculate total price
|
||||
$totalPrice = $totalRoomPrice + $demandsPrice;
|
||||
|
||||
$smartyVars['hotel_location'] = $hotelLocation;
|
||||
$smartyVars['order_date_restrict'] = $orderDateRestrict;
|
||||
$smartyVars['max_order_date'] = $maxOrderDate;
|
||||
$smartyVars['date_from'] = $dateFrom;
|
||||
$smartyVars['date_to'] = $dateTo;
|
||||
$smartyVars['allow_oosp'] = $objProduct->isAvailableWhenOutOfStock((int) $objProduct->out_of_stock);
|
||||
$smartyVars['quantity'] = $quantity;
|
||||
$smartyVars['num_days'] = $numDays;
|
||||
$smartyVars['warning_count'] = $warningCount;
|
||||
$smartyVars['total_available_rooms'] = $totalAvailableRooms;
|
||||
$smartyVars['has_room_type_demands'] = $roomTypeDemands ? true : false; // whether to show price breakup
|
||||
$smartyVars['rooms_price'] = $totalRoomPrice;
|
||||
$smartyVars['demands_price'] = $demandsPrice;
|
||||
$smartyVars['total_price'] = $totalPrice;
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign price and tax to the template
|
||||
*/
|
||||
@@ -922,6 +1036,33 @@ class ProductControllerCore extends FrontController
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function displayAjaxRefreshBookingForm()
|
||||
{
|
||||
$response = array('status' => 'ko');
|
||||
$idProduct = (int) Tools::getValue('id_product');
|
||||
$dateFrom = Tools::getValue('date_from');
|
||||
$dateTo = Tools::getValue('date_to');
|
||||
$quantity = (int) Tools::getValue('quantity');
|
||||
$roomTypeDemands = Tools::getValue('room_type_demands');
|
||||
|
||||
$dateFrom = date('Y-m-d', strtotime($dateFrom));
|
||||
$dateTo = date('Y-m-d', strtotime($dateTo));
|
||||
|
||||
if ($this->assignBookingFormVars(
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$quantity,
|
||||
$roomTypeDemands
|
||||
)) {
|
||||
$html = $this->context->smarty->fetch('_partials/booking-form.tpl');
|
||||
$response['status'] = 'ok';
|
||||
$response['html_booking_form'] = $html;
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function displayAjaxCheckRoomAvailabilityAndRate()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
@@ -178,19 +178,14 @@ $(document).ready(function()
|
||||
data.sort_value = sort_value;
|
||||
}
|
||||
|
||||
filter_ajax = $.ajax(
|
||||
{
|
||||
url: cat_link,
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
data: data,
|
||||
success: function (result)
|
||||
{
|
||||
if (result) {
|
||||
$('#category_data_cont').html(result);
|
||||
} else {
|
||||
var html = '<div class="noRoomsAvailAlert">'+noRoomAvailTxt+'</div>';
|
||||
$('#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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
126
themes/hotel-reservation-theme/_partials/booking-form.tpl
Normal file
126
themes/hotel-reservation-theme/_partials/booking-form.tpl
Normal file
@@ -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
|
||||
*}
|
||||
|
||||
<div class="booking-form card">
|
||||
<div class="booking_room_fields">
|
||||
<form action="" method="post">
|
||||
<div class="form-group htl_location_block">
|
||||
<label for="" class="control-label">{l s='Hotel Location'}</label>
|
||||
<p>{$hotel_location|escape:'html':'UTF-8'}</p>
|
||||
</div>
|
||||
{if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="" class="control-label">{l s='Check-in Date'}</label>
|
||||
<input type="text" class="form-control input-date" name="room_check_in" id="room_check_in" value="{if isset($date_from)}{$date_from|date_format:"%d-%m-%Y"}{/if}" autocomplete="off" readonly />
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="" class="control-label">{l s='Check-out Date'}</label>
|
||||
<input type="text" class="form-control input-date" name="room_check_out" id="room_check_out" value="{if isset($date_to)}{$date_to|escape:'html':'UTF-8'|date_format:"%d-%m-%Y"}{/if}" autocomplete="off" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="room_unavailability_date_error_div"></div>
|
||||
{if $total_available_rooms > 0}
|
||||
<div class="unvail_rooms_cond_display row">
|
||||
<div class="form-group col-sm-6" id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
|
||||
<label for="quantity_wanted">{l s='No. of Rooms'}</label>
|
||||
<div class="qty_sec_cont">
|
||||
<div class="qty_input_cont row margin-lr-0">
|
||||
<input autocomplete="off" type="text" min="1" name="qty" id="quantity_wanted" class="text" value="{$quantity|intval}">
|
||||
|
||||
<input type="hidden" id="num_days" value="{if isset($num_days)}{$num_days|escape:'html':'UTF-8'}{/if}">
|
||||
<input type="hidden" id="max_avail_type_qty" value="{if isset($total_available_rooms)}{$total_available_rooms|escape:'html':'UTF-8'}{/if}">
|
||||
</div>
|
||||
<div class="qty_direction">
|
||||
<a href="#" data-field-qty="qty" class="btn btn-default product_quantity_up">
|
||||
<span>
|
||||
<i class="icon-plus"></i>
|
||||
</span>
|
||||
</a>
|
||||
<a href="#" data-field-qty="qty" class="btn btn-default product_quantity_down">
|
||||
<span>
|
||||
<i class="icon-minus"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<span class="clearfix"></span>
|
||||
</div>
|
||||
</div>
|
||||
{if isset($has_room_type_demands) && $has_room_type_demands}
|
||||
<hr class="separator-hr-mg-10 unvail_rooms_cond_display">
|
||||
<div class="row price_desc_block unvail_rooms_cond_display">
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label">{l s='Room Price'}</label>
|
||||
<p>
|
||||
<span class="total_rooms_price_block">{convertPrice price=$rooms_price|floatval}</span>
|
||||
<span class="pull-right plus-sign">+</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label">{l s='Extra Facilities'}</label>
|
||||
<p class="extra_demands_price_block">
|
||||
{if isset($demands_price)}{convertPrice price=$demands_price}{else}{convertPrice price=0}{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="separator-hr-mg-10 form-group unvail_rooms_cond_display">
|
||||
{/if}
|
||||
<div class="room_unavailability_qty_error_div"></div>
|
||||
<div class="row unvail_rooms_cond_display">
|
||||
<div class="total_price_block col-xs-7 form-group">
|
||||
<label class="control-label">{l s='Subtotal'}</label>
|
||||
<p>{convertPrice price=$total_price|floatval}</p>
|
||||
</div>
|
||||
{if $total_available_rooms <= $warning_count}
|
||||
<div class="col-xs-5 form-group pull-right num_quantity_alert">
|
||||
<span class="num_searched_avail_rooms">
|
||||
{$total_available_rooms|escape:'html':'UTF-8'}
|
||||
</span>
|
||||
{if $total_available_rooms > 1} {l s='rooms left!'} {else} {l s='room left!'} {/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="unvail_rooms_cond_display">
|
||||
{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE || $order_date_restrict}
|
||||
{else}
|
||||
<p id="add_to_cart" class="buttons_bottom_block no-print">
|
||||
<button type="submit" name="Submit" class="exclusive book_now_submit">
|
||||
<span>
|
||||
{if isset($content_only) && $content_only && (isset($product->customization_required) && $product->customization_required)}{l s='Customize'}{else}{l s='Book Now'}{/if}
|
||||
</span>
|
||||
</button>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{else}
|
||||
<div class="sold_out_alert">
|
||||
<span>{l s='All rooms sold out!'}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{if $order_date_restrict}
|
||||
<div class="order_restrict_alert">
|
||||
<span>{l s='You can\'t book rooms after %s.' sprintf=[{dateFormat date=$max_order_date full=0}]}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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') {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
@@ -289,106 +289,8 @@
|
||||
<input type="hidden" name="add" value="1" />
|
||||
<input type="hidden" name="id_product_attribute" id="idCombination" value="" />
|
||||
</p>
|
||||
<div class="booking-form card">
|
||||
<div class="booking_room_fields">
|
||||
<form action="" method="post">
|
||||
<div class="form-group htl_location_block">
|
||||
<label for="" class="control-label">{l s='Hotel Location'}</label>
|
||||
<p>{$hotel_location|escape:'html':'UTF-8'}</p>
|
||||
</div>
|
||||
{if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="" class="control-label">{l s='Check In Date'}</label>
|
||||
<input type="text" class="form-control input-date" name="room_check_in" id="room_check_in" value="{if isset($date_from)}{$date_from|date_format:"%d-%m-%Y"}{/if}" autocomplete="off" readonly />
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="" class="control-label">{l s='Check Out Date'}</label>
|
||||
<input type="text" class="form-control input-date" name="room_check_out" id="room_check_out" value="{if isset($date_to)}{$date_to|escape:'html':'UTF-8'|date_format:"%d-%m-%Y"}{/if}" autocomplete="off" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="room_unavailability_date_error_div"></div>
|
||||
<div class="unvail_rooms_cond_display row">
|
||||
<div class="form-group col-sm-6" id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
|
||||
<label for="quantity_wanted">{l s='No. of Rooms'}</label>
|
||||
<div class="qty_sec_cont">
|
||||
<div class="qty_input_cont row margin-lr-0">
|
||||
<input autocomplete="off" type="text" min="1" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}">
|
||||
|
||||
<input type="hidden" id="num_days" value="{if isset($num_days)}{$num_days|escape:'html':'UTF-8'}{/if}">
|
||||
<input type="hidden" id="max_avail_type_qty" value="{if isset($total_available_rooms)}{$total_available_rooms|escape:'html':'UTF-8'}{/if}">
|
||||
</div>
|
||||
<div class="qty_direction">
|
||||
<a href="#" data-field-qty="qty" class="btn btn-default product_quantity_up">
|
||||
<span>
|
||||
<i class="icon-plus"></i>
|
||||
</span>
|
||||
</a>
|
||||
<a href="#" data-field-qty="qty" class="btn btn-default product_quantity_down">
|
||||
<span>
|
||||
<i class="icon-minus"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<span class="clearfix"></span>
|
||||
</div>
|
||||
</div>
|
||||
{if isset($room_type_demands) && $room_type_demands}
|
||||
<hr class="separator-hr-mg-10 unvail_rooms_cond_display">
|
||||
<div class="row price_desc_block unvail_rooms_cond_display">
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label">{l s='Room Price'}</label>
|
||||
<p>
|
||||
<span class="total_rooms_price_block">{convertPrice price=$total_price|floatval}</span>
|
||||
<span class="pull-right plus-sign">+</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label">{l s='Extra Facilities'}</label>
|
||||
<p class="extra_demands_price_block">{convertPrice price=0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="separator-hr-mg-10 form-group unvail_rooms_cond_display">
|
||||
{/if}
|
||||
<div class="room_unavailability_qty_error_div"></div>
|
||||
<div class="row unvail_rooms_cond_display">
|
||||
<div class="total_price_block col-xs-7 form-group">
|
||||
<label class="control-label">{l s='Subtotal'}</label>
|
||||
<p>
|
||||
{convertPrice price=$total_price|floatval}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-xs-5 form-group pull-right num_quantity_alert">
|
||||
<span class="num_searched_avail_rooms">{$total_available_rooms|escape:'html':'UTF-8'}</span> {l s='Room(s) Left !'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- End -->
|
||||
<div class="sold_out_alert">
|
||||
<span>{l s='Rooms Sold Out !'}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if $order_date_restrict}
|
||||
<div class="order_restrict_alert">
|
||||
<span>{l s='You can\'t book for rooms after date'} {$max_order_date|date_format:"%d-%m-%Y"}</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="unvail_rooms_cond_display">
|
||||
{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE || $order_date_restrict}
|
||||
{else}
|
||||
<p id="add_to_cart" class="buttons_bottom_block no-print">
|
||||
<button type="submit" name="Submit" class="exclusive book_now_submit">
|
||||
<span>
|
||||
{if $content_only && (isset($product->customization_required) && $product->customization_required)}{l s='Customize'}{else}{l s='Book Now'}{/if}
|
||||
</span>
|
||||
</button>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{include file='./_partials/booking-form.tpl'}
|
||||
|
||||
{* extra room type demands *}
|
||||
{if isset($room_type_demands) && $room_type_demands}
|
||||
|
||||
Reference in New Issue
Block a user