Merge pull request #1678 from AradhanaSingh63/gli-2901

Fixed: Price not updating when 'Booking Carts' edit permission is not enabled in back office.
This commit is contained in:
Rohit Jain
2026-08-14 20:01:31 +05:30
committed by GitHub
7 changed files with 88 additions and 24 deletions

View File

@@ -124,8 +124,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>

View File

@@ -27,6 +27,8 @@
var id_cart = {$cart->id|intval};
{/if}
var id_customer = 0;
var can_edit_booking_carts = {if isset($can_edit_booking_carts) && $can_edit_booking_carts}true{else}false{/if};
var can_add_addresses = {if isset($can_add_addresses) && $can_add_addresses}true{else}false{/if};
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}";
var changed_shipping_price = false;
var shipping_price_selected_carrier = '';
@@ -620,6 +622,10 @@
$(booking_occupancy_wrapper).siblings('.booking_guest_occupancy').find('span').text(guestButtonVal);
}
{/literal}
if (!can_edit_booking_carts || !can_add_addresses) {
$('#address_part').hide();
}
});
function resetBind()
@@ -953,7 +959,9 @@
{if isset($cart->id) && $cart->id}
id_cart = "{$cart->id}";
{/if}
$('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer));
if (address_link) {
$('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer));
}
$.ajax({
type:"POST",
url : "{$link->getAdminLink('AdminCarts')|addslashes}",
@@ -1505,13 +1513,20 @@
if (addresses.length == 0)
{
$('#address_delivery, #address_invoice').hide();
$("#new_address").show();
if (can_edit_booking_carts && can_add_addresses) {
$('#address_part').show();
$("#new_address").show();
} else {
$('#address_part').hide();
}
}
else
{
$('#addresses_err').hide();
$("#new_address").hide();
$('#address_delivery, #address_invoice').show();
$('#address_part').show();
$('#address_part .panel-heading').show();
}
$('#id_address_delivery').html(addresses_delivery_options).hide();
@@ -1894,13 +1909,15 @@
</span>
</div>
</div>
<div class="col-lg-6">
<span class="form-control-static">{l s='Or'}&nbsp;</span>
<a class="fancybox_customer btn btn-default" href="{$link->getAdminLink('AdminCustomers')|escape:'html':'UTF-8'}&amp;addcustomer&amp;liteDisplaying=1&amp;submitFormAjax=1#">
<i class="icon-plus-sign-alt"></i>
{l s='Add new customer'}
</a>
</div>
{if isset($can_edit_booking_carts) && $can_edit_booking_carts && isset($can_add_customers) && $can_add_customers}
<div class="col-lg-6">
<span class="form-control-static">{l s='Or'}&nbsp;</span>
<a class="fancybox_customer btn btn-default" href="{$link->getAdminLink('AdminCustomers')|escape:'html':'UTF-8'}&amp;addcustomer&amp;liteDisplaying=1&amp;submitFormAjax=1#">
<i class="icon-plus-sign-alt"></i>
{l s='Add new customer'}
</a>
</div>
{/if}
</div>
</div>
</div>
@@ -1918,7 +1935,7 @@
<a href="{$link->getAdminLink('AdminCustomers')}&id_customer={$customer->id}&viewcustomer&liteDisplaying=1" class="btn btn-default fancybox">
<i class="icon-search"></i> Details </a>
<button type="button" data-id_cart="6" data-customer="2" class="btn btn-default pull-right change-customer">
<i class="icon-refresh"></i>&nbsp;Change
<i class="icon-refresh"></i>&nbsp;Change
</button>
</div>
</div>
@@ -2127,13 +2144,15 @@
</div>
</div>
</div>
<div class="col-lg-6">
<span class="form-control-static">{l s='Or'}&nbsp;</span>
<a class="fancybox btn btn-default" href="{$link->getAdminLink('AdminCartRules')|escape:'html':'UTF-8'}&amp;addcart_rule&amp;liteDisplaying=1&amp;submitFormAjax=1#">
<i class="icon-plus-sign-alt"></i>
{l s='Add new voucher'}
</a>
</div>
{if isset($can_edit_booking_carts) && $can_edit_booking_carts && isset($can_add_vouchers) && $can_add_vouchers}
<div class="col-lg-6">
<span class="form-control-static">{l s='Or'}&nbsp;</span>
<a class="fancybox btn btn-default" href="{$link->getAdminLink('AdminCartRules')|escape:'html':'UTF-8'}&amp;addcart_rule&amp;liteDisplaying=1&amp;submitFormAjax=1#">
<i class="icon-plus-sign-alt"></i>
{l s='Add new voucher'}
</a>
</div>
{/if}
</div>
</div>
</div>
@@ -2155,7 +2174,7 @@
</div>
<div class="panel" id="address_part" style="">
<div class="panel-heading">
<div class="panel-heading" id="address_panel_heading">
<i class="icon-envelope"></i>
{l s='Addresses'}
</div>
@@ -2189,6 +2208,7 @@
</div>
</div>
</div>
{if isset($can_edit_booking_carts) && $can_edit_booking_carts && isset($can_add_addresses) && $can_add_addresses}
<div class="row">
<div class="col-lg-12">
<a class="fancybox btn btn-default" id="new_address" href="{$link->getAdminLink('AdminAddresses')|escape:'html':'UTF-8'}&amp;addaddress&amp;id_customer=42&amp;liteDisplaying=1&amp;submitFormAjax=1#">
@@ -2197,6 +2217,7 @@
</a>
</div>
</div>
{/if}
</div>
<div class="panel" id="carriers_part" style="display:none;">
<div class="panel-heading">

View File

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

View File

@@ -695,6 +695,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
));
@@ -1265,7 +1266,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(
@@ -1574,6 +1576,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(
@@ -1589,7 +1592,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);
@@ -1667,7 +1672,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,

View File

@@ -484,6 +484,22 @@ class AdminOrdersControllerCore extends AdminController
}
$objHotelAdvancedPayment = new HotelAdvancedPayment();
$adminCartsAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminCarts')
);
$adminCustomersAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminCustomers')
);
$adminCartRulesAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminCartRules')
);
$adminAddressesAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminAddresses')
);
$this->context->smarty->assign(array(
'order_total' => $cart->getOrderTotal(true),
'is_advance_payment_active' => $objHotelAdvancedPayment->isAdvancePaymentAvailableForCurrentCart(),
@@ -497,6 +513,11 @@ 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),
'can_add_customers' => (!empty($adminCustomersAccess['add']) && (int) $adminCustomersAccess['add'] === 1),
'can_add_vouchers' => (!empty($adminCartRulesAccess['add']) && (int) $adminCartRulesAccess['add'] === 1),
'can_add_addresses' => (!empty($adminAddressesAccess['add']) && (int) $adminAddressesAccess['add'] === 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,
));

