Updated search form, added new hooks, updated cart to support time along with date

This commit is contained in:
Shreesh Arora
2024-09-06 10:39:07 +05:30
parent 9d4aaa8541
commit 03094d2108
16 changed files with 100 additions and 163 deletions

View File

@@ -30,6 +30,7 @@
</div>
</div>
<div class="add_room_fields bookingDuration" style="display:none;">
{hook h='displayAddRoomBookingModal'}
<div class="row form-group">
<div class="col-sm-6 room_check_in_div">
<label class="control-label">{l s='Check-In'}</label>

View File

@@ -942,8 +942,8 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart = new Cart($id_cart);
$date_from = date('Y-m-d', strtotime($date_from));
$date_to = date('Y-m-d', strtotime($date_to));
$date_from = date('Y-m-d H:i:s', strtotime($date_from));
$date_to = date('Y-m-d H:i:s', strtotime($date_to));
if ($this->context->cart->id_currency != (int)Configuration::get('PS_CURRENCY_DEFAULT')) {
$currency = Currency::getCurrencyInstance($this->context->cart->id_currency);

View File

@@ -3923,9 +3923,9 @@ class AdminOrdersControllerCore extends AdminController
$product_informations = $_POST['add_product'];
/*By Webkul Code is added to add order information In our table while adding product in the process order edit from order detail page.*/
$date_from = date('Y-m-d', strtotime($product_informations['date_from']));
$date_to = date('Y-m-d', strtotime($product_informations['date_to']));
$curr_date = date('Y-m-d');
$date_from = date('Y-m-d H:i:s', strtotime($product_informations['date_from']));
$date_to = date('Y-m-d H:i:s', strtotime($product_informations['date_to']));
$curr_date = date('Y-m-d H:i:s');
$occupancy = Tools::getValue('occupancy');
/*Validations*/
if ($date_from == '') {
@@ -4674,8 +4674,8 @@ class AdminOrdersControllerCore extends AdminController
$cart = new Cart($obj_booking_detail->id_cart);
$product_informations = $_POST['edit_product'];
$new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from'])));
$new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to'])));
$new_date_from = trim(date('Y-m-d H:i:s', strtotime($product_informations['date_from'])));
$new_date_to = trim(date('Y-m-d H:i:s', strtotime($product_informations['date_to'])));
$old_date_from = trim(Tools::getValue('date_from'));
$old_date_to = trim(Tools::getValue('date_to'));
$id_hotel = trim(Tools::getValue('id_hotel'));
@@ -5652,10 +5652,10 @@ class AdminOrdersControllerCore extends AdminController
$product_price_tax_incl = str_replace(',', '.', Tools::getValue('product_price_tax_incl'));
$product_price_tax_excl = str_replace(',', '.', Tools::getValue('product_price_tax_excl'));
$product_informations = $_POST['edit_product'];
$new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from'])));
$new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to'])));
$old_date_from = date('Y-m-d', strtotime(trim(Tools::getValue('date_from'))));
$old_date_to = date('Y-m-d', strtotime(trim(Tools::getValue('date_to'))));
$new_date_from = trim(date('Y-m-d H:i:s', strtotime($product_informations['date_from'])));
$new_date_to = trim(date('Y-m-d H:i:s', strtotime($product_informations['date_to'])));
$old_date_from = date('Y-m-d H:i:s', strtotime(trim(Tools::getValue('date_from'))));
$old_date_to = date('Y-m-d H:i:s', strtotime(trim(Tools::getValue('date_to'))));
$id_hotel = trim(Tools::getValue('id_hotel'));
$id_room = trim(Tools::getValue('id_room'));
$id_product = trim(Tools::getValue('id_product'));

View File

@@ -141,11 +141,11 @@ class CategoryControllerCore extends FrontController
$id_category = Tools::getValue('id_category');
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$date_from = date('Y-m-d H:i:s');
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
}
// get occupancy of the search
@@ -160,9 +160,9 @@ class CategoryControllerCore extends FrontController
if ($preparationTime
&& strtotime('+ '.$preparationTime.' day') >= strtotime($date_from)
) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
$date_from = date('Y-m-d H:i:s', strtotime('+ '.$preparationTime.' day'));
if (strtotime($date_from) >= strtotime($date_to)) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
}
}

