Merge branch 'develop' into gli-2285

This commit is contained in:
Shreesh Arora
2024-09-11 10:53:11 +05:30
30 changed files with 1086 additions and 1257 deletions

View File

@@ -124,7 +124,7 @@
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#" class="room_reallocate_swap" id="reallocate_room_{$data['id']}" data-room_type_name="{$data['room_type_name']}" data-toggle="modal" data-target="#mySwappigModal" data-id_htl_booking="{$data['id']}" data-id_order="{$data['id_order']}" data-room_num='{$data.room_num}' data-id_room_type='{$data.id_product}' data-cust_name='{$data.alloted_cust_name}' data-cust_email='{$data.alloted_cust_email}' data-avail_rm_swap='{$data.avail_rooms_to_swap|@json_encode}' data-avail_realloc_room_types='{$data.avail_room_types_to_realloc|@json_encode}' data-allotment_type='{$data['booking_type']}' data-allotment_type_label='{if $data['booking_type'] == $ALLOTMENT_MANUAL}{l s='Manual'}{else}{l s='Auto'}{/if}' data-comment='{$data.comment}'>
<a href="#" class="room_reallocate_swap" id="reallocate_room_{$data['id']}" data-room_type_name="{$data['room_type_name']}" data-toggle="modal" data-target="#mySwappigModal" data-id_htl_booking="{$data['id']}" data-id_order="{$data['id_order']}" data-room_num='{$data.room_num}' data-id_room_type='{$data.id_product}' data-cust_name='{$data.alloted_cust_name}' data-cust_email='{$data.alloted_cust_email}' data-avail_rm_swap='{$data.avail_rooms_to_swap|@json_encode}' data-avail_realloc_room_types='{$data.avail_room_types_to_realloc|@json_encode}' data-allotment_type='{$data.booking_type}' data-allotment_type_label='{if $data.booking_type == $ALLOTMENT_MANUAL}{l s='Manual'}{else}{l s='Auto'}{/if}' data-comment='{$data.comment}'>
<i class="icon-refresh"></i>
{l s='Reallocate/Swap Room'}
</a>

View File

@@ -45,7 +45,7 @@
<td>
<div class="input-group">
<span class="input-group-addon">{$currencySign}</span>
<input type="text" class="form-control unit_price" value="{Tools::ps_round($demand['unit_price_tax_excl'], 2)}">
<input type="text" class="form-control unit_price" value="{$demand['unit_price_tax_excl']}">
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
<span class="input-group-addon">{l s='/ night'}</span>
{/if}
@@ -115,7 +115,7 @@
{else}
{assign var=demand_price value=$demand['price_tax_excl']}
{/if}
<input type="text" class="form-control unit_price" value="{Tools::ps_round($demand_price, 2)}" data-id-product="{$product['id_product']}">
<input type="text" class="form-control unit_price" value="{$demand_price}" data-id-product="{$product['id_product']}">
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
<span class="input-group-addon">{l s='/ night'}</span>
{/if}

View File

@@ -78,7 +78,7 @@
<td class="demand_price_{$demand['id_global_demand']}">
<div class="input-group price_input" {if !isset($selectedDemands[$demand['id_global_demand']])}style="display:none"{/if}>
<span class="input-group-addon">{$defaultcurrencySign|escape:'html':'UTF-8'}</span>
<input type="text" name="option_price_{$option['id']|escape:'html':'UTF-8'}" value="{if isset($selectedDemands[$demand['id_global_demand']]['adv_option'][$option['id']]['price'])}{Tools::ps_round($selectedDemands[$demand['id_global_demand']]['adv_option'][$option['id']]['price'], 2)|escape:'html':'UTF-8'}{else}{Tools::ps_round($option['price'], 2)|escape:'html':'UTF-8'}{/if}"/>
<input type="text" name="option_price_{$option['id']|escape:'html':'UTF-8'}" value="{if isset($selectedDemands[$demand['id_global_demand']]['adv_option'][$option['id']]['price'])}{$selectedDemands[$demand['id_global_demand']]['adv_option'][$option['id']]['price']|escape:'html':'UTF-8'}{else}{$option['price']|escape:'html':'UTF-8'}{/if}"/>
</div>
<div class="price_display" {if isset($selectedDemands[$demand['id_global_demand']])}style="display:none"{/if}>
{displayPrice price={$option['price']|escape:'html':'UTF-8'} currency=$idDefaultcurrency}
@@ -112,7 +112,7 @@
<div class="input-group price_input" {if !isset($selectedDemands[$demand['id_global_demand']])}style="display:none"{/if}>
<span class="input-group-addon">{$defaultcurrencySign|escape:'html':'UTF-8'}</span>
<input type="text" name="demand_price_{$demand['id_global_demand']|escape:'html':'UTF-8'}"
value="{if isset($selectedDemands[$demand['id_global_demand']]['price'])}{Tools::ps_round($selectedDemands[$demand['id_global_demand']]['price'], 2)|escape:'html':'UTF-8'}{elseif isset($demand['price'])}{Tools::ps_round($demand['price'], 2)|escape:'html':'UTF-8'}{/if}"/>
value="{if isset($selectedDemands[$demand['id_global_demand']]['price'])}{$selectedDemands[$demand['id_global_demand']]['price']|escape:'html':'UTF-8'}{elseif isset($demand['price'])}{$demand['price']|escape:'html':'UTF-8'}{/if}"/>
</div>
<div class="price_display" {if isset($selectedDemands[$demand['id_global_demand']])}style="display:none"{/if}>
{displayPrice price={$demand['price']|escape:'html':'UTF-8'} currency=$idDefaultcurrency}

View File

@@ -721,29 +721,6 @@ class CartCore extends ObjectModel
$cart_shop_context
);
/*Before Changes by webkul*/
// switch (Configuration::get('PS_ROUND_TYPE'))
// {
// case Order::ROUND_TOTAL:
// $row['total'] = $row['price_with_reduction_without_tax'] * (int)$row['cart_quantity'];
// $row['total_wt'] = $row['price_with_reduction'] * (int)$row['cart_quantity'];
// break;
// case Order::ROUND_LINE:
// $row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'] * (int)$row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
// $row['total_wt'] = Tools::ps_round($row['price_with_reduction'] * (int)$row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
// break;
// case Order::ROUND_ITEM:
// default:
// $row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'], _PS_PRICE_COMPUTE_PRECISION_) * (int)$row['cart_quantity'];
// $row['total_wt'] = Tools::ps_round($row['price_with_reduction'], _PS_PRICE_COMPUTE_PRECISION_) * (int)$row['cart_quantity'];
// break;
// }
//$row['price_wt'] = $row['price_with_reduction'];
//
//
/*By Webkul */
if ($row['booking_product']) {
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
@@ -757,81 +734,57 @@ class CartCore extends ObjectModel
$priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) {
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$cartRoomInfo['id_product'],
$cartRoomInfo['date_from'],
$cartRoomInfo['date_to'],
0,
Group::getCurrent()->id,
$cartRoomInfo['id_cart'],
$cartRoomInfo['id_guest'],
$cartRoomInfo['id_room'],
0
);
$cartRoomInfo['id_product'],
$cartRoomInfo['date_from'],
$cartRoomInfo['date_to'],
0,
Group::getCurrent()->id,
$cartRoomInfo['id_cart'],
$cartRoomInfo['id_guest'],
$cartRoomInfo['id_room'],
0
);
$totalPriceByProductTaxIncl += $roomTotalPrice['total_price_tax_incl'];
$totalPriceByProductTaxExcl += $roomTotalPrice['total_price_tax_excl'];
}
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
$row['total'] = $totalPriceByProductTaxExcl;
$row['total_wt'] = $totalPriceByProductTaxIncl;
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($totalPriceByProductTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($totalPriceByProductTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($totalPriceByProductTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($totalPriceByProductTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
break;
}
// Rounding as per configurations
$row['total'] = Tools::processPriceRounding($totalPriceByProductTaxExcl);
$row['total_wt'] = Tools::processPriceRounding($totalPriceByProductTaxIncl);
}
} else if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $row['service_product_type']) {
$row['total'] = 0;
$row['total_wt'] = 0;
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$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:
$row['total'] = $totalPriceByProductTaxExcl;
$row['total_wt'] = $totalPriceByProductTaxIncl;
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($totalPriceByProductTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($totalPriceByProductTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($totalPriceByProductTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($totalPriceByProductTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
break;
if ($servicesWithRoom = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$this->id,
(int)$row['id_product'],
0,
0,
0,
0,
0,
0,
null,
$row['auto_add_to_cart'],
null,
null
)) {
foreach ($servicesWithRoom as $service) {
// Rounding as per configurations
$row['total'] += Tools::processPriceRounding($service['unit_price_tax_excl'], $service['quantity']);
$row['total_wt'] += Tools::processPriceRounding($service['unit_price_tax_incl'], $service['quantity']);
}
}
} else {
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
$unitPriceByProductTaxIncl = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$row['id_product'], 0, true);
$unitPriceByProductTaxExcl = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$row['id_product'], 0, false);
switch (Configuration::get('PS_ROUND_TYPE'))
{
case Order::ROUND_TOTAL:
$row['total'] = $unitPriceByProductTaxExcl * (int)$row['cart_quantity'];
$row['total_wt'] = $unitPriceByProductTaxIncl * (int)$row['cart_quantity'];
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($unitPriceByProductTaxExcl * (int)$row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($unitPriceByProductTaxIncl * (int)$row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
break;
// Rounding as per configurations
$row['total'] += Tools::processPriceRounding($unitPriceByProductTaxExcl, $row['cart_quantity']);
$row['total_wt'] += Tools::processPriceRounding($unitPriceByProductTaxIncl, $row['cart_quantity']);
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($unitPriceByProductTaxExcl, _PS_PRICE_COMPUTE_PRECISION_) * (int)$row['cart_quantity'];
$row['total_wt'] = Tools::ps_round($unitPriceByProductTaxIncl, _PS_PRICE_COMPUTE_PRECISION_) * (int)$row['cart_quantity'];
break;
}
$row['price_wt'] = $row['price_with_reduction'];
}
@@ -1794,19 +1747,36 @@ class CartCore extends ObjectModel
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
$price = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$product['id_product'], 0, $with_taxes);
} else if (!$product['booking_product'] && Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$totalPriceByProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
if ($servicesWithRoom = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$this->id,
(int)$product['id_product'],
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
0,
0,
0,
0,
$with_taxes,
0,
0,
null,
$product['auto_add_to_cart'],
null,
null
);
)) {
foreach ($servicesWithRoom as $service) {
if ($with_taxes) {
$servicePrice = $service['total_price_tax_incl'];
} else {
$servicePrice = $service['total_price_tax_excl'];
}
// Rounding as per configurations
if ($ps_round_type == Order::ROUND_TOTAL) {
$products_total[$id_tax_rules_group.'_'.$id_address] += $servicePrice;
} else {
$products_total[$id_tax_rules_group] += $servicePrice;
}
}
}
} else if ($roomTypesByIdProduct = $objCartBookingData->getCartInfoIdCartIdProduct($this->id, $product['id_product'])) {
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
$totalPriceByProduct = 0;
@@ -1825,9 +1795,9 @@ class CartCore extends ObjectModel
0
);
if ($with_taxes) {
$totalPriceByProduct += $roomTotalPrice['total_price_tax_incl'];
$totalPriceByProduct = $roomTotalPrice['total_price_tax_incl'];
} else {
$totalPriceByProduct += $roomTotalPrice['total_price_tax_excl'];
$totalPriceByProduct = $roomTotalPrice['total_price_tax_excl'];
}
// If customer has selected advance payment of the cart
@@ -1846,40 +1816,16 @@ class CartCore extends ObjectModel
$totalPriceByProduct = $advProductPrice;
}
}
// Rounding as per configurations
if ($ps_round_type == Order::ROUND_TOTAL) {
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($totalPriceByProduct);
} else {
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($totalPriceByProduct);
}
}
}
switch ($ps_round_type) {
case Order::ROUND_TOTAL:
if ($product['booking_product'] || (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type'])) {
$products_total[$id_tax_rules_group.'_'.$id_address] += $totalPriceByProduct;
} else {
$products_total[$id_tax_rules_group.'_'.$id_address] += $price * (int)$product['cart_quantity'];
}
break;
case Order::ROUND_LINE:
if ($product['booking_product'] || (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type'])) {
$product_price = $totalPriceByProduct;
} else {
$product_price = $price * $product['cart_quantity'];
}
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision);
break;
case Order::ROUND_ITEM:
default:
if ($product['booking_product'] || (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type'])) {
$product_price = $totalPriceByProduct;
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision);
} else {
$product_price = /*$with_taxes ? $tax_calculator->addTaxes($price) : */$price;
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision) * (int)$product['cart_quantity'];
}
break;
}
// price of extra demands on room type in the cart
$totalDemandsPrice += $objCartBookingData->getCartExtraDemands($this->id, $product['id_product'], 0, 0, 0, 1, 0, (int)$with_taxes);
}

