Fixed some minor issues and improved ajax responses
This commit is contained in:
@@ -195,30 +195,31 @@
|
||||
{if isset($room['selected_services']) && $room['selected_services']}
|
||||
{foreach $room['selected_services'] as $service}
|
||||
<div class="row room_demand_block">
|
||||
<div class="col-xs-5">
|
||||
<div class="row">
|
||||
<div class="col-xs-10">
|
||||
<p>{$service['name']|escape:'html':'UTF-8'}</p>
|
||||
{if $service.allow_multiple_quantity}
|
||||
<div class="qty_container">
|
||||
{l s='Quantity:'} {$service.quantity}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="col-xs-5">
|
||||
<div class="row">
|
||||
<div class="col-xs-10">
|
||||
<div>{$service['name']|escape:'html':'UTF-8'}</div>
|
||||
{if $service.allow_multiple_quantity}
|
||||
<div class="qty_container">
|
||||
{l s='Quantity:'} {$service.quantity}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
|
||||
<span class="badge badge-info label">{l s='Convenience fee'}</span>
|
||||
{/if}
|
||||
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
|
||||
<span class="badge badge-info label">{l s='Auto added'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<span class="pull-right">{convertPrice price=$service.total_price}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
|
||||
<span class="badge badge-info label">{l s='Convenience fee'}</span>
|
||||
{/if}
|
||||
{if $service['auto_add_to_cart'] && $service['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
|
||||
<span class="badge badge-info label">{l s='Auto added'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<span class="pull-right">{convertPrice price=$service.total_price}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p></p>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1148,11 +1148,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
$objRoomTypeServPrice = new RoomTypeServiceProductPrice();
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $objRoomTypeServPrice->getServicePrice($servProduct['id_product'], 0, 1, null, null, false, $idCart);
|
||||
if ($additionalServices
|
||||
&& (in_array($servProduct['id_product'], array_column($additionalServices['additional_services'], 'id_product')))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1190,7 +1185,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
);
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Some error occurred. please try again.');
|
||||
$response['errors'][] = Tools::displayError('Some error occurred. please try again.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
@@ -1218,15 +1213,15 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessUpdateServiceProduct()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$operator = Tools::getValue('operator', 'up');
|
||||
$idServiceProduct = Tools::getValue('id_product');
|
||||
$idCartBooking = Tools::getValue('id_cart_booking');
|
||||
$qty = Tools::getValue('qty');
|
||||
|
||||
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
|
||||
if ($operator == 'up') {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) {
|
||||
@@ -1248,7 +1243,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('This Service is not available with selected room.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($this->errors)) {
|
||||
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
@@ -1263,7 +1258,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
|
||||
@@ -1369,28 +1364,28 @@ class AdminCartsControllerCore extends AdminController
|
||||
$priceAdditionType = 0;
|
||||
if (empty($productQty)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service quantity is required');
|
||||
$response['errors'][] = Tools::displayError('Service quantity is required');
|
||||
} elseif (!Validate::isUnsignedInt($productQty)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service quantity');
|
||||
$response['errors'][] = Tools::displayError('Invalid service quantity');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate service data provided
|
||||
if (empty($name)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service name is required');
|
||||
$response['errors'][] = Tools::displayError('Service name is required');
|
||||
} elseif (!Validate::isCatalogName($name)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service name');
|
||||
$response['errors'][] = Tools::displayError('Invalid service name');
|
||||
}
|
||||
|
||||
if (empty($price)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service price is required');
|
||||
$response['errors'][] = Tools::displayError('Service price is required');
|
||||
} elseif (!Validate::isPrice($price)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service price');
|
||||
$response['errors'][] = Tools::displayError('Invalid service price');
|
||||
}
|
||||
|
||||
// if no validation errors then add service
|
||||
@@ -1457,28 +1452,28 @@ class AdminCartsControllerCore extends AdminController
|
||||
$response['service_panel'] = $this->getBookingServicesTabContent($objHtlCartBooking->id);
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Some error occurred while adding service to the room');
|
||||
$response['errors'][] = Tools::displayError('Some error occurred while adding service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Room not found');
|
||||
$response['errors'][] = Tools::displayError('Room not found');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Adding a new custom service is not allowed.');
|
||||
$response['errors'][] = Tools::displayError('Adding a new custom service is not allowed.');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
@@ -1562,14 +1557,14 @@ class AdminCartsControllerCore extends AdminController
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!isset($serviceQuantities[$idServiceProduct])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Quantity not provided for service').': '.$objProduct->name;
|
||||
$response['errors'][] = Tools::displayError('Quantity not provided for service').': '.$objProduct->name;
|
||||
} else if (!Validate::isUnsignedInt($serviceQuantities[$idServiceProduct])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid quantity provided for service').': '.$objProduct->name;
|
||||
$response['errors'][] = Tools::displayError('Invalid quantity provided for service').': '.$objProduct->name;
|
||||
}
|
||||
} elseif ($serviceQuantities[$idServiceProduct] > 1) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Can not order multiple quanitity for service').': '.$objProduct->name;
|
||||
$response['errors'][] = Tools::displayError('Can not order multiple quanitity for service').': '.$objProduct->name;
|
||||
}
|
||||
|
||||
if (!$objProduct->allow_multiple_quantity) {
|
||||
@@ -1580,12 +1575,10 @@ class AdminCartsControllerCore extends AdminController
|
||||
|| !ValidateCore::isPrice($serviceUnitPrices[$idServiceProduct])
|
||||
) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid unit price for service').': '.$objProduct->name;
|
||||
$response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objProduct->name;
|
||||
}
|
||||
|
||||
} else {
|
||||
die($idServiceProduct);
|
||||
$response['errors'] = $this->l('Some services not found. please try after refreshing the page');
|
||||
$response['errors'][] = Tools::displayError('Some services not found. please try after refreshing the page');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1609,7 +1602,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
)) {
|
||||
$originalPrice = Product::getPriceStatic($idServiceProduct, false);
|
||||
// if price is different than the original service price then update the price
|
||||
if ($operator == 'up' && $originalPrice != $price) {
|
||||
if ($operator == 'up' && $originalPrice != $unitPrice) {
|
||||
if ($specificPriceInfo = SpecificPrice::getSpecificPrice(
|
||||
(int)$idServiceProduct,
|
||||
0,
|
||||
@@ -1649,20 +1642,20 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
if (!$result) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Error while updating services, please try again after refresing the page');
|
||||
$response['errors'][] = Tools::displayError('Error while updating services, please try again after refresing the page');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('No service found');
|
||||
$response['errors'][] = Tools::displayError('No service found');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Room info not found');
|
||||
$response['errors'][] = Tools::displayError('Room info not found');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
|
||||
@@ -3515,18 +3515,18 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$response['msg'] = $this->l('Guest details are updated.');
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Unable to save guest details.');
|
||||
$response['errors'][] = Tools::displayError('Unable to save guest details.');
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Guest details not found.');
|
||||
$response['errors'][] = Tools::displayError('Guest details not found.');
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Guest details not found.');
|
||||
$response['errors'][] = Tools::displayError('Guest details not found.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
if ($response['errors']) {
|
||||
@@ -5068,7 +5068,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($qty_diff != 0) {
|
||||
$cartQty = $qty_diff;
|
||||
$op = 'up';
|
||||
@@ -5679,7 +5678,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypServiceProductCartDetail);
|
||||
$serviceQuantity = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()) {
|
||||
if ($objRoomTypeServiceProductCartDetail->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');
|
||||
}
|
||||
@@ -6588,25 +6589,25 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($objOrderDetail->product_allow_multiple_quantity) {
|
||||
if (!isset($serviceQuantities[$idRoomTypeServiceProductOrderDetail])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Quantity not provided for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
$response['errors'][] = Tools::displayError('Quantity not provided for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
} else if (!Validate::isUnsignedInt($serviceQuantities[$idRoomTypeServiceProductOrderDetail])) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid quantity provided for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
$response['errors'][] = Tools::displayError('Invalid quantity provided for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
}
|
||||
} elseif ($serviceQuantities[$idRoomTypeServiceProductOrderDetail] > 1) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Can not order multiple quanitity for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
$response['errors'][] = Tools::displayError('Can not order multiple quanitity for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
}
|
||||
|
||||
if (!isset($serviceUnitPrices[$idRoomTypeServiceProductOrderDetail])
|
||||
|| !ValidateCore::isPrice($serviceUnitPrices[$idRoomTypeServiceProductOrderDetail])
|
||||
) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Invalid unit price for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
$response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Service not found for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
$response['errors'][] = Tools::displayError('Service not found for service').': '.$objRoomTypeServiceOrderDetail->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6704,7 +6705,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (!$result) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Error while updating service, please try again after refresing the page');
|
||||
$response['errors'][] = Tools::displayError('Error while updating service, please try again after refresing the page');
|
||||
} else {
|
||||
$response['service_panel']= $servicesBlock = $this->processRenderServicesPanel(
|
||||
$objOrderDetail->id_order,
|
||||
@@ -6719,11 +6720,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('Service not found');
|
||||
$response['errors'][] = Tools::displayError('Service not found');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
@@ -6954,12 +6955,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
);
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Room not found');
|
||||
$response['errors'][] = Tools::displayError('Room not found');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
@@ -6982,7 +6983,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
$objHotelBookingDetail->id_room
|
||||
)) {
|
||||
)) {
|
||||
$name = Tools::getValue('new_service_name');
|
||||
$price = Tools::getValue('new_service_price');
|
||||
$priceCalcMethod = Tools::getValue('new_service_price_calc_method');
|
||||
@@ -7003,28 +7004,28 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$priceAdditionType = 0;
|
||||
if (empty($productQty)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service quantity is required');
|
||||
$response['errors'][] = Tools::displayError('Service quantity is required');
|
||||
} elseif (!Validate::isUnsignedInt($productQty)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service quantity');
|
||||
$response['errors'][] = Tools::displayError('Invalid service quantity');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate service data provided
|
||||
if (empty($name)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service name is required');
|
||||
$response['errors'][] = Tools::displayError('Service name is required');
|
||||
} elseif (!Validate::isCatalogName($name)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service name');
|
||||
$response['errors'][] = Tools::displayError('Invalid service name');
|
||||
}
|
||||
|
||||
if (empty($price)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Service price is required');
|
||||
$response['errors'][] = Tools::displayError('Service price is required');
|
||||
} elseif (!Validate::isPrice($price)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Invalid service price');
|
||||
$response['errors'][] = Tools::displayError('Invalid service price');
|
||||
}
|
||||
|
||||
// if no validation errors then add service
|
||||
@@ -7232,7 +7233,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
);
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Some error occurred while updating the order');
|
||||
$response['errors'][] = Tools::displayError('Some error occurred while updating the order');
|
||||
}
|
||||
|
||||
// at last delete the specific price created for the service
|
||||
@@ -7242,42 +7243,42 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Some error occurred while updating the order');
|
||||
$response['errors'][] = Tools::displayError('Some error occurred while updating the order');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
// at last delete the created service
|
||||
$objServiceProduct->delete();
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Unable to add service to the room');
|
||||
$response['errors'][] = Tools::displayError('Unable to add service to the room');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Room not found');
|
||||
$response['errors'][] = Tools::displayError('Room not found');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('Adding a new custom service is not allowed.');
|
||||
$response['errors'][] = Tools::displayError('Adding a new custom service is not allowed.');
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
@@ -7289,15 +7290,39 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response = array('hasError' => false);
|
||||
// Check tab access is allowed to edit
|
||||
if ($this->tabAccess['edit'] == 1) {
|
||||
$id_room_type_service_product_order_detail = Tools::getValue('id_room_type_service_product_order_detail');
|
||||
|
||||
if (Validate::isLoadedObject($objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($id_room_type_service_product_order_detail))) {
|
||||
$idRoomTypeServiceProductOrderDetail = Tools::getValue('id_room_type_service_product_order_detail');
|
||||
if (Validate::isLoadedObject($objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($idRoomTypeServiceProductOrderDetail))) {
|
||||
$objOrderDetail = new OrderDetail($objRoomTypeServiceProductOrderDetail->id_order_detail);
|
||||
$priceTaxExcl = $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
|
||||
$priceTaxIncl = $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
|
||||
$quantity = $objRoomTypeServiceProductOrderDetail->quantity;
|
||||
$res = true;
|
||||
$objHotelBookingDetail = new HotelBookingDetail($objRoomTypeServiceProductOrderDetail->id_htl_booking_detail);
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
if ($roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objHotelBookingDetail->id_cart,
|
||||
$objHotelBookingDetail->id_product,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
$objHotelBookingDetail->id_room
|
||||
)) {
|
||||
if ($idRoomTypServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$objRoomTypeServiceProductOrderDetail->id_product,
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart,
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($idRoomTypServiceProductCartDetail);
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()
|
||||
// Since the service product is deleted after adding them directly from the order the cart will throw exception on the service delete process.
|
||||
&& Validate::isLoadedObject(new Product($objRoomTypeServiceProductOrderDetail->id_product))
|
||||
) {
|
||||
$objCart = new Cart($objRoomTypeServiceProductOrderDetail->id_cart);
|
||||
$objCart->updateQty((int) abs($quantity), $objRoomTypeServiceProductOrderDetail->id_product, null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($res &= $objRoomTypeServiceProductOrderDetail->delete()) {
|
||||
$order = new Order($objRoomTypeServiceProductOrderDetail->id_order);
|
||||
@@ -7502,7 +7527,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
} else {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = $this->l('You do not have permission to edit this order.');
|
||||
$response['errors'][] = Tools::displayError('You do not have permission to edit this order.');
|
||||
}
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user