added services popup in admin booking carts page

This commit is contained in:
Shreesh Arora
2023-03-09 15:30:05 +05:30
parent fd728e9011
commit 87f81835ea
9 changed files with 459 additions and 188 deletions

View File

@@ -98,36 +98,141 @@
</thead>
<tbody>
{foreach from=$cart_htl_data item='room'}
<tr>
<td><img src="{$room.image_link}" class="img-responsive" /></td>
<td>
<a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}&amp;id_product={$room.id_product}&amp;updateproduct">
<span class="productName">{$room.room_type}</span>
<tr>
<td><img src="{$room['image_link']}" class="img-responsive" /></td>
<td>
<a href="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}&amp;id_product={$room['id_product']}&amp;updateproduct">
<span class="productName">{$room['room_type']}</span>
</a>
</td>
<td><a href="{$link->getAdminLink('AdminAddHotel')|escape:'html':'UTF-8'}&amp;id={$room['id_hotel']}&amp;updatehtl_branch_info">{$room['room_type_info'].hotel_name}</a></td>
<td>{dateFormat date=$room['date_from']} - {dateFormat date=$room['date_to']}</td>
<td>
<span>
{if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
</span>
</td>
<td>{displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency}</td>
<td>
{if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])}
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands_{$room['id']}" edit_orde_line="0">
{displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency}
</a>
</td>
<td><a href="{$link->getAdminLink('AdminAddHotel')|escape:'html':'UTF-8'}&amp;id={$room.id_hotel}&amp;updatehtl_branch_info">{$room.room_type_info.hotel_name}</a></td>
<td>{dateFormat date=$room.date_from} - {dateFormat date=$room.date_to}</td>
<td>
<span>
{if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
</span>
</td>
<td>{displayWtPriceWithCurrency price=$room.feature_price_tax_excl currency=$currency}</td>
<td>
{if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)}
{displayWtPriceWithCurrency price=($room.demand_price + $room.additional_service_price + $room.additional_services_auto_add_price)|escape:'html':'UTF-8' currency=$currency}
{else}
{displayWtPriceWithCurrency price=0 currency=$currency}
{/if}
</td>
<td class="text-right">
{if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)}
{displayWtPriceWithCurrency price=($room.amt_with_qty + $room.additional_services_auto_add_price + $room.demand_price + $room.additional_service_price)|escape:'html':'UTF-8' currency=$currency}
{else}
{displayWtPriceWithCurrency price=$room.amt_with_qty|escape:'html':'UTF-8' currency=$currency}
{/if}
</td>
</tr>
{else}
{displayWtPriceWithCurrency price=0 currency=$currency}
{/if}
</td>
<td class="text-right">
{if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])}
{displayWtPriceWithCurrency price=($room['amt_with_qty'] + $room['additional_services_auto_add_price'] + $room['demand_price'] + $room['additional_service_price'])|escape:'html':'UTF-8' currency=$currency}
{else}
{displayWtPriceWithCurrency price=$room['amt_with_qty']|escape:'html':'UTF-8' currency=$currency}
{/if}
</td>
</tr>
<div class="modal" tabindex="-1" role="dialog" id="rooms_type_extra_demands_{$room['id']}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" id="rooms_extra_demands">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<ul class="nav nav-tabs" role="tablist">
{if isset($room['selected_demands']) && $room['selected_demands']}
<li role="presentation" class="active"><a href="#room_type_demands_desc_{$room['id']}" aria-controls="facilities" role="tab" data-toggle="tab">{l s='Facilities'}</a></li>
{/if}
{if isset($room['selected_services']) && $room['selected_services']}
<li role="presentation" {if !isset($room['selected_demands']) || !$room['selected_demands']}class="active"{/if}><a href="#room_type_service_product_desc_{$room['id']}" aria-controls="services" role="tab" data-toggle="tab">{l s='Services'}</a></li>
{/if}
</ul>
<div class="tab-content panel">
{if isset($room['selected_demands']) && $room['selected_demands']}
<div id="room_type_demands_desc_{$room['id']}" class="tab-pane active">
<div id="room_type_demands_desc">
{if isset($room['selected_demands']) && $room['selected_demands']}
{assign var=roomCount value=1}
{foreach $room['selected_demands'] as $demand}
<div class="row room_demands_container">
<div class="col-sm-12 room_demand_detail">
{if isset($room['selected_demands']) && $room['selected_demands']}
{foreach $room['extra_demands'] as $idGlobalDemand => $roomDemand}
{if $demand.id_global_demand == $idGlobalDemand}
<div class="row room_demand_block">
<div class="col-xs-6">
<div class="row">
<div class="col-xs-10 demand_adv_option_block">
<p>
{$roomDemand['name']|escape:'html':'UTF-8'}<br>
{if isset($roomDemand['adv_option']) && $roomDemand['adv_option']}
{$roomDemand['adv_option'][$demand['id_option']]['name']}
{/if}
</p>
</div>
</div>
</div>
<div class="col-xs-6">
<p><span class="pull-right extra_demand_option_price">{if isset($roomDemand['adv_option']) && $roomDemand['adv_option']}{convertPrice price = $roomDemand['adv_option'][$idGlobalDemand]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $roomDemand['price']|escape:'html':'UTF-8'}{/if}</span></p>
</div>
</div>
{/if}
{/foreach}
{/if}
</div>
</div>
{assign var=roomCount value=$roomCount+1}
{/foreach}
{/if}
</div>
</div>
{/if}
{if isset($room['selected_services']) && $room['selected_services']}
<div id="room_type_service_product_desc_{$room['id']}" class="tab-pane{if !isset($room['selected_demands']) || !$room['selected_demands']} active{/if}">
<div id="room_type_services_desc">
{assign var=roomCount value=1}
<div class="row room_demands_container">
<div class="col-sm-12 room_demand_detail">
{if isset($room['selected_services']) && $room['selected_services']}
{foreach $room['selected_services'] as $service}
<div class="row room_demand_block">
<div class="col-xs-5">
<div class="row">
<div class="col-xs-10">
<p>{$service['name']|escape:'html':'UTF-8'}</p>
{if $service.allow_multiple_quantity}
<div class="qty_container">
{l s='Quantity:'} {$service.quantity}
</div>
{/if}
</div>
</div>
</div>
<div class="col-xs-3">
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</div>
<div class="col-xs-4">
<span class="pull-right">{convertPrice price=$service.total_price}</span>
</div>
</div>
{/foreach}
{/if}
</div>
</div>
</div>
</div>
{/if}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{l s='Close'}</button>
</div>
</div>
</div>
</div>
{/foreach}
</tbody>
<tfoot>