View File

@@ -477,6 +477,8 @@ class HotelBookingDetail extends ObjectModel
}
unset($roomTypesDetail);
Hook::exec('actionBookingDataResultModifier', array('params' => &$params, 'finalSearchResponse' => &$finalSearchResponse ));
return $finalSearchResponse;
}
}

View File

@@ -484,7 +484,7 @@ class HotelCartBookingData extends ObjectModel
) {
$objHotelBranchInformation = new HotelBranchInformation($id_hotel);
$date_from = date('Y-m-d H:i:s', strtotime($objHotelBranchInformation->check_in, strtotime($date_from)));
$date_to = date('Y-m-d H:i:s', strtotime($objHotelBranchInformation->check_in, strtotime($date_to)));
$date_to = date('Y-m-d H:i:s', strtotime($objHotelBranchInformation->check_out, strtotime($date_to)));
}
$obj_htl_cart_booking_data->date_from = $date_from;
$obj_htl_cart_booking_data->date_to = $date_to;
@@ -1610,11 +1610,11 @@ class HotelCartBookingData extends ObjectModel
$numDays = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_rm'] = 1;
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['data_form'] = date(
'Y-m-d',
'Y-m-d H:i:s',
strtotime($data_v['date_from'])
);
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['data_to'] = date(
'Y-m-d',
'Y-m-d H:i:s',
strtotime($data_v['date_to'])
);
$cartHotelData[$prodKey]['date_diff'][$dateJoin]['num_days'] = $numDays;

View File

@@ -646,9 +646,6 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$with_auto_room_services = 1,
$use_reduc = 1
) {
if ($date_from == $date_to) {
ddd('<pre>'.print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true).'</pre>');
}
$totalPrice = array();
$totalPrice['total_price_tax_incl'] = 0;
$totalPrice['total_price_tax_excl'] = 0;
@@ -727,9 +724,15 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
'idRoom' => $id_room,
'dateFrom' => $date_from,
'dateTo' => $date_to,
'idCurrency' => $id_currency,
'quantity' => $quantity,
'idCart' => $id_cart,
'idGuest' => $id_guest,
'useReduc' => $use_reduc
'idGroup' => $id_group,
'useReduc' => $use_reduc,
'taxRate' => $taxRate,
'productPriceTI' => $productPriceTI,
'productPriceTE' => $productPriceTE
)
);
if ($with_auto_room_services) {

View File

@@ -313,8 +313,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'is_occupancy_wise_search' => $isOccupancyWiseSearch,
));
MediaCore::addJsDef(array(
'initialDate' => $this->date_from,
'initialView' => 'timeGridDay'
'initialDate' => $this->date_from
));
}

View File

