diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 12147b3d6..11e43ac75 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -44,11 +44,18 @@ {foreach $serviceProducts as $product} + {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])} + {assign var='serviceSelected' value=true} + {$product.price_tax_incl = $selectedRoomServiceProduct['selected_service'][$product['id_product']]['unit_price_tax_incl']} + {$product.price_tax_exc = $selectedRoomServiceProduct['selected_service'][$product['id_product']]['unit_price_tax_excl']} + {else} + {assign var='serviceSelected' value=false} + {/if} - + - +

{$product['name']|escape:'html':'UTF-8'}

@@ -64,9 +71,9 @@ {if $product.allow_multiple_quantity}
- + -

+

{l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity}

diff --git a/classes/Product.php b/classes/Product.php index 66c238744..29c60f73f 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3042,7 +3042,7 @@ class ProductCore extends ObjectModel public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null, $only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null, $id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, ?Context $context = null, - $use_customer_price = true, $id_hotel = false, $id_product_room_type = false, $id_group = null) + $use_customer_price = true, $id_hotel = false, $id_product_room_type = false, $id_group = null, $id_cart_booking_data = 0) { if (!$context) { $context = Context::getContext(); @@ -3177,7 +3177,8 @@ class ProductCore extends ObjectModel $id_cart, $cart_quantity, $id_hotel, - $id_product_room_type + $id_product_room_type, + $id_cart_booking_data ); return $return; @@ -3211,7 +3212,7 @@ class ProductCore extends ObjectModel **/ public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction, - $id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity = 0, $id_hotel = false, $id_product_room_type = false) + $id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity = 0, $id_hotel = false, $id_product_room_type = false, $id_cart_booking_data = 0) { static $address = null; static $context = null; @@ -3246,7 +3247,8 @@ class ProductCore extends ObjectModel $cache_id = (int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.$id_state.'-'.$zipcode.'-'.(int)$id_group. '-'.(int)$quantity.'-'.(int)$id_product_attribute. '-'.(int)$with_ecotax.'-'.(int)$id_customer.'-'.(int)$use_group_reduction.'-'.(int)$id_cart.'-'.(int)$real_quantity. - '-'.($only_reduc?'1':'0').'-'.($use_reduc?'1':'0').'-'.($use_tax?'1':'0').'-'.(int)$decimals.'-'.($id_hotel?(int)$id_hotel:'0').'-'.($id_product_option?(int)$id_product_option:'0'.'-'.($id_product_room_type?(int)$id_product_room_type:'0')); + '-'.($only_reduc?'1':'0').'-'.($use_reduc?'1':'0').'-'.($use_tax?'1':'0').'-'.(int)$decimals.'-'.($id_hotel?(int)$id_hotel:'0') + .'-'.($id_product_option?(int)$id_product_option:'0'.'-'.($id_product_room_type?(int)$id_product_room_type:'0').'-'.(int)$id_cart_booking_data); // reference parameter is filled before any returns $specific_price = SpecificPrice::getSpecificPrice( @@ -3259,7 +3261,8 @@ class ProductCore extends ObjectModel $id_product_option, $id_customer, $id_cart, - $real_quantity + $real_quantity, + $id_cart_booking_data ); if (isset(self::$_prices[$cache_id])) { @@ -6815,7 +6818,9 @@ class ProductCore extends ObjectModel $dateTo = null, $idCart = false, $idAddress = null, - $useReduc = 1 + $useReduc = 1, + $idGroup = null, + $idCartBooking = 0 ) { if ($useTax === null) { $useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true; @@ -6840,7 +6845,9 @@ class ProductCore extends ObjectModel null, true, (int)$idHotel, - (int)$idProductRoomType + (int)$idProductRoomType, + $idGroup, + $idCartBooking ); Hook::exec('actionServiceProductPricePriceModifier', @@ -6854,7 +6861,8 @@ class ProductCore extends ObjectModel 'date_to' => $dateTo, 'use_tax' => $useTax, 'id_cart' => $idCart, - 'use_reduc' => $useReduc + 'use_reduc' => $useReduc, + 'id_cart_booking_data' => $idCartBooking ) ); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index c92d6eed4..75a384de1 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -43,6 +43,7 @@ class SpecificPriceCore extends ObjectModel public $reduction_type; public $from; public $to; + public $id_cart_booking_data; /** * @see ObjectModel::$definition @@ -68,6 +69,7 @@ class SpecificPriceCore extends ObjectModel 'reduction_type' => array('type' => self::TYPE_STRING, 'validate' => 'isReductionType', 'required' => true), 'from' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), 'to' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), + 'id_cart_booking_data' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), ), ); @@ -345,7 +347,7 @@ class SpecificPriceCore extends ObjectModel } } - public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute = null, $id_customer = 0, $id_cart = 0, $real_quantity = 0, $id_room = 0) + public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute = null, $id_customer = 0, $id_cart = 0, $real_quantity = 0, $id_cart_booking_data = 0) { if (!SpecificPrice::isFeatureActive()) { return array(); @@ -355,7 +357,7 @@ class SpecificPriceCore extends ObjectModel ** The price must not change between the top and the bottom of the page */ - $key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity); + $key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity.'-'.(int) $id_cart_booking_data); if (!array_key_exists($key, SpecificPrice::$_specificPriceCache)) { $query_extra = self::computeExtraConditions($id_product, $id_product_attribute, $id_customer, $id_cart); $query = ' @@ -365,6 +367,7 @@ class SpecificPriceCore extends ObjectModel `id_shop` '.self::formatIntInQuery(0, $id_shop).' AND `id_currency` '.self::formatIntInQuery(0, $id_currency).' AND `id_country` '.self::formatIntInQuery(0, $id_country). + ' AND `id_cart_booking_data`='.(int)$id_cart_booking_data.' '. (Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= '; diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 6f0019822..91625980e 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1663,8 +1663,10 @@ class AdminCartsControllerCore extends AdminController 0, 1, 0, - $objCart->id_customer, - $objCart->id + 0, + $objCart->id, + 0, + $objHotelCartBookingData->id )) { $objSpecificPrice = new SpecificPrice($specificPriceInfo['id_specific_price']); } else { @@ -1676,12 +1678,13 @@ class AdminCartsControllerCore extends AdminController $objSpecificPrice->id_currency = $objCart->id_currency; $objSpecificPrice->id_country = 0; $objSpecificPrice->id_group = 0; - $objSpecificPrice->id_customer = $objCart->id_customer; + $objSpecificPrice->id_customer = 0; $objSpecificPrice->id_product = $idServiceProduct; $objSpecificPrice->id_product_attribute = 0; $objSpecificPrice->price = $unitPrice; $objSpecificPrice->from_quantity = 1; $objSpecificPrice->reduction = 0; + $objSpecificPrice->id_cart_booking_data = $objHotelCartBookingData->id; $objSpecificPrice->reduction_type = 'amount'; $objSpecificPrice->reduction_tax = 0; $objSpecificPrice->from = '0000-00-00 00:00:00'; diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 079d3e928..ab3b92f81 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1888,6 +1888,7 @@ CREATE TABLE `PREFIX_specific_price` ( `id_country` INT UNSIGNED NOT NULL, `id_group` INT UNSIGNED NOT NULL, `id_customer` INT UNSIGNED NOT NULL, + `id_cart_booking_data` INT UNSIGNED NOT NULL, `id_product_attribute` INT UNSIGNED NOT NULL, `price` DECIMAL(20, 6) NOT NULL, `from_quantity` mediumint(8) UNSIGNED NOT NULL, diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 7c033fe24..e5042cf80 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -237,7 +237,11 @@ class ServiceProductCartDetail extends ObjectModel $qty, $product['date_from'], $product['date_to'], - $idCart + $idCart, + null, + 1, + null, + $product['htl_cart_booking_id'] ); } else { $numDays = 1; @@ -257,7 +261,11 @@ class ServiceProductCartDetail extends ObjectModel 1, $product['date_from'], $product['date_to'], - $idCart + $idCart, + null, + 1, + null, + $product['htl_cart_booking_id'] )/$numDays; $priceTaxExcl = Product::getServiceProductPrice( $objProduct->id, @@ -268,7 +276,11 @@ class ServiceProductCartDetail extends ObjectModel 1, $product['date_from'], $product['date_to'], - $idCart + $idCart, + null, + 1, + null, + $product['htl_cart_booking_id'] )/$numDays; $optionDetails = false; @@ -527,6 +539,29 @@ class ServiceProductCartDetail extends ObjectModel return true; } + public function delete() + { + $objCart = new Cart($this->id_cart); + if ($specificPriceInfo = SpecificPrice::getSpecificPrice( + (int)$this->id_product, + 0, + $objCart->id_currency, + 0, + 0, + 1, + 0, + 0, + $objCart->id, + 0, + $this->htl_cart_booking_id + )) { + $objSpecificPrice = new SpecificPrice($specificPriceInfo['id_specific_price']); + $objSpecificPrice->delete(); + } + + return parent::delete(); + } + public static function validateServiceProductsInCart() { $context = Context::getContext(); diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index c2e24b386..29aa46dd8 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -26,7 +26,7 @@
  • {l s='Facilities'}
  • {/if} {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {l s='Services'} +
  • {l s='Services'}
  • {/if} {/block} @@ -113,13 +113,20 @@
    {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} {foreach $roomTypeServiceProducts as $product} + {if isset($cartRoom['selected_service']) && $cartRoom['selected_service'] && ($product['id_product']|array_key_exists:$cartRoom['selected_service'])} + {assign var='serviceSelected' value=true} + {$product.price_tax_incl = $cartRoom['selected_service'][$product['id_product']]['unit_price_tax_incl']} + {$product.price_tax_exc = $cartRoom['selected_service'][$product['id_product']]['unit_price_tax_excl']} + {else} + {assign var='serviceSelected' value=false} + {/if}
    {if $product.available_for_order}

    - +

    {/if}
    @@ -127,8 +134,8 @@

    {$product['name']|escape:'html':'UTF-8'}

    {if $product.allow_multiple_quantity}
    - - + +