Merge branch 'develop' into gli-2599_2
This commit is contained in:
@@ -513,7 +513,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
if (((int) $order->isReturnable())
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG)
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
|
||||
) {
|
||||
$orderTotalPaid = $order->getTotalPaid();
|
||||
$orderDiscounts = $order->getCartRules();
|
||||
@@ -537,6 +537,18 @@ class AdminOrdersControllerCore extends AdminController
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function initToolbarTitle()
|
||||
{
|
||||
parent::initToolbarTitle();
|
||||
switch ($this->display) {
|
||||
case '':
|
||||
case 'list':
|
||||
array_pop($this->toolbar_title);
|
||||
$this->toolbar_title[] = $this->l('Orders');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessInitBookingDocumentsModal()
|
||||
{
|
||||
$response['hasError'] = 1;
|
||||
@@ -977,8 +989,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
@@ -2022,6 +2034,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Validate::isLoadedObject($objCart)) {
|
||||
$this->context->cart = $objCart;
|
||||
$this->context->currency = new Currency((int)$objCart->id_currency);
|
||||
$this->context->customer = new Customer((int) $objCart->id_customer);
|
||||
|
||||
$this->errors = HotelCartBookingData::validateCartBookings(!Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING'));
|
||||
|
||||
@@ -2076,8 +2089,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$this->context->currency = new Currency((int) $objCart->id_currency);
|
||||
$this->context->customer = new Customer((int) $objCart->id_customer);
|
||||
|
||||
// Set payment module details
|
||||
$objPaymentModule = new BoOrder();
|
||||
@@ -3560,7 +3571,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'refundReqProducts' => $refundReqProducts,
|
||||
'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG),
|
||||
'refundedAmount' => $refundedAmount,
|
||||
'totalDemandsPriceTI' => $totalDemandsPriceTI,
|
||||
'totalDemandsPriceTE' => $totalDemandsPriceTE,
|
||||
@@ -4684,7 +4694,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
$obj_booking_detail = new HotelBookingDetail();
|
||||
$num_days = HotelHelper::getNumberOfDays($date_from, $date_to);
|
||||
$product_informations['product_quantity'] = $product_informations['product_quantity'] * (int) $num_days;
|
||||
$product_informations['product_quantity'] = $req_rm * (int) $num_days;
|
||||
|
||||
$obj_room_type = new HotelRoomType();
|
||||
$room_info_by_id_product = $obj_room_type->getRoomTypeInfoByIdProduct($product_informations['product_id']);
|
||||
@@ -4699,9 +4709,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'date_to' => $date_to,
|
||||
'hotel_id' => $id_hotel,
|
||||
'id_room_type' => $product_informations['product_id'],
|
||||
'only_search_data' => 1,
|
||||
'id_cart' => $id_cart,
|
||||
'id_guest' => $id_guest,
|
||||
'only_search_data' => 1
|
||||
);
|
||||
$hotel_room_data = $objBookingDetail->dataForFrontSearch($bookingParams);
|
||||
$total_available_rooms = $hotel_room_data['stats']['num_avail'];
|
||||
@@ -5601,26 +5609,38 @@ class AdminOrdersControllerCore extends AdminController
|
||||
*/
|
||||
public function updateOrderStatusOnOrderChange($objOrder)
|
||||
{
|
||||
// check if new order amount is greater that old order amount and order payment is accepted
|
||||
// then update order status to partial payment accepted
|
||||
$currentOrderState = $objOrder->getCurrentOrderState();
|
||||
$psOsPartialPaymentAccepted = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
if ($currentOrderState->paid == 1 && $currentOrderState->id != $psOsPartialPaymentAccepted) {
|
||||
// calculate due amount
|
||||
$dueAmount = $objOrder->total_paid_tax_incl - $objOrder->total_paid_real;
|
||||
if ($dueAmount > 0) {
|
||||
// now change order status to partial payment
|
||||
$objOrderHistory = new OrderHistory();
|
||||
$objOrderHistory->id_order = $objOrder->id;
|
||||
$objOrderHistory->id_employee = (int) $this->context->employee->id;
|
||||
// If order is completely refunded or cancelled then change the order state
|
||||
if ($idOrderState = $objOrder->getOrderCompleteRefundStatus()) {
|
||||
$objOrderHistory = new OrderHistory();
|
||||
$objOrderHistory->id_order = (int)$objOrder->id;
|
||||
$useExistingPayment = false;
|
||||
if (!$objOrder->hasInvoice()) {
|
||||
$useExistingPayment = true;
|
||||
}
|
||||
$objOrderHistory->changeIdOrderState($idOrderState, $objOrder, $useExistingPayment);
|
||||
$objOrderHistory->add();
|
||||
} else {
|
||||
// check if new order amount is greater that old order amount and order payment is accepted
|
||||
// then update order status to partial payment accepted
|
||||
$currentOrderState = $objOrder->getCurrentOrderState();
|
||||
$psOsPartialPaymentAccepted = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
if ($currentOrderState->paid == 1 && $currentOrderState->id != $psOsPartialPaymentAccepted) {
|
||||
// calculate due amount
|
||||
$dueAmount = $objOrder->total_paid_tax_incl - $objOrder->total_paid_real;
|
||||
if ($dueAmount > 0) {
|
||||
// now change order status to partial payment
|
||||
$objOrderHistory = new OrderHistory();
|
||||
$objOrderHistory->id_order = $objOrder->id;
|
||||
$objOrderHistory->id_employee = (int) $this->context->employee->id;
|
||||
|
||||
$useExistingPayment = false;
|
||||
if (!$objOrder->hasInvoice()) {
|
||||
$useExistingPayment = true;
|
||||
$useExistingPayment = false;
|
||||
if (!$objOrder->hasInvoice()) {
|
||||
$useExistingPayment = true;
|
||||
}
|
||||
|
||||
$objOrderHistory->changeIdOrderState($psOsPartialPaymentAccepted, $objOrder, $useExistingPayment);
|
||||
$objOrderHistory->add();
|
||||
}
|
||||
|
||||
$objOrderHistory->changeIdOrderState($psOsPartialPaymentAccepted, $objOrder, $useExistingPayment);
|
||||
$objOrderHistory->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5678,10 +5698,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product_quantity = (int) HotelHelper::getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) HotelHelper::getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
|
||||
$occupancy = Tools::getValue('occupancy');
|
||||
$occupancy = array_shift($occupancy);
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
$child_ages = isset($occupancy['child_ages']) ? $occupancy['child_ages'] : false;
|
||||
|
||||
$totalRoomPriceBeforeTE = $obj_booking_detail->total_price_tax_excl;
|
||||
$totalRoomPriceBeforeTI = $obj_booking_detail->total_price_tax_incl;
|
||||
@@ -6346,40 +6368,43 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
// update order detail for selected aditional services
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
foreach ($selectedAdditonalServices as $service) {
|
||||
$serviceOrderDetail = new OrderDetail($service['id_order_detail']);
|
||||
if (isset($selectedAdditonalServices[$idHotelBooking])) {
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail();
|
||||
foreach ($selectedAdditonalServices[$idHotelBooking]['additional_services'] as $service) {
|
||||
$serviceOrderDetail = new OrderDetail($service['id_order_detail']);
|
||||
|
||||
$cart_quantity = $service['quantity'];
|
||||
if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$cart_quantity = $cart_quantity * $product_quantity;
|
||||
}
|
||||
if ($cart_quantity >= $serviceOrderDetail->product_quantity) {
|
||||
$serviceOrderDetail->delete();
|
||||
} else {
|
||||
$serviceOrderDetail->total_price_tax_incl -= $service['total_price_tax_incl'];
|
||||
$serviceOrderDetail->total_price_tax_excl -= $service['total_price_tax_excl'];
|
||||
$serviceOrderDetail->product_quantity -= $cart_quantity;
|
||||
$cart_quantity = $service['quantity'];
|
||||
if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$cart_quantity = $cart_quantity * $product_quantity;
|
||||
}
|
||||
if ($cart_quantity >= $serviceOrderDetail->product_quantity) {
|
||||
$serviceOrderDetail->delete();
|
||||
} else {
|
||||
$serviceOrderDetail->total_price_tax_incl -= $service['total_price_tax_incl'];
|
||||
$serviceOrderDetail->total_price_tax_excl -= $service['total_price_tax_excl'];
|
||||
$serviceOrderDetail->product_quantity -= $cart_quantity;
|
||||
|
||||
// update taxes
|
||||
$res &= $serviceOrderDetail->updateTaxAmount($order);
|
||||
// update taxes
|
||||
$res &= $serviceOrderDetail->updateTaxAmount($order);
|
||||
|
||||
// Save order detail
|
||||
$res &= $serviceOrderDetail->update();
|
||||
}
|
||||
// Save order detail
|
||||
$res &= $serviceOrderDetail->update();
|
||||
}
|
||||
|
||||
if (isset($roomHtlCartInfo['id'])) {
|
||||
if ($idServiceProductCartDetail = $objServiceProductCartDetail->alreadyExists(
|
||||
$service['id_product'],
|
||||
$service['id_cart'],
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$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']);
|
||||
$objCart->updateQty((int)abs($serviceQuantity), $service['id_product'], null, false, 'down');
|
||||
if (isset($roomHtlCartInfo['id'])) {
|
||||
if ($idServiceProductCartDetail = $objServiceProductCartDetail->alreadyExists(
|
||||
$service['id_product'],
|
||||
$selectedAdditonalServices[$idHotelBooking]['id_cart'],
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objServiceProductCartDetail = new ServiceProductCartDetail((int) $idServiceProductCartDetail);
|
||||
$serviceQuantity = $objServiceProductCartDetail->quantity;
|
||||
if ($objServiceProductCartDetail->delete()
|
||||
&& Validate::isLoadedObject(new Product((int) $service['id_product']))
|
||||
) {
|
||||
$objCart = new Cart($selectedAdditonalServices[$idHotelBooking]['id_cart']);
|
||||
$objCart->updateQty((int)abs($serviceQuantity), $service['id_product'], null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6501,7 +6526,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'invoices_collection' => $invoice_collection,
|
||||
'current_id_lang' => Context::getContext()->language->id,
|
||||
'link' => Context::getContext()->link,
|
||||
'current_index' => self::$currentIndex
|
||||
'current_index' => self::$currentIndex,
|
||||
'can_edit' => ($this->tabAccess['edit'] === 1),
|
||||
));
|
||||
|
||||
$this->sendChangedNotification($order);
|
||||
@@ -6652,10 +6678,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product_quantity = (int) HotelHelper::getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) HotelHelper::getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
$occupancy = Tools::getValue('occupancy');
|
||||
$occupancy = array_shift($occupancy);
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
$child_ages = isset($occupancy['child_ages']) ? $occupancy['child_ages'] : false;
|
||||
|
||||
// If order is refunded, the validate changes which are not allowed
|
||||
$objOrderReturn = new OrderReturn();
|
||||
@@ -7188,8 +7215,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) {
|
||||
// get all services
|
||||
$objProduct = new Product();
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
@@ -7197,9 +7224,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if ($serviceProducts) {
|
||||
if (isset($additionalServices[$idHtlBookingDetail]) && $additionalServices[$idHtlBookingDetail]) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $servProduct['price'];
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $servProduct['price'];
|
||||
if (isset($additionalServices[$idHtlBookingDetail]) && $additionalServices[$idHtlBookingDetail]) {
|
||||
if (in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product'))) {
|
||||
unset($serviceProducts[$key]);
|
||||
}
|
||||
@@ -7714,10 +7741,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$autoAdded = Tools::getValue('new_service_auto_added');
|
||||
|
||||
// adjust values for auto added services
|
||||
$objOrderDetail = new OrderDetail($objHotelBookingDetail->id_order_detail);
|
||||
if ($autoAdded) {
|
||||
$productQty = 1;
|
||||
// check if booking room type tax rule is still exist
|
||||
$objOrderDetail = new OrderDetail($objHotelBookingDetail->id_order_detail);
|
||||
if (Validate::isLoadedObject($objTaxRuleGroup = new TaxRulesGroup($objOrderDetail->id_tax_rules_group))) {
|
||||
$idTaxRuleGroup = $objOrderDetail->id_tax_rules_group;
|
||||
}
|
||||
@@ -7858,7 +7885,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objHotelBookingDetail->date_to,
|
||||
$objCart->id
|
||||
) / $numDays;
|
||||
$unitPriceTaxExcl = Product::getServiceProductPrice(
|
||||
$unitPriceTaxIncl = Product::getServiceProductPrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$roomHtlCartInfo['id_hotel'],
|
||||
@@ -8044,7 +8071,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
&& Validate::isLoadedObject(new Product($objServiceProductOrderDetail->id_product))
|
||||
) {
|
||||
$objCart = new Cart($objServiceProductOrderDetail->id_cart);
|
||||
$objCart->updateQty((int) abs($quantity), $objServiceProductOrderDetail->id_product, null, false, 'down');
|
||||
$objCart->updateQty((int) abs($quantity), $objServiceProductOrderDetail->id_product, null, 0, 'down', 0, null, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user