Fixed: issues after conflict resolve
This commit is contained in:
@@ -47,10 +47,10 @@
|
||||
<tbody>
|
||||
{if isset($additionalServices) && $additionalServices}
|
||||
{foreach $additionalServices['additional_services'] as $service}
|
||||
<tr class="room_demand_block" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}">
|
||||
<tr class="room_demand_block" data-id_service_product_order_detail="{$service['id_service_product_order_detail']}">
|
||||
<td>
|
||||
<div>{$service['name']|escape:'html':'UTF-8'}</div>
|
||||
<input value="{$service['id_room_type_service_product_order_detail']|escape:'html':'UTF-8'}" name="id_room_type_service_product_order_detail[]" type="hidden"/>
|
||||
<input value="{$service['id_service_product_order_detail']|escape:'html':'UTF-8'}" name="id_service_product_order_detail[]" type="hidden"/>
|
||||
</td>
|
||||
<td>
|
||||
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
|
||||
@@ -63,7 +63,7 @@
|
||||
<td class="text-center">
|
||||
{if $service['allow_multiple_quantity']}
|
||||
<div class="qty_container">
|
||||
<input type="number" class="form-control qty" min="1" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}" name="service_qty[{$service['id_room_type_service_product_order_detail']|escape:'html':'UTF-8'}]">
|
||||
<input type="number" class="form-control qty" min="1" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}" name="service_qty[{$service['id_service_product_order_detail']|escape:'html':'UTF-8'}]">
|
||||
{if $service['max_quantity']}
|
||||
<p style="display:{if $service['quantity'] > $service['max_quantity']}block{else}none{/if}; margin-top: 4px;">
|
||||
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$service['max_quantity']}</span>
|
||||
@@ -77,7 +77,7 @@
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{$currencySign}</span>
|
||||
<input type="text" class="form-control unit_price" value="{Tools::ps_round($service['unit_price_tax_excl'], 2)}" data-id-product="{$service['id_product']}" name="service_price[{$service['id_room_type_service_product_order_detail']}]">
|
||||
<input type="text" class="form-control unit_price" value="{Tools::ps_round($service['unit_price_tax_excl'], 2)}" data-id-product="{$service['id_product']}" name="service_price[{$service['id_service_product_order_detail']}]">
|
||||
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $service.product_price_calculation_method}
|
||||
<span class="input-group-addon">{l s='/ night'}</span>
|
||||
{/if}
|
||||
@@ -87,7 +87,7 @@
|
||||
{/if} *}
|
||||
</td>
|
||||
<td>{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}</td>
|
||||
<td class="text-right"><a class="btn btn-danger pull-right del_room_additional_service" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" href="#"><i class="icon-trash"></i></a></td>
|
||||
<td class="text-right"><a class="btn btn-danger pull-right del_room_additional_service" data-id_service_product_order_detail="{$service['id_service_product_order_detail']}" href="#"><i class="icon-trash"></i></a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{else}
|
||||
|
||||
@@ -317,7 +317,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
$formattedHotelAddress = '';
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
$obj_htl_bk_dtl = new HotelBookingDetail();
|
||||
$obj_rm_type = new HotelRoomType();
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
|
||||
$objHotelBranchInfo = new HotelBranchInformation((int) HotelBookingDetail::getIdHotelByIdOrder($order_obj->id), $this->context->language->id);
|
||||
$invoiceAddressPatternRules['avoid'][] = 'lastname';
|
||||
@@ -520,7 +519,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['total_price_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
@@ -533,7 +532,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order_obj->id,
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -1151,35 +1151,54 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idRoom
|
||||
)) {
|
||||
$selectedRoomServiceProduct['selected_service'] = $objServiceProductCartDetail->getServiceProductsInCart(
|
||||
$idCart,
|
||||
[],
|
||||
null,
|
||||
$selectedRoomServiceProduct['id'],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
}
|
||||
|
||||
if ($serviceProducts) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice(
|
||||
$servProduct['id_product'],
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
1
|
||||
0,
|
||||
$idProduct,
|
||||
false,
|
||||
1,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idCart
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idRoom
|
||||
)) {
|
||||
$selectedRoomServiceProduct['selected_service'] = $objServiceProductCartDetail->getServiceProductsInCart(
|
||||
$idCart,
|
||||
[],
|
||||
null,
|
||||
$selectedRoomServiceProduct['id'],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
$objCart = new Cart($idCart);
|
||||
$cartCurrency = new Currency($objCart->id_currency);
|
||||
$taxRulesGroups = TaxRulesGroup::getTaxRulesGroups(true);
|
||||
@@ -1224,65 +1243,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateServiceProduct()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$operator = Tools::getValue('operator', 'up');
|
||||
$idServiceProduct = Tools::getValue('id_product');
|
||||
$idCartBooking = Tools::getValue('id_cart_booking');
|
||||
$qty = Tools::getValue('qty');
|
||||
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
if ($operator == 'up') {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) {
|
||||
// validate quanitity
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) {
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!Validate::isUnsignedInt($qty)) {
|
||||
$this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.');
|
||||
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
|
||||
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
|
||||
}
|
||||
} else {
|
||||
$qty = 1;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This Service is not available.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This Service is not available with selected room.');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
$idServiceProduct,
|
||||
$qty,
|
||||
$objHotelCartBookingData->id_cart,
|
||||
$operator
|
||||
)) {
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => false
|
||||
)));
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
|
||||
}
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
@@ -1406,7 +1366,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
// ======= START: Create Service product =========
|
||||
$objServiceProduct = new Product();
|
||||
$objServiceProduct->price_calculation_method = $priceCalcMethod;
|
||||
$objServiceProduct->service_product_type = Product::SERVICE_PRODUCT_WITH_ROOMTYPE;
|
||||
$objServiceProduct->selling_preference_type = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE;
|
||||
$objServiceProduct->id_category_default = Configuration::get('PS_SERVICE_CATEGORY');
|
||||
$objServiceProduct->name[Configuration::get('PS_LANG_DEFAULT')] = $name;
|
||||
$objServiceProduct->id_shop_default = Configuration::get('PS_SHOP_DEFAULT');
|
||||
@@ -1432,15 +1392,22 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
// ======= Create Service product END =========
|
||||
if ($objServiceProduct->save()) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objRoomTypeServiceProduct->addRoomProductLink(
|
||||
$objServiceProduct->id,
|
||||
[$objHtlCartBooking->id_product],
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
// If service product is create successfully the start adding the product in cart and order
|
||||
$objCart = new Cart($objHtlCartBooking->id_cart);
|
||||
$objServiceProduct = new Product($objServiceProduct->id, false, $objCart->id_lang);
|
||||
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
if ($objServiceProductCartDetail->addServiceProductInCart(
|
||||
$objCart->id,
|
||||
$objServiceProduct->id,
|
||||
$productQty,
|
||||
$objCart->id,
|
||||
0,
|
||||
$objHtlCartBooking->id
|
||||
)) {
|
||||
// Lets create a specific price for the service to match the price provided by the user
|
||||
@@ -1499,7 +1466,9 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($objCartBookingData->id_product, 1, 0, false, 2, null);
|
||||
@@ -1508,27 +1477,30 @@ class AdminCartsControllerCore extends AdminController
|
||||
if ($serviceProducts) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $servProduct['price'];
|
||||
if ($additionalServices
|
||||
&& (in_array($servProduct['id_product'], array_column($additionalServices['additional_services'], 'id_product')))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objCartBookingData->id_cart,
|
||||
$objCartBookingData->id_product,
|
||||
$objCartBookingData->date_from,
|
||||
$objCartBookingData->date_to,
|
||||
$objCartBookingData->id_room
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$selectedRoomServiceProduct['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts(
|
||||
$selectedRoomServiceProduct['selected_service'] = $objServiceProductCartDetail->getServiceProductsInCart(
|
||||
$objCartBookingData->id_cart,
|
||||
[],
|
||||
null,
|
||||
$selectedRoomServiceProduct['id'],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1597,7 +1569,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
if (!$response['hasError']) {
|
||||
$result = true;
|
||||
$objRoomTypeServiceProductCart = new RoomTypeServiceProductCartDetail();
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
foreach ($selectedServiceProducts as $idServiceProduct => $selected) {
|
||||
if ($selected) {
|
||||
$operator = 'up';
|
||||
@@ -1606,12 +1578,13 @@ class AdminCartsControllerCore extends AdminController
|
||||
}
|
||||
$quantity = $serviceQuantities[$idServiceProduct];
|
||||
$unitPrice = $serviceUnitPrices[$idServiceProduct];
|
||||
if ($result &= $objRoomTypeServiceProductCart->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
$idServiceProduct,
|
||||
$quantity,
|
||||
if ($result &= $objServiceProductCartDetail->updateCartServiceProduct(
|
||||
$objHotelCartBookingData->id_cart,
|
||||
$idServiceProduct,
|
||||
$operator,
|
||||
$quantity,
|
||||
0,
|
||||
$idCartBooking
|
||||
)) {
|
||||
$originalPrice = Product::getPriceStatic($idServiceProduct, false);
|
||||
// if price is different than the original service price then update the price
|
||||
|
||||
@@ -977,17 +977,21 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
}
|
||||
|
||||
if ($serviceProducts) {
|
||||
if (isset($additionalServices[$productLineData['id']]) && $additionalServices[$productLineData['id']]) {
|
||||
if ($additionalServices) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $servProduct['price'];
|
||||
if (in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product'))) {
|
||||
if (isset($additionalServices[$productLineData['id']])
|
||||
&& in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product'))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
}
|
||||
}
|
||||
@@ -5981,7 +5985,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->save();
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice)) {
|
||||
if (isset($order_invoice) && $order_invoice instanceof OrderInvoice) {
|
||||
$order_invoice->total_products = $order_invoice->total_paid_tax_excl;
|
||||
$order_invoice->total_products_wt = $order_invoice->total_paid_tax_incl;
|
||||
$res &= $order_invoice->update();
|
||||
@@ -6290,8 +6294,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$res &= $order_detail->update();
|
||||
}
|
||||
// update order detail for selected aditional services
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
foreach ($selectedAdditonalServices['additional_services'] as $service) {
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
foreach ($selectedAdditonalServices as $service) {
|
||||
$serviceOrderDetail = new OrderDetail($service['id_order_detail']);
|
||||
|
||||
$cart_quantity = $service['quantity'];
|
||||
@@ -6313,14 +6317,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if (isset($roomHtlCartInfo['id'])) {
|
||||
if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
if ($idServiceProductCartDetail = $objServiceProductCartDetail->alreadyExists(
|
||||
$service['id_product'],
|
||||
$service['id_cart'],
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypServiceProductCartDetail);
|
||||
$serviceQuantity = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail((int) $idServiceProductCartDetail);
|
||||
$serviceQuantity = $objServiceProductCartDetail->quantity;
|
||||
if ($objServiceProductCartDetail->delete()
|
||||
&& Validate::isLoadedObject(new Product((int) $service['id_product']))
|
||||
) {
|
||||
$objCart = new Cart($service['id_cart']);
|
||||
@@ -7133,7 +7137,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$serviceProducts = $objProduct->getServiceProducts(true);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
@@ -7697,7 +7703,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
// ======= START: Create Service product =========
|
||||
$objServiceProduct = new Product();
|
||||
$objServiceProduct->price_calculation_method = $priceCalcMethod;
|
||||
$objServiceProduct->service_product_type = Product::SERVICE_PRODUCT_WITH_ROOMTYPE;
|
||||
$objServiceProduct->selling_preference_type = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE;
|
||||
$objServiceProduct->id_category_default = Configuration::get('PS_SERVICE_CATEGORY');
|
||||
$objServiceProduct->name[Configuration::get('PS_LANG_DEFAULT')] = $name;
|
||||
$objServiceProduct->id_shop_default = Configuration::get('PS_SHOP_DEFAULT');
|
||||
@@ -7743,11 +7749,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
// set context currency So that we can get prices in the order currency
|
||||
$this->context->currency = new Currency($objOrder->id_currency);
|
||||
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
if ($objServiceProductCartDetail->addServiceProductInCart(
|
||||
$objCart->id,
|
||||
$objServiceProduct->id,
|
||||
$productQty,
|
||||
$objCart->id,
|
||||
0,
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
if ($productList = $objCart->getProducts()) {
|
||||
@@ -7764,9 +7771,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
foreach ($productList as &$product) {
|
||||
// This is used to get the actual quanity of the service as it is calculated incorrectly if the service is per night
|
||||
if ($idRoomTypeServProductCart = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$product['id_product'],
|
||||
if ($idRoomTypeServProductCart = $objServiceProductCartDetail->alreadyExists(
|
||||
$objCart->id,
|
||||
$product['id_product'],
|
||||
$roomHtlCartInfo['id'])
|
||||
) {
|
||||
// Lets create a specific price for the service to match the price provided by the user
|
||||
@@ -7788,36 +7795,39 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objSpecificPrice->from = '0000-00-00 00:00:00';
|
||||
$objSpecificPrice->to = '0000-00-00 00:00:00';
|
||||
if ($objSpecificPrice->add()) {
|
||||
if (Validate::isLoadedObject($objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypeServProductCart))) {
|
||||
$unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
if (Validate::isLoadedObject($objServiceProductCartDetail = new ServiceProductCartDetail((int) $idRoomTypeServProductCart))) {
|
||||
$unitPriceTaxExcl = Product::getServiceProductPrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$roomHtlCartInfo['id_hotel'],
|
||||
$roomHtlCartInfo['id_product'],
|
||||
false,
|
||||
1,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
false,
|
||||
$objCart->id
|
||||
) / $numDays;
|
||||
|
||||
$unitPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
$unitPriceTaxExcl = Product::getServiceProductPrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$roomHtlCartInfo['id_hotel'],
|
||||
$roomHtlCartInfo['id_product'],
|
||||
true,
|
||||
1,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
true,
|
||||
$objCart->id
|
||||
) / $numDays;
|
||||
|
||||
$totalPriceChangeTaxExcl += $totalPriceTaxExcl = Tools::processPriceRounding(
|
||||
($unitPriceTaxExcl * $numDays),
|
||||
$objRoomTypeServiceProductCartDetail->quantity,
|
||||
$objServiceProductCartDetail->quantity,
|
||||
$objOrder->round_type,
|
||||
$objOrder->round_mode
|
||||
);
|
||||
$totalPriceChangeTaxIncl += $totalPriceTaxIncl = Tools::processPriceRounding(
|
||||
($unitPriceTaxIncl * $numDays),
|
||||
$objRoomTypeServiceProductCartDetail->quantity,
|
||||
$objServiceProductCartDetail->quantity,
|
||||
$objOrder->round_type,
|
||||
$objOrder->round_mode
|
||||
);
|
||||
@@ -7849,20 +7859,20 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$orderDetail->createList($objOrder, $objCart, $objOrder->getCurrentOrderState(), $productList, (isset($objOrderInvoice) ? $objOrderInvoice->id : 0), true);
|
||||
|
||||
// Add in room type service product order detail
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $objServiceProduct->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $objHotelBookingDetail->id_order;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $orderDetail->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $objCart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_htl_booking_detail = $objHotelBookingDetail->id;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl;
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $totalPriceTaxExcl;
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $totalPriceTaxIncl;
|
||||
$objRoomTypeServiceProductOrderDetail->name = $name;
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = $productQty;
|
||||
$objRoomTypeServiceProductOrderDetail->auto_added = $autoAdded;
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
|
||||
$objServiceProductOrderDetail->id_product = $objServiceProduct->id;
|
||||
$objServiceProductOrderDetail->id_order = $objHotelBookingDetail->id_order;
|
||||
$objServiceProductOrderDetail->id_order_detail = $orderDetail->id;
|
||||
$objServiceProductOrderDetail->id_cart = $objCart->id;
|
||||
$objServiceProductOrderDetail->id_htl_booking_detail = $objHotelBookingDetail->id;
|
||||
$objServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl;
|
||||
$objServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl;
|
||||
$objServiceProductOrderDetail->total_price_tax_excl = $totalPriceTaxExcl;
|
||||
$objServiceProductOrderDetail->total_price_tax_incl = $totalPriceTaxIncl;
|
||||
$objServiceProductOrderDetail->name = $name;
|
||||
$objServiceProductOrderDetail->quantity = $productQty;
|
||||
$objServiceProductOrderDetail->auto_added = $autoAdded;
|
||||
$objServiceProductOrderDetail->save();
|
||||
|
||||
// update totals amount of order
|
||||
$objOrder->total_products = Tools::ps_round((float)($objOrder->total_products + $totalPriceChangeTaxExcl), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
@@ -7954,16 +7964,16 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response = array('hasError' => false);
|
||||
// Check tab access is allowed to edit
|
||||
if ($this->tabAccess['edit'] == 1) {
|
||||
$idRoomTypeServiceProductOrderDetail = Tools::getValue('id_room_type_service_product_order_detail');
|
||||
if (Validate::isLoadedObject($objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($idRoomTypeServiceProductOrderDetail))) {
|
||||
$objOrderDetail = new OrderDetail($objRoomTypeServiceProductOrderDetail->id_order_detail);
|
||||
$priceTaxExcl = $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
|
||||
$priceTaxIncl = $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
|
||||
$quantity = $objRoomTypeServiceProductOrderDetail->quantity;
|
||||
$idServiceProductOrderDetail = Tools::getValue('id_service_product_order_detail');
|
||||
if (Validate::isLoadedObject($objServiceProductOrderDetail = new ServiceProductOrderDetail($idServiceProductOrderDetail))) {
|
||||
$objOrderDetail = new OrderDetail($objServiceProductOrderDetail->id_order_detail);
|
||||
$priceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl;
|
||||
$priceTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl;
|
||||
$quantity = $objServiceProductOrderDetail->quantity;
|
||||
$res = true;
|
||||
$objHotelBookingDetail = new HotelBookingDetail($objRoomTypeServiceProductOrderDetail->id_htl_booking_detail);
|
||||
$objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail);
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
|
||||
if ($roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objHotelBookingDetail->id_cart,
|
||||
@@ -7972,24 +7982,24 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objHotelBookingDetail->date_to,
|
||||
$objHotelBookingDetail->id_room
|
||||
)) {
|
||||
if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$objRoomTypeServiceProductOrderDetail->id_product,
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart,
|
||||
if ($idServiceProductCartDetail = $objServiceProductCartDetail->alreadyExists(
|
||||
$objServiceProductOrderDetail->id_cart,
|
||||
$objServiceProductOrderDetail->id_product,
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($idRoomTypServiceProductCartDetail);
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail($idServiceProductCartDetail);
|
||||
if ($objServiceProductCartDetail->delete()
|
||||
// Since the service product is deleted after adding them directly from the order the cart will throw exception on the service delete process.
|
||||
&& Validate::isLoadedObject(new Product($objRoomTypeServiceProductOrderDetail->id_product))
|
||||
&& Validate::isLoadedObject(new Product($objServiceProductOrderDetail->id_product))
|
||||
) {
|
||||
$objCart = new Cart($objRoomTypeServiceProductOrderDetail->id_cart);
|
||||
$objCart->updateQty((int) abs($quantity), $objRoomTypeServiceProductOrderDetail->id_product, null, false, 'down');
|
||||
$objCart = new Cart($objServiceProductOrderDetail->id_cart);
|
||||
$objCart->updateQty((int) abs($quantity), $objServiceProductOrderDetail->id_product, null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($res &= $objRoomTypeServiceProductOrderDetail->delete()) {
|
||||
$order = new Order($objRoomTypeServiceProductOrderDetail->id_order);
|
||||
if ($res &= $objServiceProductOrderDetail->delete()) {
|
||||
$order = new Order($objServiceProductOrderDetail->id_order);
|
||||
if ($quantity >= $objOrderDetail->product_quantity) {
|
||||
$objOrderDetail->delete();
|
||||
} else {
|
||||
|
||||
@@ -385,7 +385,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$objProduct = new Product();
|
||||
$allServiceProducts = $objProduct->getServiceProducts();
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
$serviceProducts = array();
|
||||
foreach ($allServiceProducts as $serviceProduct) {
|
||||
$serviceProducts[$serviceProduct['id_product']] = $serviceProduct['name'];
|
||||
@@ -3106,9 +3108,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
$objRoomType = new HotelRoomType();
|
||||
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) {
|
||||
$serviceProductsWithHtlRt = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$serviceProductsWithRt = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$allServiceProducts = array_merge($serviceProductsWithRt, $serviceProductsWithHtlRt);
|
||||
$hotelServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
|
||||
@@ -485,7 +485,7 @@ class ServiceProductCartDetail extends ObjectModel
|
||||
$controllerType = 'front';
|
||||
}
|
||||
if ($controllerType == 'admin' || $controllerType == 'moduleadmin') {
|
||||
if ($cartQty = Cart::getProductQtyInCart($idCart, $product['id_product '])) {
|
||||
if ($cartQty = Cart::getProductQtyInCart($idCart, (int) $product['id_product'])) {
|
||||
if ($removedQuantity < $cartQty) {
|
||||
$res &= Db::getInstance()->update(
|
||||
'cart_product',
|
||||
|
||||
@@ -265,16 +265,16 @@ class ServiceProductOrderDetail extends ObjectModel
|
||||
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
|
||||
}
|
||||
|
||||
$sql = 'SELECT rsod.*';
|
||||
$sql = 'SELECT spod.*';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`, p.`max_quantity`,
|
||||
od.`product_auto_add`, od.`product_price_calculation_method`, od.`product_price_addition_type`';
|
||||
}
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
|
||||
INNER JOIN `'._DB_PREFIX_.'service_product_order_detail` spod ON(spod.`id_htl_booking_detail` = hbd.`id`)';
|
||||
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = rsod.`id_order_detail`)';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rsod.`id_product`)';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = spod.`id_order_detail`)';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = spod.`id_product`)';
|
||||
|
||||
$sql .= ' WHERE hbd.`id` = '.(int)$idHotelBookingDetail;
|
||||
|
||||
@@ -309,7 +309,7 @@ class ServiceProductOrderDetail extends ObjectModel
|
||||
$selectedAdditionalServices['total_price_tax_excl'] += $product['total_price_tax_excl'];
|
||||
$selectedAdditionalServices['total_price_tax_incl'] += $product['total_price_tax_incl'];
|
||||
$selectedAdditionalServices['additional_services'][] = array(
|
||||
'id_room_type_service_product_order_detail' => $product['id_room_type_service_product_order_detail'],
|
||||
'id_service_product_order_detail' => $product['id_service_product_order_detail'],
|
||||
'id_order_detail' => $product['id_order_detail'],
|
||||
'id_product' => $product['id_product'],
|
||||
'name' => $product['name'],
|
||||
@@ -336,7 +336,7 @@ class ServiceProductOrderDetail extends ObjectModel
|
||||
$selectedAdditionalServices['id_room'] = $product['id_room'];
|
||||
$selectedAdditionalServices['additional_services'] = array(
|
||||
array(
|
||||
'id_room_type_service_product_order_detail' => $product['id_room_type_service_product_order_detail'],
|
||||
'id_service_product_order_detail' => $product['id_service_product_order_detail'],
|
||||
'id_order_detail' => $product['id_order_detail'],
|
||||
'id_product' => $product['id_product'],
|
||||
'name' => $product['name'],
|
||||
|
||||
@@ -695,8 +695,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
|
||||
$opt = Tools::getValue('opt'); // if 1 then add quantity or if 0 means delete quantity
|
||||
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
$num_day = $obj_booking_dtl->getNumberOfDays($date_from, $date_to); //quantity of product
|
||||
$num_day = HotelHelper::getNumberOfDays($date_from, $date_to); //quantity of product
|
||||
|
||||
if ($opt) {
|
||||
$unit_price = Product::getPriceStatic(
|
||||
|
||||
@@ -870,10 +870,7 @@ class QloCleaner extends Module
|
||||
'htl_booking_demands',
|
||||
'htl_booking_demands_tax',
|
||||
'service_product_order_detail',
|
||||
'service_product_cart_detail',
|
||||
'htl_room_type_service_product_order_detail',
|
||||
'htl_room_type_service_product_cart_detail',
|
||||
'htl_hotel_service_product_cart_detail',
|
||||
'service_product_cart_detail'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1334,7 +1334,9 @@ var BookingForm = {
|
||||
width: '100%',
|
||||
});
|
||||
this.currentRequest = null;
|
||||
BookingForm.initDatepicker(max_order_date, min_booking_offset, $('#room_check_in').val(), $('#room_check_out').val());
|
||||
if (parseInt($('#product_page_booking_product').val())) {
|
||||
BookingForm.initDatepicker(max_order_date, min_booking_offset, $('#room_check_in').val(), $('#room_check_out').val());
|
||||
}
|
||||
// initialize tootltip for extra service
|
||||
if ($('.price_desc_block .services-info').length) {
|
||||
$('.price_desc_block .services-info img').tooltip({
|
||||
@@ -1417,9 +1419,6 @@ var BookingForm = {
|
||||
$("#room_date_range").off("datepicker-change");
|
||||
}
|
||||
|
||||
if (max_order_date) {
|
||||
max_order_date = $.datepicker.formatDate('dd-mm-yy', max_order_date);
|
||||
}
|
||||
$('#room_date_range').dateRangePicker({
|
||||
endDate: max_order_date,
|
||||
startDate: start_date,
|
||||
|
||||
Reference in New Issue
Block a user