View File

@@ -373,6 +373,11 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$occupancyRequiredForBooking = true;
}
$adminCartsAccess = Profile::getProfileAccess(
(int) $this->context->employee->id_profile,
(int) Tab::getIdFromClassName('AdminCarts')
);
$this->context->smarty->assign(array(
'adults' => $adults,
'children' => $children,
@@ -386,6 +391,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'link' => $this->context->link,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
'can_add_booking_carts' => (!empty($adminCartsAccess['add']) && (int) $adminCartsAccess['add'] === 1),
'htl_connected_rooms' => HotelConnectedRoom::getConnectedRooms(null, null, $this->id_hotel, $this->context->language->id),
));

View File

@@ -34,7 +34,9 @@
{if $occupancy_required_for_booking}
<th class="fixed-width-xxl"><span class="title_box">{l s='Guests' mod='hotelreservationsystem'}</span></th>
{/if}
{if isset($can_add_booking_carts) && $can_add_booking_carts}
<th><span class="title_box">{l s='Action' mod='hotelreservationsystem'}</span></th>
{/if}
</tr>
</thead>
<tbody>
@@ -105,7 +107,9 @@
</td>
{/if}
<td>
{if isset($can_add_booking_carts) && $can_add_booking_carts}
<button type="button" data-id-cart="" data-id-cart-book-data="" data-id-product="{$avai_v['id_product']|escape:'htmlall':'UTF-8'}" data-id-room="{$avai_v['id_room']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$avai_v['id_hotel']}" data-date-from="{$date_from|escape:'htmlall':'UTF-8'}" data-date-to ="{$date_to|escape:'htmlall':'UTF-8'}" class="btn btn-primary avai_add_cart">{l s='Add To Cart' mod='hotelreservationsystem'}</button>
{/if}
</td>
</tr>
{/foreach}
@@ -124,7 +128,7 @@
{if $occupancy_required_for_booking}
<th class="fixed-width-xxl"><span class="title_box">{l s='Guests' mod='hotelreservationsystem'}</span></th>
{/if}
<th><span class="title_box">{l s='Action' mod='hotelreservationsystem'}</span></th>
{if isset($can_add_booking_carts) && $can_add_booking_carts}<th><span class="title_box">{l s='Action' mod='hotelreservationsystem'}</span></th>{/if}
</tr>
</thead>
<tbody>