Merge branch 'develop' into gli-2525

This commit is contained in:
vishalsingh.qlo325
2025-05-15 16:07:33 +05:30
25 changed files with 638 additions and 119 deletions

View File

@@ -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']);

View File

@@ -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'],

View File

@@ -1701,7 +1701,7 @@ 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;
@@ -1709,7 +1709,7 @@ class HotelBookingDetail extends ObjectModel
if (count($value['data']['available']) || (isset($get_all_room_types) && $get_all_room_types)) {
$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');
@@ -2065,11 +2065,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,

View File

@@ -346,7 +346,8 @@ class HotelCartBookingData extends ObjectModel
$idRoom = 0,
$dateFrom = 0,
$dateTo = 0,
$updPsCart = 1
$updPsCart = 1,
$idOrder = 0
) {
$where = '1';
if ($idCart) {
@@ -364,8 +365,8 @@ class HotelCartBookingData extends ObjectModel
if ($dateTo) {
$where .= ' AND `date_to`=\''.pSQL($dateTo).'\'';
}
// we have to delete only rows which order is not created
$where .= ' AND `id_order`= 0';
$where .= ' AND `id_order`='.(int) $idOrder;
// If rooms is deleting from cart the we need to delete the ps_cart quantity of the product from table
// if product will delete the prestashop will handle
$numRooms = 0;
@@ -1112,7 +1113,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);
@@ -1125,7 +1132,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'],
@@ -1136,7 +1145,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;
@@ -1238,7 +1249,7 @@ class HotelCartBookingData extends ObjectModel
$value['id_product'],
$value['date_from'],
$value['date_to'],
0,
$occupancy,
0,
$id_cart,
$value['id_guest'],
@@ -1556,7 +1567,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;
@@ -1572,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,
@@ -1582,7 +1599,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,
@@ -1593,7 +1610,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,
@@ -1634,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,
@@ -1644,7 +1661,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,
@@ -1655,7 +1672,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,

View File

@@ -636,7 +636,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$id_product,
$date_from,
$date_to,
$quantity = 0,
$occupancy = null,
$id_group = 0,
$id_cart = 0,
$id_guest = 0,
@@ -657,6 +657,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$taxRate = 0;
}
if (is_array($occupancy) && count($occupancy)) {
$quantity = count($occupancy);
} else {
$quantity = $occupancy;
}
// Initializations
if (!$id_group) {
$id_group = (int)Group::getCurrent()->id;
@@ -726,7 +732,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) {
@@ -805,7 +812,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));
@@ -813,7 +821,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$id_product,
$dateFrom,
$dateTo,
0,
$occupancy,
$id_group,
$id_cart,
$id_guest,

View File

@@ -217,7 +217,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$idLang = Context::getContext()->language->id;
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, cbd.`id` as `htl_cart_booking_id` ,
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, rscd.`id_cart` as service_id_cart, cbd.`id` as `htl_cart_booking_id` ,
cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`, cbd.`date_from`, cbd.`date_to`';
if (!$getTotalPrice) {
$sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`,
@@ -233,7 +233,8 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$idLang.')';
}
$sql .= ' WHERE 1';
$sql .= ' WHERE 1 AND rscd.`id_product`!=0';
if (!is_null($autoAddToCart)) {
$sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart;
@@ -334,6 +335,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'name' => $product['name'],
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'id_cart' => $product['service_id_cart'],
'allow_multiple_quantity' => $product['allow_multiple_quantity'],
'price_addition_type' => $product['price_addition_type'],
'price_calculation_method' => $product['price_calculation_method'],
@@ -449,6 +451,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'allow_multiple_quantity' => $product['allow_multiple_quantity'],
'id_cart' => $product['service_id_cart'],
'price_addition_type' => $product['price_addition_type'],
'price_calculation_method' => $product['price_calculation_method'],
'unit_price_tax_excl' => ($objRoomTypeServiceProductPrice->getServicePrice(

View File

@@ -254,6 +254,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'id_order_detail' => $product['id_order_detail'],
'id_product' => $product['id_product'],
'name' => $product['name'],
'id_cart' => $product['id_cart'],
'quantity' => $product['quantity'],
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'max_quantity' => $product['max_quantity'],
@@ -280,6 +281,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'id_order_detail' => $product['id_order_detail'],
'id_product' => $product['id_product'],
'name' => $product['name'],
'id_cart' => $product['id_cart'],
'quantity' => $product['quantity'],
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'max_quantity' => $product['max_quantity'],
@@ -323,4 +325,4 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
// delete entry from order detail table.
return parent::delete();
}
}
}