View File

@@ -540,7 +540,7 @@ abstract class PaymentModuleCore extends Module
$price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart);
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, _PS_PRICE_COMPUTE_PRECISION_) : $price_wt;
$product_var_tpl = array(
'reference' => $product['reference'],
@@ -627,11 +627,11 @@ abstract class PaymentModuleCore extends Module
$used = array('incl' => 0, 'excl' => 0);
if (!isset($cart_rules[$key]['remaining'])) {
$cart_rules[$key]['remaining'] = $cart_rule['obj']->reduction_amount;
if ((int) $cart_rule['obj']->reduction_currency !== (int) $cart->id_currency) {
if ((int) $cart_rule['obj']->reduction_currency !== (int) $this->context->cart->id_currency) {
$cart_rules[$key]['remaining'] = Tools::convertPriceFull(
$cart_rule['obj']->reduction_amount,
new Currency($cart_rule['obj']->reduction_currency),
new Currency($cart->id_currency)
new Currency($this->context->cart->id_currency)
);
}
}
@@ -819,10 +819,11 @@ abstract class PaymentModuleCore extends Module
$objCartBookingData->id_room,
0
);
$objBookingDetail->date_from = $objCartBookingData->date_from;
$objBookingDetail->date_to = $objCartBookingData->date_to;
$objBookingDetail->total_price_tax_excl = Tools::ps_round($total_price['total_price_tax_excl'], 6);
$objBookingDetail->total_price_tax_incl = Tools::ps_round($total_price['total_price_tax_incl'], 6);
$objBookingDetail->total_price_tax_excl = $total_price['total_price_tax_excl'];
$objBookingDetail->total_price_tax_incl = $total_price['total_price_tax_incl'];
$objBookingDetail->adults = $objCartBookingData->adults;
$objBookingDetail->children = $objCartBookingData->children;
$objBookingDetail->child_ages = $objCartBookingData->child_ages;
@@ -850,7 +851,7 @@ abstract class PaymentModuleCore extends Module
}
/*for saving details of the advance payment product wise*/
$objBookingDetail->total_paid_amount = Tools::ps_round($total_price['total_price_tax_incl'], 5);
$objBookingDetail->total_paid_amount = $total_price['total_price_tax_incl'];
if ($this->context->cart->is_advance_payment) {
$prod_adv_payment = $objAdvancedPayment->getIdAdvPaymentByIdProduct($idProduct);
if (!$prod_adv_payment
@@ -898,18 +899,17 @@ abstract class PaymentModuleCore extends Module
$idOption,
1
);
$qty = 1;
$numDays = 1;
if ($objGlobalDemand->price_calc_method == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY) {
$numDays = $objBookingDetail->getNumberOfDays(
$objBookingDetail->date_from,
$objBookingDetail->date_to
);
if ($numDays > 1) {
$qty *= $numDays;
}
}
$objBookingDemand->total_price_tax_excl = $objBookingDemand->unit_price_tax_excl * $qty;
$objBookingDemand->total_price_tax_incl = $objBookingDemand->unit_price_tax_incl * $qty;
$objBookingDemand->total_price_tax_excl = Tools::processPriceRounding(($objBookingDemand->unit_price_tax_excl * $numDays));
$objBookingDemand->total_price_tax_incl = Tools::processPriceRounding(($objBookingDemand->unit_price_tax_incl * $numDays));
$objBookingDemand->price_calc_method = $objGlobalDemand->price_calc_method;
$objBookingDemand->id_tax_rules_group = $objGlobalDemand->id_tax_rules_group;

View File

@@ -3800,6 +3800,27 @@ exit;
}
return $base;
}
public static function processPriceRounding($value, $qty = 1, $roundType = null, $roundMode = null)
{
if (!$roundType) {
$roundType = Configuration::get('PS_ROUND_TYPE');
}
switch ($roundType) {
case Order::ROUND_TOTAL:
$value = $value;
break;
case Order::ROUND_LINE:
$value = Tools::ps_round(($value * $qty), _PS_PRICE_COMPUTE_PRECISION_, $roundMode);
break;
case Order::ROUND_ITEM:
default:
$value = Tools::ps_round($value, _PS_PRICE_COMPUTE_PRECISION_, $roundMode) * $qty;
break;
}
return $value;
}
}
/**

View File

@@ -2535,20 +2535,8 @@ class OrderCore extends ObjectModel
}
foreach ($tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $unit_amount) {
$total_tax_base = 0;
switch ($round_type) {
case Order::ROUND_ITEM:
$total_tax_base = $quantity * Tools::ps_round($discounted_price_tax_excl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
$total_amount = $quantity * Tools::ps_round($unit_amount, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
break;
case Order::ROUND_LINE:
$total_tax_base = Tools::ps_round($quantity * $discounted_price_tax_excl, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
$total_amount = Tools::ps_round($quantity * $unit_amount, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
break;
case Order::ROUND_TOTAL:
$total_tax_base = $quantity * $discounted_price_tax_excl;
$total_amount = $quantity * $unit_amount;
break;
}
$total_tax_base = Tools::processPriceRounding($discounted_price_tax_excl, $quantity);
$totalPrice = Tools::processPriceRounding($unit_amount, $quantity);
if (!isset($breakdown[$id_tax])) {
$breakdown[$id_tax] = array('tax_base' => 0, 'tax_amount' => 0);

View File

@@ -398,22 +398,10 @@ class OrderDetailCore extends ObjectModel
$values = '';
foreach ($this->tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $amount) {
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_ITEM:
$unit_amount = (float)Tools::ps_round($amount, _PS_PRICE_COMPUTE_PRECISION_);
$total_amount = $unit_amount * $this->product_quantity;
break;
case Order::ROUND_LINE:
$unit_amount = $amount;
$total_amount = Tools::ps_round($unit_amount * $this->product_quantity, _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_TOTAL:
$unit_amount = $amount;
$total_amount = $unit_amount * $this->product_quantity;
break;
}
$values .= '('.(int)$this->id.','.(int)$id_tax.','.(float)$unit_amount.','.(float)$total_amount.'),';
$total_amount = Tools::processPriceRounding($unit_amount, $this->product_quantity, $order->round_type, $order->round_mode);
$values .= '('.(int)$this->id.','.(int)$id_tax.','.(float)$amount.','.(float)$total_amount.'),';
}
if ($replace) {

View File

@@ -283,7 +283,6 @@ class OrderSlipCore extends ObjectModel
/**
* @deprecated since 1.6.0.10 use OrderSlip::create() instead
*
*/
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
{
@@ -374,49 +373,55 @@ class OrderSlipCore extends ObjectModel
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int)$order_detail->product_id);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
$order_slip->{'total_products_tax_'.$inc_or_ex_1} += $price * $numDays;
if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
if (!isset($total_products[$id_tax_rules_group])) {
$total_products[$id_tax_rules_group] = 0;
}
} else {
$ps_round_type = Configuration::get('PS_ROUND_TYPE');
if ($ps_round_type == Order::ROUND_TOTAL) {
if (!isset($total_products[$id_tax_rules_group.'_'.$id_address])) {
$total_products[$id_tax_rules_group.'_'.$id_address] = 0;
}
} else {
if (!isset($total_products[$id_tax_rules_group])) {
$total_products[$id_tax_rules_group] = 0;
}
}
$product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove.'Taxes'}($price) * $numDays, _PS_PRICE_COMPUTE_PRECISION_);
$product_tax_inc_or_ex_1 = Tools::processPriceRounding(
($price * $numDays),
1,
$order->round_type,
$order->round_mode
);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_ITEM:
$product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove.'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_) * $numDays;
$total_products[$id_tax_rules_group] += $product_tax_incl;
break;
case Order::ROUND_LINE:
$product_tax_incl = $product_tax_incl_line;
$total_products[$id_tax_rules_group] += $product_tax_incl;
break;
case Order::ROUND_TOTAL:
$product_tax_incl = $product_tax_incl_line;
$total_products[$id_tax_rules_group.'_'.$id_address] += $price * $numDays;
break;
$order_slip->{'total_products_tax_'.$inc_or_ex_1} += $product_tax_inc_or_ex_1;
$product_tax_inc_or_ex_2 = Tools::processPriceRounding(
($tax_calculator->{$add_or_remove.'Taxes'}($price * $numDays)),
1,
$order->round_type,
$order->round_mode
);
if ($ps_round_type == Order::ROUND_TOTAL) {
$total_products[$id_tax_rules_group.'_'.$id_address] += $product_tax_inc_or_ex_2;
} else {
$total_products[$id_tax_rules_group] += $product_tax_inc_or_ex_2;
}
$booking['unit_price_tax_'.$inc_or_ex_1] = $price;
$booking['unit_price_tax_'.$inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove.'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
$booking['total_price_tax_'.$inc_or_ex_1] = Tools::ps_round($price * $numDays, _PS_PRICE_COMPUTE_PRECISION_);
$booking['total_price_tax_'.$inc_or_ex_2] = Tools::ps_round($product_tax_incl, _PS_PRICE_COMPUTE_PRECISION_);
$booking['unit_price_tax_'.$inc_or_ex_2] = $tax_calculator->{$add_or_remove.'Taxes'}($price);
$booking['total_price_tax_'.$inc_or_ex_1] = $product_tax_inc_or_ex_1;
$booking['total_price_tax_'.$inc_or_ex_2] = $product_tax_inc_or_ex_2;
}
unset($product);
foreach ($total_products as $key => $price) {
if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
$tmp = explode('_', $key);
$address = Address::initialize((int)$tmp[1], true);
$tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
$order_slip->{'total_products_tax_'.$inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove.'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
$order_slip->{'total_products_tax_'.$inc_or_ex_2} += Tools::processPriceRounding(
($tax_calculator->{$add_or_remove.'Taxes'}($price)),
1,
$order->round_type,
$order->round_mode
);
} else {
$order_slip->{'total_products_tax_'.$inc_or_ex_2} += $price;
}

View File

@@ -841,6 +841,7 @@ class AdminCartsControllerCore extends AdminController
$cart['total_price'] = Tools::displayPrice($cart_obj->getOrderTotal(), $currency);
}
}
if (count($orders)) {
foreach ($orders as &$order) {
$order['total_paid_real'] = Tools::displayPrice($order['total_paid_real'], $currency);
@@ -1113,11 +1114,14 @@ class AdminCartsControllerCore extends AdminController
$dateTo,
$idRoom
)) {
$selectedRoomServiceProduct['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
$selectedRoomServiceProduct['id'],
$selectedRoomServiceProduct['selected_service'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$idCart,
0,
null,
null
0,
0,
0,
0,
$selectedRoomServiceProduct['id'],
);
}
$this->context->smarty->assign(array(

File diff suppressed because it is too large Load Diff

View File

@@ -1032,11 +1032,14 @@ class OrderOpcControllerCore extends ParentOrderController
$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'],
$room['selected_service'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$room['id_cart'],
0,
null,
null
0,
0,
0,
0,
$room['id']
);
}
$this->context->smarty->assign(array(

View File

@@ -885,7 +885,7 @@
<value>1</value>
</configuration>
<configuration id="PS_ROUND_TYPE" name="PS_ROUND_TYPE">
<value>2</value>
<value>1</value>
</configuration>
<configuration id="PS_PRICE_DISPLAY_PRECISION" name="PS_PRICE_DISPLAY_PRECISION">
<value>2</value>

View File

@@ -119,9 +119,9 @@ class HotelBookingDemands extends ObjectModel
if ($getTotalPrice) {
foreach ($roomTypeDemands as $demand) {
if ($useTax) {
$totalDemandsPrice += $demand['total_price_tax_incl'];
$totalDemandsPrice += Tools::processPriceRounding($demand['total_price_tax_incl']);
} else {
$totalDemandsPrice += $demand['total_price_tax_excl'];
$totalDemandsPrice += Tools::processPriceRounding($demand['total_price_tax_excl']);
}
}
} else {
@@ -202,24 +202,11 @@ class HotelBookingDemands extends ObjectModel
$objBkDetail = new HotelBookingDetail($this->id_htl_booking);
$quantity = $objBkDetail->getNumberOfDays($objBkDetail->date_from, $objBkDetail->date_to);
}
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_ITEM:
$unitAmount = (float)Tools::ps_round($amount, _PS_PRICE_COMPUTE_PRECISION_);
$totalAmount = $unitAmount * $quantity;
break;
case Order::ROUND_LINE:
$unitAmount = $amount;
$totalAmount = Tools::ps_round(
$unitAmount * $quantity,
_PS_PRICE_COMPUTE_PRECISION_
);
break;
case Order::ROUND_TOTAL:
$unitAmount = $amount;
$totalAmount = $unitAmount * $quantity;
break;
}
$values .= '('.(int)$this->id.','.(int)$idTax.','.(float)$unitAmount.','.
// Rounding as per configurations
$totalAmount += Tools::processPriceRounding($amount, $quantity);
$values .= '('.(int)$this->id.','.(int)$idTax.','.(float)$amount.','.
(float)$totalAmount.'),';
}
@@ -274,29 +261,15 @@ class HotelBookingDemands extends ObjectModel
if ($taxDetails) {
foreach ($taxDetails as &$detail) {
$priceTaxExcl = $detail['unit_price_tax_excl'];
$quantity = 1;
$numDays = 1;
$objBkDemand = new HotelBookingDemands($detail['id_booking_demand']);
if ($objBkDemand->price_calc_method == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY) {
$objBkDetail = new HotelBookingDetail($detail['id_htl_booking']);
$quantity = $objBkDetail->getNumberOfDays($objBkDetail->date_from, $objBkDetail->date_to);
}
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_ITEM:
$unitAmount = (float)Tools::ps_round($priceTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
$totalTaxBase = $unitAmount * $quantity;
break;
case Order::ROUND_LINE:
$unitAmount = $priceTaxExcl;
$totalTaxBase = Tools::ps_round(
$unitAmount * $quantity,
_PS_PRICE_COMPUTE_PRECISION_
);
break;
case Order::ROUND_TOTAL:
$unitAmount = $priceTaxExcl;
$totalTaxBase = $unitAmount * $quantity;
break;
$numDays = $objBkDetail->getNumberOfDays($objBkDetail->date_from, $objBkDetail->date_to);
}
$totalTaxBase = $unitAmount * $numDays;
$detail['total_tax_base'] = $totalTaxBase;
}
}

View File

@@ -225,9 +225,6 @@ class HotelBookingDetail extends ObjectModel
$params['occupancy'] = array();
}
if (!isset($params['ratting'])) {
$params['ratting'] = -1;
}
if (!isset($params['amenities'])) {
$params['amenities'] = 0;
}
@@ -239,6 +236,10 @@ class HotelBookingDetail extends ObjectModel
$params['only_search_data'] = 0;
}
if (!isset($params['full_detail'])) {
$params['full_detail'] = 0;
}
Hook::exec('actionBookingDataParamsModifier', array('params' => &$params));
return $params;
@@ -399,7 +400,7 @@ class HotelBookingDetail extends ObjectModel
}
// Now we will formate the data after geting search result according to search type
$roomTypesDetail = $objRoomType->getRoomTypeDetailByRoomTypeIds($allowedIdRoomTypes);
$roomTypesDetail = $objRoomType->getRoomTypeDetailByRoomTypeIds($allowedIdRoomTypes, true, $full_detail);
if ($roomTypesDetail) {
// Formate data for response
$finalSearchResponse = array(
@@ -414,15 +415,12 @@ class HotelBookingDetail extends ObjectModel
$finalSearchResponse['stats']['total_rooms'] += $roomTypeDetail['numberOfRooms'];
$idProduct = $roomTypeDetail['id_product'];
$roomTypeSearchData = array(
'name' => (new Product((int) $idProduct, false, $this->context->cookie->id_lang))->name,
'id_product' => $idProduct,
'adults' => $roomTypeDetail['adults'],
'children' => $roomTypeDetail['children'],
'max_adults' => $roomTypeDetail['max_adults'],
'max_children' => $roomTypeDetail['max_children'],
'max_guests' => $roomTypeDetail['max_guests'],
'data' => array(),
$roomTypeSearchData = array_merge(
$roomTypeDetail,
array(
'id_product' => $idProduct,
'data' => array(),
)
);
if ($search_unavai) {
@@ -1195,6 +1193,7 @@ class HotelBookingDetail extends ObjectModel
}
}
unset($datetimeObj);
unset($roomDetail);
// If all dates are covered
if (!$datesToCover) {
@@ -1634,7 +1633,6 @@ class HotelBookingDetail extends ObjectModel
* @param [int] $only_search_data [used for product page and category page for block cart]
* @param [int] $adults []
* @param [int] $children []
* @param [] $ratting [description]
* @param [] $amenities [description]
* @param [] $price [description]
* @param [int] $id_cart [Id of the cart]
@@ -1645,10 +1643,6 @@ class HotelBookingDetail extends ObjectModel
*/
public function dataForFrontSearch($bookingParams)
{
// if (Module::isInstalled('productcomments')) {
// require_once _PS_MODULE_DIR_.'productcomments/ProductComment.php';
// }
$this->context = Context::getContext();
if (!isset($bookingParams['search_available'])) {
@@ -1664,6 +1658,7 @@ class HotelBookingDetail extends ObjectModel
$bookingParams['search_unavai'] = 0;
}
$bookingParams['full_detail'] = 1;
$bookingData = $this->getBookingData($bookingParams);
extract($this->getBookingDataParams($bookingParams));
@@ -1673,104 +1668,62 @@ class HotelBookingDetail extends ObjectModel
$objRoomType = new HotelRoomType();
foreach ($bookingData['rm_data'] as $key => $value) {
if (empty($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;
}
}
}
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]);
} else {
$prod_ratting = 0;
// if (Module::isInstalled('productcomments')) {
// $prod_ratting = ProductComment::getAverageGrade($value['id_product'])['grade'];
// }
// if (empty($prod_ratting)) {
// $prod_ratting = 0;
// }
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);
$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]['price_without_reduction'] = $productPriceWithoutReduction;
$bookingData['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice;
$bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']);
// if ($prod_ratting < $ratting && $ratting != -1) {
// unset($bookingData['rm_data'][$key]);
// } else
// {
$product = new Product($value['id_product'], false, $this->context->language->id);
$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]);
}
// 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 (empty($prod_amen)) {
$prod_price = Product::getPriceStatic($value['id_product'], self::useTax());
$productPriceWithoutReduction = $product->getPriceWithoutReduct(!self::useTax());
$productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax());
$productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0);
if (empty($price) || ($price['from'] <= $prod_price && $price['to'] >= $prod_price)) {
$cover_image_arr = $product->getCover($value['id_product']);
if (!empty($cover_image_arr)) {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default');
} else {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default');
}
$room_left = count($bookingData['rm_data'][$key]['data']['available']);
$rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($value['id_product']);
$bookingData['rm_data'][$key]['name'] = $product->name;
$bookingData['rm_data'][$key]['image'] = $cover_img;
$bookingData['rm_data'][$key]['description'] = $product->description_short;
$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;
// if ($room_left <= (int)Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'))
$bookingData['rm_data'][$key]['room_left'] = $room_left;
$bookingData['rm_data'][$key]['adults'] = $rm_dtl['adults'];
$bookingData['rm_data'][$key]['children'] = $rm_dtl['children'];
$bookingData['rm_data'][$key]['ratting'] = $prod_ratting;
// if (Module::isInstalled('productcomments')) {
// $bookingData['rm_data'][$key]['num_review'] = ProductComment::getCommentNumber($value['id_product']);
// }
// 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($product).'?'.http_build_query($urlData);
} else {
$bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'&'.http_build_query($urlData);
}
} else {
unset($bookingData['rm_data'][$key]);
}
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);
}
// }
}
}
}
@@ -1902,6 +1855,7 @@ class HotelBookingDetail extends ObjectModel
public function reallocateBooking($idHotelBooking, $idRoom, $priceDiffTaxExcl = 0)
{
$result = true;
$reallocatedBookingId = 0;
// get the cart booking data for the given booking
if (Validate::isLoadedObject($objOldHotelBooking = new HotelBookingDetail($idHotelBooking))) {
$objHotelRoomInfo = new HotelRoomInformation($idRoom);
@@ -1912,7 +1866,10 @@ class HotelBookingDetail extends ObjectModel
$productQty = (int)$objOldHotelBooking->getNumberOfDays($objOldHotelBooking->date_from, $objOldHotelBooking->date_to);
$oldRoomPriceTaxExcl = $objOldHotelBooking->total_price_tax_excl / $productQty;
$newRoomPriceTaxExcl = $oldRoomPriceTaxExcl + $priceDiffTaxExcl;
// Calculate new room price per qty
$priceDiffPerQtyTaxExcl = $priceDiffTaxExcl / $productQty;
$newRoomPriceTaxExcl = $oldRoomPriceTaxExcl + $priceDiffPerQtyTaxExcl;
$totalRoomPriceTaxIncl = $objOldHotelBooking->total_price_tax_incl;
$totalRoomPriceTaxExcl = $objOldHotelBooking->total_price_tax_excl;
@@ -1936,6 +1893,7 @@ class HotelBookingDetail extends ObjectModel
$cart->add();
// Save context (in order to apply cart rule)
$this->context = Context::getContext();
$this->context->cart = $cart;
$this->context->customer = new Customer($objOrder->id_customer);
$this->context->currency = new Currency($objOrder->id_currency);
@@ -1947,7 +1905,7 @@ class HotelBookingDetail extends ObjectModel
$idNewRoomType,
$useTaxes,
null,
2,
6,
null,
false,
true,
@@ -1991,7 +1949,8 @@ class HotelBookingDetail extends ObjectModel
$objCartBookingData->id_product = $roomInfo['id_product'];
$objCartBookingData->id_room = $roomInfo['id_room'];
$objCartBookingData->id_hotel = $roomInfo['id_hotel'];
$objCartBookingData->booking_type = 1;
$objCartBookingData->booking_type = $objOldHotelBooking->booking_type;
$objCartBookingData->comment = $objOldHotelBooking->comment;
$objCartBookingData->quantity = $productQty;
$objCartBookingData->date_from = $objOldHotelBooking->date_from;
$objCartBookingData->date_to = $objOldHotelBooking->date_to;
@@ -2016,18 +1975,6 @@ class HotelBookingDetail extends ObjectModel
return false;
}
$totalRoomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$idNewRoomType,
$objCartBookingData->date_from,
$objCartBookingData->date_to,
0,
Group::getCurrent()->id,
$this->context->cart->id,
$this->context->cookie->id_guest,
$objCartBookingData->id_room,
0
);
// Add product to cart
$updateQuantity = $cart->updateQty(
$productQty,
@@ -2046,7 +1993,7 @@ class HotelBookingDetail extends ObjectModel
$objOrderInvoice->total_paid_tax_incl += (float)($cart->getOrderTotal($useTaxes, $totalMethod));
$objOrderInvoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$objOrderInvoice->total_products_wt += (float)$cart->getOrderTotal($useTaxes, Cart::ONLY_PRODUCTS);
$objOrderInvoice->update();
$result &= $objOrderInvoice->update();
}
// Create Order detail information
@@ -2062,7 +2009,7 @@ class HotelBookingDetail extends ObjectModel
$objOrder->total_paid_tax_incl += (float)($cart->getOrderTotal($useTaxes, $totalMethod));
// Save changes of order
$objOrder->update();
$result &= $objOrder->update();
// Update Tax lines
$objOrderDetail->updateTaxAmount($objOrder);
@@ -2090,10 +2037,9 @@ class HotelBookingDetail extends ObjectModel
$objBookingDetail->id_hotel = $objCartBookingData->id_hotel;
$objBookingDetail->id_customer = $objOrder->id_customer;
$objBookingDetail->booking_type = $objCartBookingData->booking_type;
$objBookingDetail->id_status = 1;
$objBookingDetail->comment = $objCartBookingData->comment;
$objBookingDetail->id_status = 1;
$objBookingDetail->room_type_name = Product::getProductName($idNewRoomType, null, $objOrder->id_lang);
$objBookingDetail->date_from = $objCartBookingData->date_from;
$objBookingDetail->date_to = $objCartBookingData->date_to;
$objBookingDetail->adults = $objCartBookingData->adults;
@@ -2135,7 +2081,8 @@ class HotelBookingDetail extends ObjectModel
$objBookingDetail->check_out_time = $objHotelBranch->check_out;
}
if ($objBookingDetail->save()) {
if ($result &= $objBookingDetail->save()) {
$reallocatedBookingId = $objBookingDetail->id;
// Get Booking Demands of the old booking to add in the new booking creation
$objBookingDemand = new HotelBookingDemands();
if ($oldBookingDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
@@ -2167,10 +2114,12 @@ class HotelBookingDetail extends ObjectModel
}
}
}
} else {
return false;
}
// delete cart feature prices after room addition success
HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
// HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
// ===============================================================
// END: Add Process of the old booking
@@ -2184,58 +2133,94 @@ class HotelBookingDetail extends ObjectModel
$deleteQty = true;
} else {
// Calculate differences of price (Before / After)
$objOldOrderDetail->total_price_tax_incl -= $totalRoomPriceTaxIncl;
$objOldOrderDetail->total_price_tax_excl -= $totalRoomPriceTaxExcl;
$objOldOrderDetail->total_price_tax_incl -= Tools::processPriceRounding(
($objOldOrderDetail->total_price_tax_incl - $totalRoomPriceTaxIncl),
1,
$objOrder->round_type,
$objOrder->round_mode
);
$objOldOrderDetail->total_price_tax_excl -= Tools::processPriceRounding(
($objOldOrderDetail->total_price_tax_excl - $totalRoomPriceTaxExcl),
1,
$objOrder->round_type,
$objOrder->round_mode
);
$old_quantity = $objOldOrderDetail->product_quantity;
$objOldOrderDetail->product_quantity = $old_quantity - $product_quantity;
$objOldOrderDetail->product_quantity = $old_quantity - $productQty;
$objOldOrderDetail->reduction_percent = 0;
// update taxes
$res &= $objOldOrderDetail->updateTaxAmount($objOrder);
$result &= $objOldOrderDetail->updateTaxAmount($objOrder);
// Save order detail
$res &= $objOldOrderDetail->update();
$result &= $objOldOrderDetail->update();
}
// Update OrderInvoice of this OrderDetail
if ($objOldOrderDetail->id_order_invoice != 0) {
// values changes as values are calculated accoding to the quantity of the product by webkul
$objOrderInvoice = new OrderInvoice($objOldOrderDetail->id_order_invoice);
$objOrderInvoice->total_paid_tax_excl -= $totalRoomPriceTaxExcl;
$objOrderInvoice->total_paid_tax_excl = Tools::ps_round(
($objOrderInvoice->total_paid_tax_excl - $totalRoomPriceTaxExcl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrderInvoice->total_paid_tax_excl = $objOrderInvoice->total_paid_tax_excl > 0 ? $objOrderInvoice->total_paid_tax_excl : 0;
$objOrderInvoice->total_paid_tax_incl -= $totalRoomPriceTaxIncl;
$objOrderInvoice->total_paid_tax_incl = Tools::ps_round(
($objOrderInvoice->total_paid_tax_incl - $totalRoomPriceTaxIncl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrderInvoice->total_paid_tax_incl = $objOrderInvoice->total_paid_tax_incl > 0 ? $objOrderInvoice->total_paid_tax_incl : 0;
$objOrderInvoice->total_products -= $totalRoomPriceTaxExcl;
$objOrderInvoice->total_products = Tools::ps_round(
($objOrderInvoice->total_products - $totalRoomPriceTaxExcl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrderInvoice->total_products = $objOrderInvoice->total_products > 0 ? $objOrderInvoice->total_products : 0;
$objOrderInvoice->total_products_wt -= $totalRoomPriceTaxIncl;
$objOrderInvoice->total_products_wt = Tools::ps_round(
($objOrderInvoice->total_products_wt - $totalRoomPriceTaxIncl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrderInvoice->total_products_wt = $objOrderInvoice->total_products_wt > 0 ? $objOrderInvoice->total_products_wt : 0;
$res &= $objOrderInvoice->update();
$result &= $objOrderInvoice->update();
}
// values changes as values are calculated accoding to the quantity of the product by webkul
$objOrder->total_paid -= $totalRoomPriceTaxIncl;
$objOrder->total_paid = Tools::ps_round(
($objOrder->total_paid_tax_incl - $totalRoomPriceTaxIncl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid = $objOrder->total_paid > 0 ? $objOrder->total_paid : 0;
$objOrder->total_paid_tax_incl -= $totalRoomPriceTaxIncl;
$objOrder->total_paid_tax_incl = Tools::ps_round(
($objOrder->total_paid_tax_incl - $totalRoomPriceTaxIncl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid_tax_incl = $objOrder->total_paid_tax_incl > 0 ? $objOrder->total_paid_tax_incl : 0;
$objOrder->total_paid_tax_excl -= $totalRoomPriceTaxExcl;
$objOrder->total_paid_tax_excl = Tools::ps_round(
($objOrder->total_paid_tax_excl - $totalRoomPriceTaxExcl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid_tax_excl = $objOrder->total_paid_tax_excl > 0 ? $objOrder->total_paid_tax_excl : 0;
$objOrder->total_products -= $totalRoomPriceTaxExcl;
$objOrder->total_products = Tools::ps_round(
($objOrder->total_products - $totalRoomPriceTaxExcl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_products = $objOrder->total_products > 0 ? $objOrder->total_products : 0;
$objOrder->total_products_wt -= $totalRoomPriceTaxIncl;
$objOrder->total_products_wt = Tools::ps_round(
($objOrder->total_products_wt - $totalRoomPriceTaxIncl),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_products_wt = $objOrder->total_products_wt > 0 ? $objOrder->total_products_wt : 0;
$objOrder->update();
$result &= $objOrder->update();
// Reinject quantity in stock
$objOldOrderDetail->reinjectQuantity($objOldOrderDetail, $objOldOrderDetail->product_quantity, $deleteQty);
@@ -2276,16 +2261,22 @@ class HotelBookingDetail extends ObjectModel
$objOldHotelBooking->is_back_order = 0;
$result &= $objOldHotelBooking->save();
$reallocatedBookingId = $objOldHotelBooking->id;
}
if ($result) {
if ($result && $reallocatedBookingId) {
Hook::exec(
'actionRoomReallocateAfter',
array(
'id_htl_booking' => $idHotelBooking,
'id_room' => $idRoom
'id_htl_booking_from' => $idHotelBooking,
'id_htl_booking_to' => $reallocatedBookingId,
)
);
return $reallocatedBookingId;
} else {
$result = false;
}
} else {
$result = false;
@@ -2519,7 +2510,7 @@ class HotelBookingDetail extends ObjectModel
$newDateFrom,
$newDateTo,
$occupancy,
$newTotalPrice = null,
$newTotalPrice,
$idHotelBookingDetail
) {
$objHotelBookingDetail = new self((int) $idHotelBookingDetail);
@@ -2535,19 +2526,7 @@ class HotelBookingDetail extends ObjectModel
$objHotelCartBookingData = new HotelCartBookingData($idHotelCartBookingData);
if (Validate::isLoadedObject($objHotelCartBookingData)) {
// calculate new prices
$newTotalPriceTE = '';
$newTotalPriceTI = '';
$newNumDays = $this->getNumberOfDays($newDateFrom, $newDateTo);
if ($newTotalPrice) {
$newTotalPriceTE = $newTotalPrice['tax_excl'];
$newTotalPriceTI = $newTotalPrice['tax_incl'];
} else {
$oldNumDays = $this->getNumberOfDays($oldDateFrom, $oldDateTo);
$unitRoomPriceTE = $objHotelBookingDetail->total_price_tax_excl / $oldNumDays;
$unitRoomPriceTI = $objHotelBookingDetail->total_price_tax_incl / $oldNumDays;
$newTotalPriceTE = $unitRoomPriceTE * $newNumDays;
$newTotalPriceTI = $unitRoomPriceTI * $newNumDays;
}
// update $objHotelCartBookingData
$objHotelCartBookingData->date_from = $newDateFrom;
@@ -2560,8 +2539,8 @@ class HotelBookingDetail extends ObjectModel
// update $objHotelBookingDetail
$objHotelBookingDetail->date_from = $newDateFrom;
$objHotelBookingDetail->date_to = $newDateTo;
$objHotelBookingDetail->total_price_tax_excl = Tools::ps_round($newTotalPriceTE, 6);
$objHotelBookingDetail->total_price_tax_incl = Tools::ps_round($newTotalPriceTI, 6);
$objHotelBookingDetail->total_price_tax_excl = $newTotalPrice['tax_excl'];
$objHotelBookingDetail->total_price_tax_incl = $newTotalPrice['tax_incl'];
$objHotelBookingDetail->adults = $occupancy['adults'];
$objHotelBookingDetail->children = $occupancy['children'];
$objHotelBookingDetail->child_ages = json_encode($occupancy['child_ages']);
@@ -3324,10 +3303,10 @@ class HotelBookingDetail extends ObjectModel
$objHotelBookingDemands = new HotelBookingDemands();
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
$reduction_amount['total_price_tax_excl'] = Tools::ps_round((float) $this->total_price_tax_excl, 6);
$reduction_amount['total_products_tax_excl'] = Tools::ps_round((float) $this->total_price_tax_excl, 6);
$reduction_amount['total_price_tax_incl'] = Tools::ps_round((float) $this->total_price_tax_incl, 6);
$reduction_amount['total_products_tax_incl'] = Tools::ps_round((float) $this->total_price_tax_incl, 6);
$reduction_amount['total_price_tax_excl'] = (float) $this->total_price_tax_excl;
$reduction_amount['total_products_tax_excl'] = (float) $this->total_price_tax_excl;
$reduction_amount['total_price_tax_incl'] = (float) $this->total_price_tax_incl;
$reduction_amount['total_products_tax_incl'] = (float) $this->total_price_tax_incl;
// reduce facilities amount from order and services_detail
if ($roomDemands = $objHotelBookingDemands->getRoomTypeBookingExtraDemands(
@@ -3343,8 +3322,8 @@ class HotelBookingDetail extends ObjectModel
)) {
foreach ($roomDemands as $roomDemand) {
$objHotelBookingDemands = new HotelBookingDemands($roomDemand['id_booking_demand']);
$reduction_amount['total_price_tax_excl'] += Tools::ps_round((float) $objHotelBookingDemands->total_price_tax_excl, 6);
$reduction_amount['total_price_tax_incl'] += Tools::ps_round((float) $objHotelBookingDemands->total_price_tax_incl, 6);
$reduction_amount['total_price_tax_excl'] += (float) $objHotelBookingDemands->total_price_tax_excl;
$reduction_amount['total_price_tax_incl'] += (float) $objHotelBookingDemands->total_price_tax_incl;
$objHotelBookingDemands->total_price_tax_excl = 0;
$objHotelBookingDemands->total_price_tax_incl = 0;
$objHotelBookingDemands->save();
@@ -3359,10 +3338,10 @@ class HotelBookingDetail extends ObjectModel
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(
$roomService['id_room_type_service_product_order_detail']
);
$reduction_amount['total_price_tax_excl'] += Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_excl, 6);
$reduction_amount['total_products_tax_excl'] += Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_excl, 6);
$reduction_amount['total_price_tax_incl'] += Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_incl, 6);
$reduction_amount['total_products_tax_incl'] += Tools::ps_round((float) $objRoomTypeServiceProductOrderDetail->total_price_tax_incl, 6);
$reduction_amount['total_price_tax_excl'] += (float) $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
$reduction_amount['total_products_tax_excl'] += (float) $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
$reduction_amount['total_price_tax_incl'] += (float) $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
$reduction_amount['total_products_tax_incl'] += (float) $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($objRoomTypeServiceProductOrderDetail->id_order_detail))) {
$objOrderDetail->product_quantity_refunded += $objRoomTypeServiceProductOrderDetail->quantity;
@@ -3370,13 +3349,17 @@ class HotelBookingDetail extends ObjectModel
$objOrderDetail->product_quantity_refunded = $objOrderDetail->product_quantity;
}
$objOrderDetail->total_price_tax_excl = Tools::ps_round(
($objOrderDetail->total_price_tax_excl - $objRoomTypeServiceProductOrderDetail->total_price_tax_excl),
6
$objOrderDetail->total_price_tax_excl -= Tools::processPriceRounding(
$objOrderDetail->total_price_tax_excl,
1,
$objOrder->round_type,
$objOrder->round_mode
);
$objOrderDetail->total_price_tax_incl = Tools::ps_round(
($objOrderDetail->total_price_tax_incl - $objRoomTypeServiceProductOrderDetail->total_price_tax_incl),
6
$objOrderDetail->total_price_tax_incl -= Tools::processPriceRounding(
$objOrderDetail->total_price_tax_incl,
1,
$objOrder->round_type,
$objOrder->round_mode
);
$objOrderDetail->save();
@@ -3404,42 +3387,44 @@ class HotelBookingDetail extends ObjectModel
if (!$hasOrderDiscountOrPayment) {
// reduce room amount from order and order detail
$objOrderDetail->total_price_tax_incl = Tools::ps_round(
($objOrderDetail->total_price_tax_incl - $this->total_price_tax_incl),
6
$objOrderDetail->total_price_tax_incl -= Tools::processPriceRounding(
$this->total_price_tax_incl,
1,
$objOrder->round_type,
$objOrder->round_mode
);
$objOrderDetail->total_price_tax_excl = Tools::ps_round(
($objOrderDetail->total_price_tax_excl - $this->total_price_tax_excl),
6
$objOrderDetail->total_price_tax_excl -= Tools::processPriceRounding(
$this->total_price_tax_excl,
1,
$objOrder->round_type,
$objOrder->round_mode
);
if (Validate::isLoadedObject($objOrder = new Order($this->id_order))) {
$objOrder->total_paid = Tools::ps_round(
($objOrder->total_paid - $reduction_amount['total_price_tax_incl']),
6
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid = $objOrder->total_paid > 0 ? $objOrder->total_paid : 0;
$objOrder->total_paid_tax_excl = Tools::ps_round(
($objOrder->total_paid_tax_excl - $reduction_amount['total_price_tax_excl']),
6
$objOrder->total_paid_tax_excl = Tools::ps_round(($objOrder->total_paid_tax_excl - $reduction_amount['total_price_tax_excl']),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid_tax_excl = $objOrder->total_paid_tax_excl > 0 ? $objOrder->total_paid_tax_excl : 0;
$objOrder->total_paid_tax_incl = Tools::ps_round(
($objOrder->total_paid_tax_incl - $reduction_amount['total_price_tax_incl']),
6
$objOrder->total_paid_tax_incl = Tools::ps_round(($objOrder->total_paid_tax_incl - $reduction_amount['total_price_tax_incl']),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_paid_tax_incl = $objOrder->total_paid_tax_incl > 0 ? $objOrder->total_paid_tax_incl : 0;
$objOrder->total_products = Tools::ps_round(
($objOrder->total_products - $reduction_amount['total_products_tax_excl']),
6
$objOrder->total_products = Tools::ps_round(($objOrder->total_products - $reduction_amount['total_products_tax_excl']),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_products = $objOrder->total_products > 0 ? $objOrder->total_products : 0;
$objOrder->total_products_wt = Tools::ps_round(
($objOrder->total_products_wt - $reduction_amount['total_products_tax_incl']),
6
$objOrder->total_products_wt = Tools::ps_round(($objOrder->total_products_wt - $reduction_amount['total_products_tax_incl']),
_PS_PRICE_COMPUTE_PRECISION_
);
$objOrder->total_products_wt = $objOrder->total_products_wt > 0 ? $objOrder->total_products_wt : 0;

View File

@@ -1170,13 +1170,16 @@ class HotelCartBookingData extends ObjectModel
2,
null
);
$cart_detail_data[$key]['selected_services'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
$value['id'],
$cart_detail_data[$key]['selected_services'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$value['id_cart'],
0,
null,
null
0,
0,
0,
0,
$value['id']
);
$cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$id_cart,
0,
0,
@@ -1184,9 +1187,10 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
1,
false
);
$cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$id_cart,
0,
0,
@@ -1194,10 +1198,11 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
1,
false,
1
);
$cart_detail_data[$key]['additional_services_auto_add_with_room_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$cart_detail_data[$key]['additional_services_auto_add_with_room_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$id_cart,
0,
0,
@@ -1205,12 +1210,13 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
1,
false,
1,
null,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
);
$cart_detail_data[$key]['additional_services_auto_add_independent_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$cart_detail_data[$key]['additional_services_auto_add_independent_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$id_cart,
0,
0,
@@ -1218,6 +1224,7 @@ class HotelCartBookingData extends ObjectModel
$value['date_from'],
$value['date_to'],
$value['id'],
1,
false,
1,
null,
@@ -1534,14 +1541,15 @@ class HotelCartBookingData extends ObjectModel
$data_v['date_to'],
1
);
$serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart(
$serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
$context->cart->id,
0,
$data_v['id_hotel'],
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id']
$data_v['id'],
1
);
$totalAdditionalServicePrice = $demandPrice + $serviceProductPrice;
@@ -1698,6 +1706,7 @@ class HotelCartBookingData extends ObjectModel
}
}
}
return $cartHotelData;
}

View File

@@ -281,12 +281,18 @@ class HotelRoomType extends ObjectModel
/**
* @param [int] $roomTypesList: string of idRoomTypes seperated by ","
*/
public function getRoomTypeDetailByRoomTypeIds($roomTypesList, $position = true)
public function getRoomTypeDetailByRoomTypeIds($roomTypesList, $position = true, $fullDetail = false, $idLang = false)
{
$sql = 'SELECT COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests`'.
($position ? ', cp.`position`' : '').'
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
$sql = 'SELECT pl.`name`, COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests`
'.($position ? ', cp.`position`' : '').'
'.($fullDetail ? ', pl.`link_rewrite`, pl.`description_short`' : '').'
FROM `'._DB_PREFIX_.'htl_room_type` AS `hrt`
INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS `hri` ON (hri.`id_product` = hrt.`id_product`)';
$sql .= ' INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (hrt.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.')';
if ($position) {
$sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (hbi.`id` = hrt.`id_hotel`)

View File

@@ -95,9 +95,12 @@ class HotelRoomTypeDemandPrice extends ObjectModel
}
}
}
$totalDemandsPrice += $price;
// Rounding as per configurations
$totalDemandsPrice += Tools::processPriceRounding($price);
}
}
return $totalDemandsPrice;
}

View File

@@ -729,7 +729,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$use_reduc
)) {
foreach($servicesWithTax as $service) {
$totalPrice['total_price_tax_incl'] += $service['price'];
$totalPrice['total_price_tax_incl'] += Tools::processPriceRounding($service['price']);
}
}
if ($servicesWithoutTax = RoomTypeServiceProduct::getAutoAddServices(
@@ -743,14 +743,17 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$use_reduc
)) {
foreach($servicesWithoutTax as $service) {
$totalPrice['total_price_tax_excl'] += $service['price'];
$totalPrice['total_price_tax_excl'] += Tools::processPriceRounding($service['price']);
}
}
}
if ($quantity) {
$totalPrice['total_price_tax_incl'] = $totalPrice['total_price_tax_incl'] * $quantity;
$totalPrice['total_price_tax_excl'] = $totalPrice['total_price_tax_excl'] * $quantity;
if (!$quantity) {
$quantity = 1;
}
$totalPrice['total_price_tax_incl'] = Tools::processPriceRounding($totalPrice['total_price_tax_incl'], $quantity);
$totalPrice['total_price_tax_excl'] = Tools::processPriceRounding($totalPrice['total_price_tax_excl'], $quantity);
return $totalPrice;
}

View File

@@ -163,6 +163,7 @@ class RoomTypeServiceProduct extends ObjectModel
$use_reduc
);
}
return $services;
}
}

View File

@@ -132,6 +132,9 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
return true;
}
/**
* @deprecated since 1.6.1 use getServiceProductsInCart() instead
*/
public function getServiceProductsTotalInCart(
$idCart,
$idProduct = 0,
@@ -145,61 +148,25 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$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`, cbd.`date_from`, cbd.`date_to`
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->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
$useTax,
false,
$id_address
);
}
}
return $totalPrice;
return $this->getServiceProductsInCart(
$idCart,
$idProduct,
$idHotel,
$roomTypeIdProduct,
$dateFrom,
$dateTo,
$htlCartBookingId,
1,
$useTax,
$autoAddToCart,
$id_address,
$priceAdditionType
);
}
/**
* @deprecated since 1.6.1 use getServiceProductsInCart() instead
*/
public function getRoomServiceProducts(
$htlCartBookingId,
$idLang = 0,
@@ -208,129 +175,28 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$id_address = null,
$priceAdditionType = null
) {
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId))) {
$selectedServiceProducts = $this->getServiceProductsInCart(
$objHotelCartBookingData->id_cart,
0,
0,
0,
0,
0,
$htlCartBookingId,
0,
$useTax,
$autoAddToCart,
$id_address,
$priceAdditionType
);
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`, cbd.`date_from`, cbd.`date_to`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
INNER 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 (isset($selectedServiceProducts[$htlCartBookingId]['selected_products_info'])) {
return $selectedServiceProducts;
}
}
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->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
true,
false,
$id_address
);
} else {
$selectedServiceProducts[$product['id_product']] = $product;
$selectedServiceProducts[$product['id_product']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
null,
null,
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
null,
null,
true,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
false,
false,
$id_address
);
$selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
$product['date_from'],
$product['date_to'],
true,
false,
$id_address
);
}
}
}
return $selectedServiceProducts;
return array();
}
public function getServiceProductsInCart(
@@ -404,12 +270,12 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
foreach ($serviceProducts as $product) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
if ($getTotalPrice) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
$totalPrice += $objRoomTypeServiceProductPrice->getServicePrice(
$servicePrice = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
$useTax,
@@ -417,8 +283,8 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$id_address
);
$totalPrice += Tools::processPriceRounding($servicePrice, $qty);
} else {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
if (isset($selectedServiceProducts[$product['htl_cart_booking_id']])) {
if ($idProduct) {
$selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] += $product['quantity'];
@@ -452,36 +318,43 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
),
);
}
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += $objRoomTypeServiceProductPrice->getServicePrice(
$servicePrice = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getServicePrice(
$servicePriceTE = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
false,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getServicePrice(
$servicePriceTI = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
true,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += Tools::processPriceRounding($servicePrice, $qty);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] += Tools::processPriceRounding($servicePriceTE, $qty);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] += Tools::processPriceRounding($servicePriceTI, $qty);
} else {
$selectedServiceProducts[$product['htl_cart_booking_id']]['htl_cart_booking_id'] = $product['htl_cart_booking_id'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['id_cart'] = $product['id_cart'];
@@ -553,40 +426,45 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
);
}
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = $objRoomTypeServiceProductPrice->getServicePrice(
$servicePrice = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
$useTax,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
$servicePriceTE = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
false,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
$servicePriceTI = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
1,
$product['date_from'],
$product['date_to'],
true,
false,
$id_address
);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = Tools::processPriceRounding($servicePrice, $qty);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] = Tools::processPriceRounding($servicePriceTE, $qty);
$selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] = Tools::processPriceRounding($servicePriceTI, $qty);
}
}
}
}
if ($getTotalPrice) {
@@ -641,4 +519,4 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
}
}
}
}
}

