Merge branch 'develop' into gli-2349

This commit is contained in:
vishalsingh.qlo325
2025-03-28 15:30:10 +05:30
34 changed files with 389 additions and 272 deletions

View File

@@ -855,6 +855,7 @@ class AdminOrdersControllerCore extends AdminController
$this->context->smarty->assign(
array(
'order' => $objOrder,
'invoices_collection' => $objOrder->getInvoicesCollection(),
'currency' => new Currency($objOrder->id_currency),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
)
@@ -895,89 +896,92 @@ class AdminOrdersControllerCore extends AdminController
&& ($productLineData = Tools::getValue('product_line_data'))
) {
$productLineData = json_decode($productLineData, true);
if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($productLineData['id_order_detail']))) {
$productLineData['id_order_invoice'] = $objOrderDetail->id_order_invoice;
$smartyVars = array(
'order' => $objOrder,
'data' => $productLineData,
'currency' => new Currency($objOrder->id_currency),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'orderEdit' => 1,
);
$smartyVars = array(
'order' => $objOrder,
'data' => $productLineData,
'currency' => new Currency($objOrder->id_currency),
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'orderEdit' => 1,
);
$objCurrency = new Currency($objOrder->id_currency);
$smartyVars['orderCurrency'] = $objOrder->id_currency;
$smartyVars['currencySign'] = $objCurrency->sign;
$smartyVars['link'] = $this->context->link;
$objCurrency = new Currency($objOrder->id_currency);
$smartyVars['orderCurrency'] = $objOrder->id_currency;
$smartyVars['currencySign'] = $objCurrency->sign;
$smartyVars['link'] = $this->context->link;
$smartyVars['id_booking_detail'] = $productLineData['id'];
$smartyVars['id_booking_detail'] = $productLineData['id'];
$objBookingDemand = new HotelBookingDemands();
$objBookingDemand = new HotelBookingDemands();
// set context currency So that we can get prices in the order currency
$this->context->currency = $objCurrency;
// set context currency So that we can get prices in the order currency
$this->context->currency = $objCurrency;
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
$idOrder,
0,
0,
0,
0,
1,
0,
1,
$productLineData['id']
)) {
$smartyVars['extraDemands'] = $extraDemands;
}
// get room type additional demands
$objRoomDemands = new HotelRoomTypeDemand();
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
foreach ($roomTypeDemands as &$demand) {
// if demand has advance options then set demand price as first advance option price.
if (isset($demand['adv_option']) && $demand['adv_option']) {
$demand['price'] = current($demand['adv_option'])['price'];
}
if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
$idOrder,
0,
0,
0,
0,
1,
0,
1,
$productLineData['id']
)) {
$smartyVars['extraDemands'] = $extraDemands;
}
$smartyVars['roomTypeDemands'] = $roomTypeDemands;
}
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
$productLineData['id']
)) {
$smartyVars['additionalServices'] = $additionalServices;
}
// get room type additional demands
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
if ($additionalServices) {
foreach ($roomTypeServiceProducts as $key => $product) {
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
unset($roomTypeServiceProducts[$key]);
// get room type additional demands
$objRoomDemands = new HotelRoomTypeDemand();
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
foreach ($roomTypeDemands as &$demand) {
// if demand has advance options then set demand price as first advance option price.
if (isset($demand['adv_option']) && $demand['adv_option']) {
$demand['price'] = current($demand['adv_option'])['price'];
}
}
$smartyVars['roomTypeDemands'] = $roomTypeDemands;
}
$smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts;
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
$productLineData['id']
)) {
$smartyVars['additionalServices'] = $additionalServices;
}
// get room type additional demands
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
if ($additionalServices) {
foreach ($roomTypeServiceProducts as $key => $product) {
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
unset($roomTypeServiceProducts[$key]);
}
}
}
$smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts;
}
$objOrderReturn = new OrderReturn();
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1);
$smartyVars['refundReqBookings'] = $refundReqBookings;
$smartyVars['invoices_collection'] = $objOrder->getInvoicesCollection();
$this->context->smarty->assign($smartyVars);
$modal = array(
'modal_id' => 'edit-room-booking-modal',
'modal_class' => 'modal-lg order_detail_modal',
'modal_title' => '<i class="icon icon-bed"></i> &nbsp'.$this->l('Edit Room'),
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_edit_room_booking.tpl'),
);
$this->context->smarty->assign($modal);
$response['hasError'] = 0;
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
}
$objOrderReturn = new OrderReturn();
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1);
$smartyVars['refundReqBookings'] = $refundReqBookings;
$this->context->smarty->assign($smartyVars);
$modal = array(
'modal_id' => 'edit-room-booking-modal',
'modal_class' => 'modal-lg order_detail_modal',
'modal_title' => '<i class="icon icon-bed"></i> &nbsp'.$this->l('Edit Room'),
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_edit_room_booking.tpl'),
);
$this->context->smarty->assign($modal);
$response['hasError'] = 0;
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
}
die(Tools::jsonEncode($response));
@@ -4408,14 +4412,15 @@ class AdminOrdersControllerCore extends AdminController
}
}
// Create Order detail information
$order_detail = new OrderDetail();
$order_detail->createList($order, $cart, $order->getCurrentOrderState(), $cart->getProducts(), (isset($order_invoice) ? $order_invoice->id : 0), $use_taxes, (int)Tools::getValue('add_product_warehouse'));
// update totals amount of order
$order->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$order->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
// Create Order detail information
$order_detail = new OrderDetail();
// In case there is no room in the order the the create list will not add taxes as total_products is zero.
$order_detail->createList($order, $cart, $order->getCurrentOrderState(), $cart->getProducts(), (isset($order_invoice) ? $order_invoice->id : 0), $use_taxes, (int)Tools::getValue('add_product_warehouse'));
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
@@ -4871,8 +4876,6 @@ class AdminOrdersControllerCore extends AdminController
if (isset($order_invoice)) {
// Apply changes on OrderInvoice
$order_invoice->total_products += (float)$diff_price_tax_excl;
$order_invoice->total_products_wt += (float)$diff_price_tax_incl;
$order_invoice->total_paid_tax_excl += (float)$diff_price_tax_excl;
$order_invoice->total_paid_tax_incl += (float)$diff_price_tax_incl;
}
@@ -4884,10 +4887,6 @@ class AdminOrdersControllerCore extends AdminController
$order->total_products_wt += (float)$diff_price_tax_incl;
$order->total_products_wt = $order->total_products_wt > 0 ? $order->total_products_wt : 0;
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
$res &= $order->update();
}
@@ -4912,10 +4911,6 @@ class AdminOrdersControllerCore extends AdminController
}
}
// Save order invoice
if (isset($order_invoice)) {
$res &= $order_invoice->update();
}
if ($qty_diff != 0) {
$cartQty = $qty_diff;
@@ -5041,7 +5036,6 @@ class AdminOrdersControllerCore extends AdminController
)) {
// update extra demands total prices if dates are changes (price calc method for each day)
if ($extraDemands) {
$order = new Order($id_order);
foreach ($extraDemands as $demand) {
if (isset($demand['extra_demands']) && $demand['extra_demands']) {
foreach ($demand['extra_demands'] as $rDemand) {
@@ -5066,23 +5060,23 @@ class AdminOrdersControllerCore extends AdminController
$objBookingDemand->total_price_tax_incl = $demandPriceTI;
$objBookingDemand->save();
$order_invoice->total_paid_tax_excl -= $rDemand['total_price_tax_excl'];
$order_invoice->total_paid_tax_incl -= $rDemand['total_price_tax_incl'];
$order_invoice->total_paid_tax_excl += (float)$objBookingDemand->total_price_tax_excl;
$order_invoice->total_paid_tax_incl += (float)$objBookingDemand->total_price_tax_incl;
}
}
}
}
// change order total save
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
$order->save();
}
if (isset($orderServiceProducts)
&& is_array($orderServiceProducts)
&& count($orderServiceProducts)
) {
$order = new Order((int) $id_order);
foreach ($orderServiceProducts as $orderServiceProduct) {
if (isset($orderServiceProduct['additional_services'])
&& is_array($orderServiceProduct['additional_services'])
@@ -5128,6 +5122,12 @@ class AdminOrdersControllerCore extends AdminController
$objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity);
$objOrderDetail->save();
$order_invoice->total_paid_tax_excl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
$order_invoice->total_paid_tax_incl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
$order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl;
$order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl;
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl;
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl;
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl;
@@ -5137,14 +5137,21 @@ class AdminOrdersControllerCore extends AdminController
}
}
}
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
$order->save();
}
}
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
$order->save();
// Save order invoice
if (isset($order_invoice)) {
$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();
}
if (is_array(Tools::getValue('product_quantity'))) {
$view = $this->createTemplate('_customized_data.tpl')->fetch();
} else {
@@ -5549,8 +5556,8 @@ class AdminOrdersControllerCore extends AdminController
// Update Order
// values changes as values are calculated accoding to the quantity of the product by webkul
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal() - $roomExtraDemandTI, _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false) - $roomExtraDemandTE, _PS_PRICE_COMPUTE_PRECISION_);
$order->total_products -= ($diff_products_tax_excl + $additionlServicesTE);
$order->total_products = $order->total_products > 0 ? $order->total_products : 0;
@@ -5621,15 +5628,15 @@ class AdminOrdersControllerCore extends AdminController
$objOrderCartRule->delete();
}
// If no rooms left in the order, Update Order total and discounts to 0
$order->total_discounts = 0;
$order->total_discounts_tax_incl = 0;
$order->total_discounts_tax_excl = 0;
$order->total_paid = 0;
$order->total_paid_tax_incl = 0;
$order->total_paid_tax_excl = 0;
$order->update();
}
// If no rooms left in the order, Update Order total and discounts to 0
$order->total_discounts = 0;
$order->total_discounts_tax_incl = 0;
$order->total_discounts_tax_excl = 0;
$order->total_paid = 0;
$order->total_paid_tax_incl = 0;
$order->total_paid_tax_excl = 0;
$order->update();
}
// Assign to smarty informations in order to show the new product line
@@ -6163,7 +6170,7 @@ class AdminOrdersControllerCore extends AdminController
$del_id = Tools::getValue('del_id');
$room_id = Tools::getValue('id_room');
$obj_hotel_cart_detail = new HotelCartBookingData();
$deleted = $obj_hotel_cart_detail->deleteRowById($del_id);
$deleted = $obj_hotel_cart_detail->deleteCartBookingData($cart_id, $id_product, $room_id, $dt_frm, $dt_to);
if ($deleted) {
HotelRoomTypeFeaturePricing::deleteByIdCart($cart_id, $id_product, $room_id, $dt_frm, $dt_to );
$obj_product_process = new HotelCartBookingData();