@@ -22,7 +22,7 @@ $(document).ready(function() {
// calender
if ($('#fullcalendar').length) {
var calendar = new FullCalendar.Calendar($('#fullcalendar').get(0), {
initialView: initialView,
initialView: 'dayGridMonth',
initialDate: initialDate,
events: {
url: rooms_booking_url,
@@ -934,23 +934,17 @@ $(document).ready(function() {
function refreshStatsData()
{
var search_id_room_type = $("#search_id_room_type").val();
var search_id_hotel = $("#search_id_hotel").val();
var search_date_from = $("#search_date_from").val();
var search_date_to = $("#search_date_to").val();
var formData = new FormData($('form#room-search-form').get(0));
formData.append('ajax', true);
formData.append('action', 'getBookingStats');
$.ajax({
url: rooms_booking_url,
type: 'POST',
dataType: 'JSON',
data: {
ajax: true,
action: 'getBookingStats',
search_id_room_type: search_id_room_type,
search_id_hotel: search_id_hotel,
search_date_from: search_date_from,
search_date_to: search_date_to,
},
data: formData,
processData: false,
contentType: false,
success: function(result) {
if (result.success) {
$(".htl_room_data_cont").html(result.data.stats_panel);

View File

@@ -41,7 +41,7 @@
{foreach from=$book_v['data']['available'] key=avai_k item=avai_v}
<tr>
<td>{$avai_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$avai_v type='available'}</td>
<td>{dateFormat date=date('Y-m-d', strtotime($date_from))} - {dateFormat date=date('Y-m-d', strtotime($date_to))}</td>
<td>{dateFormat date=$date_from} - {dateFormat date=$date_to}</td>
<td>{$avai_v['room_comment']|escape:'htmlall':'UTF-8'}</td>
<td>
{foreach $allotment_types as $allotment_type}
@@ -127,7 +127,7 @@
<tr>
{if $sub_part_v@first}
<td rowspan="{$part_v['rooms']|count}">
<p>{dateFormat date=date('Y-m-d', strtotime($part_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($part_v['date_to']))}</p>
<p>{dateFormat date=$part_v['date_from']} - {dateFormat date=$part_v['date_to']}</p>
</td>
{/if}
<td >{$sub_part_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$sub_part_v type='partially_available'}</td>
@@ -216,7 +216,7 @@
{if $rm_dtl_v@first}
<td rowspan="{$booked_v['detail']|count}">{$booked_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$booked_v key=$rm_dtl_k type='booked'}</td>
{/if}
<td>{dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_to']))}</td>
<td>{dateFormat date=$rm_dtl_v['date_from']} - {dateFormat date=$rm_dtl_v['date_to']}</td>
<td><a href="{$link->getAdminLink('AdminOrders')}&id_order={$rm_dtl_v['id_order']|intval}&vieworder" target="_blank">#{$rm_dtl_v['id_order']}</a></td>
<td>{$rm_dtl_v['comment']|escape:'htmlall':'UTF-8'}</td>
<td>
@@ -259,7 +259,7 @@
<td>{HotelRoomInformation::getRoomStatusTitle($unavail_dtl_v['id_status'])|escape:'htmlall':'UTF-8'}</td>
<td>
{if $unavail_dtl_v['date_from'] && $unavail_dtl_v['date_to']}
{dateFormat date=date('Y-m-d', strtotime($unavail_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($unavail_dtl_v['date_to']))}
{dateFormat date=$unavail_dtl_v['date_from']} - {dateFormat date=$unavail_dtl_v['date_to']}
{else}
--
{/if}

View File

@@ -6,7 +6,7 @@
<i class="icon-info"></i> {l s='Booking Form' mod='hotelreservationsystem'}
</div>
<div class="panel-body">
<form method="post" action="">
<form method="post" action="" id="room-search-form">
<div class="row">
{* <div class="form-group col-sm-12">
<label for="booking_product" class="control-label col-sm-4 required">

View File

@@ -253,65 +253,17 @@ class WkRoomSearchHelper
$smartyVars['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
$smartyVars['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($idHotel);
// set base width for each elements
$search_column_widths = array(
'location' => 4,
'hotel' => 5,
'date' => 5,
'occupancy' => 4,
'search' => 4
);
if (!$locationEnabled) {
unset($search_column_widths['location']);
$search_column_widths['date'] += 2;
$search_column_widths['search'] += 1;
if ($occupancyEnabled) {
$search_column_widths['occupancy'] += 1;
} elseif ($smartyVars['show_hotel_name'] || count($hotelsInfo) > 1) {
$search_column_widths['hotel'] += 1;
} else {
$search_column_widths['date'] += 1;
}
}
if (!$smartyVars['show_hotel_name'] && count($hotelsInfo) <= 1) {
unset($search_column_widths['hotel']);
$search_column_widths['date'] += 2;
$search_column_widths['search'] += 1;
if ($occupancyEnabled) {
$search_column_widths['occupancy'] += 2;
} else {
$search_column_widths['date'] += 2;
}
}
if (!$occupancyEnabled) {
unset($search_column_widths['occupancy']);
$search_column_widths['date'] += 1;
if ($smartyVars['show_hotel_name'] || count($hotelsInfo) > 1) {
$search_column_widths['hotel'] += 1;
$search_column_widths['date'] += 1;
if ($locationEnabled) {
$search_column_widths['location'] += 1;
} else {
$search_column_widths['date'] += 1;
}
} else {
$search_column_widths['date'] += 3;
}
}
$smartyVars['column_widths'] = $search_column_widths;
if (count($search_column_widths) == 2) {
if (!$locationEnabled
&& !$smartyVars['show_hotel_name']
&& count($hotelsInfo) <= 1
&& !$occupancyEnabled
) {
$smartyVars['multiple_dates_input'] = true;
Media::addJSDef(array(
'multiple_dates_input' => true
));
}
Context::getContext()->smarty->assign($smartyVars);
}
}

View File

@@ -54,11 +54,11 @@
#search_hotel_block_form .hotel-selector-wrap .chosen-container-single .chosen-search {
height: 45px;
}
/* #search_hotel_block_form #search_room_submit {
height: 45px;
} */
#search_hotel_block_form {
grid-template-columns: 1fr;
#search_hotel_block_form.grid {
display: block;
}
#search_hotel_block_form.grid > div {
display: block;
}
#search_hotel_block_form > div {
grid-column-end: unset!important;

View File

@@ -19,78 +19,41 @@
#search_hotel_block_form.grid {
display: grid;
grid-template-columns: repeat(22, 1fr);
column-gap: 5px;
}
#search_hotel_block_form.grid > div {
#search_hotel_block_form.grid .grid-item {
display: grid;
}
#search_hotel_block_form .area-1 {
--col-span: 1;
}
#search_hotel_block_form .area-2 {
--col-span: 2;
}
#search_hotel_block_form .area-3 {
grid-column-end: span 3;
--col-span: 3;
}
#search_hotel_block_form .area-4 {
grid-column-end: span 4;
--col-span: 4;
}
#search_hotel_block_form .area-5 {
grid-column-end: span 5;
--col-span: 5;
}
#search_hotel_block_form .area-6 {
grid-column-end: span 6;
}
#search_hotel_block_form .area-7 {
grid-column-end: span 7;
}
#search_hotel_block_form .area-8 {
grid-column-end: span 8;
}
#search_hotel_block_form .area-9 {
grid-column-end: span 9;
}
#search_hotel_block_form .area-10 {
grid-column-end: span 10;
}
#search_hotel_block_form .area-11 {
grid-column-end: span 11;
}
#search_hotel_block_form .area-14 {
grid-column-end: span 14;
}
#search_hotel_block_form .area-16 {
grid-column-end: span 16;
}
#daterange_value.grid {
display: grid;
#daterange_value.multi-date {
column-gap: 5px;
grid-template-columns: repeat(2, 1fr);
}
.fancybox-wrap #search_hotel_block_form .form-group.xs-calendar {
position: relative;
}
/* #search_hotel_block_form {
display: grid;
grid-template-columns: 0.8fr repeat(3, 1fr) 0.6fr;
column-gap: 5px;
}
@media (min-width: 768px) and (max-width: 991px) {
#search_hotel_block_form {
grid-template-columns: repeat(12, 1fr);
grid-template-rows: repeat(2, 1fr);
}
#search_hotel_block_form > div {
grid-column-end: span 4;
}
#search_hotel_block_form > div:nth-child(1) {
grid-column: 1 / span 5;
}
#search_hotel_block_form > div:nth-child(2) {
grid-column: 6 / span 5;
}
}
@media (max-width: 767px) {
#search_hotel_block_form {
grid-template-columns: 1fr;
#search_hotel_block_form.grid {
display: block;
}
} */
#search_hotel_block_form.grid .grid-item {
display: block;
}
}
#search_hotel_block_form .header-rmsearch-input {
border-radius: 4px;
border: none;

