Fixed the booking dates incase prepration time is applied to the hotel

This commit is contained in:
vishalsingh.qlo325
2024-06-26 12:48:55 +05:30
parent 08d9017845
commit 60fd1bc2d1
3 changed files with 43 additions and 7 deletions

View File

@@ -165,6 +165,16 @@ class CategoryControllerCore extends FrontController
$currency = new Currency($this->context->currency->id);
if ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($id_category)) {
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($id_hotel);
if ($preparationTime
&& strtotime('+ '.$preparationTime.' day') >= strtotime($date_from)
) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
if (strtotime($date_from) >= strtotime($date_to)) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
}
}
$id_cart = $this->context->cart->id;
$id_guest = $this->context->cookie->id_guest;

View File

@@ -344,10 +344,6 @@ class ProductControllerCore extends FrontController
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id);
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
if ($preparationTime) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
}
// set date to according to los
$objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange();
$los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from);
@@ -360,6 +356,17 @@ class ProductControllerCore extends FrontController
$date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from)));
}
if ($preparationTime
&& strtotime('+ '.$preparationTime.' day') >= strtotime($date_from)
) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
if (strtotime($date_from) >= strtotime($date_to)) {
$objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange();
$los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from);
$date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from)));
}
}
$hotel_branch_obj = new HotelBranchInformation($hotel_id);
/*Max date of ordering for order restrict*/
$order_date_restrict = false;

View File

@@ -140,11 +140,31 @@ class WkRoomSearchHelper
if (!$dateTo = Tools::getValue('date_to')) {
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateFrom)));
}
$smartyVars['date_from'] = $dateFrom;
$smartyVars['date_to'] = $dateTo;
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idHotelCategory);
$htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent);
$searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel);
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($idHotel);
if ($preparationTime
&& strtotime('+ '.$preparationTime.' day') >= strtotime($dateFrom)
) {
$dateFrom = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
if (strtotime($dateFrom) >= strtotime($dateTo)) {
$controller = Tools::getValue('controller');
if ($controller == 'product'
&& ($idProduct = Tools::getValue('id_product'))
) {
$objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange();
$los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom);
$dateTo = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($dateFrom)));
} else {
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateFrom)));
}
}
}
$smartyVars['date_from'] = $dateFrom;
$smartyVars['date_to'] = $dateTo;
$objBookingDetail = new HotelBookingDetail();
$searchedData['num_days'] = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo);
@@ -152,7 +172,6 @@ class WkRoomSearchHelper
$searchedData['parent_data'] = $htlCategoryInfo;
$searchedData['date_from'] = $dateFrom;
$searchedData['date_to'] = $dateTo;
$searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel);
if ($locationCategoryId) {
$objLocationCategory = new Category($locationCategoryId, $context->language->id);