View File

@@ -103,57 +103,54 @@
</div>
<div id="room_type_services_desc">
{assign var=roomCount value=1}
{foreach $selectedRoomServiceProduct as $cartRoom}
<div class="row room_demands_container">
<div class="col-sm-12 demand_header">
<span>
<i class="icon-bed"></i>
{if isset($cartRoom['room_num']) && $cartRoom['room_num']}
{l s='Room'} {$cartRoom['room_num']|escape:'html':'UTF-8'}
{else}
{l s='Room'} {$roomCount|escape:'html':'UTF-8'}
{/if}
</span>
</div>
<div class="col-sm-12 room_demand_detail">
{if isset($roomTypeServiceProducts) && $roomTypeServiceProducts}
{foreach $roomTypeServiceProducts as $product}
<div class="row room_demand_block">
<div class="col-xs-5">
<div class="row">
<div class="col-xs-2">
<input data-id_cart_booking="{$cartRoom['htl_cart_booking_id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($cartRoom['selected_products']) && $cartRoom['selected_products'] && ($product['id_product']|in_array:$cartRoom['selected_products'])}checked{/if}/>
</div>
<div class="col-xs-10">
<p>{$product['name']|escape:'html':'UTF-8'}</p>
{if $product.allow_multiple_quantity}
<div class="qty_container">
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" min="1" value="{if isset($cartRoom['selected_products']) && $cartRoom['selected_products'] && ($product['id_product']|in_array:$cartRoom['selected_products'])}{$cartRoom['selected_products_info'][$product['id_product']]['quantity']}{else}1{/if}">
</div>
{/if}
</div>
<div class="row room_demands_container">
<div class="col-sm-12 demand_header">
<span>
<i class="icon-bed"></i>
{if isset($selectedRoomServiceProduct['room_num']) && $selectedRoomServiceProduct['room_num']}
{l s='Room'} {$selectedRoomServiceProduct['room_num']|escape:'html':'UTF-8'}
{else}
{l s='Room'} {$roomCount|escape:'html':'UTF-8'}
{/if}
</span>
</div>
<div class="col-sm-12 room_demand_detail">
{if isset($roomTypeServiceProducts) && $roomTypeServiceProducts}
{foreach $roomTypeServiceProducts as $product}
<div class="row room_demand_block">
<div class="col-xs-5">
<div class="row">
<div class="col-xs-2">
<input data-id_cart_booking="{$selectedRoomServiceProduct['htl_cart_booking_id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}checked{/if}/>
</div>
<div class="col-xs-10">
<p>{$product['name']|escape:'html':'UTF-8'}</p>
{if $product.allow_multiple_quantity}
<div class="qty_container">
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" min="1" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}{$selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity']}{else}1{/if}">
</div>
{/if}
</div>
</div>
<div class="col-xs-3">
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</div>
<div class="col-xs-4">
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)}
<span class="pull-right">{convertPrice price=$product.price_tax_exc}</span>
{/if}
</div>
</div>
{/foreach}
{/if}
</div>
<div class="col-xs-3">
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</div>
<div class="col-xs-4">
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)}
<span class="pull-right">{convertPrice price=$product.price_tax_exc}</span>
{/if}
</div>
</div>
{/foreach}
{/if}
</div>
{assign var=roomCount value=1}
{/foreach}
</div>
</div>
</div>
{/if}

