Fix: Price not updating on order creation when employee lacks 'Booking Carts' edit permission
This commit is contained in:
@@ -119,8 +119,15 @@
|
||||
{/if}
|
||||
<td id="cart_detail_data_unit_price_{$data.id|escape:'html':'UTF-8'}">
|
||||
{assign var=shown_room_type_price value=$data.feature_price_tax_excl}
|
||||
{if isset($can_edit_booking_carts)}
|
||||
{assign var=can_edit_booking_cart_price value=$can_edit_booking_carts}
|
||||
{elseif isset($can_edit)}
|
||||
{assign var=can_edit_booking_cart_price value=$can_edit}
|
||||
{else}
|
||||
{assign var=can_edit_booking_cart_price value=0}
|
||||
{/if}
|
||||
<div class="input-group">
|
||||
<input type="text" class="room_unit_price" value="{Tools::ps_round($shown_room_type_price, $smarty.const._PS_PRICE_DISPLAY_PRECISION_)|escape:'html':'UTF-8'}">
|
||||
<input type="text" class="room_unit_price" value="{Tools::ps_round($shown_room_type_price, $smarty.const._PS_PRICE_DISPLAY_PRECISION_)|escape:'html':'UTF-8'}"{if !$can_edit_booking_cart_price} readonly="readonly"{/if}>
|
||||
<span class="input-group-addon">{$currency->prefix}{$currency->suffix}</span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<span class="input-group-addon">
|
||||
{$cartCurrency->sign}
|
||||
</span>
|
||||
<input class="service_cart_price_input" id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}" type="text" value="{$product.price_tax_exc}" name="service_price[{$product['id_product']|escape:'html':'UTF-8'}]"/>
|
||||
<input class="service_cart_price_input" id="service_cart_price_{$selectedRoomServiceProduct['id']}_{$product['id_product']}" type="text" value="{$product.price_tax_exc}" name="service_price[{$product['id_product']|escape:'html':'UTF-8'}]"{if isset($can_edit) && !$can_edit} readonly{/if}/>
|
||||
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']}
|
||||
<span class="input-group-addon">{l s='/ night'}</span>
|
||||
{/if}
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<span class="input-group-addon">{$currencySign}</span>
|
||||
<input type="text" class="form-control unit_price" name="service_price[{$product['id_product']|escape:'html':'UTF-8'}]" value="{$product['price_tax_exc']}" data-id-product="{$product.id_product}">
|
||||
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']}
|
||||
<span class="input-group-addon">{l s='/ night'}</span>
|
||||
<span class="input-group-addon">{l s='/ nnnnight'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -687,6 +687,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
'cart_detail_data' => $cart_detail_data,
|
||||
'cart' => $objCart,
|
||||
'currency' => new Currency((int)$this->context->cart->id_currency),
|
||||
'can_edit_booking_carts' => ($this->tabAccess['edit'] === 1),
|
||||
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
|
||||
'ajax' => true
|
||||
));
|
||||
@@ -1257,7 +1258,8 @@ class AdminCartsControllerCore extends AdminController
|
||||
'serviceProducts' => $serviceProducts,
|
||||
'selectedRoomServiceProduct' => $selectedRoomServiceProduct,
|
||||
'customServiceAllowed' => Configuration::get('PS_ALLOW_CREATE_CUSTOM_SERVICES_IN_BOOKING'),
|
||||
'loaderImg' => $this->context->link->getMediaLink(_PS_IMG_.'admin/ajax-loader.gif')
|
||||
'loaderImg' => $this->context->link->getMediaLink(_PS_IMG_.'admin/ajax-loader.gif'),
|
||||
'can_edit' => $this->tabAccess['edit'],
|
||||
));
|
||||
|
||||
$response['html_exta_demands'] = $this->context->smarty->fetch(
|
||||
@@ -1566,6 +1568,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
'serviceProducts' => $serviceProducts,
|
||||
'selectedRoomServiceProduct' => $selectedRoomServiceProduct,
|
||||
'customServiceAllowed' => Configuration::get('PS_ALLOW_CREATE_CUSTOM_SERVICES_IN_BOOKING'),
|
||||
'can_edit' => $this->tabAccess['edit'],
|
||||
));
|
||||
|
||||
$servicesTpl = $this->context->smarty->fetch(
|
||||
@@ -1581,7 +1584,9 @@ class AdminCartsControllerCore extends AdminController
|
||||
{
|
||||
$response = array('hasError' => false);
|
||||
// Check tab access is allowed to edit
|
||||
if ($this->tabAccess['add'] === 1) {
|
||||
$canAdd = ($this->tabAccess['add'] === 1);
|
||||
$canEdit = ($this->tabAccess['edit'] === 1);
|
||||
if ($canAdd || $canEdit) {
|
||||
$idCartBooking = Tools::getValue('id_hotel_cart_booking');
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objCart = new Cart($objHotelCartBookingData->id_cart);
|
||||
@@ -1608,11 +1613,30 @@ class AdminCartsControllerCore extends AdminController
|
||||
$response['errors'][] = Tools::displayError('Can not order multiple quanitity for service').': '.$objProduct->name;
|
||||
}
|
||||
|
||||
if (!isset($serviceUnitPrices[$idServiceProduct])
|
||||
|| !ValidateCore::isPrice($serviceUnitPrices[$idServiceProduct])
|
||||
) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objProduct->name;
|
||||
if ($canEdit) {
|
||||
if (!isset($serviceUnitPrices[$idServiceProduct])
|
||||
|| !ValidateCore::isPrice($serviceUnitPrices[$idServiceProduct])
|
||||
) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objProduct->name;
|
||||
}
|
||||
} else {
|
||||
$serviceUnitPrices[$idServiceProduct] = Product::getPriceStatic($idServiceProduct, false);
|
||||
if ($specificPriceInfo = SpecificPrice::getSpecificPrice(
|
||||
(int)$idServiceProduct,
|
||||
0,
|
||||
$objCart->id_currency,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$objCart->id,
|
||||
0,
|
||||
$objHotelCartBookingData->id
|
||||
)) {
|
||||
$serviceUnitPrices[$idServiceProduct] = $specificPriceInfo['price'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = Tools::displayError('Some services not found. please try after refreshing the page');
|
||||
@@ -1659,7 +1683,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 != $unitPrice) {
|
||||
if ($canEdit && $operator == 'up' && $originalPrice != $unitPrice) {
|
||||
if ($specificPriceInfo = SpecificPrice::getSpecificPrice(
|
||||
(int)$idServiceProduct,
|
||||
0,
|
||||
|
||||
@@ -431,6 +431,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$objHotelAdvancedPayment = new HotelAdvancedPayment();
|
||||
$adminCartsAccess = Profile::getProfileAccess(
|
||||
(int) $this->context->employee->id_profile,
|
||||
(int) Tab::getIdFromClassName('AdminCarts')
|
||||
);
|
||||
$this->context->smarty->assign(array(
|
||||
'order_total' => $cart->getOrderTotal(true),
|
||||
'is_advance_payment_active' => $objHotelAdvancedPayment->isAdvancePaymentAvailableForCurrentCart(),
|
||||
@@ -443,6 +447,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'payment_types' => $paymentTypes,
|
||||
'PAYMENT_TYPE_PAY_AT_HOTEL' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
|
||||
'currency' => new Currency((int)$cart->id_currency),
|
||||
'can_edit_booking_carts' => (!empty($adminCartsAccess['edit']) && (int) $adminCartsAccess['edit'] === 1),
|
||||
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
|
||||
|
||||
Reference in New Issue
Block a user