View File

@@ -337,6 +337,21 @@ const BookingSearchManager = {
return true;
},
}
function updateGridColumns() {
const gridContainer = $('#search_hotel_block_form');
const gridItems = $('#search_hotel_block_form div.grid-item');
let totalColumns = 0;
Array.from(gridItems).forEach(item => {
totalColumns += parseInt(getComputedStyle(item).getPropertyValue('--col-span'));
});
$(gridContainer).css('grid-template-columns', `repeat(${totalColumns}, 1fr)`);
Array.from(gridItems).forEach(item => {
item.style.gridColumn = `span ${getComputedStyle(item).getPropertyValue('--col-span')}`;
});
}
$(document).ready(function() {
// initialize booking search fields

View File

@@ -18,8 +18,9 @@
*}
<form method="POST" id="search_hotel_block_form" class="grid">
{hook h='displaySearchFormTop'}
{if isset($location_enabled) && $location_enabled}
<div class="form-group area-{$column_widths['location']}">
<div class="form-group grid-item area-3">
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data)}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data)}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
<div class="dropdown">
@@ -34,7 +35,7 @@
<input type="hidden" id="id_hotel" name="id_hotel" value="{$hotels_info[0]['id']|escape:'htmlall':'UTF-8'}">
<input type="hidden" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
{else}
<div class="form-group area-{$column_widths['hotel']}">
<div class="form-group grid-item area-3">
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
@@ -51,7 +52,7 @@
</div>
{/if}
{if isset($multiple_dates_input) && $multiple_dates_input}
<div class="grid area-{$column_widths['date']}" id="daterange_value">
<div class="grid-item area-5 multi-date" id="daterange_value">
<div class="form-group">
<input type="hidden" id="check_in_time" name="check_in_time" {if isset($search_data)}value="{$search_data['date_from']|escape:'htmlall':'UTF-8'}"{/if}>
<div class="form-control header-rmsearch-input input-date" autocomplete="off" id="daterange_value_from" placeholder="{l s='Check-in' mod='wkroomsearchblock'}"><span>{l s='Check-in' mod='wkroomsearchblock'}</span></div>
@@ -62,7 +63,7 @@
</div>
</div>
{else}
<div class="form-group area-{$column_widths['date']}">
<div class="form-group grid-item area-4">
<input type="hidden" id="check_in_time" name="check_in_time" {if isset($search_data)}value="{$search_data['date_from']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="check_out_time" name="check_out_time" {if isset($search_data)}value="{$search_data['date_to']|escape:'htmlall':'UTF-8'}"{/if}>
<div class="form-control header-rmsearch-input input-date" id="daterange_value" autocomplete="off" placeholder="{l s='Check-in - Check-out' mod='wkroomsearchblock'}" tabindex="-1"><span>{l s='Check-in' mod='wkroomsearchblock'} &nbsp;<i class="icon icon-minus"></i>&nbsp; {l s='Check-out' mod='wkroomsearchblock'}</span></div>
@@ -70,7 +71,7 @@
{/if}
{if isset($is_occupancy_wise_search) && $is_occupancy_wise_search}
<div class="form-group area-{$column_widths['occupancy']}">
<div class="form-group grid-item area-4">
<div class="dropdown">
<button class="form-control input-occupancy header-rmsearch-input {if isset($error) && $error == 1}error_border{/if}" type="button" data-toggle="dropdown" id="guest_occupancy">
<span class="pull-left">{if (isset($search_data['occupancy_adults']) && $search_data['occupancy_adults'])}{$search_data['occupancy_adults']} {if $search_data['occupancy_adults'] > 1}{l s='Adults' mod='wkroomsearchblock'}{else}{l s='Adult' mod='wkroomsearchblock'}{/if}, {if isset($search_data['occupancy_children']) && $search_data['occupancy_children']}{$search_data['occupancy_children']} {if $search_data['occupancy_children'] > 1}
@@ -222,9 +223,16 @@
</div>
</div>
{/if}
<div class="form-group search_room_submit_block area-{$column_widths['search']}">
<button type="submit" class="btn btn btn-primary pull-right" name="search_room_submit" id="search_room_submit">
<div class="form-group grid-item search_room_submit_block area-3">
<button type="submit" class="btn btn btn-primary" name="search_room_submit" id="search_room_submit">
<span>{l s='Search Rooms' mod='wkroomsearchblock'}</span>
</button>
</div>
</form>
</form>
<script>
{literal}
// Call the function to set the grid columns on load
updateGridColumns();
{/literal}
</script>