Merge branch 'develop' into gli-2482

This commit is contained in:
vishalsingh.qlo325
2025-07-03 17:18:36 +05:30
64 changed files with 1143 additions and 631 deletions

View File

@@ -115,22 +115,14 @@
</td>
{/if}
<td id="cart_detail_data_unit_price_{$data.id|escape:'html':'UTF-8'}">
{if $data.feature_price_diff != 0}
{assign var=shown_room_type_price value=$data.feature_price_tax_excl}
{else}
{assign var=shown_room_type_price value=$data.product_price_tax_excl}
{/if}
{assign var=shown_room_type_price value=$data.feature_price_tax_excl}
<div class="input-group">
<input type="text" class="room_unit_price" value="{Tools::ps_round($shown_room_type_price, $smarty.const._PS_PRICE_DISPLAY_PRECISION_)|escape:'html':'UTF-8'}">
<span class="input-group-addon">{$currency->prefix}{$currency->suffix}</span>
</div>
</td>
<td>
{if (isset($data.extra_demands) && $data.extra_demands) || (isset($data.additional_service) && $data.additional_service)}
{displayPrice price=($data.demand_price + $data.additional_service_price + $data.additional_services_auto_add_price)|escape:'html':'UTF-8'}
{else}
{displayPrice price=0}
{/if}
{displayPrice price=($data.demand_price + $data.additional_service_price + $data.additional_services_auto_add_price)|escape:'html':'UTF-8'}
</td>
{* <td class="cart_line_total_rooms_price" id="cart_detail_data_price_{$data.id|escape:'html':'UTF-8'}">
{displayPrice price=$data.amt_with_qty}</td> *}
@@ -145,12 +137,10 @@
<button class="delete_hotel_cart_data btn btn-danger" data-id_room="{$data.id_room|escape:'html':'UTF-8'}" data-id_product="{$data.id_product|escape:'html':'UTF-8'}" data-id="{$data.id|escape:'html':'UTF-8'}" data-id_cart="{$data.id_cart|escape:'html':'UTF-8'}" data-date_to="{$data.date_to|escape:'html':'UTF-8'}" data-date_from="{$data.date_from|escape:'html':'UTF-8'}">
<i class="icon-trash"></i>&nbsp;{l s='Delete'}
</button>
{if (isset($data.extra_demands) && $data.extra_demands) || isset($data.additional_service) && $data.additional_service}
<br />
<a href="#" id_hotel_cart_booking="{$data.id|escape:'html':'UTF-8'}" id_room="{$data.id_room|escape:'html':'UTF-8'}" date_from="{$data.date_from|escape:'html':'UTF-8'}" date_to="{$data.date_to|escape:'html':'UTF-8'}" id_product="{$data.id_product|escape:'html':'UTF-8'}" id_cart="{$data.id_cart|escape:'html':'UTF-8'}" class="open_rooms_extra_demands btn btn-success" title="{l s='Click here to add or remove the extra services of this room type.'}">
<i class="icon-pencil"></i>&nbsp;{l s='Services'}
</a>
{/if}
<br />
<a href="#" id_hotel_cart_booking="{$data.id|escape:'html':'UTF-8'}" id_room="{$data.id_room|escape:'html':'UTF-8'}" date_from="{$data.date_from|escape:'html':'UTF-8'}" date_to="{$data.date_to|escape:'html':'UTF-8'}" id_product="{$data.id_product|escape:'html':'UTF-8'}" id_cart="{$data.id_cart|escape:'html':'UTF-8'}" class="open_rooms_extra_demands btn btn-success" title="{l s='Click here to add or remove the extra services of this room type.'}">
<i class="icon-pencil"></i>&nbsp;{l s='Services'}
</a>
</td>
</tr>
{/foreach}

View File

@@ -147,6 +147,7 @@
<div id="new_service_price_tax_rule_container" class="col-sm-6">
<label class="control-label">{l s='Tax rule'}</label>
<select name="new_service_price_tax_rule_group">
<option value="0">{l s='No Tax'}</option>
{foreach from=$taxRulesGroups item=taxRuleGroup}
<option value="{$taxRuleGroup.id_tax_rules_group}">{$taxRuleGroup.name}</option>
{/foreach}

View File

@@ -55,7 +55,7 @@
</div>
</div>
{if $order->hasInvoice()}
<div class="row">
<div class="row" style="display: none;">
<div class="col-sm-12">
<label class="control-label">{l s='Invoice'}</label>
<select name="discount_invoice">

View File

@@ -211,6 +211,7 @@
<div id="new_service_price_tax_rule_container" class="col-sm-6">
<label class="control-label">{l s='Tax rule'}</label>
<select name="new_service_price_tax_rule_group">
<option value="0">{l s='No Tax'}</option>
{foreach from=$taxRulesGroups item=taxRuleGroup}
<option value="{$taxRuleGroup.id_tax_rules_group}">{$taxRuleGroup.name}</option>
{/foreach}

View File

@@ -70,7 +70,7 @@
</div>
</div>
{if count($invoices_collection) > 0}
<div class="form-group row">
<div class="form-group row" style="display: none;">
<div class="col-sm-6">
<label class="control-label">{l s='Invoice'}</label>
<select name="payment_invoice" id="payment_invoice">

View File

@@ -19,24 +19,42 @@
<label class="control-label col-sm-3 required" for="min_los">
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="{l s='Enter minimum length of stay for the hotel. set 1 day for setting no limit on minimum length of stay.'}">{l s='Minimum length of stay'}</span>
</label>
<div class="col-sm-2">
<div class="input-group">
<input type="text" id="min_los" name="min_los" value="{if isset($smarty.post.min_los)}{$smarty.post.min_los|escape:'html':'UTF-8'}{elseif isset($roomTypeInfo['min_los']) && $roomTypeInfo['min_los']}{$roomTypeInfo['min_los']|escape:'html':'UTF-8'}{else}1{/if}">
<span class="input-group-addon">{l s='Day(s)'}</span>
</div>
</div>
<div class="col-sm-9">
<div class="row">
<div class="col-md-4 col-lg-3">
<div class="input-group">
<input type="text" id="min_los" name="min_los" value="{if isset($smarty.post.min_los)}{$smarty.post.min_los|escape:'html':'UTF-8'}{elseif isset($roomTypeInfo['min_los']) && $roomTypeInfo['min_los']}{$roomTypeInfo['min_los']|escape:'html':'UTF-8'}{else}1{/if}">
<span class="input-group-addon">{l s='Day(s)'}</span>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p class="help-block">{l s='Set 1 for no limit'}</p>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3 required" for="max_los">
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="{l s='Enter maximum length of stay for the hotel. set 0 day for setting no limit on maximum length of stay.'}">{l s='Maximum length of stay'}</span>
</label>
<div class="col-sm-2">
<div class="input-group">
<input type="text" id="max_los" name="max_los" value="{if isset($smarty.post.max_los)}{$smarty.post.max_los|escape:'html':'UTF-8'}{elseif isset($roomTypeInfo['max_los'])}{$roomTypeInfo['max_los']|escape:'html':'UTF-8'}{else}0{/if}">
<span class="input-group-addon">{l s='Day(s)'}</span>
</div>
</div>
<div class="col-sm-9">
<div class="row">
<div class="col-md-4 col-lg-3">
<div class="input-group">
<input type="text" id="max_los" name="max_los" value="{if isset($smarty.post.max_los)}{$smarty.post.max_los|escape:'html':'UTF-8'}{elseif isset($roomTypeInfo['max_los'])}{$roomTypeInfo['max_los']|escape:'html':'UTF-8'}{else}0{/if}">
<span class="input-group-addon">{l s='Day(s)'}</span>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p class="help-block">{l s='Set 0 for no limit'}</p>
</div>
</div>
</div>
</div>
</div>
@@ -62,8 +80,16 @@
<thead>
<th>{l s='Date From'}</th>
<th>{l s='Date To'}</th>
<th>{l s='Minimum length of stay'}</th>
<th>{l s='Maximum length of stay'}</th>
<th>
<label class="control-label">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Set 1 for no limit.'}">{l s='Minimum length of stay'}</span>
</label>
</th>
<th>
<label class="control-label">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Set 0 for no limit.'}">{l s='Maximum length of stay'}</span>
</label>
</th>
<th></th>
</thead>
<tbody>

View File

@@ -1816,15 +1816,15 @@ class CartCore extends ObjectModel
if ($servicePorducts) {
foreach ($servicePorducts as $servicePorduct) {
if ($with_taxes) {
$priceAdd = $servicePorduct['unit_price_tax_incl'];
$priceAdd = $servicePorduct['total_price_tax_incl'];
} else {
$priceAdd = $servicePorduct['unit_price_tax_excl'];
$priceAdd = $servicePorduct['total_price_tax_excl'];
}
if ($ps_round_type == Order::ROUND_TOTAL) {
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
$products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd;
} else {
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
$products_total[$id_tax_rules_group] += $priceAdd;
}
}
}

View File

@@ -188,7 +188,7 @@ class ConfigurationTestCore
public static function test_upload_max_filesize()
{
$upload_max_filesize = preg_replace('/[^0-9\.-]/', '', ini_get('upload_max_filesize'));
if ($upload_max_filesize >= 2) {
if ($upload_max_filesize >= 16) {
return true;
}
return false;

View File

@@ -1571,8 +1571,12 @@ abstract class PaymentModuleCore extends Module
}
}
}
$order->updateOrderDetailTax();
/**
* This function is not being called because taxes are already saved correctly.
* The issue lies only in displaying the tax breakdown.
*
* $order->updateOrderDetailTax();
*/
} else {
$error = Tools::displayError('Order creation failed');
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));

View File