View File

@@ -101,7 +101,7 @@ class RoomTypeServiceProductPrice extends ObjectModel
);
}
public function getServicePrice($idProduct, $idProductRoomType, $quantity, $dateFrom = null, $dateTo = null, $useTax = null, $id_cart = false, $id_address = null, $use_reduc= 1)
public function getServicePrice($idProduct, $idProductRoomType, $quantity = 1, $dateFrom = null, $dateTo = null, $useTax = null, $id_cart = false, $id_address = null, $use_reduc= 1)
{
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;

View File

@@ -226,50 +226,209 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser
}
// now call the function
$objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$objBookingDtl = new HotelBookingDetail();
$searchAriData = [];
// If api is called for getting ari info for all the dates in the provided date range
if (isset($ariParams['date_wise_breakdown']) && $ariParams['date_wise_breakdown'] && $bookingParams['search_available']) {
if (isset($ariParams['date_wise_breakdown']) && $ariParams['date_wise_breakdown']) {
$dateWiseBreakdown = 1;
$datesAriInfo = [];
/**
* To generate data for each day, we will need to get data for booked and unavailable dates, s
* so saving the booking_params for generating the response later
*/
$getavail = $bookingParams['search_available'];
$getBooked = $bookingParams['search_booked'];
$getUnavai = $bookingParams['search_unavai'];
$bookingParams['search_available'] = 1;
$bookingParams['search_booked'] = 1;
$bookingParams['search_unavai'] = 1;
$bookingData = $objBookingDtl->getBookingData($bookingParams);
$dateFrom = $bookingParams['date_from'];
$dateTo = $bookingParams['date_to'];
// saving date wise booked and unavailable rooms to manage available rooms calculation .
$bookedDates = array();
$unavailableDates = array();
if (isset($bookingData['rm_data']) && $bookingData['rm_data']) {
foreach ($bookingData['rm_data'] as $key => $roomType) {
if ($rooms = HotelRoomInformation::getHotelRoomsInfo($ariParams['id_hotel'], $roomType['id_product'])) {
foreach ($rooms as $room) {
$bookingData['rm_data'][$key]['all_rooms'][$room['id']] = array('id_room' => $room['id'], 'room_num' => $room['room_num']);
}
if (count($roomType['data']['booked'])) {
foreach ($roomType['data']['booked'] as $bookedRoom) {
foreach ($bookedRoom['detail'] as $bookDetail) {
for ($currentDate = date('Y-m-d', strtotime($bookDetail['date_from']));
$currentDate < date('Y-m-d', strtotime($bookDetail['date_to']));
$currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))
) {
$bookedDates[$currentDate][$roomType['id_product']][$bookedRoom['id_room']] = $bookedRoom['id_room'];
}
}
}
}
if (count($roomType['data']['unavailable'])) {
foreach ($roomType['data']['unavailable'] as $unavailableRooms) {
foreach ($unavailableRooms['detail'] as $unavailableDetail) {
for ($currentDate = date('Y-m-d', strtotime($unavailableDetail['date_from']));
$currentDate < date('Y-m-d', strtotime($unavailableDetail['date_to']));
$currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))
) {
$unavailableDates[$currentDate][$roomType['id_product']][$bookedRoom['id_room']] = $bookedRoom['id_room'];
}
}
}
}
}
}
}
// Lets get data date by date (Every date in the date range)
$dateBookingParams = $bookingParams;
// for a single date there is no use of partial available rooms
$dateBookingParams['search_partial'] = 0;
for ($currentDate = $dateFrom; $currentDate < $dateTo; $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) {
$dateBookingParams['date_from'] = $currentDate;
$dateBookingParams['date_to'] = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
// get inventories for every date
$ariInfo = $objBookingDtl->getBookingData($dateBookingParams);
// creating ari details for every date
for ($currentDate = $bookingParams['date_from']; $currentDate < $bookingParams['date_to']; $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) {
$nextDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
// append request fields also. will be attached in the response xml
$ariInfo['id_hotel'] = $ariParams['id_hotel'];
$ariInfo['date_from'] = $dateBookingParams['date_from'];
$ariInfo['date_to'] = $dateBookingParams['date_to'];
$ariInfo['num_rooms'] = $totalRooms;
$ariDateInfo['id_hotel'] = $ariParams['id_hotel'];
$ariDateInfo['date_from'] = $currentDate;
$ariDateInfo['date_to'] = $nextDate;
$ariDateInfo['currency'] = $objCurrency->iso_code;
if (isset($bookingData['rm_data']) && $bookingData['rm_data']) {
$ariDateInfo['total_rooms'] = 0;
$ariDateInfo['room_types'] = array();
if ($getavail) {
$ariDateInfo['total_available_rooms'] = 0;
}
if ($getUnavai) {
$ariDateInfo['total_unavailable_rooms'] = 0;
}
if ($getBooked) {
$ariDateInfo['total_booked_rooms'] = 0;
}
foreach ($bookingData['rm_data'] as $roomType)
{
if (count($roomType['all_rooms'])) {
$ariDateInfo['total_rooms'] += count($roomType['all_rooms']);
$roomDetail = array();
$searchAriData[] = $ariInfo;
$roomDetail['available'] = $roomType['all_rooms'];
if (isset($bookedDates[$currentDate][$roomType['id_product']])) {
$roomDetail['available'] = array_diff_key($roomDetail['available'], $bookedDates[$currentDate][$roomType['id_product']]);
$roomDetail['booked'] = array_intersect_key($roomType['all_rooms'], $bookedDates[$currentDate][$roomType['id_product']]);
} else {
$roomDetail['booked'] = array();
}
if (isset($unavailableDates[$currentDate][$roomType['id_product']])) {
$roomDetail['available'] = array_diff_key($roomDetail['available'], $unavailableDates[$currentDate][$roomType['id_product']]);
$roomDetail['unavailable'] = array_intersect_key($roomType['all_rooms'], $unavailableDates[$currentDate][$roomType['id_product']]);
} else {
$roomDetail['unavailable'] = array();
}
if ($getavail) {
$ariDateInfo['total_available_rooms'] += count($roomDetail['available']);
} else {
unset($roomDetail['available']);
}
if ($getUnavai) {
$ariDateInfo['total_unavailable_rooms'] += count($roomDetail['available']);
} else {
unset($roomDetail['unavailable']);
}
if ($getBooked) {
$ariDateInfo['total_booked_rooms'] += count($roomDetail['available']);
} else {
unset($roomDetail['booked']);
}
}
$roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomType['id_product'],
$currentDate,
date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))),
0
);
$roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomType['id_product'],
$currentDate,
date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))),
1
);
$totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$roomType['id_product'],
$currentDate,
date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))),
$totalRooms
);
$ariDateInfo['room_types'][] = array(
'id_room_type' => $roomType['id_product'],
'base_price' => $roomTypePriceTE,
'base_price_with_tax' => $roomTypePriceTI,
'total_price' => $totalBookingPrice['total_price_tax_excl'],
'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'],
'name' => $roomType['name'],
'rooms' => $roomDetail
);
}
}
$searchAriData[] = $ariDateInfo;
}
} else { // If api is called for getting ari info for a particular date range
$dateWiseBreakdown = 0;
// If api is called for getting ari info for a particular date range
$ariInfo = $objBookingDtl->getBookingData($bookingParams);
$bookingData = $objBookingDtl->getBookingData($bookingParams);
// append request fields also. will be attached in the response xml
$ariInfo = array();
$ariInfo['id_hotel'] = $ariParams['id_hotel'];
$ariInfo['date_from'] = $bookingParams['date_from'];
$ariInfo['date_to'] = $bookingParams['date_to'];
$ariInfo['num_rooms'] = $totalRooms;
$ariInfo['currency'] = $objCurrency->iso_code;
if (isset($bookingData['rm_data']) && $bookingData['rm_data']) {
if (isset($bookingData['stats']['total_rooms'])) {
$ariInfo['total_rooms'] = $bookingData['stats']['total_rooms'];
}
if (isset($bookingData['stats']['num_avail'])) {
$ariInfo['total_available_rooms'] = $bookingData['stats']['num_avail'];
}
if (isset($bookingData['stats']['num_unavail'])) {
$ariInfo['total_unavailable_rooms'] = $bookingData['stats']['num_unavail'];
}
if (isset($bookingData['stats']['num_part_avai'])) {
$ariInfo['total_partial_available_rooms'] = $bookingData['stats']['num_part_avai'];
}
if (isset($bookingData['stats']['num_booked'])) {
$ariInfo['total_booked_rooms'] = $bookingData['stats']['num_booked'];
}
$ariInfo['room_types'] = array();
foreach ($bookingData['rm_data'] as $roomType) {
$roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomType['id_product'],
$bookingParams['date_from'],
$bookingParams['date_to'],
0
);
$roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomType['id_product'],
$bookingParams['date_from'],
$bookingParams['date_to'],
1
);
$totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$roomType['id_product'],
$bookingParams['date_from'],
$bookingParams['date_to'],
$totalRooms
);
$ariInfo['room_types'][] = array(
'id_room_type' => $roomType['id_product'],
'base_price' => $roomTypePriceTE,
'base_price_with_tax' => $roomTypePriceTI,
'total_price' => $totalBookingPrice['total_price_tax_excl'],
'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'],
'name' => $roomType['name'],
'rooms' => $roomType['data']
);
}
}
$searchAriData[] = $ariInfo;
}
@@ -450,92 +609,67 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser
$field = array('sqlId' => 'date_to', 'value' => $ariInfo['date_to']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
$objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$field = array('sqlId' => 'currency', 'value' => $objCurrency->iso_code);
$field = array('sqlId' => 'currency', 'value' => $ariInfo['currency']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
// check if availability stats are available then only process further
if (isset($ariInfo['stats']) && $ariInfo['stats']) {
$field = array('sqlId' => 'total_rooms', 'value' => $ariInfo['stats']['total_rooms']);
if (isset($ariInfo['total_rooms'])) {
$field = array('sqlId' => 'total_rooms', 'value' => $ariInfo['total_rooms']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['stats']['num_avail'])) {
$field = array('sqlId' => 'total_available_rooms', 'value' => $ariInfo['stats']['num_avail']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['total_available_rooms'])) {
$field = array('sqlId' => 'total_available_rooms', 'value' => $ariInfo['total_available_rooms']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['stats']['num_unavail'])) {
$field = array('sqlId' => 'total_unavailable_rooms', 'value' => $ariInfo['stats']['num_unavail']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['total_unavailable_rooms'])) {
$field = array('sqlId' => 'total_unavailable_rooms', 'value' => $ariInfo['total_unavailable_rooms']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['stats']['num_part_avai'])) {
$field = array('sqlId' => 'total_partial_available_rooms', 'value' => $ariInfo['stats']['num_part_avai']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['total_partial_available_rooms'])) {
$field = array('sqlId' => 'total_partial_available_rooms', 'value' => $ariInfo['total_partial_available_rooms']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['stats']['num_booked'])) {
$field = array('sqlId' => 'total_booked_rooms', 'value' => $ariInfo['stats']['num_booked']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
if (isset($ariInfo['total_booked_rooms'])) {
$field = array('sqlId' => 'total_booked_rooms', 'value' => $ariInfo['total_booked_rooms']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
}
// check if room type data is available then only process further
if (isset($ariInfo['rm_data']) && $ariInfo['rm_data']) {
if (isset($ariInfo['room_types']) && $ariInfo['room_types']) {
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_types', array());
foreach ($ariInfo['rm_data'] as $roomTypeInfo) {
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_type', array(), array('id' => $roomTypeInfo['id_product'], 'xlink_resource' => $this->wsObject->wsUrl.'room_types'.'/'.$roomTypeInfo['id_product']));
foreach ($ariInfo['room_types'] as $roomTypeInfo) {
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_type', array(), array(
'id' => $roomTypeInfo['id_room_type'],
'xlink_resource' => $this->wsObject->wsUrl.'room_types'.'/'.$roomTypeInfo['id_room_type']
));
$field = array('sqlId' => 'id_room_type', 'value' => $roomTypeInfo['id_product'], 'xlink_resource' => 'room_types');
$field = array('sqlId' => 'id_room_type', 'value' => $roomTypeInfo['id_room_type'], 'xlink_resource' => 'room_types');
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
// get feature price of room type
$roomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
0
);
$field = array('sqlId' => 'base_price', 'value' => $roomTypePrice);
$field = array('sqlId' => 'base_price', 'value' => $roomTypeInfo['base_price']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
// get feature price of room type
$roomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
1
);
$field = array('sqlId' => 'base_price_with_tax', 'value' => $roomTypePrice);
$field = array('sqlId' => 'base_price_with_tax', 'value' => $roomTypeInfo['base_price_with_tax']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
$totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
$ariInfo['num_rooms']
);
$field = array('sqlId' => 'total_price', 'value' => $totalBookingPrice['total_price_tax_excl']);
$field = array('sqlId' => 'total_price', 'value' => $roomTypeInfo['total_price']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
$totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
$ariInfo['num_rooms']
);
$field = array('sqlId' => 'total_price_with_tax', 'value' => $totalBookingPrice['total_price_tax_incl']);
$field = array('sqlId' => 'total_price_with_tax', 'value' => $roomTypeInfo['total_price_with_tax']);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
$objRoomType = new Product($roomTypeInfo['id_product']);
$objRoomType = new Product($roomTypeInfo['id_room_type']);
$field = array('sqlId' => 'name', 'value' => $objRoomType->name, 'i18n' => true);
$this->output .= $this->objOutput->getObjectRender()->renderField($field);
// rooms info of the room type
if (isset($roomTypeInfo['data']) && $roomTypeInfo['data']) {
if (isset($roomTypeInfo['rooms']) && $roomTypeInfo['rooms']) {
$this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('rooms', array());
foreach ($roomTypeInfo['data'] as $key => $roomsInfo) {
foreach ($roomTypeInfo['rooms'] as $key => $roomsInfo) {
if ($key == 'available') {
$nodeRoomAvailability = 'available';
} elseif ($key == 'unavailable') {
@@ -614,141 +748,12 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser
// create json for the response of the ari request
private function getResponseJson($ariInfoArray, $dateWiseBreakdown = 0)
{
$ariFormatted = array();
if ($ariInfoArray) {
foreach ($ariInfoArray as $ariInfo) {
$dateAriInfo = array();
$dateAriInfo = array();
$dateAriInfo['id_hotel'] = $ariInfo['id_hotel'];
$dateAriInfo['date_from'] = $ariInfo['date_from'];
$dateAriInfo['date_to'] = $ariInfo['date_to'];
$objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$dateAriInfo['currency'] = $objCurrency->iso_code;
// check if availability stats are available then only process further
if (isset($ariInfo['stats']) && $ariInfo['stats']) {
$dateAriInfo['total_rooms'] = $ariInfo['stats']['total_rooms'];
if (isset($ariInfo['stats']['num_avail'])) {
$dateAriInfo['total_available_rooms'] = $ariInfo['stats']['num_avail'];
}
if (isset($ariInfo['stats']['num_unavail'])) {
$dateAriInfo['total_unavailable_rooms'] = $ariInfo['stats']['num_unavail'];
}
if (isset($ariInfo['stats']['num_part_avai'])) {
$dateAriInfo['total_partial_available_rooms'] = $ariInfo['stats']['num_part_avai'];
}
if (isset($ariInfo['stats']['num_booked'])) {
$dateAriInfo['total_booked_rooms'] = $ariInfo['stats']['num_booked'];
}
}
// check if room type data is available then only process further
if (isset($ariInfo['rm_data']) && $ariInfo['rm_data']) {
$dateAriInfo['room_types'] = array();
foreach ($ariInfo['rm_data'] as $roomTypeIndex => $roomTypeInfo) {
// get feature price of room type
$roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
0
);
$roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
1
);
$totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$roomTypeInfo['id_product'],
$ariInfo['date_from'],
$ariInfo['date_to'],
$ariInfo['num_rooms']
);
$dateAriInfo['room_types'][$roomTypeIndex] = array(
'id_room_type' => $roomTypeInfo['id_product'],
'base_price' => $roomTypePriceTE,
'base_price_with_tax' => $roomTypePriceTI,
'total_price' => $totalBookingPrice['total_price_tax_excl'],
'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl']
);
$objRoomType = new Product($roomTypeInfo['id_product']);
$dateAriInfo['room_types'][$roomTypeIndex]['name'] = array();
foreach ($this->objOutput->getObjectRender()->languages as $idLang) {
$dateAriInfo['room_types'][$roomTypeIndex]['name'][] = array(
'id' => $idLang,
'value' => $objRoomType->name[$idLang]
);
}
// if only one lang than do not set name as array and set only value of the room
if (count($dateAriInfo['room_types'][$roomTypeIndex]['name']) == 1) {
$dateAriInfo['room_types'][$roomTypeIndex]['name'] = $dateAriInfo['room_types'][$roomTypeIndex]['name'][0]['value'];
}
// rooms info of the room type
if (isset($roomTypeInfo['data']) && $roomTypeInfo['data']) {
$dateAriInfo['room_types'][$roomTypeIndex]['rooms'] = array();
foreach ($roomTypeInfo['data'] as $key => $roomsInfo) {
$roomsAriInfo = array();
if ($key == 'available') {
$keyRoomAvailability = 'available';
} elseif ($key == 'unavailable') {
$keyRoomAvailability = 'unavailable';
} elseif ($key == 'booked') {
$keyRoomAvailability = 'booked';
} elseif ($key == 'partially_available') {
$keyRoomAvailability = 'partially_available';
}
if ($roomsInfo) {
if ($key == 'partially_available') {
foreach ($roomsInfo as $dateIndex => $partialRoomsInfo) {
if (isset($partialRoomsInfo['rooms']) && $partialRoomsInfo['rooms']) {
$roomsAriInfo[$dateIndex]['date_from'] = $partialRoomsInfo['date_from'];
$roomsAriInfo[$dateIndex]['date_to'] = $partialRoomsInfo['date_to'];
$roomsAriInfo[$dateIndex]['rooms'] = array();
foreach ($partialRoomsInfo['rooms'] as $roomInfo) {
$roomDetail = array();
$roomDetail['id_room'] = $roomInfo['id_room'];
$roomDetail['room_number'] = $roomInfo['room_num'];
$roomsAriInfo[$dateIndex]['rooms'][] = $roomDetail;
}
}
}
} else {
foreach ($roomsInfo as $roomIndex => $roomInfo) {
$roomsAriInfo[$roomIndex]['id_room'] = $roomInfo['id_room'];
$roomsAriInfo[$roomIndex]['room_number'] = $roomInfo['room_num'];
}
}
}
$dateAriInfo['room_types'][$roomTypeIndex]['rooms'][$keyRoomAvailability] = array_values($roomsAriInfo);
}
}
$dateAriInfo['room_types'] = array_values($dateAriInfo['room_types']);
}
}
$ariFormatted[] = $dateAriInfo;
}
}
// change the content to the json form for api response
$ariReponse = [];
if ($dateWiseBreakdown) {
// if date wise breakup is requested the parent node will be 'hotel_aris' as per other APIs in QloApps (orders > order)
$ariReponse['hotel_aris'] = array_values($ariFormatted);
$ariReponse['hotel_aris'] = array_values($ariInfoArray);
} else {
$ariReponse['hotel_ari'] = $ariFormatted[0];
$ariReponse['hotel_ari'] = $ariInfoArray[0];
}
$this->output .= json_encode($ariReponse);

View File

@@ -149,11 +149,6 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$occupancy = array();
}
// $booking_product = 1;
// if (Tools::getisset('booking_product')) {
// $booking_product = Tools::getValue('booking_product');
// }
$this->id_cart = (int) $this->context->cart->id;
$this->id_guest = (int) $this->context->cookie->id_guest;
$this->id_hotel = $id_hotel;
@@ -177,7 +172,6 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking').'&'.http_build_query($urlData));
}
// Process reallocation of rooms
// Process reallocation of rooms
if (Tools::isSubmit('realloc_allocated_rooms')) {
if ($this->tabAccess['edit'] === '1') {
@@ -204,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 {
@@ -379,7 +373,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
'link' => $this->context->link
'link' => $this->context->link,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
));
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {

View File

@@ -224,7 +224,7 @@
</td>
<td>
{if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}
<button type="button" class="btn btn-primary room_reallocate_swap" id="reallocate_room_{$rm_dtl_v['id_htl_booking']}" data-room_type_name="{$rm_dtl_v['room_type_name']}" data-id_htl_booking="{$rm_dtl_v['id_htl_booking']}" data-id_order="{$rm_dtl_v['id_order']}" data-room_num='{$booked_v['room_num']}' data-currency_sign='{$rm_dtl_v['currency_sign']}' data-id_room_type='{$booked_v['id_product']}' data-cust_name='{$rm_dtl_v['alloted_cust_name']}' data-cust_email='{$rm_dtl_v['alloted_cust_email']}' data-avail_rm_swap='{$rm_dtl_v['avail_rooms_to_swap']|@json_encode}' data-avail_realloc_room_types='{$rm_dtl_v['avail_room_types_to_realloc']|@json_encode}' data-allotment_type_label='{if $rm_dtl_v['booking_type'] == $ALLOTMENT_MANUAL}{l s='Manual'}{else}{l s='Auto'}{/if}' data-comment='{$rm_dtl_v.comment}'>
<button type="button" class="btn btn-primary room_reallocate_swap" id="reallocate_room_{$rm_dtl_v.id_htl_booking}" data-room_type_name="{$rm_dtl_v.room_type_name}" data-id_htl_booking="{$rm_dtl_v.id_htl_booking}" data-id_order="{$rm_dtl_v.id_order}" data-room_num="{$booked_v.room_num}" data-currency_sign="{$rm_dtl_v.currency_sign}" data-id_room_type="{$booked_v.id_product}" data-cust_name="{$rm_dtl_v.alloted_cust_name}" data-cust_email="{$rm_dtl_v.alloted_cust_email}" data-avail_rm_swap='{$rm_dtl_v.avail_rooms_to_swap|@json_encode}' data-avail_realloc_room_types='{$rm_dtl_v.avail_room_types_to_realloc|@json_encode}' data-allotment_type_label="{if $rm_dtl_v.booking_type == $ALLOTMENT_MANUAL}{l s='Manual'}{else}{l s='Auto'}{/if}" data-comment="{$rm_dtl_v.comment}">
{l s='Reallocate Room' mod='hotelreservationsystem'}
</button>
{else}

View File

@@ -87,8 +87,8 @@ $(document).ready(function()
values: [min_price, max_price],
slide: function(event, ui)
{
$("#filter_price_from").html(ui.values[0]);
$("#filter_price_to").html(ui.values[1]);
$("#filter_price_from").html(formatCurrency(ui.values[0], currencyFormat, currencySign, currencyBlank));
$("#filter_price_to").html(formatCurrency(ui.values[1], currencyFormat, currencySign, currencyBlank));
},
change: function(event, ui)
{

View File

@@ -54,8 +54,8 @@
</div>
<div class="col-sm-12 lf_sub_cont">
<div class="row margin-lr-0 price_filter_subcont">
<span class="pull-left">{$currency->prefix} <span id="filter_price_from">{$min_price}</span> {$currency->suffix}</span>
<span class="pull-right">{$currency->prefix} <span id="filter_price_to">{$max_price}</span> {$currency->suffix}</span>
<span class="pull-left"><span id="filter_price_from">{displayPrice price=$min_price}</span></span>
<span class="pull-right"><span id="filter_price_to">{displayPrice price=$max_price}</span></span>
</div>
<div id="filter_price_silder"></div>
</div>

View File

@@ -199,7 +199,7 @@ class wkhotelfilterblock extends Module
$prod_price = array();
if ($room_types) {
foreach ($room_types as $key => $value) {
$prod_price[] = Product::getPriceStatic($value['id_product'], HotelBookingDetail::useTax());
$prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax());
}
}

View File

@@ -27,11 +27,11 @@
<thead>
<tr>
<th class="product header small" width="30%">{l s='Room Type / Reference' pdf='true'}</th>
<th class="product header small" width="30%">{l s='Duration' pdf='true'}</th>
<th class="product header small" width="35%">{l s='Room Type / Reference' pdf='true'}</th>
<th class="product header small" width="35%">{l s='Duration' pdf='true'}</th>
<th class="product header small" width="10%">{l s='Num rooms' pdf='true'}</th>
<th class="product header-right small" width="15%">{l s='Unit price' pdf='true'}<br />{if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}</th>
<th class="product header-right small" width="15%">{l s='Price' pdf='true'}<br />{if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}</th>
{* <th class="product header-right small" width="15%">{l s='Unit price' pdf='true'}<br />{if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}</th> *}
<th class="product header-right small" width="20%">{l s='Total Price' pdf='true'}<br />{if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}</th>
</tr>
</thead>
@@ -55,13 +55,13 @@
<td class="product center">
{$order_detail.num_rooms}
</td>
<td class="product right">
{* <td class="product right">
{if $tax_excluded_display}
- {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
{else}
- {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl}
{/if}
</td>
</td> *}
<td class="product right">
{if $tax_excluded_display}
- {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}

View File

@@ -18,87 +18,89 @@
*}
{hook h='displayRoomTypeListBefore'}
{if isset($booking_data['rm_data']) && $booking_data['rm_data']}
{if isset($booking_data['stats']) && $booking_data['stats']['num_avail']}
{foreach from=$booking_data['rm_data'] key=room_k item=room_v}
<div class="col-sm-12 room_cont" data-id-product="{$room_v['id_product']|escape:'htmlall':'UTF-8'}">
<div class="row">
<div class="col-sm-4">
<a href="{$room_v['product_link']|escape:'htmlall':'UTF-8'}">
<img src="{$room_v['image']|escape:'htmlall':'UTF-8'}" class="img-responsive room-type-image">
{hook h='displayRoomTypeListImageAfter' product=$room_v}
</a>
</div>
<div class="col-sm-8 room_info_cont">
<div class="row">
<p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p>
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_left col-sm-12 col-md-5" {if $room_v['room_left']>$warning_num} style="display:none"{/if}>
{l s='Hurry!'} <span class="remain_rm_qty">{$room_v['room_left']|escape:'htmlall':'UTF-8'}</span> {l s='rooms left'}
</p>
{/if}
{if $room_v['data']['available']|count}
<div class="col-sm-12 room_cont" data-id-product="{$room_v['id_product']|escape:'htmlall':'UTF-8'}">
<div class="row">
<div class="col-sm-4">
<a href="{$room_v['product_link']|escape:'htmlall':'UTF-8'}">
<img src="{$room_v['image']|escape:'htmlall':'UTF-8'}" class="img-responsive room-type-image">
{hook h='displayRoomTypeListImageAfter' product=$room_v}
</a>
</div>
<div class="rm_desc">{$room_v['description']|truncate:190:"":true}&nbsp;<a class="view_more" href="{$room_v['product_link']|escape:'htmlall':'UTF-8'}">{l s='View More'}....</a></div>
<div class="room_features_cont">
<div class="col-sm-8 room_info_cont">
<div class="row">
<div class="col-sm-12 col-md-5 col-lg-6">
{if !empty($room_v['feature'])}
<p class="rm_amenities_cont">
{foreach from=$room_v['feature'] key=feat_k item=feat_v}
<img title="{$feat_v.name|escape:'htmlall':'UTF-8'}" src="{$link->getMediaLink("`$feat_img_dir`{$feat_v.value}")|escape:'htmlall':'UTF-8'}" class="rm_amen">
{/foreach}
</p>
{/if}
</div>
<div class="col-sm-12 hidden-md hidden-lg">
<p class="capa_txt"><span>{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}</span><span class="capa_data"> {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}</span></p>
</div>
<div class="col-sm-12 col-md-7 col-lg-6">
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_price_cont">
{if $room_v['feature_price_diff'] >= 0}
<span class="rm_price_val {if $room_v['feature_price_diff']>0}room_type_old_price{/if}">
{displayPrice price = $room_v['price_without_reduction_with_auto_add']|round:2|floatVal}
</span>
{/if}
{if $room_v['feature_price_diff']}
<span class="rm_price_val">
{displayPrice price = $room_v['feature_price']|round:2|floatVal}
</span>
{/if}
<span class="rm_price_txt">/{l s='Per Night'}</span>
</p>
{/if}
</div>
<p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p>
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_left col-sm-12 col-md-5" {if $room_v['room_left'] > $warning_num} style="display:none"{/if}>
{l s='Hurry!'} <span class="remain_rm_qty">{$room_v['room_left']|escape:'htmlall':'UTF-8'}</span> {l s='rooms left'}
</p>
{/if}
</div>
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-4 visible-md visible-lg">
<div class="capa_txt"><span>{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}</span><br><span class="capa_data"> {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}</span></div>
</div>
<div class="col-sm-12 col-md-6 col-lg-8">
<div class="booking_room_fields">
<div class="rm_desc">{$room_v['description_short']|truncate:190:"":true}&nbsp;<a class="view_more" href="{$room_v['product_link']|escape:'htmlall':'UTF-8'}">{l s='View More'}....</a></div>
<div class="room_features_cont">
<div class="row">
<div class="col-sm-12 col-md-5 col-lg-6">
{if !empty($room_v['feature'])}
<p class="rm_amenities_cont">
{foreach from=$room_v['feature'] key=feat_k item=feat_v}
<img title="{$feat_v.name|escape:'htmlall':'UTF-8'}" src="{$link->getMediaLink("`$feat_img_dir`{$feat_v.value}")|escape:'htmlall':'UTF-8'}" class="rm_amen">
{/foreach}
</p>
{/if}
</div>
<div class="col-sm-12 hidden-md hidden-lg">
<p class="capa_txt"><span>{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}</span><span class="capa_data"> {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}</span></p>
</div>
<div class="col-sm-12 col-md-7 col-lg-6">
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}
<div class="booking_guest_occupancy_conatiner">
{include file="./occupancy_field.tpl" room_type_info=$room_v total_available_rooms=$room_v['room_left']}
</div>
{else}
<p class="rm_price_cont">
{if $room_v['feature_price_diff'] >= 0}
<span class="rm_price_val {if $room_v['feature_price_diff']>0}room_type_old_price{/if}">
{displayPrice price = $room_v['price_without_reduction']|round:2|floatVal}
</span>
{/if}
{if $room_v['feature_price_diff']}
<span class="rm_price_val">
{displayPrice price = $room_v['feature_price']|round:2|floatVal}
</span>
{/if}
<span class="rm_price_txt">/{l s='Per Night'}</span>
</p>
{/if}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-4 visible-md visible-lg">
<div class="capa_txt"><span>{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}</span><br><span class="capa_data"> {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}</span></div>
</div>
<div class="col-sm-12 col-md-6 col-lg-8">
<div class="booking_room_fields">
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
{if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}
<div class="booking_guest_occupancy_conatiner">
{include file="./occupancy_field.tpl" room_type_info=$room_v total_available_rooms=$room_v['room_left']}
</div>
{else}
<div>
<label>{l s='Qty:'}</label>
{include file="./quantity_field.tpl" total_available_rooms=$room_v['room_left']}
</div>
{/if}
<div>
<label>{l s='Qty:'}</label>
{include file="./quantity_field.tpl" total_available_rooms=$room_v['room_left']}
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
</div>
{/if}
<div>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
</div>
{/if}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
{/foreach}
{else}
<div class="noRoomsAvailAlert">