View File

@@ -199,7 +199,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 {
@@ -875,11 +875,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,

View File

@@ -33,6 +33,8 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'customer` cust ON (cust.`id_customer` = ord.`id_customer`)';
$this->_orderWay = 'DESC';
$this->allow_export = true;
$this->_new_list_header_design = true;
if ($idOrder = Tools::getValue('id_order')) {
$this->_select .= ', orsl.`name` as `status_name`, ors.`color`, COUNT(ordrd.`id_order_return_detail`) as num_rooms';
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)';
@@ -176,9 +178,83 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
public function setCustomerLink($customerName, $row)
{
if ($this->action == 'export') {
return $customerName.' (#'.$row['id_customer'].')';
}
return '<a href="'.$this->context->link->getAdminLink('AdminCustomers').'&id_customer='.$row['id_customer'].'&viewcustomer">'.$customerName.' (#'.$row['id_customer'].')</a>';
}
public function getList(
$id_lang,
$order_by = null,
$order_way = null,
$start = 0,
$limit = null,
$id_lang_shop = false
){
if ($this->action == 'export' && empty($this->_listsql)) {
if (Tools::getValue('id_order')) {
$this->_select .= ', ordtl.*';
} else {
$this->_select .= ', GROUP_CONCAT(ordtl.`room_num`) AS `room_num`,
GROUP_CONCAT(DISTINCT ordtl.`room_type_name`) AS `room_type_name`,
ordtl.`hotel_name`, ordtl.`id_order`,
GROUP_CONCAT(ordtl.`date_from`) AS `date_from`,
GROUP_CONCAT(ordtl.`date_to`) AS `date_to`';
}
$this->_join .= ' LEFT JOIN (
SELECT GROUP_CONCAT(hbd.`room_num`) AS room_num,
GROUP_CONCAT(DISTINCT(hbd.`room_type_name`)) AS room_type_name,
ord.`id_order_return`, hbd.`hotel_name`, hbd.`id_order`,
GROUP_CONCAT(hbd.`date_from`) AS date_from,
GROUP_CONCAT(hbd.`date_to`) AS date_to
FROM `'._DB_PREFIX_.'order_return_detail` ord
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON ord.`id_htl_booking` = hbd.`id`
GROUP BY ord.`id_order_return`
) AS ordtl ON (ordtl.`id_order_return` = a.`id_order_return`)';
$this->fields_list = array_merge($this->fields_list, array(
'room_num' => array(
'title' => $this->l('Room num(s)')
),
'room_type_name' => array(
'title' => $this->l('Room type(s)'),
'callback' => 'getUniqueRoomTypeNames'
),
'hotel_name' => array(
'title' => $this->l('Hotel')
),
'date_from' => array(
'title' => $this->l('Date From')
),
'date_to' => array(
'title' => $this->l('Date To')
),
));
}
parent::getList(
$id_lang,
$order_by,
$order_way,
$start,
$limit,
$id_lang_shop
);
}
public function getUniqueRoomTypeNames($roomTypeNames, $tr)
{
if ($roomTypeNames) {
$roomTypeNames = explode(',', $roomTypeNames);
$roomTypeNames = array_unique($roomTypeNames);
$roomTypeNames = implode(',', $roomTypeNames);
}
return $roomTypeNames;
}
public function initToolbar()
{
parent::initToolbar();

View File

@@ -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'];

View File

@@ -182,7 +182,6 @@ class wkhotelfilterblock extends Module
$max_adult = HotelRoomType::getMaxAdults($id_hotel);
$max_child = HotelRoomType::getMaxChild($id_hotel);
$category = new Category($htl_id_category);
$urlData = array ();
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d H:i:s');
@@ -203,15 +202,15 @@ 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
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$categoryUrl = $this->context->link->getCategoryLink(
new Category($htl_id_category, $this->context->language->id),