@@ -266,6 +266,8 @@ class SpecificPriceRuleCore extends ObjectModel
$result = array_merge($result, Db::getInstance()->executeS($query));
}
// Remove duplicate after the array_merge
$result = array_unique($result, SORT_REGULAR);
} else {
// All products without conditions
if ($products && count($products)) {

View File

@@ -876,20 +876,35 @@ class AdminControllerCore extends Controller
$filters = array();
if (isset($this->list_id)) {
foreach ($_POST as $key => $value) {
if (is_array($value)) {
if ($value[0] === '' && $value[1] === '') {
$value = '';
} else {
$value = json_encode($value);
}
}
if ($value === '') {
unset($this->context->cookie->{$prefix.$key});
} elseif (stripos($key, $this->list_id.'Filter_') === 0) {
$filters[$prefix.$key] = !is_array($value) ? $value : json_encode($value);
$filters[$prefix.$key] = $value;
} elseif (stripos($key, 'submitFilter') === 0) {
$this->context->cookie->$key = !is_array($value) ? $value : json_encode($value);
$this->context->cookie->$key = $value;
}
}
foreach ($_GET as $key => $value) {
if (is_array($value)) {
if ($value[0] === '' && $value[1] === '') {
$value = '';
} else {
$value = json_encode($value);
}
}
if (stripos($key, $this->list_id.'Filter_') === 0) {
$filters[$prefix.$key] = !is_array($value) ? $value : json_encode($value);
$filters[$prefix.$key] = $value;
} elseif (stripos($key, 'submitFilter') === 0) {
$this->context->cookie->$key = !is_array($value) ? $value : json_encode($value);
$this->context->cookie->$key = $value;
}
if (stripos($key, $this->list_id.'Orderby') === 0 && Validate::isOrderBy($value)) {
if ($value === '' || $value == $this->_defaultOrderBy) {

View File

@@ -2520,78 +2520,174 @@ class OrderCore extends ObjectModel
$order_ecotax_tax = 0;
$tax_rates = array();
foreach ($order_details as $order_detail) {
$tax_rates = array();
$id_order_detail = $order_detail['id_order_detail'];
$taxesList = OrderDetail::getTaxListStatic($id_order_detail);
if (!$taxesList) {
continue;
}
$tax_calculator = OrderDetail::getTaxCalculatorStatic($id_order_detail);
// TODO: probably need to make an ecotax tax breakdown here instead,
// but it seems unlikely there will be different tax rates applied to the
// ecotax in the same order in the real world
$unit_ecotax_tax = $order_detail['ecotax'] * $order_detail['ecotax_tax_rate'] / 100.0;
$order_ecotax_tax += $order_detail['product_quantity'] * $unit_ecotax_tax;
$discount_ratio = 0;
if ($this->total_products > 0) {
$discount_ratio = ($order_detail['unit_price_tax_excl'] + $order_detail['ecotax']) / $this->total_products;
}
// share of global discount
$discounted_price_tax_excl = $order_detail['unit_price_tax_excl'] - $discount_ratio * $order_discount_tax_excl;
// specific discount
if (!empty($product_specific_discounts[$order_detail['product_id']])) {
$discounted_price_tax_excl -= $product_specific_discounts[$order_detail['product_id']];
}
$quantity = $order_detail['product_quantity'];
$unit_price_tax_excl = $order_detail['total_price_tax_excl'] / $quantity;
/*
* Discounted taxes are intentionally not calculated here, as we do not want to display them.
*
* TODO: Consider implementing a proper ecotax breakdown if needed in future.
* However, it is unlikely that different tax rates would apply to ecotax within the same order.
*
*
* $unit_ecotax_tax = $order_detail['ecotax'] * $order_detail['ecotax_tax_rate'] / 100.0;
* $order_ecotax_tax += $order_detail['product_quantity'] * $unit_ecotax_tax;
*
* $discount_ratio = 0;
* if ($this->total_products > 0) {
* $discount_ratio = ($order_detail['unit_price_tax_excl'] + $order_detail['ecotax']) / $this->total_products;
* }
*
* // Apply share of global discount
* $discounted_price_tax_excl = $order_detail['unit_price_tax_excl'] - $discount_ratio * $order_discount_tax_excl;
*
* // Apply specific product-level discount
* if (!empty($product_specific_discounts[$order_detail['product_id']])) {
* $discounted_price_tax_excl -= $product_specific_discounts[$order_detail['product_id']];
* }
*/
foreach ($tax_calculator->taxes as $tax) {
$tax_rates[$tax->id] = $tax->rate;
}
foreach ($tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $unit_amount) {
$total_tax_base = 0;
$total_tax_base = Tools::processPriceRounding($discounted_price_tax_excl, $quantity);
$total_amount = Tools::processPriceRounding($unit_amount, $quantity);
if (!isset($breakdown[$id_tax])) {
$breakdown[$id_tax] = array('tax_base' => 0, 'tax_amount' => 0);
$totalTaxBase = Tools::processPriceRounding($unit_price_tax_excl, $quantity);
if (!$order_detail['is_booking_product']) {
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
if ($serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder(
$order_detail['id_order'],
$id_order_detail
)) {
$totals = array_reduce($serviceProductDetail, function ($carry, $item) {
if (!empty($item['id_tax_rules_group'])) {
$qty = isset($item['quantity']) ? $item['quantity'] : 0;
$price = isset($item['total_price_tax_excl']) ? $item['total_price_tax_excl'] : 0;
$carry['quantity'] += $qty;
$carry['total_price_tax_excl'] += $price;
}
return $carry;
}, ['quantity' => 0, 'total_price_tax_excl' => 0]);
$quantity = $totals['quantity'];
$totalTaxBase = $totals['total_price_tax_excl'];
}
$breakdown[$id_tax]['tax_base'] += $total_tax_base;
$breakdown[$id_tax]['tax_amount'] += $total_amount;
$order_detail_tax_rows[] = array(
'id_order_detail' => $id_order_detail,
'id_tax' => $id_tax,
'tax_rate' => $tax_rates[$id_tax],
'unit_tax_base' => $discounted_price_tax_excl,
'total_tax_base' => $total_tax_base,
'unit_amount' => $unit_amount,
'total_amount' => $total_amount
);
}
}
if (!empty($order_detail_tax_rows)) {
foreach ($breakdown as $data) {
$actual_total_tax += Tools::ps_round($data['tax_amount'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
$actual_total_base += Tools::ps_round($data['tax_base'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
}
$order_ecotax_tax = Tools::ps_round($order_ecotax_tax, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
$groupedTaxDetails = array();
$additionalTaxAmounts = array();
$tax_rounding_error = $expected_total_tax - $actual_total_tax - $order_ecotax_tax;
if ($tax_rounding_error != 0) {
Tools::spreadAmount($tax_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_amount');
if (
$order_detail['is_booking_product'] &&
$autoAddedPriceExcl = $objServiceProductOrderDetail->getRoomTypeServiceProducts(
$order_detail['id_order'],
0, 0,
$order_detail['product_id'],
0, 0, 0,
true, false, true,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
)
) {
$additionalTaxAmounts = $tax_calculator->getTaxesAmount($autoAddedPriceExcl);
$totalTaxBase += $autoAddedPriceExcl;
}
$base_rounding_error = $expected_total_base - $actual_total_base;
if ($base_rounding_error != 0) {
Tools::spreadAmount($base_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_tax_base');
$taxBaseShare = $totalTaxBase;
foreach ($taxesList as $detailTax) {
$taxId = $detailTax['id_tax'];
$unitAmount = $detailTax['unit_amount'] + ($additionalTaxAmounts[$taxId] ?? 0);
$totalAmount = $detailTax['total_amount'] + ($additionalTaxAmounts[$taxId] ?? 0);
if (!isset($groupedTaxDetails[$taxId])) {
$groupedTaxDetails[$taxId] = array(
'id_order_detail' => $id_order_detail,
'id_tax' => $taxId,
'tax_rate' => $tax_rates[$taxId],
'unit_tax_base' => $unit_price_tax_excl,
'total_tax_base' => $taxBaseShare,
'unit_amount' => $unitAmount,
'total_amount' => $totalAmount,
);
} else {
$groupedTaxDetails[$taxId]['total_amount'] += $totalAmount;
}
}
if (!empty($groupedTaxDetails)) {
foreach ($groupedTaxDetails as $item) {
$order_detail_tax_rows[] = $item;
}
}
/*
* This tax recalculation logic is intentionally disabled.
*
* Taxes have already been calculated and stored in the `order_detail_tax` table,
* so there is no need to recompute them here.
*
* foreach ($tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $unit_amount) {
* $total_tax_base = 0;
* $total_tax_base = Tools::processPriceRounding($discounted_price_tax_excl, $quantity);
* $total_amount = Tools::processPriceRounding($unit_amount, $quantity);
*
* if (!isset($breakdown[$id_tax])) {
* $breakdown[$id_tax] = array('tax_base' => 0, 'tax_amount' => 0);
* }
*
* $breakdown[$id_tax]['tax_base'] += $total_tax_base;
* $breakdown[$id_tax]['tax_amount'] += $total_amount;
*
* $order_detail_tax_rows[] = array(
* 'id_order_detail' => $id_order_detail,
* 'id_tax' => $id_tax,
* 'tax_rate' => $tax_rates[$id_tax],
* 'unit_tax_base' => $discounted_price_tax_excl,
* 'total_tax_base' => $total_tax_base,
* 'unit_amount' => $unit_amount,
* 'total_amount' => $total_amount
* );
* }
*/
}
/*
* The following tax adjustment logic was disabled as it is not currently in use.
* It was intended to handle rounding errors in tax and base amounts by spreading
* the discrepancy across order detail tax rows. However, this logic is not required
* due to updated tax calculation and breakdown handling.
*/
// if (!empty($order_detail_tax_rows)) {
// foreach ($breakdown as $data) {
// $actual_total_tax += Tools::ps_round($data['tax_amount'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
// $actual_total_base += Tools::ps_round($data['tax_base'], _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
// }
// $order_ecotax_tax = Tools::ps_round($order_ecotax_tax, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
// $tax_rounding_error = $expected_total_tax - $actual_total_tax - $order_ecotax_tax;
// if ($tax_rounding_error != 0) {
// Tools::spreadAmount($tax_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_amount');
// }
// $base_rounding_error = $expected_total_base - $actual_total_base;
// if ($base_rounding_error != 0) {
// Tools::spreadAmount($base_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_tax_base');
// }
// }
return $order_detail_tax_rows;
}

View File

@@ -372,23 +372,6 @@ class OrderDetailCore extends ObjectModel
*/
public function saveTaxCalculator(Order $order, $replace = false)
{
// Nothing to save
if ($this->tax_calculator == null) {
return true;
}
if (!($this->tax_calculator instanceof TaxCalculator)) {
return false;
}
if (count($this->tax_calculator->taxes) == 0) {
return true;
}
if ($order->total_products <= 0) {
return true;
}
$shipping_tax_amount = 0;
foreach ($order->getCartRules() as $cart_rule) {
@@ -398,27 +381,171 @@ class OrderDetailCore extends ObjectModel
}
}
$ratio = $this->unit_price_tax_excl / $order->total_products;
$order_reduction_amount = ($order->total_discounts_tax_excl - $shipping_tax_amount) * $ratio;
$discounted_price_tax_excl = $this->unit_price_tax_excl - $order_reduction_amount;
$values = '';
foreach ($this->tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $amount) {
$total_amount = Tools::processPriceRounding($amount, $this->product_quantity, $order->round_type, $order->round_mode);
$values .= '('.(int)$this->id.','.(int)$id_tax.','.(float)$amount.','.(float)$total_amount.'),';
$idCart = $this->context->cart->id ?? $order->id_cart;
if (empty($this->vat_address)) {
$this->vat_address = new Address((int)$order->id_address_tax);
}
if ($replace) {
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_detail_tax` WHERE id_order_detail='.(int)$this->id);
/**
* Calculate tax rule groups for the service product based on each associated room type.
*/
if (!$this->is_booking_product && $this->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) {
if ($this->product_auto_add && $this->product_price_addition_type == Product::PRICE_ADDITION_TYPE_WITH_ROOM) {
return true;
}
// Get all associated room type IDs for this service product and cart
$associatedRoomTypes = Db::getInstance()->executeS(
'SELECT hcbd.`id_product`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` hcbd
INNER JOIN `'._DB_PREFIX_.'service_product_cart_detail` spcd
ON spcd.`htl_cart_booking_id` = hcbd.`id`
WHERE spcd.`id_product` = '.(int)$this->product_id.'
AND spcd.`id_cart` = '.(int)$idCart
);
if (!empty($associatedRoomTypes)) {
$associatedRoomTypeIds = array_column($associatedRoomTypes, 'id_product');
$taxGroupInfoList = array();
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
foreach ($associatedRoomTypeIds as $idRoomType) {
$key = $this->product_id.'_'.$idRoomType;
if ($serviceProductPriceRoomInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
$this->product_id,
$idRoomType,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
)) {
//Special tax rule group for the Service product accroding to Room type
$taxGroupInfoList[$key] = array(
'id_room_type' => $idRoomType,
'id_tax_rules_group' => $serviceProductPriceRoomInfo['id_tax_rules_group']
);
} else {
// Use default tax rule group for the service product
$taxGroupInfoList[$key] = array(
'id_room_type' => $idRoomType,
'id_tax_rules_group' => $this->id_tax_rules_group
);
}
}
}
}
/**
* Calculate service product tax separately for each room type because
* a service product can be attached to multiple room types with different tax rules.
*/
if (!$this->is_booking_product && isset($taxGroupInfoList) && $taxGroupInfoList) {
$objServiceProductCartDetail = new ServiceProductCartDetail();
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
// Saving tax details according to the service product tax groups for different rooms
foreach ($taxGroupInfoList as $taxGroupInfo) {
$tax_manager = TaxManagerFactory::getManager($this->vat_address, (int)$taxGroupInfo['id_tax_rules_group']);
$this->tax_calculator = $tax_manager->getTaxCalculator();
if ($this->tax_calculator == null) {
continue;
}
if (!($this->tax_calculator instanceof TaxCalculator)) {
continue;
}
if (count($this->tax_calculator->taxes) == 0) {
continue;
}
if ($serviceProductData = $objServiceProductOrderDetail->getRoomTypeServiceProducts(
$this->id_order,
$this->product_id,
0,
$taxGroupInfo['id_room_type'],
)) {
$total_price_tax_excl = array_reduce($serviceProductData, function ($totalPriceTaxExcl, $item) {
return $totalPriceTaxExcl + (isset($item['total_price_tax_excl']) ? $item['total_price_tax_excl'] : 0);
}, 0);
$serviceProductData = array_shift($serviceProductData);
$quantity = array_reduce($serviceProductData['additional_services'], function ($totalQty, $item) {
return $totalQty + (isset($item['quantity']) ? $item['quantity'] : 0);
}, 0);
} elseif ($serviceProductData = $objServiceProductCartDetail->getServiceProductsInCart(
$idCart,
array(),
null,
null,
$taxGroupInfo['id_room_type'],
$this->product_id
)) {
$total_price_tax_excl = array_reduce($serviceProductData, function ($totalPriceTaxExcl, $item) {
return $totalPriceTaxExcl + (isset($item['total_price_tax_excl']) ? $item['total_price_tax_excl'] : 0);
}, 0);
$quantity = array_reduce($serviceProductData, function ($totalQty, $item) {
return $totalQty + (isset($item['quantity']) ? $item['quantity'] : 0);
}, 0);
}
if (isset($quantity) && isset($total_price_tax_excl)) {
$unit_price_tax_excl = $total_price_tax_excl / $quantity;
foreach ($this->tax_calculator->getTaxesAmount($unit_price_tax_excl) as $id_tax => $amount) {
$total_amount = Tools::processPriceRounding($amount, $quantity, $order->round_type, $order->round_mode);
$values .= '('.(int)$this->id.','.(int)$id_tax.','.(float)$amount.','.(float)$total_amount.'),';
}
}
}
} else {
if ($this->tax_calculator == null) {
return true;
}
if (!($this->tax_calculator instanceof TaxCalculator)) {
return false;
}
if (count($this->tax_calculator->taxes) == 0) {
return true;
}
if ($order->total_products <= 0) {
return true;
}
$unit_price_tax_excl = $this->total_price_tax_excl / $this->product_quantity;
/*
* The logic for distributing discount proportionally across products is intentionally skipped,
* as we do not want to save taxes on discounted amounts.
*
* $ratio = $unit_price_tax_excl / $order->total_products;
* $order_reduction_amount = ($order->total_discounts_tax_excl - $shipping_tax_amount) * $ratio;
* $discounted_price_tax_excl = $unit_price_tax_excl - $order_reduction_amount;
*/
foreach ($this->tax_calculator->getTaxesAmount($unit_price_tax_excl) as $id_tax => $amount) {
$total_amount = Tools::processPriceRounding($amount, $this->product_quantity, $order->round_type, $order->round_mode);
$values .= '('.(int)$this->id.','.(int)$id_tax.','.(float)$amount.','.(float)$total_amount.'),';
}
}
$values = rtrim($values, ',');
$sql = 'INSERT INTO `'._DB_PREFIX_.'order_detail_tax` (id_order_detail, id_tax, unit_amount, total_amount)
VALUES '.$values;
return Db::getInstance()->execute($sql);
if ($values) {
if ($replace) {
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_detail_tax` WHERE id_order_detail='.(int)$this->id);
}
$sql = 'INSERT INTO `'._DB_PREFIX_.'order_detail_tax` (id_order_detail, id_tax, unit_amount, total_amount)
VALUES '.$values;
return Db::getInstance()->execute($sql);
}
return true;
}
public function updateTaxAmount($order)
@@ -550,7 +677,7 @@ class OrderDetailCore extends ObjectModel
if ($product !== null) {
$this->setContext((int)$product['id_shop']);
}
$id_tax_rules = (int)Product::getIdTaxRulesGroupByIdProduct((int)$this->specificPrice['id_product'], $this->context);
$id_tax_rules = (int)Product::getIdTaxRulesGroupByIdProduct((int)$this->product_id, $this->context);
$tax_manager = TaxManagerFactory::getManager($this->vat_address, $id_tax_rules);
$this->tax_calculator = $tax_manager->getTaxCalculator();

View File

@@ -365,14 +365,13 @@ class OrderInvoiceCore extends ObjectModel
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;
@@ -430,14 +429,13 @@ class OrderInvoiceCore extends ObjectModel
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;
@@ -494,14 +492,13 @@ class OrderInvoiceCore extends ObjectModel
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;
@@ -563,14 +560,13 @@ class OrderInvoiceCore extends ObjectModel
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;
@@ -632,14 +628,13 @@ class OrderInvoiceCore extends ObjectModel
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;

View File

@@ -298,14 +298,13 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_tax_base' => $row['total_tax_base'],
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;

View File

@@ -49,8 +49,8 @@ class ShopUrlCore extends ObjectModel
'domain' => array('type' => self::TYPE_STRING, 'required' => true, 'size' => 255, 'validate' => 'isCleanHtml'),
'domain_ssl' => array('type' => self::TYPE_STRING, 'size' => 255, 'validate' => 'isCleanHtml'),
'id_shop' => array('type' => self::TYPE_INT, 'required' => true),
'physical_uri' => array('type' => self::TYPE_STRING, 'size' => 64),
'virtual_uri' => array('type' => self::TYPE_STRING, 'size' => 64),
'physical_uri' => array('type' => self::TYPE_STRING, 'size' => 256),
'virtual_uri' => array('type' => self::TYPE_STRING, 'size' => 256),
),
);

View File

@@ -101,6 +101,10 @@ class TaxRulesGroupCore extends ObjectModel
UPDATE '._DB_PREFIX_.'product
SET id_tax_rules_group='.(int)$tax_rules_group->id.'
WHERE id_tax_rules_group='.(int)$this->id) &&
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'htl_room_type_service_product_price
SET id_tax_rules_group='.(int)$tax_rules_group->id.'
WHERE id_tax_rules_group='.(int)$this->id) &&
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'product_shop
SET id_tax_rules_group='.(int)$tax_rules_group->id.'

View File

@@ -1396,7 +1396,7 @@ class AdminCartsControllerCore extends AdminController
$response['errors'][] = Tools::displayError('Invalid service name');
}
if (empty($price)) {
if (!isset($price)) {
$response['hasError'] = true;
$response['errors'][] = Tools::displayError('Service price is required');
} elseif (!Validate::isPrice($price)) {

View File

@@ -175,7 +175,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
'id_order' => array(
'title' => $this->l('ID Order'),
'filter_key' => 'a!id_order',
'optional' => true,
'optional' => false,
'visible_default' => false,
'displayed' => false,
),

View File

@@ -397,12 +397,7 @@ class AdminOrdersControllerCore extends AdminController
$cart_detail_data = array();
$cart_detail_data_obj = new HotelCartBookingData();
$objServiceProductCartDetail = new ServiceProductCartDetail();
if ($cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart(
(int) $id_cart,
[],
null,
0
)) {
if ($cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart((int) $id_cart)) {
$objRoomType = new HotelRoomType();
foreach ($cart_detail_data as $key => $cart_data) {
$cart_detail_data[$key]['room_type_info'] = $objRoomType->getRoomTypeInfoByIdProduct($cart_data['id_product']);
@@ -540,12 +535,12 @@ class AdminOrdersControllerCore extends AdminController
public function initToolbarTitle()
{
parent::initToolbarTitle();
switch ($this->display) {
case '':
case 'list':
array_pop($this->toolbar_title);
$this->toolbar_title[] = $this->l('Orders');
break;
if ($this->display == 'add') {
array_pop($this->toolbar_title);
$this->toolbar_title[] = $this->l('Add new');
} elseif ($this->display != 'view') {
array_pop($this->toolbar_title);
$this->toolbar_title[] = $this->l('Orders');
}
}
@@ -553,7 +548,12 @@ class AdminOrdersControllerCore extends AdminController
{
$response['hasError'] = 1;
if (Validate::isLoadedObject($objOrder = new Order(Tools::getValue('id_order')))) {
$this->context->smarty->assign('can_edit', $this->tabAccess['edit']);
$this->context->smarty->assign(
array(
'can_edit' => $this->tabAccess['edit'],
'current_id_lang' => $this->context->language->id,
)
);
// set modal details
$modal = array(
'modal_id' => 'booking-documents-modal',
@@ -626,6 +626,7 @@ class AdminOrdersControllerCore extends AdminController
'order' => $objOrder,
'currency' => new Currency($objOrder->id_currency),
'invoices_collection' => $objOrder->getInvoicesCollection(),
'current_id_lang' => $this->context->language->id
)
);
@@ -684,6 +685,7 @@ class AdminOrdersControllerCore extends AdminController
'payment_methods' => $payment_methods,
'payment_types' => $this->getPaymentsTypes(),
'invoices_collection' => $objOrder->getInvoicesCollection(),
'current_id_lang' => $this->context->language->id,
)
);
$modal = array(
@@ -1177,6 +1179,7 @@ class AdminOrdersControllerCore extends AdminController
'order' => $objOrder,
'currency' => new Currency($objOrder->id_currency),
'invoices_collection' => $objOrder->getInvoicesCollection(),
'current_id_lang' => $this->context->language->id,
)
);
$modal = array(
@@ -1238,6 +1241,7 @@ class AdminOrdersControllerCore extends AdminController
$smartyVars['currencySign'] = $objCurrency->sign;
$smartyVars['link'] = $this->context->link;
$smartyVars['invoices_collection'] = $objOrder->getInvoicesCollection();
$smartyVars['current_id_lang'] = $this->context->language->id;
// set context currency So that we can get prices in the order currency
$this->context->currency = $objCurrency;
@@ -2865,7 +2869,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->color = 'color1';
$helper->title = $this->l('Total Rooms');
$helper->tooltip = $this->l('Total rooms is the number of rooms booked in this order.');
$helper->href = '#start_rooms';
$helper->href = '#start_products';
$helper->value = $numRooms;
$this->kpis[] = $helper;
@@ -6135,7 +6139,7 @@ class AdminOrdersControllerCore extends AdminController
$product_quantity = $editProductInfo['product_quantity'];
if ($updateQty = (int)($product_quantity - $objServiceProductOrderDetail->quantity)) {
$this->checkStockAvailable($objOrderDetail, ($product_quantity - $objOrderDetail->product_quantity));
$this->checkStockAvailable($objOrderDetail, $updateQty);
}
$taxRate = $objServiceProductOrderDetail->unit_price_tax_incl / $objServiceProductOrderDetail->unit_price_tax_excl;
@@ -6203,7 +6207,7 @@ class AdminOrdersControllerCore extends AdminController
// Update product available quantity
if ($updateQty) {
$result &= StockAvailable::updateQuantity($objOrderDetail->product_id, $objOrderDetail->product_attribute_id, $updateQty, $objOrder->id_shop);
$result &= StockAvailable::updateQuantity($objOrderDetail->product_id, $objOrderDetail->product_attribute_id, -(int)$updateQty, $objOrder->id_shop);
}
if (!$result) {
@@ -7776,7 +7780,7 @@ class AdminOrdersControllerCore extends AdminController
$response['errors'][] = Tools::displayError('Invalid service name');
}
if (empty($price)) {
if (!isset($price)) {
$response['hasError'] = true;
$response['errors'][] = Tools::displayError('Service price is required');
} elseif (!Validate::isPrice($price)) {

View File

@@ -331,80 +331,80 @@ class AdminPPreferencesControllerCore extends AdminController
),
'submit' => array('title' => $this->l('Save'))
),
'stock' => array(
'title' => $this->l('Products stock'),
'fields' => array(
'PS_ORDER_OUT_OF_STOCK' => array(
'title' => $this->l('Allow ordering of out-of-stock products'),
'hint' => $this->l('By default, the Add to Cart button is hidden when a product is unavailable. You can choose to have it displayed in all cases.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_STOCK_MANAGEMENT' => array(
'title' => $this->l('Enable stock management'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'js' => array(
'on' => 'onchange="stockManagementActivationAuthorization()"',
'off' => 'onchange="stockManagementActivationAuthorization()"'
)
),
// 'PS_ADVANCED_STOCK_MANAGEMENT' => array(
// 'title' => $this->l('Enable advanced stock management'),
// 'hint' => $this->l('Allows you to manage physical stock, warehouses and supply orders in a new Stock menu.'),
// 'validation' => 'isBool',
// 'cast' => 'intval',
// 'required' => false,
// 'type' => 'bool',
// 'visibility' => Shop::CONTEXT_ALL,
// 'js' => array(
// 'on' => 'onchange="advancedStockManagementActivationAuthorization()"',
// 'off' => 'onchange="advancedStockManagementActivationAuthorization()"'
// )
// ),
// 'PS_FORCE_ASM_NEW_PRODUCT' => array(
// 'title' => $this->l('New products use advanced stock management'),
// 'hint' => $this->l('New products will automatically use advanced stock management and depends on stock, but no warehouse will be selected'),
// 'validation' => 'isBool',
// 'cast' => 'intval',
// 'required' => false,
// 'type' => 'bool',
// 'visibility' => Shop::CONTEXT_ALL,
// ),
// 'PS_DEFAULT_WAREHOUSE_NEW_PRODUCT' => array(
// 'title' => $this->l('Default warehouse on new products'),
// 'hint' => $this->l('Automatically set a default warehouse when new product is created'),
// 'type' => 'select',
// 'list' => $warehouse_list,
// 'identifier' => 'id_warehouse'
// ),
// 'PS_PACK_STOCK_TYPE' => array(
// 'title' => $this->l('Default pack stock management'),
// 'type' => 'select',
// 'list' =>array(
// array(
// 'pack_stock' => 0,
// 'name' => $this->l('Decrement pack only.')
// ),
// array(
// 'pack_stock' => 1,
// 'name' => $this->l('Decrement products in pack only.')
// ),
// array(
// 'pack_stock' => 2,
// 'name' => $this->l('Decrement both.')
// ),
// ),
// 'identifier' => 'pack_stock',
// ),
),
// 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
'submit' => array('title' => $this->l('Save'))
),
// 'stock' => array(
// 'title' => $this->l('Products stock'),
// 'fields' => array(
// 'PS_ORDER_OUT_OF_STOCK' => array(
// 'title' => $this->l('Allow ordering of out-of-stock products'),
// 'hint' => $this->l('By default, the Add to Cart button is hidden when a product is unavailable. You can choose to have it displayed in all cases.'),
// 'validation' => 'isBool',
// 'cast' => 'intval',
// 'required' => false,
// 'type' => 'bool'
// ),
// 'PS_STOCK_MANAGEMENT' => array(
// 'title' => $this->l('Enable stock management'),
// 'validation' => 'isBool',
// 'cast' => 'intval',
// 'required' => false,
// 'type' => 'bool',
// 'js' => array(
// 'on' => 'onchange="stockManagementActivationAuthorization()"',
// 'off' => 'onchange="stockManagementActivationAuthorization()"'
// )
// ),
// // 'PS_ADVANCED_STOCK_MANAGEMENT' => array(
// // 'title' => $this->l('Enable advanced stock management'),
// // 'hint' => $this->l('Allows you to manage physical stock, warehouses and supply orders in a new Stock menu.'),
// // 'validation' => 'isBool',
// // 'cast' => 'intval',
// // 'required' => false,
// // 'type' => 'bool',
// // 'visibility' => Shop::CONTEXT_ALL,
// // 'js' => array(
// // 'on' => 'onchange="advancedStockManagementActivationAuthorization()"',
// // 'off' => 'onchange="advancedStockManagementActivationAuthorization()"'
// // )
// // ),
// // 'PS_FORCE_ASM_NEW_PRODUCT' => array(
// // 'title' => $this->l('New products use advanced stock management'),
// // 'hint' => $this->l('New products will automatically use advanced stock management and depends on stock, but no warehouse will be selected'),
// // 'validation' => 'isBool',
// // 'cast' => 'intval',
// // 'required' => false,
// // 'type' => 'bool',
// // 'visibility' => Shop::CONTEXT_ALL,
// // ),
// // 'PS_DEFAULT_WAREHOUSE_NEW_PRODUCT' => array(
// // 'title' => $this->l('Default warehouse on new products'),
// // 'hint' => $this->l('Automatically set a default warehouse when new product is created'),
// // 'type' => 'select',
// // 'list' => $warehouse_list,
// // 'identifier' => 'id_warehouse'
// // ),
// // 'PS_PACK_STOCK_TYPE' => array(
// // 'title' => $this->l('Default pack stock management'),
// // 'type' => 'select',
// // 'list' =>array(
// // array(
// // 'pack_stock' => 0,
// // 'name' => $this->l('Decrement pack only.')
// // ),
// // array(
// // 'pack_stock' => 1,
// // 'name' => $this->l('Decrement products in pack only.')
// // ),
// // array(
// // 'pack_stock' => 2,
// // 'name' => $this->l('Decrement both.')
// // ),
// // ),
// // 'identifier' => 'pack_stock',
// // ),
// ),
// // 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
// 'submit' => array('title' => $this->l('Save'))
// ),
);
}

View File

@@ -944,6 +944,12 @@ class AdminProductsControllerCore extends AdminController
$id_hotel_new = $room_type_info['id_hotel'];
}
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
if ($roomTypeBedTypes = $objHotelRoomTypeBedType->getRoomTypeBedTypes($id_product_old)) {
$roomTypeBedTypes = array_column($roomTypeBedTypes, 'id_bed_type');
$objHotelRoomTypeBedType->updateRoomTypeBedTypes($roomTypeBedTypes, $product->id);
}
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
} else {
@@ -1918,7 +1924,8 @@ class AdminProductsControllerCore extends AdminController
$this->copyFromPost($this->object, $this->table);
$this->object->booking_product = true;
if ($this->object->add()) {
$objHotelRoomTypeBedType = new HotelRoomTypeBedType();
$objHotelRoomTypeBedType->updateRoomTypeBedTypes(Tools::getValue('id_bed_types'), $this->object->id);
// associateroom type to hotel
// if ($this->object->is_virtual) {

View File

@@ -474,7 +474,7 @@ class CartControllerCore extends FrontController
$finalQuantity += $quantityInCart;
}
if ($product->max_quantity && $finalQuantity > $product->max_quantity) {
$this->errors[] = Tools::displayError(sprintf('You can now add more than %d quantity for this product in the cart.', $product->max_quantity));
$this->errors[] = Tools::displayError(sprintf('You cannot add more than %d quantity for this product in the cart.', $product->max_quantity));
}
} else {
if ($id_cart) {
@@ -517,7 +517,7 @@ class CartControllerCore extends FrontController
$finalQuantity += $productCartDetail['quantity'];
}
if ($product->max_quantity && $finalQuantity > $product->max_quantity) {
$this->errors[] = Tools::displayError(sprintf('You can not add more than %d quantity for this product in the cart.', $product->max_quantity));
$this->errors[] = Tools::displayError(sprintf('You cannot add more than %d quantity for this product in the cart.', $product->max_quantity));
}
} elseif ($productCartDetail) {
$this->errors[] = Tools::displayError('You can only order one quantity for this product.');

View File

@@ -169,8 +169,23 @@ class CategoryControllerCore extends FrontController
}
}
$id_cart = $this->context->cart->id;
$id_guest = $this->context->cookie->id_guest;
$sort_by = Tools::getValue('sort_by');
$sort_value = Tools::getValue('sort_value');
$filter_data = Tools::getValue('filter_data');
$amenities = [];
$price = [];
if (!empty($filter_data)) {
foreach ($filter_data as $key => $value) {
if ($key == 'amenities') {
foreach ($value as $a_k => $a_v) {
$amenities[] = $a_v;
}
} elseif ($key == 'price') {
$price['from'] = $value[0];
$price['to'] = $value[1];
}
}
}
$objBookingDetail = new HotelBookingDetail();
$bookingParams = array(
@@ -179,20 +194,36 @@ class CategoryControllerCore extends FrontController
'occupancy' => $occupancy,
'hotel_id' => $id_hotel,
'get_total_rooms' => 0,
'id_cart' => $id_cart,
'id_guest' => $id_guest,
'id_cart' => $this->context->cart->id,
'id_guest' => $this->context->cookie->id_guest,
'amenities' => $amenities,
'price' => $price,
);
if ($displayAllRoomsTypes) {
$bookingParams['get_all_room_types'] = 1;
}
$booking_data = $objBookingDetail->dataForFrontSearch($bookingParams);
if ($booking_data = $objBookingDetail->dataForFrontSearch($bookingParams)) {
$booking_data['rm_data'] = array_values($booking_data['rm_data']);
if ($sort_by && $sort_value) {
$indi_arr = array();
if ($sort_value == 1) {
$direction = SORT_ASC;
} elseif ($sort_value == 2) {
$direction = SORT_DESC;
}
foreach ($booking_data['rm_data'] as $s_k => $s_v) {
$indi_arr[$s_k] = $s_v['price'];
}
array_multisort($indi_arr, $direction, $booking_data['rm_data']);
}
}
$num_days = HotelHelper::getNumberOfDays($date_from, $date_to);
$warning_num = Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER');
/*Max date of ordering for order restrict*/
$order_date_restrict = false;
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($id_hotel);
@@ -204,8 +235,9 @@ class CategoryControllerCore extends FrontController
$order_date_restrict = true;
}
}
/*End*/
$feat_img_dir = _PS_IMG_.'rf/';
$ratting_img = _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png';
$this->context->smarty->assign(array(
'warning_num' => $warning_num,
'num_days' => $num_days,
@@ -214,23 +246,25 @@ class CategoryControllerCore extends FrontController
'booking_data' => $booking_data,
'max_order_date' => $max_order_date,
'order_date_restrict' => $order_date_restrict,
'display_all_room_types' => $displayAllRoomsTypes
'display_all_room_types' => $displayAllRoomsTypes,
'id_hotel' => $id_hotel,
'currency' => $currency,
'feat_img_dir' => $feat_img_dir,
'ratting_img' => $ratting_img,
));
$action = Tools::toCamelCase(Tools::getValue('action'), true);
if ($this->ajax && $action == 'Filterresults') {
$response = array(
'status' => true,
'html_room_type_list' => $this->context->smarty->fetch('_partials/room_type_list.tpl')
);
$this->ajaxDie(json_encode($response));
}
} else {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
}
$feat_img_dir = _PS_IMG_.'rf/';
$ratting_img = _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png';
$this->context->smarty->assign(array(
'id_hotel' => $id_hotel,
'currency' => $currency,
'feat_img_dir' => $feat_img_dir,
'ratting_img' => $ratting_img,
));
/*End*/
/*if (isset($this->context->cookie->id_compare))
$this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
@@ -262,109 +296,6 @@ class CategoryControllerCore extends FrontController
));*/
}
public function displayAjaxFilterResults()
{
$response = array('status' => false);
$this->display_header = false;
$this->display_footer = false;
$displayAllRoomsTypes = false;
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d H:i:s');
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
$displayAllRoomsTypes = true;
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
$displayAllRoomsTypes = true;
}
$htl_id_category = Tools::getValue('id_category');
// occupancy of the search
$occupancy = Tools::getValue('occupancy');
if (!Validate::isOccupancy($occupancy)) {
$occupancy = array();
}
$sort_by = Tools::getValue('sort_by');
$sort_value = Tools::getValue('sort_value');
$filter_data = Tools::getValue('filter_data');
$adults = 0;
$children = 0;
$amenities = 0;
$price = 0;
if (!empty($filter_data)) {
foreach ($filter_data as $key => $value) {
if ($key == 'adults') {
$adults = min($value);
} elseif ($key == 'children') {
$children = min($value);
} elseif ($key == 'amenities') {
$amenities = array();
foreach ($value as $a_k => $a_v) {
$amenities[] = $a_v;
}
} elseif ($key == 'price') {
$price = array();
$price['from'] = $value[0];
$price['to'] = $value[1];
}
}
}
if (Module::isInstalled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
$id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category);
$objBookingDetail = new HotelBookingDetail();
$bookingParams = array(
'date_from' => $date_from,
'date_to' => $date_to,
'hotel_id' => $id_hotel,
'occupancy' => $occupancy,
'amenities' => $amenities,
'price' => $price,
'get_total_rooms' => 0,
'id_cart' => $this->context->cart->id,
'id_guest' => $this->context->cookie->id_guest,
);
if ($displayAllRoomsTypes) {
$bookingParams['get_all_room_types'] = 1;
}
$booking_data = $objBookingDetail->dataForFrontSearch($bookingParams);
// reset array keys from 0
$booking_data['rm_data'] = array_values($booking_data['rm_data']);
if ($sort_by && $sort_value) {
$indi_arr = array();
if ($sort_value == 1) {
$direction = SORT_ASC;
} elseif ($sort_value == 2) {
$direction = SORT_DESC;
}
foreach ($booking_data['rm_data'] as $s_k => $s_v) {
$indi_arr[$s_k] = $s_v['price'];
}
array_multisort($indi_arr, $direction, $booking_data['rm_data']);
}
$this->context->smarty->assign(array('booking_data' => $booking_data));
$html = $this->context->smarty->fetch('_partials/room_type_list.tpl');
$response['status'] = true;
$response['html_room_type_list'] = $html;
}
$this->ajaxDie(json_encode($response));
}
/**
* Assigns scenes template variables
*/

View File

@@ -237,15 +237,16 @@ class ContactControllerCore extends FrontController
$this->addJS(_PS_JS_DIR_.'validate.js');
// GOOGLE MAP
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && ($PS_MAP_ID = Configuration::get('PS_MAP_ID')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
Media::addJsDef(
array(
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'PS_MAP_ID' => $PS_MAP_ID,
)
);
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
'&libraries=places&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}

View File

@@ -639,6 +639,7 @@ class GuestTrackingControllerCore extends FrontController
if (Validate::isLoadedObject($objHotelBranchInformation)) {
if (($apiKey = Configuration::get('PS_API_KEY'))
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
) {
if (floatval($objHotelBranchInformation->latitude) != 0
&& floatval($objHotelBranchInformation->longitude) != 0
@@ -646,10 +647,11 @@ class GuestTrackingControllerCore extends FrontController
Media::addJsDef(array(
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'initiateMap' => 1,
'PS_MAP_ID' => $PS_MAP_ID,
));
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places,marker&loading=async&callback=initMap&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);

View File

@@ -871,6 +871,7 @@ class OrderDetailControllerCore extends FrontController
if (Validate::isLoadedObject($objHotelBranchInformation)) {
if (($apiKey = Configuration::get('PS_API_KEY'))
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
) {
if (floatval($objHotelBranchInformation->latitude) != 0
&& floatval($objHotelBranchInformation->longitude) != 0
@@ -878,10 +879,10 @@ class OrderDetailControllerCore extends FrontController
Media::addJsDef(array(
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'initiateMap' => 1,
'PS_MAP_ID' => $PS_MAP_ID,
));
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places,marker&loading=async&callback=initMap&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}

View File

@@ -111,7 +111,7 @@ class OurPropertiesControllerCore extends FrontController
$hotelsInfo = array_slice($hotelsInfo, $page * 10, 10);
}
if ($displayHotelMap && Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
if ($displayHotelMap && Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP') && Configuration::get('PS_MAP_ID')) {
if ($hotelLocations = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY'))) {
$hotelLocationArray = str_replace(array('\n', '\r'), '', json_encode($hotelLocations));
}
@@ -144,16 +144,17 @@ class OurPropertiesControllerCore extends FrontController
$this->addJS(_THEME_JS_DIR_.'our-properties.js');
$this->addCSS(_THEME_CSS_DIR_.'our-properties.css');
// GOOGLE MAP
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && ($PS_MAP_ID = Configuration::get('PS_MAP_ID')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
Media::addJsDef(
array(
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'PS_MAP_ID' => $PS_MAP_ID
)
);
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
'&libraries=places&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}

View File

@@ -66,10 +66,11 @@ class ProductControllerCore extends FrontController
$this->addJqueryPlugin('jqzoom');
}
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))) {
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
) {
$objHotelRoomType = new HotelRoomType();
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id);
if ($roomTypeInfo) {
if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id)) {
$objHotelBranchInformation = new HotelBranchInformation($roomTypeInfo['id_hotel']);
if (floatval($objHotelBranchInformation->latitude) != 0
&& floatval($objHotelBranchInformation->longitude) != 0
@@ -79,12 +80,13 @@ class ProductControllerCore extends FrontController
'latitude' => $objHotelBranchInformation->latitude,
'longitude' => $objHotelBranchInformation->longitude,
),
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON'))
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'PS_MAP_ID' => $PS_MAP_ID
));
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}
@@ -129,6 +131,20 @@ class ProductControllerCore extends FrontController
}
}
// if product is a service product then check type of selling preference
if (!$this->product->booking_product) {
if ($this->product->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
} elseif ($this->product->selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) {
// if selling preference is hotel standalone and with room type then check if product is associated to any hotel
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$associatedHotels = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($this->product->id);
if (!isset($associatedHotels['hotel']) || !$associatedHotels['hotel']) {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
}
}
}
if (!Validate::isLoadedObject($this->product)) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
@@ -496,6 +512,19 @@ class ProductControllerCore extends FrontController
$this->context->smarty->assign('error', Tools::getValue('error'));
}
} else {
if ($this->product->allow_multiple_quantity) {
$this->product->cart_quantity = 0;
if ($products = $this->context->cart->getProducts()) {
$products = array_column($products, 'cart_quantity', 'id_product');
if (isset($products[$this->product->id])) {
$this->product->cart_quantity = $products[$this->product->id];
$this->product->max_quantity -= $products[$this->product->id];
if (!$this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock)) {
$this->product->quantity -= $products[$this->product->id];
}
}
}
}
$this->assignServiceProductVars();
}

View File

@@ -2175,8 +2175,8 @@ CREATE TABLE IF NOT EXISTS `PREFIX_shop_url` (
`id_shop` int(11) unsigned NOT NULL,
`domain` varchar(150) NOT NULL,
`domain_ssl` varchar(150) NOT NULL,
`physical_uri` varchar(64) NOT NULL,
`virtual_uri` varchar(64) NOT NULL,
`physical_uri` varchar(256) NOT NULL,
`virtual_uri` varchar(256) NOT NULL,
`main` TINYINT(1) NOT NULL,
`active` TINYINT(1) NOT NULL,
PRIMARY KEY (`id_shop_url`),

View File

@@ -83,7 +83,8 @@ class Bankwire extends PaymentModule
'bankwire_owner' => Configuration::get('BANK_WIRE_OWNER'),
'bankwire_details' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
'bankwire_address' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')),
'lang' => new Language($order->id_lang)
'lang' => new Language($order->id_lang),
'total_paid' => Tools::displayPrice($order->total_paid, $this->context->currency, false)
));
return array(

View File

@@ -27,7 +27,7 @@
{l s='Here are the bank details for your transfer:' mod='bankwire' lang=$lang}
</p>
<span style="color:#777">
<span style="color:#333"><strong>{l s='Amount:' mod='bankwire' lang=$lang}</strong></span> {literal}{total_paid}{/literal}<br />
<span style="color:#333"><strong>{l s='Amount:' mod='bankwire' lang=$lang}</strong></span> {$total_paid}<br />
<span style="color:#333"><strong>{l s='Account owner:' mod='bankwire' lang=$lang}</strong></span> {$bankwire_owner}<br />
<span style="color:#333"><strong>{l s='Account details:' mod='bankwire' lang=$lang}</strong></span> {$bankwire_details}<br />
<span style="color:#333"><strong>{l s='Bank address:' mod='bankwire' lang=$lang}</strong></span> {$bankwire_address}

View File

@@ -18,7 +18,7 @@
*}
{l s='Here are the bank details for your transfer:' mod='bankwire'}
{l s='Amount:' mod='bankwire'} {literal}{total_paid}{/literal}
{l s='Amount:' mod='bankwire'} {$total_paid}
{l s='Account owner:' mod='bankwire'} {$bankwire_owner}
{l s='Account details:' mod='bankwire'} {$bankwire_details}
{l s='Bank address:' mod='bankwire'} {$bankwire_address}

View File

@@ -432,6 +432,10 @@ var ajaxCart = {
resetRoomtypeServices();
if (parseInt($('#product_page_booking_product').val()) == 0) {
$('#service_product_qty').val(1);
}
BookingForm.refresh(true);
}
@@ -874,7 +878,7 @@ var ajaxCart = {
content += '</div>';
if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE
|| parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)
&& (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length)
&& (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined')
) {
content += '<div class="hotel-name">' + hotel_wise_data.hotel_name + '</div>';
}

View File

@@ -78,7 +78,8 @@ class Cheque extends PaymentModule
'cheque_name' => Configuration::get('CHEQUE_NAME'),
'cheque_address' => Configuration::get('CHEQUE_ADDRESS'),
'cheque_address_html' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS')),
'lang' => new Language($order->id_lang)
'lang' => new Language($order->id_lang),
'total_paid' => Tools::displayPrice($order->total_paid, $this->context->currency, false)
));
return array(

View File

@@ -27,7 +27,7 @@
{l s='Here are the bank details for your check:' mod='cheque' lang=$lang}
</p>
<span style="color:#777">
<span style="color:#333"><strong>{l s='Amount:' mod='cheque' lang=$lang}</strong></span> {literal}{total_paid}{/literal}<br />
<span style="color:#333"><strong>{l s='Amount:' mod='cheque' lang=$lang}</strong></span> {$total_paid}<br />
<span style="color:#333"><strong>{l s='Payable to the order of:' mod='cheque' lang=$lang}</strong></span> {$cheque_name}<br />
<span style="color:#333"><strong>{l s='Please mail your check to:' mod='cheque' lang=$lang}</strong></span> {$cheque_address_html}
</span>

View File

@@ -18,6 +18,6 @@
*}
{l s='Here are the bank details for your check:' mod='cheque' lang=$lang}
{l s='Amount:' mod='cheque' lang=$lang} {literal}{total_paid}{/literal}
{l s='Amount:' mod='cheque' lang=$lang} {$total_paid}
{l s='Payable to the order of:' mod='cheque' lang=$lang} {$cheque_name}
{l s='Please mail your check to:' mod='cheque' lang=$lang} {$cheque_address}

View File

@@ -2175,7 +2175,11 @@ class HotelBookingDetail extends ObjectModel
// delete cart feature prices after room addition success
HotelRoomTypeFeaturePricing::deleteFeaturePrices($context->cart->id);
// since only one room is added in the cart on reallocation process.
$idNewCartBookingData = false;
if (isset($objCartBookingData->id)) {
$idNewCartBookingData = $objCartBookingData->id;
}
// ===============================================================
// END: Add Process of the old booking
// ===============================================================
@@ -2286,6 +2290,21 @@ class HotelBookingDetail extends ObjectModel
AND id_room = '.(int) $objOldHotelBooking->id_room.' AND `id_order` = '.(int) $objOldHotelBooking->id_order
);
$objCartBookingData = new HotelCartBookingData($idHotelCartBookingData);
if ($idNewCartBookingData) {
$objServiceProductCartDetail = new ServiceProductCartDetail();
if ($oldCartAdditonalServices = $objServiceProductCartDetail->getServiceProductsInCart(
0, // if reallocated twice the id cart will not be used as it was not changed in first reallocation.
[],
null,
$objCartBookingData->id
)) {
foreach ($oldCartAdditonalServices as $service) {
$objServiceProductCartDetail = new ServiceProductCartDetail($service['id_service_product_cart_detail']);
$objServiceProductCartDetail->htl_cart_booking_id = (int) $idNewCartBookingData;
$objServiceProductCartDetail->save();
}
}
}
$objCartBookingData->delete();
// delete the booking detail

View File

@@ -951,7 +951,8 @@ class HotelCartBookingData extends ObjectModel
if (!Validate::isLoadedObject($product = new Product($service['id_product']))) {
$toRemoveService = 1;
} else {
if (!$product->active) {
// check if product is active and (available for order for front office)
if (!$product->active || (!$forAdminCart && !$product->available_for_order)) {
$toRemoveService = 1;
} else if ($checkServiceRoomLink) {
if ($product->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) {
@@ -1579,7 +1580,13 @@ class HotelCartBookingData extends ObjectModel
if ($detailed) {
// extra demands
$cartHotelData[$prodKey]['extra_demands'] = $objRoomDemands->getRoomTypeDemands($product['id_product']);
$cartHotelData[$prodKey]['service_products'] = $objRoomTypeServiceProduct->getServiceProductsData($product['id_product'], 1, 0, true);
$cartHotelData[$prodKey]['service_products'] = $objRoomTypeServiceProduct->getServiceProductsData(
$product['id_product'],
1,
0,
true,
isset($context->employee->id) ? 2 : 1
);
// add hotel info of the room
if ($hotelInfo = $objHotelBranch->hotelBranchesInfo(
false,

View File

@@ -430,6 +430,8 @@ class HotelReservationSystemDb
`id_hotel` int(11) NOT NULL,
`id_htl_booking_detail` int(11) NOT NULL,
`id_product_option` int(11) NOT NULL,
`tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0',
`id_tax_rules_group` int(11) unsigned NOT NULL DEFAULT '0',
`unit_price_tax_excl` decimal(20,6) NOT NULL,
`unit_price_tax_incl` decimal(20,6) NOT NULL,
`total_price_tax_excl` decimal(20,6) NOT NULL,

View File

@@ -389,9 +389,10 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
1,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
)) {
$selectedServices = array_shift($roomServicesServices);
$totalPrice['total_price_tax_incl'] += $selectedServices['total_price_tax_incl'];
$totalPrice['total_price_tax_excl'] += $selectedServices['total_price_tax_excl'];
foreach($roomServicesServices as $selectedService) {
$totalPrice['total_price_tax_incl'] += $selectedService['total_price_tax_incl'];
$totalPrice['total_price_tax_excl'] += $selectedService['total_price_tax_excl'];
}
}
}

View File

@@ -140,7 +140,7 @@ class ServiceProductCartDetail extends ObjectModel
*/
// public function getProducts(
public function getServiceProductsInCart(
$idCart,
$idCart = 0,
$sellingPreferenceTypes = [],
$idHotel = null,
$idHotelCartBooking = null,
@@ -179,7 +179,10 @@ class ServiceProductCartDetail extends ObjectModel
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = spc.`id_hotel` AND hbil.`id_lang` = '. $language->id.')';
}
$sql .= ' WHERE spc.`id_product`!=0 AND spc.`id_cart`='.(int) $idCart;
$sql .= ' WHERE spc.`id_product`!=0 ';
if ($idCart) {
$sql .= ' AND spc.`id_cart`='.(int) $idCart;
}
if (!is_null($idProductRoomType)) {
$sql .= ' AND hcbd.`id_product`='.(int) $idProductRoomType;

View File

@@ -28,6 +28,8 @@ class ServiceProductOrderDetail extends ObjectModel
public $id_hotel;
public $id_htl_booking_detail;
public $id_product_option;
public $tax_computation_method;
public $id_tax_rules_group;
public $unit_price_tax_excl;
public $unit_price_tax_incl;
public $total_price_tax_excl;
@@ -53,6 +55,8 @@ class ServiceProductOrderDetail extends ObjectModel
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_htl_booking_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_product_option' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'tax_computation_method' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_tax_rules_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'unit_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
@@ -69,6 +73,52 @@ class ServiceProductOrderDetail extends ObjectModel
)
);
public function add($autodate = true, $null_values = true)
{
if (Validate::isLoadedObject($objOrder = new Order((int)$this->id_order))
&& Validate::isLoadedObject($objServiceProduct = new Product((int)$this->id_product))
&& Validate::isLoadedObject($objOrderDetail = new OrderDetail((int)$this->id_order_detail))
) {
if ($objOrderDetail->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) {
if ($this->id_htl_booking_detail
&& Validate::isLoadedObject($objHotelBookingDetail = new HotelBookingDetail((int)$this->id_htl_booking_detail))
) {
$idRoomType = $objHotelBookingDetail->id_product;
$objAddress = new Address((int)$objOrder->id_address_tax);
if ($objServiceProduct->auto_add_to_cart && $objServiceProduct->price_addition_type == Product::PRICE_ADDITION_TYPE_WITH_ROOM) {
if (Validate::isLoadedObject($objRoomTypeProduct = new Product((int)$idRoomType))) {
$this->id_tax_rules_group = $objRoomTypeProduct->id_tax_rules_group;
}
} else {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
if ($serviceProductPriceRoomInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
$this->id_product,
$idRoomType,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
)) {
//Special tax rule group for the Service product accroding to Room type
$this->id_tax_rules_group = $serviceProductPriceRoomInfo['id_tax_rules_group'];
} else {
// Use default tax rule group for the service product
$this->id_tax_rules_group = $objOrderDetail->id_tax_rules_group;
}
}
$taxCalculator = TaxManagerFactory::getManager($objAddress, $this->id_tax_rules_group)->getTaxCalculator();
$this->tax_computation_method = (int)$taxCalculator->computation_method;
}
} else {
// Use default tax rule group for the service product
$this->id_tax_rules_group = $objOrderDetail->id_tax_rules_group;
$this->tax_computation_method = $objOrderDetail->tax_computation_method;
}
return parent::add($autodate, $null_values);
}
return false;
}
public function getServiceProductsInOrder(
$idOrder,
$idOrderDetail = 0,

View File

@@ -214,7 +214,7 @@ class AdminAddHotelController extends ModuleAdminController
}
$smartyVars['state_var'] = $stateOptions;
$smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP');
$smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('PS_MAP_ID') && Configuration::get('WK_GOOGLE_ACTIVE_MAP');
$smartyVars['ps_img_dir'] = _PS_IMG_.'l/';
$smartyVars['PS_MAX_CHECKOUT_OFFSET'] = (int) Configuration::get('PS_MAX_CHECKOUT_OFFSET');
$smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET');
@@ -605,8 +605,8 @@ class AdminAddHotelController extends ModuleAdminController
$objHotelBranch->check_in = $check_in;
$objHotelBranch->check_out = $check_out;
$objHotelBranch->rating = $rating;
$objHotelBranch->latitude = $latitude;
$objHotelBranch->longitude = $longitude;
$objHotelBranch->latitude = Tools::ps_round($latitude, 8);
$objHotelBranch->longitude = Tools::ps_round($longitude, 8);
$objHotelBranch->map_formated_address = $map_formated_address;
$objHotelBranch->map_input_text = $map_input_text;
$objHotelBranch->save();
@@ -984,15 +984,16 @@ class AdminAddHotelController extends ModuleAdminController
'primaryHotelId' => Configuration::get('WK_PRIMARY_HOTEL'),
'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.', null, true),
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
'PS_MAP_ID' => ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
)
);
// GOOGLE MAP
$language = $this->context->language;
$country = $this->context->country;
if ($PS_API_KEY = Configuration::get('PS_API_KEY')) {
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && $PS_MAP_ID) {
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
$language->iso_code.'&region='.$country->iso_code
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places,marker&loading=async&language='.
$language->iso_code.'&region='.$country->iso_code.'&callback=initGoogleMaps'
);
}
//tinymce

View File

@@ -70,6 +70,24 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
);
$priorities = Configuration::get('HTL_FEATURE_PRICING_PRIORITY');
$hotelsArray = array();
$roomTypesArray = array();
$objHotelRoomType = new HotelRoomType();
if ($accsHlts = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1)) {
foreach ($accsHlts as $hotel) {
$addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']);
$hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city'];
}
foreach ($accsHlts as $hotel) {
if ($hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($hotel['id_hotel'], $this->context->language->id)) {
foreach ($hotelRoomTypes as $room_type) {
$roomTypesArray[$room_type['id_product']] = $room_type['room_type'].', '.$hotel['hotel_name'];
}
}
}
}
$this->context->smarty->assign('featurePricePriority', explode(';', $priorities));
$this->fields_options = array('feature_price_priority' => array());
$this->fields_list = array(
@@ -85,12 +103,19 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
'product_name' => array(
'title' => $this->l('Room Type'),
'align' => 'center',
'havingFilter' => true,
'type' => 'select',
'callback' => 'getRoomTypeLink',
'filter_key' => 'a!id_product',
'list' => $roomTypesArray,
'class' => 'chosen',
),
'hotel_name' => array(
'title' => $this->l('Hotel'),
'align' => 'center',
'type' => 'select',
'filter_key' => 'hrt!id_hotel',
'list' => $hotelsArray,
'class' => 'chosen'
),
'impact_way' => array(
'title' => $this->l('Impact Way'),
@@ -663,4 +688,50 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
}
public function ajaxProcessGetHotelRoomTypes()
{
$response = array('status' => false);
$idHotel = (int) Tools::getValue('id_hotel');
$objHotelRoomType = new HotelRoomType();
$hotelRoomTypes = array();
if ($idHotel > 0) {
if ($hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($idHotel, $this->context->language->id)) {
$objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id);
foreach ($hotelRoomTypes as &$hotelRoomType) {
$hotelRoomType['hotel_name'] = $objHotelBranchInformation->hotel_name;
}
}
} else if ($allHotelRoomTypes = $objHotelRoomType->getAllRoomTypes()) {
$hotels = array();
foreach ($allHotelRoomTypes as $hotelRoomType) {
if (!array_key_exists($hotelRoomType['id_hotel'], $hotels)) {
$hotels[$hotelRoomType['id_hotel']] = new HotelBranchInformation(
$hotelRoomType['id_hotel'],
$this->context->language->id
);
}
$objProduct = new Product($hotelRoomType['id_product'], false, $this->context->language->id);
$hotelRoomTypes[] = array(
'id_product' => $hotelRoomType['id_product'],
'room_type' => $objProduct->name,
'hotel_name' => $hotels[$hotelRoomType['id_hotel']]->hotel_name,
);
}
}
if ($hotelRoomTypes) {
$response['status'] = true;
$response['has_room_types'] = true;
$response['room_types_info'] = $hotelRoomTypes;
} else {
$response['has_room_types'] = false;
$response['status'] = true;
}
$this->ajaxDie(json_encode($response));
}
}

View File

@@ -397,6 +397,12 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
'hint' => $this->l('Unique API key for Google Maps.'),
'type' => 'text',
),
'PS_MAP_ID' => array(
'title' => $this->l('Google Map ID'),
'hint' => $this->l('Map Id for Google Maps.'),
'type' => 'text',
'desc' => $this->l('Google Maps API Key and Google Map ID is required to display Google Maps.')
),
'WK_GOOGLE_ACTIVE_MAP' => array(
'title' => $this->l('Display Google Maps For Hotel Location'),
'cast' => 'intval',
@@ -600,6 +606,9 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
if (!Tools::getValue('PS_API_KEY')) {
$this->errors[] = $this->l('Please enter Google API key.');
}
if (!Tools::getValue('PS_MAP_ID')) {
$this->errors[] = $this->l('Please enter Google Map Id.');
}
}
if (!trim(Tools::getValue('PS_SHOP_NAME'))) {
$this->errors[] = $this->l('Website name field is required');

View File

@@ -97,8 +97,16 @@ class AdminHotelFeaturesController extends ModuleAdminController
public function postProcess()
{
if (!$this->loadObject(true)) {
return;
}
if (Tools::isSubmit('submitHtlFeatures') || Tools::isSubmit('submitHtlFeaturesAndStay')) {
$parentFeatureId = Tools::getValue('id');
$conf = 3;
if ($parentFeatureId = Tools::getValue('id')) {
$conf = 4;
}
$pos = Tools::getValue('position');
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
@@ -142,9 +150,6 @@ class AdminHotelFeaturesController extends ModuleAdminController
}
}
}
if (!count($this->errors)) {
}
} else {
$this->errors[] = $this->l('Please add atleast one Child features.');
}
@@ -217,10 +222,10 @@ class AdminHotelFeaturesController extends ModuleAdminController
if (Tools::isSubmit('submitHtlFeaturesAndStay')) {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table.
'&conf=4&token='.$this->token
'&conf='.$conf.'&token='.$this->token
);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
} else {
$this->errors[] = $this->l('Some error has been occurred while saving features.');
@@ -262,10 +267,10 @@ class AdminHotelFeaturesController extends ModuleAdminController
if (Tools::isSubmit('submitHtlFeaturesAndStay')) {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table.
'&conf=4&token='.$this->token
'&conf='.$conf.'&token='.$this->token
);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
}
} else {
@@ -279,7 +284,10 @@ class AdminHotelFeaturesController extends ModuleAdminController
$this->display = 'add';
}
}
parent::postProcess();
if (empty($this->errors) || $this->ajax) {
parent::postProcess();
}
}
public function ajaxProcessDeleteFeature()