View File

@@ -792,8 +792,9 @@ class CartCore extends ObjectModel
}
} else if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $row['service_product_type']) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$totalPriceByProductTaxIncl = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, 1, true, null);
$totalPriceByProductTaxExcl = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, 1, false, null);
$totalPriceByProductTaxIncl = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, true, null);
$totalPriceByProductTaxExcl = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, false, null);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
@@ -1795,7 +1796,7 @@ class CartCore extends ObjectModel
} else if (!$product['booking_product'] && Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$totalPriceByProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$totalPriceByProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$this->id,
(int)$product['id_product'],
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
@@ -1803,7 +1804,6 @@ class CartCore extends ObjectModel
0,
0,
0,
1,
$with_taxes,
null
);

View File

@@ -585,7 +585,7 @@ class CustomerCore extends ObjectModel
WHERE c.`id_customer` = '.(int)$this->id);
$result['last_visit'] = $result2['last_visit'];
$result['age'] = ($result3['age'] != date('Y') ? $result3['age'] : '--');
$result['age'] = isset($result3['age']) && ($result3['age'] != date('Y') ? $result3['age'] : '--');
return $result;
}

View File

@@ -295,7 +295,6 @@ class AdminCartsControllerCore extends AdminController
}
}
//end
ddd($cartHtlData);
$this->tpl_view_vars = array(
'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data
'kpi' => $kpi,
@@ -1054,6 +1053,27 @@ class AdminCartsControllerCore extends AdminController
$this->context->smarty->assign('selectedRoomDemands', $selectedRoomDemands);
}
}
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
$idCart,
$idProduct,
$dateFrom,
$dateTo,
$idRoom
)) {
$selectedRoomServiceProduct['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
$selectedRoomServiceProduct['id'],
0,
null,
null
);
}
$this->context->smarty->assign(array(
'roomTypeServiceProducts' => $roomTypeServiceProducts,
'selectedRoomServiceProduct' => $selectedRoomServiceProduct
));
$htlCartBoookingata = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
$idCart,
$idProduct,
@@ -1061,35 +1081,6 @@ class AdminCartsControllerCore extends AdminController
$dateTo,
$idRoom
);
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if ($selectedRoomServiceProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$idCart,
0,
0,
$idProduct,
$dateFrom,
$dateTo,
$htlCartBoookingata['id'],
0,
null,
null
)) {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
foreach ($selectedRoomServiceProduct as $key => $selectedProducts) {
$objRoom = new HotelRoomInformation($selectedProducts['id_room']);
$selectedRoomServiceProduct[$key]['room_num'] = $objRoom->room_num;
foreach ($selectedProducts['selected_products_info'] as $product) {
$selectedRoomServiceProduct[$key]['selected_products'][] = $product['id_product'];
}
}
$this->context->smarty->assign(array(
'roomTypeServiceProducts' => $roomTypeServiceProducts,
'selectedRoomServiceProduct' => $selectedRoomServiceProduct
));
}
}
}
$response['status'] = true;

