From 07bd2983d6bda70d8696c15c2d4cdf6184ae4f57 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 7 Oct 2024 15:28:09 +0530 Subject: [PATCH 01/56] Added: occupancy in hook 'actionRoomTypeTotalPriceModifier' in functions HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(), HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay() and in the calls. --- classes/Cart.php | 18 +++++++++-- classes/PaymentModule.php | 32 ++++++++++++++----- controllers/admin/AdminOrdersController.php | 19 +++++++++-- controllers/front/ProductController.php | 32 +++++++++++++------ modules/blockcart/blockcart.php | 2 +- .../classes/HotelAdvancedPayment.php | 9 +++++- .../classes/HotelBookingDetail.php | 14 ++++++-- .../classes/HotelRoomTypeFeaturePricing.php | 16 +++++++--- .../AdminHotelRoomsBookingController.php | 11 +++++-- .../classes/WkPaypalCommerceHelper.php | 10 +++++- .../wkhotelfilterblock/wkhotelfilterblock.php | 4 +-- 11 files changed, 132 insertions(+), 35 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 6fef5ee79..ed44f01b6 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -733,11 +733,18 @@ class CartCore extends ObjectModel $totalPriceByProductTaxExcl = 0; $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, Group::getCurrent()->id, $cartRoomInfo['id_cart'], $cartRoomInfo['id_guest'], @@ -1782,12 +1789,19 @@ class CartCore extends ObjectModel $totalPriceByProduct = 0; $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); // get the real price of the room type $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, Group::getCurrent()->id, $cartRoomInfo['id_cart'], $cartRoomInfo['id_guest'], diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index a41e558b0..1e1326d96 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -808,11 +808,18 @@ abstract class PaymentModuleCore extends Module $objBookingDetail->is_back_order = $objCartBookingData->is_back_order; $objBookingDetail->comment = $objCartBookingData->comment; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); $total_price = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $objCartBookingData->id_cart, $objCartBookingData->id_guest, @@ -1694,6 +1701,7 @@ abstract class PaymentModuleCore extends Module } else { $cart_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); } + if ($cart_bk_data) { $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']); @@ -1714,11 +1722,20 @@ abstract class PaymentModuleCore extends Module $cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; $cart_htl_data[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; + $occupancy = array( + array( + 'adults' => $data_v['adults'], + 'children' => $data_v['children'], + 'child_ages' => json_decode($data_v['child_ages']) + ) + ); - - - $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']); - + $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( + $type_value['id_product'], + $data_v['date_from'], + $data_v['date_to'], + $occupancy + ); $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl']*$vart_quant; $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; @@ -1739,9 +1756,7 @@ abstract class PaymentModuleCore extends Module $cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; $cart_htl_data[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; - - - // extra demands prices + // extra demands prices $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( $order->id, $type_value['product_id'], @@ -1825,6 +1840,7 @@ abstract class PaymentModuleCore extends Module } $result['cart_htl_data'] = $cart_htl_data; } + return $result; } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d2dc4d1fe..57395c897 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4536,11 +4536,19 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->children = $objCartBookingData->children; $objBookingDetail->child_ages = $objCartBookingData->child_ages; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); + $total_price = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $this->context->cart->id, $this->context->cookie->id_guest, @@ -4781,7 +4789,7 @@ class AdminOrdersControllerCore extends AdminController $id_product, $new_date_from, $new_date_to, - 0, + array($occupancy), Group::getCurrent()->id, $cart->id, $cart->id_guest, @@ -7202,6 +7210,13 @@ class AdminOrdersControllerCore extends AdminController // set context currency So that we can get prices in the order currency $objOrder = new Order($objHotelBooking->id_order); $this->context->currency = new Currency($objOrder->id_currency); + $occupancy = array( + array( + 'adults' => $objHotelBooking->adults, + 'children' => $objHotelBooking->children, + 'child_ages' => json_decode($objHotelBooking->child_ages) + ) + ); $newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objHotelBooking->date_from, diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index d9222203d..105d9e5b0 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -419,7 +419,7 @@ class ProductControllerCore extends FrontController ) ); - $occupancy_value = array(); + $occupancy_value = Tools::getValue('occupancy', array()); if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY) { $occupancy_value = 1; } else { @@ -450,10 +450,10 @@ class ProductControllerCore extends FrontController // product price after imposing feature prices... if ($useTax) { $priceProduct = Product::getPriceStatic($this->product->id, true); - $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, true); + $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, true, 0, 0, 0, 0, 1, 1, $occupancy_value); } else { $priceProduct = Product::getPriceStatic($this->product->id, false); - $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, false); + $feature_price = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($this->product->id, $date_from, $date_to, false, 0, 0, 0, 0, 1, 1, $occupancy_value); } $productPriceWithoutReduction = $this->product->getPriceWithoutReduct(!$useTax); $feature_price_diff = (float)($productPriceWithoutReduction - $feature_price); @@ -649,7 +649,7 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - 0, + $occupancy, 0, 0, 0, @@ -660,7 +660,8 @@ class ProductControllerCore extends FrontController $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $dateFrom, - $dateTo + $dateTo, + $occupancy ); $featurePrice = 0; @@ -669,7 +670,14 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - true + true, + 0, + 0, + 0, + 0, + 1, + 1, + $occupancy ); $roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_incl']; $totalPriceWithoutDiscount = $priceWithoutDiscount['total_price_tax_incl']; @@ -679,14 +687,20 @@ class ProductControllerCore extends FrontController $idProduct, $dateFrom, $dateTo, - false + false, + 0, + 0, + 0, + 0, + 1, + 1, + $occupancy ); $roomTypeDateRangePrice = $roomTypeDateRangePrice['total_price_tax_excl']; $totalPriceWithoutDiscount = $priceWithoutDiscount['total_price_tax_excl']; } - $totalPriceWithoutDiscount *= $quantity; - $totalRoomPrice = $roomTypeDateRangePrice * $quantity; + $totalRoomPrice = $roomTypeDateRangePrice; // calculate demand price now $demandsPricePerRoom = 0; $roomTypeDemands = $objHRTDemand->getRoomTypeDemands($idProduct); diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index eb4edfc71..deb0ab0d8 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -241,7 +241,7 @@ class Blockcart extends Module $objProduct->id, $addedProduct['date_from'], $addedProduct['date_to'], - $addedProduct['req_rm'] + $addedProduct['occupancy'] ); if ($priceDisplayMethod == PS_TAX_EXC) { $addedProduct['price'] = Tools::displayPrice($price['total_price_tax_excl']); diff --git a/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php b/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php index 076663010..b2702b310 100644 --- a/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php +++ b/modules/hotelreservationsystem/classes/HotelAdvancedPayment.php @@ -105,11 +105,18 @@ class HotelAdvancedPayment extends ObjectModel $objHtlCartBook = new HotelCartBookingData(); if ($roomTypesByIdProduct = $objHtlCartBook->getCartInfoIdCartIdProduct((int) $idCart, (int)$idProduct)) { foreach ($roomTypesByIdProduct as $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrices = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $cartRoomInfo['id_product'], $cartRoomInfo['date_from'], $cartRoomInfo['date_to'], - 0, + $occupancy, 0, $idCart, $cartRoomInfo['id_guest'], diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 5686dad65..9e830293a 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1699,14 +1699,14 @@ class HotelBookingDetail extends ObjectModel continue; } } - $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); + $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 1, $bookingParams['occupancy']); if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { unset($bookingData['rm_data'][$key]); continue; } if (count($value['data']['available'])) { $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0); + $productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0, $bookingParams['occupancy']); $cover_image_arr = Product::getCover($value['id_product']); if (!empty($cover_image_arr)) { $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); @@ -2061,11 +2061,19 @@ class HotelBookingDetail extends ObjectModel $objBookingDetail->children = $objCartBookingData->children; $objBookingDetail->child_ages = $objCartBookingData->child_ages; + $occupancy = array( + array( + 'adults' => $objCartBookingData->adults, + 'children' => $objCartBookingData->children, + 'child_ages' => json_decode($objCartBookingData->child_ages) + ) + ); + $totalRoomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objCartBookingData->date_from, $objCartBookingData->date_to, - 0, + $occupancy, Group::getCurrent()->id, $this->context->cart->id, $this->context->cookie->id_guest, diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index fd1ef9d93..4e6267382 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -638,7 +638,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_product, $date_from, $date_to, - $quantity = 0, + $occupancy = null, $id_group = 0, $id_cart = 0, $id_guest = 0, @@ -659,6 +659,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $taxRate = 0; } + if (is_array($occupancy) && count($occupancy)) { + $quantity = count($occupancy); + } else { + $quantity = 1; + } + // Initializations if (!$id_group) { $id_group = (int)Group::getCurrent()->id; @@ -728,7 +734,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel 'id_guest' => $id_guest, 'id_group' => $id_group, 'use_reduc' => $use_reduc, - 'tax_rate' => $taxRate + 'tax_rate' => $taxRate, + 'occupancy' => $occupancy ) ); if ($with_auto_room_services) { @@ -807,7 +814,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_guest = 0, $id_room = 0, $with_auto_room_services = 1, - $use_reduc = 1 + $use_reduc = 1, + $occupancy = array() ) { $dateFrom = date('Y-m-d H:i:s', strtotime($date_from)); $dateTo = date('Y-m-d H:i:s', strtotime($date_to)); @@ -815,7 +823,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_product, $dateFrom, $dateTo, - 0, + $occupancy, $id_group, $id_cart, $id_guest, diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 04d0dc8a6..b13a3037b 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -198,7 +198,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->errors[] = $this->l('Selected room is not available for reallocation.'); } elseif (!in_array($idRoomToReallocate, array_column($availableRooms, 'id_room'))) { $this->errors[] = $this->l('Selected room is not available for reallocation.'); - } elseif (!Validate::isFloat($priceDiff)) { + } elseif (!Validate::isPrice($priceDiff)) { $this->errors[] = $this->l('Invalid price difference of the room types.'); } } else { @@ -874,11 +874,18 @@ class AdminHotelRoomsBookingController extends ModuleAdminController // if room is changing in the reallocation if ($objHotelBooking->id_product != $idNewRoomType) { $result['has_room_type_change'] = 1; + $occupancy = array( + array( + 'adults' => $objHotelBooking->adults, + 'children' => $objHotelBooking->children, + 'child_ages' => json_decode($objHotelBooking->child_ages) + ) + ); $newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objHotelBooking->date_from, $objHotelBooking->date_to, - 0, + $occupancy, 0, 0, 0, diff --git a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php index 46e32a741..389bd3107 100644 --- a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php +++ b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php @@ -351,10 +351,18 @@ class WkPaypalCommerceHelper $idProduct )) { foreach ($roomTypeBookings as $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idProduct, $cartRoomInfo['date_from'], - $cartRoomInfo['date_to'] + $cartRoomInfo['date_to'], + $occupancy ); $roomTotalPriceTE = $roomTotalPrice['total_price_tax_excl']; $roomTotalPriceTI = $roomTotalPrice['total_price_tax_incl']; diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index c4208f16b..98dab011d 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -195,16 +195,16 @@ class wkhotelfilterblock extends Module $obj_rm_type = new HotelRoomType(); $room_types = $obj_rm_type->getIdProductByHotelId($id_hotel, 0, 1, 1); + $occupancy = Tools::getValue('occupancy'); $prod_price = array(); if ($room_types) { foreach ($room_types as $key => $value) { - $prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax()); + $prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax(), 0, 0, 0, 0, 1, 1, $occupancy); } } // Create URL of category - $occupancy = Tools::getValue('occupancy'); $urlData = array ( 'date_from' => $date_from, 'date_to' => $date_to, From f861e10115160c768c6bc65bd71adfac9e12970a Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 8 Nov 2024 14:50:41 +0530 Subject: [PATCH 02/56] show correct pricing on checkout page --- controllers/admin/AdminOrdersController.php | 2 +- .../classes/HotelCartBookingData.php | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 80a65ee7d..5eb4c8496 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4826,7 +4826,7 @@ class AdminOrdersControllerCore extends AdminController $id_product, $new_date_from, $new_date_to, - array($occupancy), + 0, Group::getCurrent()->id, $cart->id, $cart->id_guest, diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 0cd9c678d..3038bb9b3 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1557,7 +1557,13 @@ class HotelCartBookingData extends ObjectModel 1 ); $totalAdditionalServicePrice = $demandPrice + $serviceProductPrice; - + $occupancy = array( + array( + 'adults' => $data_v['adults'], + 'children' => $data_v['children'], + 'child_ages' => json_decode($data_v['child_ages']) + ) + ); if (isset($cartHotelData[$prodKey]['date_diff'][$dateJoin])) { $numDays = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); $cartHotelData[$prodKey]['date_diff'][$dateJoin]['demand_price'] += $totalAdditionalServicePrice; @@ -1573,7 +1579,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1583,7 +1589,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1594,7 +1600,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1635,7 +1641,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1645,7 +1651,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, @@ -1656,7 +1662,7 @@ class HotelCartBookingData extends ObjectModel $product['id_product'], $data_v['date_from'], $data_v['date_to'], - 0, + $occupancy, 0, $context->cart->id, $context->cart->id_guest, From cd18dd90af15b29e8d9a055f2c9cdc557597d993 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 11 Nov 2024 13:09:58 +0530 Subject: [PATCH 03/56] Fixed incorrect price in admin book now page --- .../classes/HotelCartBookingData.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 3038bb9b3..3ee7aad41 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1114,7 +1114,13 @@ class HotelCartBookingData extends ObjectModel $cart_detail_data[$key]['date_to'] = $value['date_to']; $cart_detail_data[$key]['child_ages'] = json_decode($value['child_ages']); - + $occupancy = array( + array( + 'adults' => $value['adults'], + 'children' => $value['children'], + 'child_ages' => json_decode($value['child_ages']) + ) + ); $unit_price = Product::getPriceStatic($value['id_product'], true); $unit_price_tax_excl = Product::getPriceStatic($value['id_product'], false); $productPriceWithoutReduction = $productObj->getPriceWithoutReduct(false); @@ -1127,7 +1133,9 @@ class HotelCartBookingData extends ObjectModel $id_cart, $value['id_guest'], $value['id_room'], - 0 + 0, + 1, + $occupancy ); $feature_price_tax_excl = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( $value['id_product'], @@ -1138,7 +1146,9 @@ class HotelCartBookingData extends ObjectModel $id_cart, $value['id_guest'], $value['id_room'], - 0 + 0, + 1, + $occupancy ); $feature_price_diff = (float)($productPriceWithoutReduction - $feature_price); $cart_detail_data[$key]['product_price'] = $unit_price; @@ -1240,7 +1250,7 @@ class HotelCartBookingData extends ObjectModel $value['id_product'], $value['date_from'], $value['date_to'], - 0, + $occupancy, 0, $id_cart, $value['id_guest'], From 5f64bc6a96407db27be7f3f751d844cad0aabbb7 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 15 Nov 2024 16:25:33 +0530 Subject: [PATCH 04/56] added feature to update ajax data using hook --- classes/controller/Controller.php | 4 ++-- controllers/admin/AdminOrdersController.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index e9628c6a8..8908d6159 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -649,8 +649,8 @@ abstract class ControllerCore $method = $bt[1]['function']; } - Hook::exec('actionBeforeAjaxDie', array('controller' => $controller, 'method' => $method, 'value' => $value)); - Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => $value)); + Hook::exec('actionBeforeAjaxDie', array('controller' => $controller, 'method' => $method, 'value' => &$value)); + Hook::exec('actionBeforeAjaxDie'.$controller.$method, array('value' => &$value)); die($value); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 5eb4c8496..feca42832 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3501,7 +3501,7 @@ class AdminOrdersControllerCore extends AdminController } } } - $this->content = json_encode($to_return); + $this->ajaxDie(json_encode($to_return)); } // public function ajaxProcessSearchProducts() From 4d739bf63dc27a054e7e5378bbb958f8628c2878 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 13 Dec 2024 15:26:05 +0530 Subject: [PATCH 05/56] fixed price issue when booking is donewithout occupancy --- .../classes/HotelRoomTypeFeaturePricing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index 4e6267382..97b60fcc5 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -662,7 +662,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel if (is_array($occupancy) && count($occupancy)) { $quantity = count($occupancy); } else { - $quantity = 1; + $quantity = $occupancy; } // Initializations From c22186b8db2e1f1f61373d0dea2bbb1ae3bb9824 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 22 Jan 2025 16:11:53 +0530 Subject: [PATCH 06/56] Added: New restrictions to the admin while updating the booking from the back office --- .../controllers/orders/modals/_edit_room_tab_content.tpl | 4 ++-- controllers/admin/AdminOrdersController.php | 4 ++++ modules/hotelreservationsystem/classes/HotelBookingDetail.php | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl index 1bb98114b..70129171d 100644 --- a/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl @@ -37,7 +37,7 @@ {if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded} {dateFormat date=$data.date_from} {else} - +
{/if} @@ -49,7 +49,7 @@ {if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded} {dateFormat date=$data.date_to} {else} - +
{/if} diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 6dfcdaced..6d8d22f65 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -7172,6 +7172,10 @@ class AdminOrdersControllerCore extends AdminController || (strtotime($statusDate) > strtotime($dateTo)) ) { $this->errors[] = Tools::displayError('Date should be between booking from date and to date.'); + } else if (date('Y-m-d', strtotime($objHotelBookingDetail->check_out)) != date('Y-m-d', strtotime($objHotelBookingDetail->date_to)) + && ($booked = $objHotelBookingDetail->chechRoomBooked($objHotelBookingDetail->id_room, $objHotelBookingDetail->check_out, $objHotelBookingDetail->date_to)) + ) { + $this->errors[] = Tools::displayError('You cannot update this room\'s booking status as a new booking has been created for this room. Please change the room to update the status.'); } } if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) { diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 5686dad65..dfecd3d73 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1427,6 +1427,10 @@ class HotelBookingDetail extends ObjectModel pSQL($date_to).'\' AND date_to >= \''.pSQL($date_to).'\') OR (date_from < \''.pSQL($date_from). '\' AND date_to > \''.pSQL($date_to).'\'))'; + if ($this->id) { + $sql .= ' AND `id` !='.(int) $this->id; + } + return Db::getInstance()->getRow($sql); } From b2f13339acec1019a079640b65c193e2356625c4 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 23 Jan 2025 11:17:07 +0530 Subject: [PATCH 07/56] Updated: Changed the max order date with maximum booking offset --- controllers/admin/AdminImportController.php | 24 ++--- .../admin/AdminOrderPreferencesController.php | 40 ++++--- controllers/front/CategoryController.php | 8 +- controllers/front/ProductController.php | 10 +- docs/csv_import/hotels_import.csv | 2 +- .../classes/HotelBranchInformation.php | 77 +++++++------ .../classes/HotelCartBookingData.php | 6 +- .../classes/HotelHelper.php | 12 +-- .../classes/HotelOrderRestrictDate.php | 51 ++++++--- .../classes/HotelReservationSystemDb.php | 8 +- .../admin/AdminAddHotelController.php | 101 +++++++++--------- .../hotelreservationsystem.php | 9 -- .../views/css/HotelReservationAdmin.css | 6 -- .../views/js/HotelReservationAdmin.js | 35 ++---- .../admin/add_hotel/helpers/form/form.tpl | 34 +++--- .../classes/WkRoomSearchHelper.php | 12 +-- .../controllers/front/autocompletesearch.php | 4 +- .../views/js/wk-room-search-block.js | 20 ++-- .../views/templates/front/hotel-options.tpl | 2 +- .../views/templates/hook/searchForm.tpl | 6 +- themes/hotel-reservation-theme/js/product.js | 8 +- themes/hotel-reservation-theme/product.tpl | 2 +- 22 files changed, 231 insertions(+), 246 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 761b3459a..2ff4032ea 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -148,8 +148,8 @@ class AdminImportControllerCore extends AdminController 'policies' => array('label' => $this->l('Hotel Policies')), 'active_refund' => array('label' => $this->l('Allow Refund (0 = No, 1 = Yes)')), 'refund_ids' => array('label' => $this->l('Refund IDs (x,y,z...)')), - 'max_order_date' => array('label' => $this->l('Max Order Date')), - 'preparation_time' => array('label' => $this->l('Prepration Time')), + 'max_booking_offset' => array('label' => $this->l('Max booking offset')), + 'min_booking_offset' => array('label' => $this->l('Min booking offset')), 'image' => array('label' => $this->l('Image URLs (x,y,z...)')), 'delete_existing_images' => array( 'label' => $this->l('Delete existing images (0 = No, 1 = Yes)') @@ -1410,19 +1410,19 @@ class AdminImportControllerCore extends AdminController } $objHotelOrderRestrictDate->id_hotel = $objHotelBranch->id; - $objHotelOrderRestrictDate->use_global_max_order_date = true; - if (isset($info['max_order_date']) - && strtotime('now') < strtotime($info['max_order_date']) + $objHotelOrderRestrictDate->use_global_max_booking_offset = true; + if (isset($info['max_booking_offset']) + && strtotime('now') < strtotime($info['max_booking_offset']) ) { - $objHotelOrderRestrictDate->use_global_max_order_date = false; - $date = date('Y-m-d', strtotime($info['max_order_date'])); - $objHotelOrderRestrictDate->max_order_date = $date; + $objHotelOrderRestrictDate->use_global_max_booking_offset = false; + $date = date('Y-m-d', strtotime($info['max_booking_offset'])); + $objHotelOrderRestrictDate->max_booking_offset = $date; } - $objHotelOrderRestrictDate->use_global_preparation_time = true; - if (isset($info['preparation_time']) && $info['preparation_time']) { - $objHotelOrderRestrictDate->use_global_preparation_time = false; - $objHotelOrderRestrictDate->preparation_time = $info['preparation_time']; + $objHotelOrderRestrictDate->use_global_min_booking_offset = true; + if (isset($info['min_booking_offset']) && $info['min_booking_offset']) { + $objHotelOrderRestrictDate->use_global_min_booking_offset = false; + $objHotelOrderRestrictDate->min_booking_offset = $info['min_booking_offset']; } $objHotelOrderRestrictDate->save(); diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index 241ed1c29..23c9e2996 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -82,22 +82,19 @@ class AdminOrderPreferencesControllerCore extends AdminController ) ); - $maxOrderDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE', Configuration::get('MAX_GLOBAL_BOOKING_DATE')); $this->fields_options = array( 'order_restrict' => array( 'title' => $this->l('Order Restrict'), 'icon' => 'icon-cogs', 'fields' => array( - 'MAX_GLOBAL_BOOKING_DATE' => array( - 'title' => $this->l('Maximum Global Check-out Date to book a room'), - 'hint' => $this->l('Maximum date of check-out for which rooms of your hotels can be booked.'), + 'GLOBAL_MAX_BOOKING_OFFSET' => array( + 'title' => $this->l('Maximum booking offset'), + 'hint' => $this->l('The maximum booking offset defines the number of days from today till which bookings can be made. It is used to limiting how far in advance reservations are allowed to the guest.'), 'type' => 'text', - 'id' => 'max_global_book_date', - 'auto_value' => false, - 'value' => date('d-m-Y', strtotime($maxOrderDate)), - 'class' => 'fixed-width-xxl readonly', + 'class' => 'fixed-width-xl', + 'suffix' => $this->l('day(s)'), ), - 'GLOBAL_PREPARATION_TIME' => array( + 'GLOBAL_MIN_BOOKING_OFFSET' => array( 'title' => $this->l('Minimum booking offset'), 'hint' => $this->l('The minimum booking offset is the minimum number of days before the check-in date that a guest must book a room. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'), 'desc' => $this->l('Set to 0 to disable this feature.'), @@ -332,24 +329,23 @@ class AdminOrderPreferencesControllerCore extends AdminController $this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.'); } - $_POST['MAX_GLOBAL_BOOKING_DATE'] = date('Y-m-d', strtotime(Tools::getValue('MAX_GLOBAL_BOOKING_DATE'))); - $maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE'); - $globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME'); - $maxGlobalBookingDateFormatted = date('Y-m-d', strtotime($maxGlobalBookingDate)); - - if ($maxGlobalBookingDate == '') { - $this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' can not be empty.'); - } elseif (!Validate::isDate($maxGlobalBookingDateFormatted)) { - $this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' is invalid.'); - } elseif (strtotime($maxGlobalBookingDateFormatted) < strtotime(date('Y-m-d'))) { - $this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' can not be a past date. Please use a future date.'); + $maxBookingOffset = Tools::getValue('GLOBAL_MAX_BOOKING_OFFSET'); + $minBookingOffset = Tools::getValue('GLOBAL_MIN_BOOKING_OFFSET'); + if ($maxBookingOffset === '') { + $this->errors[] = Tools::displayError('Field \'Maximum booking offset\' can not be empty.'); + } elseif (!$maxBookingOffset || !Validate::isUnsignedInt($maxBookingOffset)) { + $this->errors[] = Tools::displayError('Field \'Maximum booking offset\' is invalid.'); } - if ($globalPreparationTime === '') { + if ($minBookingOffset === '') { $this->errors[] = Tools::displayError('Field \'Minimum booking offset\' can not be empty.'); - } elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) { + } elseif ($minBookingOffset != 0 && !Validate::isUnsignedInt($minBookingOffset)) { $this->errors[] = Tools::displayError('Field \'Minimum booking offset\' is invalid.'); } + + if ($maxBookingOffset && $maxBookingOffset <= $minBookingOffset) { + $this->errors[] = Tools::displayError('Field \'Maximum booking offset\' cannot be be less than or equal to \'Minimum booking offset\'.'); + } } public function setMedia() diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 10d9a0ae0..e35124b33 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -156,11 +156,11 @@ 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(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))) > strtotime($date_from) + $minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($id_hotel); + if ($minBookingOffset + && strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($date_from) ) { - $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + $date_from = date('Y-m-d', strtotime('+ '.$minBookingOffset.' day')); if (strtotime($date_from) >= strtotime($date_to)) { $date_to = date('Y-m-d', strtotime($date_from) + 86400); } diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 83d3bb857..a5ca5fe85 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -334,15 +334,15 @@ class ProductControllerCore extends FrontController $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); - $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id); + $minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($hotel_id); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); } - if ($preparationTime - && strtotime(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))) > strtotime($date_from) + if ($minBookingOffset + && strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($date_from) ) { - $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + $date_from = date('Y-m-d', strtotime('+ '.$minBookingOffset.' day')); } if (!($date_to = Tools::getValue('date_to'))) { @@ -392,7 +392,7 @@ class ProductControllerCore extends FrontController 'room_type_info' => $room_info_by_product_id, 'isHotelRefundable' => $hotel_branch_obj->isRefundable(), 'max_order_date' => $max_order_date, - 'preparation_time' => $preparationTime, + 'min_booking_offset' => $minBookingOffset, 'warning_num' => Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'), 'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png', 'product_controller_url' => $this->context->link->getPageLink('product'), diff --git a/docs/csv_import/hotels_import.csv b/docs/csv_import/hotels_import.csv index 5225073f8..f3c5962fa 100644 --- a/docs/csv_import/hotels_import.csv +++ b/docs/csv_import/hotels_import.csv @@ -1,3 +1,3 @@ -Hotel ID;Active(0/1);Hotel Name;Short Description;Description;Mobile Phone;Email;Address;Rating;Check-In;Check-Out;Country ID;State ID;City;Zip Code;Hotel Policies;Allow Refund(0/1);Refund IDs (x,y,z...);Max Order Date;Prepration Time;Image URLs (x,y,z...);Delete Existing Images (0 = No, 1 = Yes) +Hotel ID;Active(0/1);Hotel Name;Short Description;Description;Mobile Phone;Email;Address;Rating;Check-In;Check-Out;Country ID;State ID;City;Zip Code;Hotel Policies;Allow Refund(0/1);Refund IDs (x,y,z...);Max booking offset;Min booking offset;Image URLs (x,y,z...);Delete Existing Images (0 = No, 1 = Yes) 2;1;The Kings Hotel;The Kings Hotel with king size rooms. visit for a wonderful experience.;The Kings Hotel with king-size rooms. visit for a wonderful experience.;0900000009;kingshotel@demo.com;Greene St, New York, NY 10003, USA;3;12:00;11:00;21;32;New York;10003;1. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.2. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.;1;1;2024-01-01;0;http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/1.jpg;0 3;1;The Sunshine Palace Inn;The Sunshine Palace Inn is a beautiful hotel in japan.;The Sunshine Palace Inn is a beautiful hotel in japan.;0900000009;sunshine@demo.com;Shingashi, Itabashi, Tokyo;4;09:00;08:00;11;306;Tokyo;611-0043;1.loremipsertmkjbg ag mixtape meggings tousled ramps VHS cred.;0;0;;3;http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/2.jpg,http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/3.jpg;0 diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index c2779a01e..d8e24647e 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -71,10 +71,10 @@ class HotelBranchInformation extends ObjectModel public $zipcode; public $address; public $phone; - public $use_global_max_order_date = 1; - public $max_order_date = '0000-00-00'; - public $use_global_preparation_time = 1; - public $preparation_time = '0000-00-00'; + public $use_global_max_booking_offset = 1; + public $max_booking_offset = '1000'; + public $use_global_min_booking_offset = 1; + public $min_booking_offset = '0'; protected $webserviceParameters = array( 'objectsNodeName' => 'hotels', @@ -106,10 +106,10 @@ class HotelBranchInformation extends ObjectModel 'subResourceName' => 'hotels' ) ), - 'use_global_max_order_date' => array(), - 'max_order_date' => array(), - 'use_global_preparation_time' => array(), - 'preparation_time' => array(), + 'use_global_max_booking_offset' => array(), + 'max_booking_offset' => array(), + 'use_global_min_booking_offset' => array(), + 'min_booking_offset' => array(), ), 'associations' => array( 'room_types' => array( @@ -149,10 +149,10 @@ class HotelBranchInformation extends ObjectModel } if ($hotelRestrictions = HotelOrderRestrictDate::getDataByHotelId($id)) { - $this->use_global_max_order_date = $hotelRestrictions['use_global_max_order_date']; - $this->max_order_date = $hotelRestrictions['max_order_date']; - $this->use_global_preparation_time = $hotelRestrictions['use_global_preparation_time']; - $this->preparation_time = $hotelRestrictions['preparation_time']; + $this->use_global_max_booking_offset = $hotelRestrictions['use_global_max_booking_offset']; + $this->max_booking_offset = $hotelRestrictions['max_booking_offset']; + $this->use_global_min_booking_offset = $hotelRestrictions['use_global_min_booking_offset']; + $this->min_booking_offset = $hotelRestrictions['min_booking_offset']; } } } @@ -1072,13 +1072,13 @@ class HotelBranchInformation extends ObjectModel } $objHotelRestrictDate->id_hotel = $this->id; - $objHotelRestrictDate->use_global_max_order_date = $this->use_global_max_order_date; - if (!$this->use_global_max_order_date) { - $objHotelRestrictDate->max_order_date = $this->max_order_date; + $objHotelRestrictDate->use_global_max_booking_offset = $this->use_global_max_booking_offset; + if (!$this->use_global_max_booking_offset) { + $objHotelRestrictDate->max_booking_offset = $this->max_booking_offset; } - $objHotelRestrictDate->use_global_preparation_time = $this->use_global_preparation_time; - if (!$this->use_global_preparation_time) { - $objHotelRestrictDate->preparation_time = $this->preparation_time; + $objHotelRestrictDate->use_global_min_booking_offset = $this->use_global_min_booking_offset; + if (!$this->use_global_min_booking_offset) { + $objHotelRestrictDate->min_booking_offset = $this->min_booking_offset; } return $objHotelRestrictDate->save(); @@ -1111,23 +1111,34 @@ class HotelBranchInformation extends ObjectModel $message = Tools::displayError('City is required field.'); } elseif (!Validate::isCityName($this->city)) { $message = Tools::displayError('Enter a Valid City Name.'); - } elseif (!Validate::isBool($this->use_global_max_order_date)) { - $message = Tools::displayError('invalid value for use_global_max_order_date.'); - } elseif (!Validate::isBool($this->use_global_preparation_time)) { - $message = Tools::displayError('invalid value for use_global_preparation_time.'); - } elseif (!$this->use_global_max_order_date && $this->max_order_date == '') { - $message = Tools::displayError('Maximum date to book a room is required.'); - } elseif (!$this->use_global_max_order_date && !Validate::isDate($this->max_order_date)) { - $message = Tools::displayError('Maximum date to book a room is invalid.'); - } elseif (!$this->use_global_max_order_date - && ($maxOrderDateFormatted = date('Y-m-d', strtotime($this->max_order_date))) - && strtotime($maxOrderDateFormatted) < strtotime(date('Y-m-d')) - ) { - $message = Tools::displayError('Maximum Global Date to book a room can not be a past date. Please use a future date.'); - } elseif (!$this->use_global_preparation_time && $this->preparation_time === '') { + } elseif (!Validate::isBool($this->use_global_max_booking_offset)) { + $message = Tools::displayError('invalid value for use_global_max_booking_offset.'); + } elseif (!Validate::isBool($this->use_global_min_booking_offset)) { + $message = Tools::displayError('invalid value for use_global_min_booking_offset.'); + } elseif (!$this->use_global_max_booking_offset && $this->max_booking_offset == '') { + $message = Tools::displayError('Maximum booking offset is required.'); + } elseif (!$this->use_global_max_booking_offset && (!$this->max_booking_offset || !Validate::isUnsignedInt($this->max_booking_offset))) { + $message = Tools::displayError('Maximum booking offset is invalid.'); + } elseif (!$this->use_global_min_booking_offset && $this->min_booking_offset === '') { $message = Tools::displayError('Minimum booking offset is a required.'); - } elseif (!$this->use_global_preparation_time && $this->preparation_time !== '0' && !Validate::isUnsignedInt($this->preparation_time)) { + } elseif (!$this->use_global_min_booking_offset && !Validate::isUnsignedInt($this->min_booking_offset)) { $message = Tools::displayError('Minimum booking offset is invalid.'); + } else if (!$this->use_global_min_booking_offset + && !$this->use_global_max_booking_offset + && $this->max_booking_offset + && $this->max_booking_offset <= $this->min_booking_offset + ) { + $message = Tools::displayError('Maximum booking cannot be less than or equal to Minimum booking offset.'); + } else if (!$this->use_global_max_booking_offset + && $this->use_global_min_booking_offset + && $this->max_booking_offset <= Configuration::get('GLOBAL_MIN_BOOKING_OFFSET') + ) { + $message = Tools::displayError('Maximum booking cannot be less than or equal to Global Minimum booking offset.'); + } else if ($this->use_global_max_booking_offset + && !$this->use_global_min_booking_offset + && $this->min_booking_offset >= Configuration::get('GLOBAL_MAX_BOOKING_OFFSET') + ) { + $message = Tools::displayError('Minimum booking offset cannot be be greater than or equal to Global Maximum booking offset.'); } elseif (!Validate::isLoadedObject($objCountry = new Country($this->id_country))) { $message = Tools::displayError('country is invalid.'); } elseif ($this->id_state diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 0cd9c678d..7dbe1b494 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1029,9 +1029,9 @@ class HotelCartBookingData extends ObjectModel } } - $preparationTime = HotelOrderRestrictDate::getPreparationTime($roomData['id_hotel']); - if ($preparationTime !== false) { - $minOrderDate = date('Y-m-d', strtotime('+'. ($preparationTime) .' days')); + $minBookingOffset = HotelOrderRestrictDate::getMinBookingOffset($roomData['id_hotel']); + if ($minBookingOffset !== false) { + $minOrderDate = date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days')); if (strtotime($minOrderDate) > strtotime($roomData['date_from']) || strtotime($minOrderDate . ' +1 day')> strtotime($roomData['date_to']) ) { diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 137697e46..e0d5ef41c 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1063,12 +1063,8 @@ class HotelHelper Configuration::updateValue('WK_GLOBAL_CHILD_MAX_AGE', 15); Configuration::updateValue('WK_GLOBAL_MAX_CHILD_IN_ROOM', 0); - Configuration::updateValue( - 'MAX_GLOBAL_BOOKING_DATE', - date('Y-m-d', strtotime(date('Y-m-d', time()).' + 1 year')) - ); - - Configuration::updateValue('GLOBAL_PREPARATION_TIME', 0); + Configuration::updateValue('GLOBAL_MAX_BOOKING_OFFSET', 1000); + Configuration::updateValue('GLOBAL_MIN_BOOKING_OFFSET', 0); Configuration::updateValue('HTL_FEATURE_PRICING_PRIORITY', 'specific_date;special_day;date_range'); Configuration::updateValue('WK_GOOGLE_ACTIVE_MAP', 0); @@ -2502,8 +2498,8 @@ class HotelHelper public static function validateDateRangeForHotel($dateFrom, $dateTo, $idHotel) { $validStartDateTimeStamp = strtotime(date('Y-m-d')); - if ($preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($idHotel)) { - $validStartDateTimeStamp = strtotime(date('Y-m-d', strtotime('+ '.$preparationTime.' day'))); + if ($minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel)) { + $validStartDateTimeStamp = strtotime(date('Y-m-d', strtotime('+ '.$minBookingOffset.' day'))); } $dateFromTimestamp = strtotime($dateFrom); diff --git a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php index d623d8bf6..89dc9cb4a 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php @@ -22,10 +22,10 @@ class HotelOrderRestrictDate extends ObjectModel { public $id; public $id_hotel; - public $use_global_max_order_date; - public $max_order_date; - public $use_global_preparation_time; - public $preparation_time; + public $use_global_max_booking_offset; + public $max_booking_offset; + public $use_global_min_booking_offset; + public $min_booking_offset; public $date_add; public $date_upd; @@ -34,10 +34,10 @@ class HotelOrderRestrictDate extends ObjectModel 'primary' => 'id', 'fields' => array( 'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'use_global_max_order_date' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'max_order_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), - 'use_global_preparation_time' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'preparation_time' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'use_global_max_booking_offset' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'max_booking_offset' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'use_global_min_booking_offset' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'min_booking_offset' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), @@ -54,12 +54,12 @@ class HotelOrderRestrictDate extends ObjectModel public static function getMaxOrderDate($idHotel) { $result = self::getDataByHotelId($idHotel); - if (is_array($result) && count($result) && !$result['use_global_max_order_date']) { - return $result['max_order_date']; + if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) { + return date('Y-m-d', strtotime('+ '.$result['max_booking_offset'].' days')); } - if ($globalBookingDate = Configuration::get('MAX_GLOBAL_BOOKING_DATE')) { - return $globalBookingDate; + if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { + return date('Y-m-d', strtotime('+ '.$globalBookingDate.' days')); } return 0; @@ -69,14 +69,33 @@ class HotelOrderRestrictDate extends ObjectModel * @param int $id_hotel * @return int|false */ - public static function getPreparationTime($idHotel) + public static function getMaxBookingOffset($idHotel) { $result = self::getDataByHotelId($idHotel); - if (is_array($result) && count($result) && !$result['use_global_preparation_time']) { - return (int) $result['preparation_time']; + if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) { + return $result['max_booking_offset']; } - $globalPreparationTime = Configuration::get('GLOBAL_PREPARATION_TIME'); + if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { + return $globalBookingDate; + } + + return 0; + } + + + /** + * @param int $id_hotel + * @return int|false + */ + public static function getMinBookingOffset($idHotel) + { + $result = self::getDataByHotelId($idHotel); + if (is_array($result) && count($result) && !$result['use_global_min_booking_offset']) { + return (int) $result['min_booking_offset']; + } + + $globalPreparationTime = Configuration::get('GLOBAL_MIN_BOOKING_OFFSET'); if ($globalPreparationTime != '0') { return (int) $globalPreparationTime; } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 484311892..cc053d515 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -267,10 +267,10 @@ class HotelReservationSystemDb "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_order_restrict_date` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_hotel` int(11) NOT NULL, - `use_global_max_order_date` tinyint(1) NOT NULL, - `max_order_date` date NOT NULL, - `use_global_preparation_time` tinyint(1) NOT NULL, - `preparation_time` int(11) NOT NULL, + `use_global_max_booking_offset` tinyint(1) NOT NULL, + `max_booking_offset` int(11) NOT NULL, + `use_global_min_booking_offset` tinyint(1) NOT NULL, + `min_booking_offset` int(11) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id`) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 19223bf00..4d6d65673 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -168,15 +168,7 @@ class AdminAddHotelController extends ModuleAdminController } } - $restrictDateInfo = HotelOrderRestrictDate::getDataByHotelId($idHotel); - if ($restrictDateInfo) { - if ($restrictDateInfo['max_order_date'] == '0000-00-00') { - $restrictDateInfo['max_order_date'] = date('d-m-Y', strtotime('1 year')); - } else { - $restrictDateInfo['max_order_date'] = date('d-m-Y', strtotime($restrictDateInfo['max_order_date'])); - } - } - $smartyVars['order_restrict_date_info'] = $restrictDateInfo; + $smartyVars['order_restrict_date_info'] = HotelOrderRestrictDate::getDataByHotelId($idHotel); $objHotelFeatures = new HotelFeatures(); $hotelFeatures = $this->object->getFeaturesOfHotelByHotelId($this->object->id); if ($features = $objHotelFeatures->HotelBranchSelectedFeaturesArray($hotelFeatures)) { @@ -220,8 +212,8 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['state_var'] = $stateOptions; $smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP'); $smartyVars['ps_img_dir'] = _PS_IMG_.'l/'; - $smartyVars['MAX_GLOBAL_BOOKING_DATE'] = (Configuration::get('MAX_GLOBAL_BOOKING_DATE')); - $smartyVars['GLOBAL_PREPARATION_TIME'] = Configuration::get('GLOBAL_PREPARATION_TIME'); + $smartyVars['GLOBAL_MAX_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET'); + $smartyVars['GLOBAL_MIN_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MIN_BOOKING_OFFSET'); $this->context->smarty->assign($smartyVars); @@ -241,6 +233,10 @@ class AdminAddHotelController extends ModuleAdminController public function processSave() { + if (!$this->loadObject(true)) { + return false; + } + $idHotel = Tools::getValue('id'); $phone = Tools::getValue('phone'); $email = Tools::getValue('email'); @@ -254,10 +250,10 @@ class AdminAddHotelController extends ModuleAdminController $address = Tools::getValue('address'); $active = Tools::getValue('ENABLE_HOTEL'); $activeRefund = Tools::getValue('active_refund'); - $enableUseGlobalMaxOrderDate = Tools::getValue('enable_use_global_max_order_date'); - $maximumBookingDate = Tools::getValue('maximum_booking_date'); - $enableUseGlobalPreparationTime = Tools::getValue('enable_use_global_preparation_time'); - $preparationTime = Tools::getValue('preparation_time'); + $enableUseGlobalMaxBookingOffset = Tools::getValue('enable_use_global_max_booking_offset'); + $maxBookingOffset = trim(Tools::getValue('max_booking_offset')); + $enableUseGlobalMinBookingOffset = Tools::getValue('enable_use_global_min_booking_offset'); + $minBookingOffset = trim(Tools::getValue('min_booking_offset')); $latitude = Tools::getValue('loclatitude'); $longitude = Tools::getValue('loclongitude'); $map_formated_address = Tools::getValue('locformatedAddr'); @@ -427,24 +423,35 @@ class AdminAddHotelController extends ModuleAdminController } if ($idHotel) { - if (!$enableUseGlobalMaxOrderDate) { - $maximumBookingDateFormatted = date('Y-m-d', strtotime($maximumBookingDate)); - if ($maximumBookingDate == '') { - $this->errors[] = $this->l('Maximum Check-out Date to book a room is a required field.'); - } elseif (!Validate::isDate($maximumBookingDateFormatted)) { - $this->errors[] = $this->l('Maximum Check-out Date to book a room is invalid.'); - } elseif (strtotime($maximumBookingDateFormatted) < strtotime(date('Y-m-d'))) { - $this->errors[] = $this->l('Maximum Check-out Date to book a room can not be a past date. Please use a future date.'); + if (!$enableUseGlobalMaxBookingOffset) { + if ($maxBookingOffset === '') { + $this->errors[] = $this->l('Maximum booking offset is a required field.'); + } elseif (!$maxBookingOffset || !Validate::isUnsignedInt($maxBookingOffset)) { + $this->errors[] = $this->l('Maximum booking offset is invalid.'); } } - if (!$enableUseGlobalPreparationTime) { - if ($preparationTime === '') { + if (!$enableUseGlobalMinBookingOffset) { + if ($minBookingOffset === '') { $this->errors[] = $this->l('Minimum booking offset is a required field.'); - } elseif ($preparationTime !== '0' && !Validate::isUnsignedInt($preparationTime)) { + } elseif (!Validate::isUnsignedInt($minBookingOffset)) { $this->errors[] = $this->l('Minimum booking offset is invalid.'); } } + + if (empty($this->errors)) { + if (!$enableUseGlobalMaxBookingOffset && !$enableUseGlobalMinBookingOffset) { + if ($maxBookingOffset && $maxBookingOffset <= $minBookingOffset) { + $this->errors[] = $this->l('Field Maximum booking offset cannot be be less than or equal to Minimum booking offset.'); + } + } else { + if (!$enableUseGlobalMaxBookingOffset && $maxBookingOffset <= Configuration::get('GLOBAL_MIN_BOOKING_OFFSET')) { + $this->errors[] = $this->l('Field Maximum booking offset cannot be be less than or equal to global Minimum booking offset.'); + } else if (!$enableUseGlobalMinBookingOffset && $minBookingOffset >= Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { + $this->errors[] = $this->l('Field Minimum booking offset cannot be be greater than or equal to Global Maximum booking offset.'); + } + } + } } if (!count($this->errors)) { @@ -734,19 +741,20 @@ class AdminAddHotelController extends ModuleAdminController $restrictDateInfo = HotelOrderRestrictDate::getDataByHotelId($newIdHotel); if ($restrictDateInfo) { $objHotelOrderRestrictDate = new HotelOrderRestrictDate($restrictDateInfo['id']); - } else { - $objHotelOrderRestrictDate = new HotelOrderRestrictDate(); } $objHotelOrderRestrictDate->id_hotel = $newIdHotel; - $objHotelOrderRestrictDate->use_global_max_order_date = $enableUseGlobalMaxOrderDate; - if (!$enableUseGlobalMaxOrderDate) { - $objHotelOrderRestrictDate->max_order_date = $maximumBookingDateFormatted; + $objHotelOrderRestrictDate->use_global_max_booking_offset = $enableUseGlobalMaxBookingOffset; + $objHotelOrderRestrictDate->use_global_min_booking_offset = $enableUseGlobalMinBookingOffset; + + if (!$enableUseGlobalMaxBookingOffset) { + $objHotelOrderRestrictDate->max_booking_offset = $maxBookingOffset; } - $objHotelOrderRestrictDate->use_global_preparation_time = $enableUseGlobalPreparationTime; - if (!$enableUseGlobalPreparationTime) { - $objHotelOrderRestrictDate->preparation_time = $preparationTime; + + if (!$enableUseGlobalMinBookingOffset) { + $objHotelOrderRestrictDate->min_booking_offset = $minBookingOffset; } + $objHotelOrderRestrictDate->save(); $objHotelFeatures = new HotelBranchFeatures(); @@ -756,32 +764,25 @@ class AdminAddHotelController extends ModuleAdminController } } + $conf = 3; + if ($idHotel) { + $con = 4; + } + if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) { - if ($idHotel) { - Tools::redirectAdmin( - self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf=4&token='. - $this->token - ); - } else { - Tools::redirectAdmin( - self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf=3&token='. - $this->token - ); - } + Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token ); } else { - if ($idHotel) { - Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); - } else { - Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token); - } + Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token); } } + if ($idHotel) { $this->display = 'edit'; } else { $this->display = 'add'; } } + public function processStatus() { parent::processStatus(); diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index f41549ee8..3c7e27ced 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -65,15 +65,6 @@ class HotelReservationSystem extends Module public function hookDisplayHeader() { - // check max global order_restriction date is set - if (!Configuration::get('MAX_GLOBAL_BOOKING_DATE') - || (strtotime(date('Y-m-d')) > strtotime(Configuration::get('MAX_GLOBAL_BOOKING_DATE'))) - ) { - Configuration::updateValue( - 'MAX_GLOBAL_BOOKING_DATE', - date('Y-m-d', strtotime(date('Y-m-d', time()).' + 1 year')) - ); - } if (!Configuration::get('PS_CATALOG_MODE')) { /*To remove room from cart before todays date*/ if (isset($this->context->cart->id) && $this->context->cart->id) { diff --git a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css index 147403354..6b2ee3587 100644 --- a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css +++ b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css @@ -426,12 +426,6 @@ p.room_cat_data } /*AdminHotelConfigurationSetting controller*/ - -#max_global_book_date -{ - width: 30%; -} - .htl_all_setting .btn.btn-default { margin: 20px!important; } diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index 1e3bc80b5..1253a45d2 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -551,22 +551,6 @@ $(document).ready(function() { $("#conf_id_WK_BO_MESSAGE").hide(); }); - /*For OrderRestrict Functionality*/ - $("#max_htl_book_date").datepicker({ - defaultDate: new Date(), - dateFormat: 'dd-mm-yy', - minDate: 0, - }); - - $("#max_global_book_date").datepicker({ - defaultDate: new Date(), - dateFormat: 'dd-mm-yy', - minDate: 0, - }); - - //$( "#max_global_book_date" ).datepicker( "option", "maxDate", '20 Mar 2020'); - /*END*/ - /* ---- AdminHotelFeaturePricesSettingsController Admin ---- */ $('#date_selection_type').on('change', function() { @@ -805,26 +789,19 @@ $(document).ready(function() { }); } - // manage hotel page - $('#maximum_booking_date').datepicker({ - defaultDate: new Date(), - dateFormat: 'dd-mm-yy', - minDate: 0, - }); - - $('input[name="enable_use_global_max_order_date"]').on('change', function () { + $('input[name="enable_use_global_max_booking_offset"]').on('change', function () { if (parseInt($(this).val())) { - $('input[name="maximum_booking_date"]').closest('.form-group').hide(200); + $('input[name="max_booking_offset"]').closest('.form-group').hide(200); } else { - $('input[name="maximum_booking_date"]').closest('.form-group').show(200); + $('input[name="max_booking_offset"]').closest('.form-group').show(200); } }); - $('input[name="enable_use_global_preparation_time"]').on('change', function () { + $('input[name="enable_use_global_min_booking_offset"]').on('change', function () { if (parseInt($(this).val())) { - $('input[name="preparation_time"]').closest('.form-group').hide(200); + $('input[name="min_booking_offset"]').closest('.form-group').hide(200); } else { - $('input[name="preparation_time"]').closest('.form-group').show(200); + $('input[name="min_booking_offset"]').closest('.form-group').show(200); } }); diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index abe5510d2..074d62a93 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -427,23 +427,23 @@ {if isset($hotel_info.id) && $hotel_info.id}
- - - - + + + + -
{l s='Global max order date:' mod='hotelreservationsystem'} {dateFormat date=$MAX_GLOBAL_BOOKING_DATE}
+
{l s='Global maximum booking offset:' mod='hotelreservationsystem'} {$GLOBAL_MAX_BOOKING_OFFSET}
-