View File

@@ -285,6 +285,7 @@ class HotelReservationSystem extends Module
if (Tools::getValue('controller') == 'category') {
if (($apiKey = Configuration::get('PS_API_KEY'))
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
) {
$idCategory = Tools::getValue('id_category');
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idCategory);
@@ -299,13 +300,14 @@ class HotelReservationSystem extends Module
'longitude' => $objHotel->longitude,
'map_input_text' => $objHotel->map_input_text,
),
'PS_MAP_ID' => $PS_MAP_ID,
'hotel_name' => $objHotel->hotel_name,
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
));
$this->context->controller->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
$this->context->controller->addJS($this->getPathUri().'views/js/searchResultsMap.js');
$this->context->controller->addCSS($this->getPathUri().'views/css/searchResultsMap.css');

View File

@@ -472,10 +472,7 @@ p.room_cat_data
}
#pac-input {
background-color: #fff;
height: 38px;
width: 300px;
font-size: 14px;
text-overflow: ellipsis;
}

View File

@@ -22,17 +22,12 @@ var GoogleMapsManager = {
defaultZoom: 10,
map: null,
markers: [],
placesService: null,
placeService: null,
init: function(jQDiv) {
this.mapDiv = jQDiv;
this.geocoder = new google.maps.Geocoder();
},
setPlacesService: function() {
if (!this.placesService && this.map) {
this.placesService = new google.maps.places.PlacesService(this.map);
}
},
setDefaultLatLng: function(cb) {
if (!this.defaultLatLng) {
var latitude = Number($("#loclatitude").val());
@@ -64,6 +59,24 @@ var GoogleMapsManager = {
}
}
},
fetchFields: async function(request) {
if (!request.placeId) return;
const place = new google.maps.places.Place({
id: request.placeId
});
const fieldsRequest = {
fields: ["displayName", "formattedAddress", "location"]
};
try {
await place.fetchFields(fieldsRequest);
this.placeService = place;
return place;
} catch (error) {
console.log(error);
}
},
initMap: function(cb) {
if (!this.map) {
var that = this;
@@ -71,85 +84,26 @@ var GoogleMapsManager = {
that.map = new google.maps.Map($(that.mapDiv).get(0), {
zoom: that.defaultZoom,
clickableIcons: true,
mapId: PS_MAP_ID
});
that.map.setCenter(that.defaultLatLng);
if (that.defaultLatLng && that.formattedAddress) {
that.addMarker(that.defaultLatLng, null, that.formattedAddress);
}
that.setPlacesService();
// register marker events
that.map.addListener('click', function (e) {
var latLng = e.latLng;
var isInfoWindowNeeded = true;
// if it is a Place Of Interest (POI), event contains the property 'placeId'
if (Object.hasOwn(e, 'placeId')) {
isInfoWindowNeeded = false;
that.geocoder.geocode({ location: latLng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK && results[0]) {
var request = {
placeId: e.placeId,
fields: ['name'],
};
that.placesService.getDetails(request, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
var content = '<div><h6>' + place.name + '</h6><p>' +
results[0].formatted_address + '</p></div>';
var callback = function (latLng) {
that.setFormVars({
lat: latLng.lat(),
lng: latLng.lng(),
formattedAddress: content,
inputText: $('#pac-input').val(),
});
}
that.addMarker(
latLng,
results[0],
null,
isInfoWindowNeeded,
callback(latLng)
);
}
});
that.fetchFields({ placeId: e.placeId }).then(place => {
if (place && place.location) {
that.addMarker(place.location, null, place.formattedAddress);
}
});
} else {
that.geocoder.geocode({ location: latLng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK && results[0]) {
var request = {
placeId: results[0].place_id,
fields: ['name'],
};
that.placesService.getDetails(request, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
var content = '<div><h6>' + place.name + '</h6><p>' +
results[0].formatted_address + '</p></div>';
var callback = function (latLng) {
that.setFormVars({
lat: latLng.lat(),
lng: latLng.lng(),
formattedAddress: content,
inputText: $('#pac-input').val(),
});
}
that.addMarker(
latLng,
results[0],
null,
isInfoWindowNeeded,
callback(latLng)
);
}
});
that.geocoder.geocode({ location: latLng }, function(results, status) {
if (status === 'OK' && results[0]) {
that.addMarker(latLng, null, results[0].formatted_address);
}
});
}
@@ -163,42 +117,37 @@ var GoogleMapsManager = {
cb();
}
}
},
initAutocomplete: function(jQInput, cb) {
var that = this;
that.initMap(function() {
that.autocompleteInput = jQInput;
var input = $(that.autocompleteInput).get(0);
that.map.controls[google.maps.ControlPosition.TOP_CENTER].push(input);
that.autocomplete = new google.maps.places.Autocomplete(input);
that.autocomplete.bindTo('bounds', that.map);
that.autocomplete.addListener('place_changed', function() {
that.clearAllMarkers();
var place = that.autocomplete.getPlace();
if (place.geometry.viewport) {
that.map.fitBounds(place.geometry.viewport);
} else {
that.map.setCenter(place.geometry.location);
that.map.setZoom(18);
}
var latLng = {
lat: place.geometry.location.lat(),
lng: place.geometry.location.lng(),
};
that.addMarker(latLng, place);
var content = '<div><h6>' + place.name + '</h6><p>' + place.formatted_address + '</p></div>';
that.setFormVars({
lat: latLng.lat,
lng: latLng.lng,
formattedAddress: content,
inputText: $('#pac-input').val(),
});
that.autocomplete = new google.maps.places.PlaceAutocompleteElement({
locationRestriction: that.map.getBounds()
});
that.autocomplete.id = "place-autocomplete-input";
input.appendChild(that.autocomplete);
that.map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
that.infoWindow = new google.maps.InfoWindow({});
that.autocomplete.addEventListener("gmp-select", async (event) => {
const place = event.placePrediction.toPlace();
await place.fetchFields({
fields: ["displayName", "formattedAddress", "location", "viewport"]
});
// Fit the map to the place
if (place.viewport) {
that.map.fitBounds(place.viewport);
} else {
that.map.setCenter(place.location);
that.map.setZoom(18);
}
that.addMarker(place.location, null, place.formattedAddress);
});
google.maps.event.addDomListener(input, 'keydown', function (e) {
if (e.keyCode === 13) {
e.preventDefault();
@@ -213,11 +162,17 @@ var GoogleMapsManager = {
addMarker: function(latLng, address = null, fa = null, addInfoWindow = true, cb = null) {
var that = this;
that.clearAllMarkers();
var marker = new google.maps.Marker({
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
var marker = new google.maps.marker.AdvancedMarkerElement({
position: latLng,
map: that.map,
content: icon,
draggable: true,
icon: PS_STORES_ICON
});
that.markers.push(marker);
marker.addListener('dragend', function(e) {
@@ -237,22 +192,11 @@ var GoogleMapsManager = {
// open info window
that.addInfoWindow(marker, fa);
} else {
var request = {
placeId: address.place_id,
fields: ['name'],
};
that.placesService.getDetails(request, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
// open info window
var content = '<div><h6>' + place.name + '</h6><p>' + address.formatted_address + '</p></div>';
that.addInfoWindow(marker, content);
if(cb && typeof cb === 'function') {
cb();
}
}
});
var content = '<div><h6>' + this.placeService.displayName + '</h6><p>' + address.formatted_address + '</p></div>';
that.addInfoWindow(marker, content);
if(cb && typeof cb === 'function') {
cb();
}
}
} else {
if(cb && typeof cb === 'function') {
@@ -287,10 +231,10 @@ var GoogleMapsManager = {
that.clearAllMarkers();
});
var latLng = marker.getPosition();
var latLng = marker.position;
that.setFormVars({
lat: latLng.lat(),
lng: latLng.lng(),
lat: latLng.lat,
lng: latLng.lng,
formattedAddress: content,
inputText: $('#pac-input').val(),
});
@@ -988,8 +932,6 @@ $(document).ready(function() {
$('input[name="min_booking_offset"]').closest('.form-group').show(200);
}
});
initGoogleMaps();
});
function toggleGoogleMapsFields()

View File

@@ -28,33 +28,36 @@ function initMap() {
center: hotelLocation,
disableDefaultUI: true,
fullscreenControl: true,
mapId: PS_MAP_ID
});
const marker = new google.maps.Marker({
position: hotelLocation,
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
const marker = new google.maps.marker.AdvancedMarkerElement({
map: map,
title: hotel_name,
icon: PS_STORES_ICON
position: hotelLocation,
title: location.hotel_name,
content: icon,
});
marker.query = location.query || null;
marker.latitude = hotelLocation.lat;
marker.longitude = hotelLocation.lng;
marker.addListener('click', function() {
let query = '';
if (hotel_location.map_input_text != '') {
query = hotel_location.map_input_text;
} else {
query = hotel_location.latitude + ',' + hotel_location.longitude;
if (this.query) {
query = this.query;
} else if (this.latitude && this.longitude) {
query = `${this.latitude},${this.longitude}`;
}
window.open('https://www.google.com/maps/search/?api=1&query='+encodeURIComponent(query), '_blank');
if (query) {
window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`, '_blank');
}
});
}
$(document).ready(function() {
if (typeof hotel_location == 'object'
&& $('#search-results-wrap .map-wrap').length
&& typeof google == 'object'
&& typeof google.maps == 'object'
) {
initMap();
}
});

View File

@@ -303,7 +303,7 @@
<input type="hidden" id="loclongitude" name="loclongitude" value="{if isset($edit)}{$hotel_info.longitude|escape:'htmlall':'UTF-8'}{/if}" />
<input type="hidden" id="locformatedAddr" name="locformatedAddr" value="{if isset($edit)}{$hotel_info.map_formated_address}{/if}" />
<input type="hidden" id="googleInputField" name="googleInputField" value="{if isset($edit)}{$hotel_info.map_input_text}{/if}" />
<input id="pac-input" class="controls" type="text" placeholder="{l s='Search' mod='hotelreservationsystem'}">
<div id="pac-input" class="controls" type="text"></div>
<div id="map"></div>
</div>
</div>

View File

@@ -124,7 +124,7 @@
{/if}
{if isset($restrictions) && $restrictions}
{foreach $restrictions as $key => $restriction}
{include file="../../../_partials/feature_price_rules.tpl" key=$key advancePriceRule=$rule}
{include file="../../../_partials/feature_price_rules.tpl" key=$key}
{/foreach}
{else}
{include file="../../../_partials/feature_price_rules.tpl" key=0 collapse=true}

View File

@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,81 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{extends file="helpers/list/list_header.tpl"}
{block name="override_form_extra"}
<script>
$(document).ready(function(){
updateRoomTypeFilter();
function updateRoomTypeFilter() {
let filterInputHotelName = $('#filter_input_hotel_name');
let filterInputRoomTypeName = $('#filter_input_product_name');
let idHotel = parseInt($(filterInputHotelName).val() || '0');
$.ajax({
url: currentIndex + '&token=' + token,
data: {
ajax: true,
action: 'GetHotelRoomTypes',
id_hotel: idHotel,
},
type: 'POST',
dataType: 'JSON',
success: function(response) {
if (response.status) {
let selectedIdRoomType = parseInt($(filterInputRoomTypeName).val() || '0');
let hasSelectedRoomType = false;
if (response.has_room_types) {
let selectElem = $('<select>').append($('<option>').attr('value', '').text('-').attr('selected', true));
$(response.room_types_info).each(function(index, roomType){
$(selectElem).append($('<option>').attr('value', roomType.id_product).text(roomType.room_type + ', '+ roomType.hotel_name));
if (!hasSelectedRoomType && roomType.id_product == selectedIdRoomType) {
hasSelectedRoomType = true;
}
});
$(filterInputRoomTypeName).html($(selectElem).html());
} else {
$(filterInputRoomTypeName).find('option').not(':first').remove();
}
if (hasSelectedRoomType && selectedIdRoomType) {
$(filterInputRoomTypeName).find('option[value="'+ selectedIdRoomType+'"]').attr('selected', true);
}
// destroy current chosen and re-initialize
$(filterInputRoomTypeName).chosen('destroy');
$(filterInputRoomTypeName).chosen({
disable_search_threshold: 5,
search_contains: true,
});
}
},
});
}
// manage Hotel filter input
$(document).on('change', '#filter_input_hotel_name', function () {
updateRoomTypeFilter();
});
});
</script>
{/block}

View File

@@ -19,7 +19,11 @@
<div class="panel">
<div class="panel-heading">
<i class="icon-plus"></i>&nbsp {l s='Add New Features' mod='hotelreservationsystem'}
{if isset($edit) && $edit}
<i class="icon-edit"></i>&nbsp {l s='Edit Features' mod='hotelreservationsystem'}
{else}
<i class="icon-plus"></i>&nbsp {l s='Add New Features' mod='hotelreservationsystem'}
{/if}
</div>
<div class="panel-content">
<form id="{$table|escape:'htmlall':'UTF-8'}_form" class="defaultForm {$name_controller|escape:'htmlall':'UTF-8'} form-horizontal" action="{$current|escape:'htmlall':'UTF-8'}&{if !empty($submit_action)}{$submit_action|escape:'htmlall':'UTF-8'}{/if}&token={$token|escape:'htmlall':'UTF-8'}" method="post" enctype="multipart/form-data">

View File

@@ -310,6 +310,17 @@ class QloCleaner extends Module
foreach ($tables as $table) {
$db->execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`');
}
$objHotelBookingDocument = new HotelBookingDocument();
if ($objHotelBookingDocument->documentsBaseDir && file_exists($objHotelBookingDocument->documentsBaseDir) && ($docs = scandir($objHotelBookingDocument->documentsBaseDir))) {
foreach ($docs as $doc) {
if ($doc != '.' && $doc != '..' && $doc != 'index.php') {
if (is_dir($objHotelBookingDocument->documentsBaseDir.'/'.$doc)) {
Tools::deleteDirectory($objHotelBookingDocument->documentsBaseDir.'/'.$doc, true);
}
}
}
}
$db->execute('DELETE FROM `'._DB_PREFIX_.'address` WHERE id_customer > 0');
$db->execute('UPDATE `'._DB_PREFIX_.'employee` SET `id_last_order` = 0,`id_last_customer_message` = 0,`id_last_customer` = 0');
@@ -870,7 +881,10 @@ class QloCleaner extends Module
'htl_booking_demands',
'htl_booking_demands_tax',
'service_product_order_detail',
'service_product_cart_detail'
'service_product_cart_detail',
'order_customer_guest_detail',
'customer_guest_detail',
'cart_customer_guest'
);
}
}

View File

@@ -245,16 +245,25 @@
{/if}
{/block}
{block name='booking_form_service_product_quantity'}
{assign var='is_out_of_stock' value=false}
{assign var='max_qty_reached' value=false}
{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE}
{assign var='is_out_of_stock' value=true}
{else if $product->allow_multiple_quantity && !$product->max_quantity}
{assign var='max_qty_reached' value=true}
{/if}
{if $product->allow_multiple_quantity}
<div class="row">
<div class="form-group col-sm-6" id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
<div class="form-group col-sm-6" id="quantity_wanted_p"{if $is_out_of_stock || $max_qty_reached} style="display: none;"{/if}>
<label for="quantity_wanted_p">{l s='Quantity'}</label>
{* {block name='quantity_field'}
{include file="./quantity_field.tpl"}
{/block} *}
<div class="qty_container">
<input type="hidden" class="service_product_qty" id="service_product_qty" name="service_product_qty" data-id-product="{$product->id}" data-max_quantity="{if isset($product->max_quantity) && $product->max_quantity}{$product->max_quantity|escape:'html':'UTF-8'}{else}{$product->quantity}{/if}" value="{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}">
<input type="hidden" class="stock_qty" id="stock_qty" name="stock_qty" data-id-product="{$product->id}" data-stock_quantity="{$product->quantity}" data-allow_oosp="{$allow_oosp}" >
<input type="hidden" class="service_product_qty" id="service_product_qty" name="service_product_qty" data-id-product="{$product->id}" data-cart_quantity="{if isset($product->cart_quantity) && $product->cart_quantity}{$product->cart_quantity}{else}0{/if}" data-max_quantity="{if isset($product->max_quantity)}{$product->max_quantity|escape:'html':'UTF-8'}{else}{$product->quantity}{/if}" value="{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}">
<div class="qty_count pull-left">
<span>{if isset($quantity)}{$quantity|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}</span>
</div>
@@ -266,7 +275,7 @@
<span class="clearfix"></span>
</div>
</div>
{if $product->available_for_order}
{if !$is_out_of_stock && !$max_qty_reached}
<hr class="separator-hr-mg-10">
{/if}
{else}
@@ -301,7 +310,14 @@
{/block}
</div>
<div>
{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || (isset($restricted_country_mode) && $restricted_country_mode) || $PS_CATALOG_MODE}
{if $is_out_of_stock}
<div class="sold_out_alert">
<span>{l s='Product is out of stock!'}</span>
</div>
{else if $max_qty_reached}
<div class="sold_out_alert">
<span>{l s='Max. quantity reached for cart!'}</span>
</div>
{else}
{block name='booking_form_book_now_button'}
<p id="add_to_cart" class="buttons_bottom_block no-print">

View File

@@ -48,15 +48,6 @@ $(document).ready(function() {
});
showProductSelect($('select[name=id_order]').attr('value'));
//By Webkul JS for Map locations of the hotels on google Map
if (typeof hotelLocationArray != 'undefined'
&& $('#map').length
&& typeof google == 'object'
&& typeof google.maps == 'object'
) {
initMap();
}
});
function showProductSelect(id_order) {
@@ -75,7 +66,7 @@ function initMap() {
hotelLocationArray = JSON.parse(hotelLocationArray);
// Display a map on the page
map = new google.maps.Map(document.getElementById("map"));
map = new google.maps.Map(document.getElementById("map"), {mapId: PS_MAP_ID});
google.maps.event.trigger(map, 'resize');
map.setTilt(45);
@@ -88,14 +79,17 @@ function initMap() {
$.each(hotelLocationArray, function(i, location) {
var position = new google.maps.LatLng(location.latitude, location.longitude);
bounds.extend(position);
marker = new google.maps.Marker({
position: position,
map: map,
title: location.hotel_name,
animation: google.maps.Animation.DROP,
icon: PS_STORES_ICON
});
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
marker = new google.maps.marker.AdvancedMarkerElement({
map: map,
position: position,
title: location.hotel_name,
content: icon,
});
// Allow each marker to have an info window
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {

View File

@@ -432,6 +432,10 @@ var ajaxCart = {
resetRoomtypeServices();
if (parseInt($('#product_page_booking_product').val()) == 0) {
$('#service_product_qty').val(1);
}
BookingForm.refresh(true);
}
@@ -874,7 +878,7 @@ var ajaxCart = {
content += '</div>';
if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE
|| parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)
&& (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length)
&& (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined')
) {
content += '<div class="hotel-name">' + hotel_wise_data.hotel_name + '</div>';
}

View File

@@ -144,24 +144,36 @@ function initMap() {
center: hotelLocation,
disableDefaultUI: true,
fullscreenControl: true,
mapId: PS_MAP_ID
});
const marker = new google.maps.Marker({
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
const marker = new google.maps.marker.AdvancedMarkerElement({
position: hotelLocation,
map: map,
title: $(this).attr('title'),
icon: PS_STORES_ICON
title: location.hotel_name,
content: icon,
});
marker.query = location.query || null;
marker.latitude = hotelLocation.lat;
marker.longitude = hotelLocation.lng;
marker.addListener('click', function() {
let query = '';
if ($(this).attr('query') != '') {
query = $(this).attr('query');
} else {
query = $(this).attr('latitude') + ',' + $(this).attr('longitude');
if (this.query) {
query = this.query;
} else if (this.latitude && this.longitude) {
query = `${this.latitude},${this.longitude}`;
}
window.open('https://www.google.com/maps/search/?api=1&query='+encodeURIComponent(query), '_blank');
if (query) {
window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`, '_blank');
}
});
});
}
@@ -376,14 +388,5 @@ $(document).ready(function () {
});
initPriceTooltip();
if (typeof google === 'object'
&& typeof google.maps === 'object'
&& typeof initiateMap !== 'undefined'
&& initiateMap === 1
) {
initMap();
}
initRefundDeniedTooltip();
});

View File

@@ -21,15 +21,6 @@
*/
$(document).ready(function() {
//By Webkul JS for Map locations of the hotels on google Map
if (typeof hotelLocationArray != 'undefined'
&& $('#map').length
&& typeof google == 'object'
&& typeof google.maps == 'object'
) {
initMap();
}
$(document).on('click', 'ul.pagination li a', function(e){
e.preventDefault();
$('#pagination').val($(this).data('pagination'));
@@ -43,7 +34,7 @@ function initMap() {
hotelLocationArray = JSON.parse(hotelLocationArray);
// Display a map on the page
map = new google.maps.Map(document.getElementById("map"));
map = new google.maps.Map(document.getElementById("map"), {mapId: PS_MAP_ID});
google.maps.event.trigger(map, 'resize');
map.setTilt(45);
@@ -56,12 +47,16 @@ function initMap() {
$.each(hotelLocationArray, function(i, location) {
var position = new google.maps.LatLng(location.latitude, location.longitude);
bounds.extend(position);
marker = new google.maps.Marker({
position: position,
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
marker = new google.maps.marker.AdvancedMarkerElement({
map: map,
position: position,
title: location.hotel_name,
animation: google.maps.Animation.DROP,
icon: PS_STORES_ICON
content: icon,
});
// Allow each marker to have an info window

View File

@@ -1089,15 +1089,6 @@ $(document).ready(function() {
}
e.preventDefault();
});
if (typeof hotel_location == 'object'
&& $('#room_type_map_tab .map-wrap').length
&& typeof google == 'object'
&& typeof google.maps == 'object'
) {
initMap();
}
// normal product
$(document).on('click', '.add_roomtype_product', function(e){
e.preventDefault();
@@ -1206,13 +1197,29 @@ $(document).ready(function() {
e.preventDefault();
qtyfield = $(this).closest('.qty_container').find('input.service_product_qty');
var newQuantity = parseInt(qtyfield.val()) + 1;
if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) {
// if max quantity is reached
newQuantity = qtyfield.data('max_quantity');
showErrorMessage(max_service_product_qty_txt+' '+qtyfield.data('max_quantity'));
let hasStockError = false;
if (parseInt($('#product_page_booking_product').val()) == 0) {
let stockQty = parseInt($(this).closest('.qty_container').find('.stock_qty').data('stock_quantity'));
let allow_oosp = parseInt($(this).closest('.qty_container').find('.stock_qty').data('allow_oosp'));
if (!allow_oosp && (stockQty < newQuantity)) {
showErrorMessage(out_of_stock_text);
newQuantity = stockQty;
hasStockError = true;
}
}
if (!hasStockError) {
if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) {
// if max quantity is reached
newQuantity = qtyfield.data('max_quantity');
let cartQty = parseInt(qtyfield.data('cart_quantity'));
if (isNaN(cartQty)) {
cartQty = 0;
}
showErrorMessage(max_service_product_qty_txt+' '+ (parseInt(qtyfield.data('max_quantity')) + cartQty));
}
$(this).closest('.qty_container').find('.qty_count span').text(newQuantity);
}
$(this).closest('.qty_container').find('.qty_count span').text(newQuantity);
qtyfield.val(newQuantity);
clearTimeout(timer);
timer = setTimeout(function() {
@@ -1306,6 +1313,7 @@ function initMap() {
const map = new google.maps.Map($('#room_type_map_tab .map-wrap').get(0), {
zoom: 10,
streetViewControl: false,
mapId: PS_MAP_ID
});
const hotelLatLng = {
@@ -1314,11 +1322,14 @@ function initMap() {
};
map.setCenter(hotelLatLng);
const marker = new google.maps.Marker({
let icon = document.createElement('img');
icon.src = PS_STORES_ICON;
icon.style.width = '24px';
icon.style.height = '24px';
let marker = new google.maps.marker.AdvancedMarkerElement({
position: hotelLatLng,
map: map,
icon: PS_STORES_ICON
content: icon,
});
const uiContent = $('#room-info-map-ui-content .hotel-info-wrap').get(0);

View File

@@ -877,6 +877,7 @@
{addJsDefL name=service_removed_txt}{l s='Service removed' js=1}{/addJsDefL}
{addJsDefL name=service_updated_txt}{l s='Service updated' js=1}{/addJsDefL}
{addJsDefL name=max_service_product_qty_txt}{l s='Maximum allowed quantity in the cart is' js=1}{/addJsDefL}
{addJsDefL name=out_of_stock_text}{l s='Requested quantitity is out of stock' js=1}{/addJsDefL}
{/strip}
{/block}
{/if}