diff --git a/classes/order/Order.php b/classes/order/Order.php index 6949bfec5..79ba75e60 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -586,8 +586,12 @@ class OrderCore extends ObjectModel return self::$_historyCache[$this->id.'_'.$id_order_state.'_'.$filters]; } - public function getProductsDetail($is_booking = null, $product_service_type = null) - { + public function getProductsDetail( + $is_booking = null, + $product_service_type = null, + $product_auto_add = null, + $product_price_addition_type = null + ) { $sql = 'SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) @@ -598,6 +602,12 @@ class OrderCore extends ObjectModel if (!$is_booking && $product_service_type !== null) { $sql .= ' AND od.`product_service_type` = '. (int)$product_service_type; } + if (!$is_booking && $product_service_type == Product::SERVICE_PRODUCT_WITH_ROOMTYPE && $product_auto_add !== null) { + $sql .= ' AND od.`product_auto_add` = '. (int)$product_auto_add; + } + if (!$is_booking && $product_service_type == Product::SERVICE_PRODUCT_WITH_ROOMTYPE && $product_auto_add == 1 && $product_price_addition_type !== null) { + $sql .= ' AND od.`product_price_addition_type` = '. (int)$product_price_addition_type; + } } return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } @@ -1063,11 +1073,16 @@ class OrderCore extends ObjectModel * * @return Product total without taxes */ - public function getTotalProductsWithoutTaxes($products = false, $bookingProducts = null, $product_service_type = null) - { + public function getTotalProductsWithoutTaxes( + $products = false, + $bookingProducts = null, + $product_service_type = null, + $product_auto_add = null, + $product_price_addition_type = null + ) { // update if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $product_service_type); + $products = $this->getProductsDetail($bookingProducts, $product_service_type, $product_auto_add, $product_price_addition_type); } $return = 0; @@ -1083,11 +1098,16 @@ class OrderCore extends ObjectModel * * @return Product total with taxes */ - public function getTotalProductsWithTaxes($products = false, $bookingProducts = null, $product_service_type = null) - { + public function getTotalProductsWithTaxes( + $products = false, + $bookingProducts = null, + $product_service_type = null, + $product_auto_add = null, + $product_price_addition_type = null + ) { /* Retro-compatibility (now set directly on the validateOrder() method) */ if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $product_service_type); + $products = $this->getProductsDetail($bookingProducts, $product_service_type, $product_auto_add, $product_price_addition_type); } $return = 0; diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 300367e9f..236780c7d 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -324,8 +324,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $room_extra_demands = array(); $room_additinal_services = array(); - $totalConvenienceFeeTE = 0; - $totalConvenienceFeeTI = 0; $totalDemandsPriceTE = 0; $totalDemandsPriceTI = 0; foreach ($order_details as $type_key => $type_value) { @@ -504,32 +502,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 1, 0 ); - $totalConvenienceFeeTI += $cart_htl_data[$type_key]['date_diff'][$date_join]['convenience_fee_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order_obj->id, - 0, - 0, - $data_v['id_product'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT - ); - $totalConvenienceFeeTE += $cart_htl_data[$type_key]['date_diff'][$date_join]['convenience_fee_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order_obj->id, - 0, - 0, - $data_v['id_product'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT - ); + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( $order_obj->id, 0, @@ -636,16 +609,16 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate // enter extra demands price to the footer total details $footer['total_extra_demands_ti'] = $totalDemandsPriceTI; $footer['total_extra_demands_te'] = $totalDemandsPriceTE; - $footer['total_convenience_fee_ti'] = $totalConvenienceFeeTI; - $footer['total_convenience_fee_te'] = $totalConvenienceFeeTE; } } - $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true); - $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true); - $footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE); - $footer['service_products_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE); - $footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $totalDemandsPriceTE; - $footer['additional_service_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $totalDemandsPriceTI; + $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + // $footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE); + // $footer['service_products_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE); + $footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0) + $totalDemandsPriceTE; + $footer['additional_service_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0) + $totalDemandsPriceTI; + $footer['total_convenience_fee_te'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $footer['total_convenience_fee_ti'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); $data = array( 'cart_htl_data' => $cart_htl_data, 'service_product_data' => $service_product_data, diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index 53bd5a8a0..b1917b305 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -63,19 +63,21 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $objRoomTypeServiceProductCartDetail->id_cart = $idCart; } - $updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity; + if ($updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity) { + if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { + $objHotelCartBookingData = new HotelCartBookingData($idHtlCartData); + $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); + $updateQty *= $numdays; - if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $objHotelCartBookingData = new HotelCartBookingData($idHtlCartData); - $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); - $updateQty *= $numdays; - - } - $way = $updateQty > 0 ? 'up' : 'down'; - $objRoomTypeServiceProductCartDetail->quantity = $quantity; - if ($objRoomTypeServiceProductCartDetail->save()) { - $objCart = new Cart($idCart); - return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way); + } + $way = $updateQty > 0 ? 'up' : 'down'; + $objRoomTypeServiceProductCartDetail->quantity = $quantity; + if ($objRoomTypeServiceProductCartDetail->save()) { + $objCart = new Cart($idCart); + return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way); + } + } else { + return true; } return false; diff --git a/pdf/invoice.total-tab.tpl b/pdf/invoice.total-tab.tpl index 748cfbc77..2f70c1267 100644 --- a/pdf/invoice.total-tab.tpl +++ b/pdf/invoice.total-tab.tpl @@ -38,7 +38,7 @@ {l s='Extra Services Cost (tax excl.)' pdf='true'} - {displayPrice currency=$order->id_currency price=($footer.additional_service_price_tax_excl - $footer.total_convenience_fee_te)} + {displayPrice currency=$order->id_currency price=($footer.additional_service_price_tax_excl)} {/if} @@ -52,6 +52,16 @@ {/if} + {if $footer.product_discounts_tax_excl > 0} + + + {l s='Total Discounts' pdf='true'} + + + - {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_excl} + + + {/if} {* {if isset($footer.product_taxes) && $footer.product_taxes} @@ -92,6 +102,7 @@ {/if} *} + {l s='Total (Tax excl.)' pdf='true'} @@ -110,16 +121,7 @@ {/if} - {if $footer.product_discounts_tax_excl > 0} - - - {l s='Total Discounts' pdf='true'} - - - - {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_excl} - - - {/if} + diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index bc79fef42..0649a68dd 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -509,8 +509,14 @@ $(document).ready(function() var newQuantity = parseInt(qtyfield.val()) + 1; if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) { newQuantity = qtyfield.data('max_quantity'); - } - qtyfield.val(newQuantity).trigger('focusout'); + if (qtyfield.val() != qtyfield.data('max_quantity')) { + qtyfield.trigger('focusout'); + } else { + showErrorMessage(txtMaxQuantityAdded); + } + } else { + qtyfield.val(newQuantity).trigger('focusout'); + } }); $(document).on('click', '#rooms_extra_services .qty_down', function(e) { @@ -520,7 +526,10 @@ $(document).ready(function() if (!isNaN(currentVal) && currentVal > 1) { qtyfield.val(currentVal - 1).trigger('focusout'); } else { - qtyfield.val(1).trigger('focusout'); + qtyfield.val(1); + if (currentVal != 1) { + qtyfield.trigger('focusout'); + } } }); diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index bf1139758..c3ee9ae7f 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1255,7 +1255,11 @@ $(document).ready(function() { $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); if (result.msg) { - showSuccessMessage(result.msg); + if (result.add) { + showSuccessMessage(result.msg); + } else { + showErrorMessage(result.msg); + } } BookingForm.refresh(); } else { diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index f63d65626..8cdc91e23 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -506,6 +506,7 @@ {capture}{l s='Update' js=1}{/capture} {addJsDefL name=liUpdate}{$smarty.capture.default|@addcslashes:'\''}{/addJsDefL} {addJsDefL name=txtExtraDemandSucc}{l s='Updated Successfully' js=1}{/addJsDefL} + {addJsDefL name=txtMaxQuantityAdded}{l s='Maximum quantity of service added' js=1}{/addJsDefL} {addJsDefL name=txtExtraDemandErr}{l s='Some error occurred while updating demands' js=1}{/addJsDefL} {/strip} {/if}