View File

@@ -985,31 +985,21 @@ class OrderOpcControllerCore extends ParentOrderController
}
}
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if ($selectedRoomServiceProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$this->context->cart->id,
0,
0,
$idProduct,
$dateFrom,
$dateTo,
0,
0,
null,
null
)) {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, true, 1);
foreach ($selectedRoomServiceProduct as $key => $selectedProducts) {
foreach ($selectedProducts['selected_products_info'] as $product) {
$selectedRoomServiceProduct[$key]['selected_products'][] = $product['id_product'];
}
}
$this->context->smarty->assign(array(
'roomTypeServiceProducts' => $roomTypeServiceProducts,
'selectedRoomServiceProduct' => $selectedRoomServiceProduct
));
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, true, 1);
$cartRooms = $objCartBookingData->getHotelCartRoomsInfoByRoomType($this->context->cart->id, $idProduct,$dateFrom, $dateTo);
foreach($cartRooms as &$room) {
$room['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
$room['id'],
0,
null,
null
);
}
$this->context->smarty->assign(array(
'roomTypeServiceProducts' => $roomTypeServiceProducts,
'cartRooms' => $cartRooms
));
}
}
$response['extra_demands'] = $this->context->smarty->fetch(

View File

@@ -968,16 +968,13 @@ class HotelCartBookingData extends ObjectModel
);
$cart_detail_data[$key]['additional_service'] = $objRoomTypeServiceProduct->getServiceProductsData($value['id_product']);
$cart_detail_data[$key]['selected_additional_service'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$id_cart,
$cart_detail_data[$key]['selected_services'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
$value['id'],
0,
0,
$value['id_product'],
$value['date_from'],
$value['date_to'],
$value['id']
null,
null
);
$cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$id_cart,
0,
0,
@@ -985,10 +982,9 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
true,
false
);
$cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$id_cart,
0,
0,
@@ -996,7 +992,6 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
true,
false,
1
);
@@ -1304,15 +1299,14 @@ class HotelCartBookingData extends ObjectModel
$data_v['date_to'],
1
);
$serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$context->cart->id,
0,
$data_v['id_hotel'],
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id'],
true
$data_v['id']
);
$totalAdditionalServicePrice = $demandPrice + $serviceProductPrice;

View File

