Merge branch 'webkul:develop' into update-demo-data

This commit is contained in:
abhishek-webkul
2023-04-14 21:00:29 +05:30
committed by GitHub
7 changed files with 82 additions and 71 deletions

View File

@@ -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;

View File

@@ -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,

View File

@@ -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;

View File

@@ -38,7 +38,7 @@
{l s='Extra Services Cost (tax excl.)' pdf='true'}
</td>
<td class="white" width="30%">
{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)}
</td>
</tr>
{/if}
@@ -52,6 +52,16 @@
</td>
</tr>
{/if}
{if $footer.product_discounts_tax_excl > 0}
<tr>
<td class="grey" width="70%">
{l s='Total Discounts' pdf='true'}
</td>
<td class="white" width="30%">
- {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_excl}
</td>
</tr>
{/if}
{* {if isset($footer.product_taxes) && $footer.product_taxes}
<tr>
<td class="grey" width="70%">
@@ -92,6 +102,7 @@
</td>
</tr>
{/if} *}
<tr class="bold">
<td class="grey">
{l s='Total (Tax excl.)' pdf='true'}
@@ -110,16 +121,7 @@
</td>
</tr>
{/if}
{if $footer.product_discounts_tax_excl > 0}
<tr>
<td class="grey" width="70%">
{l s='Total Discounts' pdf='true'}
</td>
<td class="white" width="30%">
- {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_excl}
</td>
</tr>
{/if}
<tr class="bold big">
<td class="grey">

View File

@@ -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');
}
}
});

View File

@@ -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 {

View File

@@ -506,6 +506,7 @@
{capture}<a class="button button-small btn btn-default" href="{$smarty.capture.addressUrlAdd}" title="{l s='Update' js=1}"><span>{l s='Update' js=1}<i class="icon-chevron-right right"></i></span></a>{/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}