From 3728d59b47cf726ab68e443c844265a4a45b8a65 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 21 Aug 2024 20:11:09 +0530 Subject: [PATCH] update data for all search params --- .../classes/HotelBookingDetail.php | 100 +++++++++--------- .../classes/HotelRoomType.php | 3 - 2 files changed, 49 insertions(+), 54 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 8d0bfd22c..fb7bbde27 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1525,66 +1525,64 @@ class HotelBookingDetail extends ObjectModel $objRoomType = new HotelRoomType(); foreach ($bookingData['rm_data'] as $key => $value) { - if (count($value['data']['available'])) { - $product_feature = Product::getFrontFeaturesStatic($this->context->language->id, $value['id_product']); - $prod_amen = array(); - if (!empty($amenities) && $amenities) { - $prod_amen = $amenities; - foreach ($product_feature as $a_key => $a_val) { - if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) { - unset($prod_amen[$pa_key]); - if (empty($prod_amen)) { - break; - } + $product_feature = Product::getFrontFeaturesStatic($this->context->language->id, $value['id_product']); + $prod_amen = array(); + if (!empty($amenities) && $amenities) { + $prod_amen = $amenities; + foreach ($product_feature as $a_key => $a_val) { + if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) { + unset($prod_amen[$pa_key]); + if (empty($prod_amen)) { + break; } } - if (!empty($prod_amen)) { - unset($bookingData['rm_data'][$key]); - continue; - } } - $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); - if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { + if (!empty($prod_amen)) { unset($bookingData['rm_data'][$key]); continue; } + } + $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); + if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { + unset($bookingData['rm_data'][$key]); + continue; + } - $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); - $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); - $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'); - } else { - $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); - } - $bookingData['rm_data'][$key]['image'] = $cover_img; - $bookingData['rm_data'][$key]['feature'] = $product_feature; - $bookingData['rm_data'][$key]['price'] = $prod_price; - $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; - $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; - $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; - $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); - $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; - $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); + $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); + $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); + $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); + $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'); + } else { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); + } + $bookingData['rm_data'][$key]['image'] = $cover_img; + $bookingData['rm_data'][$key]['feature'] = $product_feature; + $bookingData['rm_data'][$key]['price'] = $prod_price; + $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; + $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; + $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; + $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); + $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; + $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); - // create URL with the parameters from URL - $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); - if (!isset($occupancy)) { - $occupancy = Tools::getValue('occupancy'); - } - if ($occupancy) { - $urlData['occupancy'] = $occupancy; - } - if ($location = Tools::getValue('location')) { - $urlData['location'] = $location; - } + // create URL with the parameters from URL + $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); + if (!isset($occupancy)) { + $occupancy = Tools::getValue('occupancy'); + } + if ($occupancy) { + $urlData['occupancy'] = $occupancy; + } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } - if (Configuration::get('PS_REWRITING_SETTINGS')) { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); - } else { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); - } + if (Configuration::get('PS_REWRITING_SETTINGS')) { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); + } else { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); } } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 83ced3591..9d8bf89e8 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -298,9 +298,6 @@ class HotelRoomType extends ObjectModel $sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (hbi.`id` = hrt.`id_hotel`) INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = hbi.`id_category` AND cp.`id_product` = hrt.`id_product`'; } - if ($fullDetail) { - - } $sql .= 'WHERE hrt.`id_product` IN ('.$roomTypesList.') GROUP BY hrt.`id_product`'.