@@ -90,6 +90,189 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
return true;
}
public function getServiceProductsTotalInCart(
$idCart,
$idProduct = 0,
$idHotel = 0,
$roomTypeIdProduct = 0,
$dateFrom = 0,
$dateTo = 0,
$htlCartBookingId = 0,
$useTax = null,
$autoAddToCart = 0,
$id_address = null,
$priceAdditionType = null
) {
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_product` as `room_type_id_product`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`)
WHERE 1';
if (!is_null($autoAddToCart)) {
$sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart;
if ($autoAddToCart == 1 && !is_null($priceAdditionType)) {
$sql .= ' AND p.`price_addition_type` = '.$priceAdditionType;
}
}
if ($idCart) {
$sql .= ' AND cbd.`id_cart`='.(int) $idCart;
}
if ($idProduct) {
$sql .= ' AND rscd.`id_product`='.(int) $idProduct;
}
if ($idHotel) {
$sql .= ' AND cbd.`id_hotel`='.(int) $idHotel;
}
if ($roomTypeIdProduct) {
$sql .= ' AND cbd.`id_product`='.(int) $roomTypeIdProduct;
}
if ($dateFrom && $dateTo) {
$sql .= ' AND cbd.`date_from` = \''.pSQL($dateFrom).'\' AND cbd.`date_to` = \''.pSQL($dateTo).'\'';
}
if ($htlCartBookingId) {
$sql .= ' AND cbd.`id`='.(int) $htlCartBookingId;
}
$sql .= ' ORDER BY cbd.`id`';
$totalPrice = 0;
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
foreach ($serviceProducts as $product) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
$totalPrice += $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$useTax,
false,
$id_address
);
}
}
return $totalPrice;
}
public function getRoomServiceProducts(
$htlCartBookingId,
$idLang = 0,
$useTax = null,
$autoAddToCart = 0,
$id_address = null,
$priceAdditionType = null
) {
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, p.`auto_add_to_cart`, p.`allow_multiple_quantity`, cbd.`id` as `htl_cart_booking_id`,
p.`price_addition_type`, cbd.`id_product` as `room_type_id_product`, pl.`name`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.')
WHERE 1';
if (!is_null($autoAddToCart)) {
$sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart;
if ($autoAddToCart == 1 && !is_null($priceAdditionType)) {
$sql .= ' AND p.`price_addition_type` = '.$priceAdditionType;
}
}
if ($htlCartBookingId) {
$sql .= ' AND cbd.`id`='.(int) $htlCartBookingId;
}
$sql .= ' ORDER BY cbd.`id`';
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$selectedServiceProducts = array();
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
foreach ($serviceProducts as $product) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
if (isset($selectedServiceProducts[$product['id_product']])) {
$selectedServiceProducts[$product['id_product']]['quantity'] += $product['quantity'];
$selectedServiceProducts[$product['id_product']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
true,
false,
$id_address
);
} else {
$selectedServiceProducts[$product['id_product']] = $product;
$selectedServiceProducts[$product['id_product']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
true,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
true,
false,
$id_address
);
}
}
}
return $selectedServiceProducts;
}
public function getServiceProductsInCart(
$idCart,
$idProduct = 0,
@@ -168,18 +351,31 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['room_type_id_product']);
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
if (isset($selectedServiceProducts[$product['htl_cart_booking_id']])) {
if ($product['id_product']) {
if ($idProduct) {
$selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] += $product['quantity'];
} else {
$selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array(
'id_product' => $product['id_product'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'quantity' => $product['quantity'],
);
}
if ($idProduct) {
$selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] += $product['quantity'];
} else {
$selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array(
'id_product' => $product['id_product'],
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
false,
false,
$id_address
),
'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
true,
false,
$id_address
),
);
}
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
@@ -240,30 +436,28 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$id_address
);
} else {
$selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'] = ($product['id_product']) ? array(
$product['id_product'] => array(
'id_product' => $product['id_product'],
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
false,
false,
$id_address
),
'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
true,
false,
$id_address
),
)
): array();
$selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array(
'id_product' => $product['id_product'],
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
false,
false,
$id_address
),
'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
true,
false,
$id_address
),
);
}
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice(

View File

@@ -92,7 +92,7 @@
<p class="rooms_extra_demands_text">{l s='Add below services to the rooms for better hotel experience'}</p>
</div>
{assign var=roomCount value=1}
{foreach $selectedRoomServiceProduct as $key => $cartRoom}
{foreach $cartRooms as $key => $cartRoom}
<div class="card accordion">
<div class="row accordion-section">
<div class="col-sm-12 demand_header">
@@ -110,7 +110,7 @@
<div class="col-xs-2">
{if $product.available_for_order}
<p class="checkbox">
<input data-id_cart_booking="{$cartRoom['htl_cart_booking_id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($cartRoom['selected_products']) && $cartRoom['selected_products'] && ($product['id_product']|in_array:$cartRoom['selected_products'])}checked{/if} />
<input data-id_cart_booking="{$cartRoom['id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($cartRoom['selected_service']) && $cartRoom['selected_service'] && ($product['id_product']|array_key_exists:$cartRoom['selected_service'])}checked{/if} />
</p>
{/if}
</div>
@@ -118,7 +118,7 @@
<p>{$product['name']|escape:'html':'UTF-8'}</p>
{if $product.allow_multiple_quantity}
<div class="qty_container">
<input type="text" class="form-control qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" value="{if isset($cartRoom['selected_products']) && $cartRoom['selected_products'] && ($product['id_product']|in_array:$cartRoom['selected_products'])}{$cartRoom['selected_products_info'][$product['id_product']]['quantity']}{else}1{/if}">
<input type="text" class="form-control qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" value="{if isset($cartRoom['selected_service']) && $cartRoom['selected_service'] && ($product['id_product']|array_key_exists:$cartRoom['selected_service'])}{$cartRoom['selected_service'][$product['id_product']]['quantity']}{else}1{/if}">
<div class="qty_controls">
<a href="#" class="qty_up"><span><i class="icon-plus"></i></span></a>
<a href="#" class="qty_down"><span><i class="icon-minus"></i></span></a>