updated service pop up view on admin orders page

This commit is contained in:
Shreesh Arora
2023-03-24 13:28:58 +05:30
parent 9ae4d2a5d6
commit a4d46e690a
9 changed files with 115 additions and 65 deletions

View File

@@ -115,7 +115,7 @@
<td>{displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency}</td>
<td>
{if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])}
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands_{$room['id']}" edit_orde_line="0">
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands_{$room['id']}">
{displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency}
</a>
{else}

View File

@@ -83,7 +83,14 @@
</div>
</div>
<div class="col-xs-6">
<p><span class="pull-right extra_demand_option_price">{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}</span></p>
<p class="pull-right">
<span class="extra_demand_option_price">
{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}
</span>
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
{l s='/ day'}
{/if}
</p>
</div>
</div>
{/foreach}
@@ -121,7 +128,7 @@
<div class="col-xs-5">
<div class="row">
<div class="col-xs-2">
<input data-id_cart_booking="{$selectedRoomServiceProduct['htl_cart_booking_id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}checked{/if}/>
<input data-id_cart_booking="{$selectedRoomServiceProduct['id']}" value="{$product['id_product']|escape:'html':'UTF-8'}" type="checkbox" class="change_room_type_service_product" {if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}checked{/if}/>
</div>
<div class="col-xs-10">
<p>{$product['name']|escape:'html':'UTF-8'}</p>

View File

@@ -182,14 +182,14 @@
<td class="text-center">
<span class="extra_service_show">
{convertPriceWithCurrency price=($data['extra_demands_price_te'] + $data['additional_services_price_te'] + $data['convenience_fee_te'] + $data['additional_services_price_auto_add_te']) currency=$currency->id}
{if (isset($data['extra_demands']) && $data['extra_demands']) || (isset($data['additional_services']) && $data['additional_services'])}
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands" date_from="{$data['date_from']}" date_to="{$data['date_to']}" id_product="{$data['id_product']}" id_room="{$data['id_room']}" id_order="{$order->id}" class="open_room_extra_services" id_htl_booking="{$data['id']}" edit_orde_line="0">
{if ($data['extra_demands_price_te'] + $data['additional_services_price_te'] + $data['convenience_fee_te'] + $data['additional_services_price_auto_add_te']) > 0}
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands" date_from="{$data['date_from']}" date_to="{$data['date_to']}" id_product="{$data['id_product']}" id_room="{$data['id_room']}" id_order="{$order->id}" class="open_room_extra_services" id_htl_booking="{$data['id']}">
<i class="icon icon-lg icon-info-circle"></i>
</a>
{/if}
</span>
<span class="extra_service_edit" style="display: none;">
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands" date_from="{$data['date_from']}" date_to="{$data['date_to']}" id_product="{$data['id_product']}" id_room="{$data['id_room']}" id_order="{$order->id}" class="open_room_extra_services" id_htl_booking="{$data['id']}" edit_orde_line="0">
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands" date_from="{$data['date_from']}" date_to="{$data['date_to']}" id_product="{$data['id_product']}" id_room="{$data['id_room']}" id_order="{$order->id}" class="open_room_extra_services" id_htl_booking="{$data['id']}">
{convertPriceWithCurrency price=($data['extra_demands_price_te'] + $data['additional_services_price_te'] + $data['convenience_fee_te'] + $data['additional_services_price_auto_add_te']) currency=$currency->id}
</a>
</span>

View File

@@ -31,7 +31,8 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th>{l s='Price'}</th>
<th>{l s='Unit price'}</th>
<th>{l s='Total price'}</th>
<th class="text-right">{l s='Action'}</th>
</tr>
</thead>
@@ -41,6 +42,12 @@
{foreach $roomDemand['extra_demands'] as $demand}
<tr>
<td>{$demand['name']}</td>
<td>
{displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency}
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
{l s='/ day'}
{/if}
</td>
<td>{displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}</td>
<td><a class="btn btn-danger pull-right del-order-room-demand" href="#" id_booking_demand="{$demand['id_booking_demand']}"><i class="icon-trash"></i></a></td>
</tr>
@@ -96,7 +103,12 @@
{/if}
</td>
<td class="text-right">
<span class="extra_demand_option_price">{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}</span>
<span class="extra_demand_option_price">
{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}
</span>
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
{l s='/ day'}
{/if}
</td>
</tr>
{/foreach}
@@ -115,14 +127,21 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th>{l s='Price'}</th>
<th>{l s='Unit price'}</th>
<th class="text-right">{l s='Total price'}</th>
</tr>
</thead>
<tbody>
{foreach $roomDemand['extra_demands'] as $demand}
<tr class="room_demand_block">
<td>{$demand['name']}</td>
<td>{displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}</td>
<td>
{displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency}
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
{l s='/ day'}
{/if}
</td>
<td class="text-right">{displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}</td>
</tr>
{/foreach}
</tbody>

View File

@@ -31,9 +31,9 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th>{l s='Quantity'}</th>
<th></th>
<th class="fixed-width-md">{l s='Quantity'}</th>
<th>{l s='Price'}</th>
<th class="text-center">{l s='Options'}</th>
<th class="text-right">{l s='Action'}</th>
</tr>
</thead>
@@ -44,22 +44,24 @@
<td>
<div>{$service['name']|escape:'html':'UTF-8'}</div>
</td>
<td class="text-center">
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span><br>
{/if}
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
</td>
<td>
{if $service['allow_multiple_quantity']}
<div class="qty_container">
<input type="number" class="form-control qty" min="1" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}">
</div>
{else}
--
{/if}
</td>
<td>{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}</td>
<td class="text-center">
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</td>
<td><a class="btn btn-danger pull-right del_room_additional_service" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" href="#"><i class="icon-trash"></i></a></td>
</tr>
{/foreach}
@@ -81,7 +83,8 @@
<tr>
<th></th>
<th>{l s='Name'}</th>
<th>{l s='Quantity'}</th>
<th></th>
<th class="fixed-width-md">{l s='Quantity'}</th>
<th class="text-right">{l s='Price'}</th>
</tr>
</thead>
@@ -94,6 +97,14 @@
<td>
{$product['name']|escape:'html':'UTF-8'}
</td>
<td class="text-center">
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM}
<span class="badge badge-info label">{l s='Auto added'}</span><br>
{/if}
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT}
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
</td>
<td>
{if $product.allow_multiple_quantity}
<div class="qty_container">
@@ -124,8 +135,8 @@
<tr>
<th>{l s='ID'}</th>
<th>{l s='Name'}</th>
<th class="text-center">{l s='Options'}</th>
<th>{l s='Price'}</th>
<th></th>
<th class="text-right">{l s='Total Price'}</th>
</tr>
</thead>
</tbody>
@@ -143,7 +154,7 @@
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</td>
<td>
<td class="text-right">
{displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency}
</td>
</tr>

View File

@@ -1525,37 +1525,39 @@
extra_demand_price = formatCurrency(extra_demand_price, currency_format, currency_sign, currency_blank);
$(this).closest('.room_demand_block').find('.extra_demand_option_price').text(extra_demand_price);
var roomDemands = [];
// get the selected extra demands by customer
$(this).closest('.room_demand_detail').find('input:checkbox.id_room_type_demand:checked').each(function () {
roomDemands.push({
'id_global_demand':$(this).val(),
'id_option': $(this).closest('.room_demand_block').find('.id_option').val()
if ($(this).closest('.room_demand_block').find('input:checkbox.id_room_type_demand').is(':checked')) {
// get the selected extra demands by customer
$(this).closest('.room_demand_detail').find('input:checkbox.id_room_type_demand:checked').each(function () {
roomDemands.push({
'id_global_demand':$(this).val(),
'id_option': $(this).closest('.room_demand_block').find('.id_option').val()
});
});
});
var idBookingCart = $(this).closest('.room_demand_block').find('.id_room_type_demand').attr('id_cart_booking');
$.ajax({
type: 'POST',
dataType: 'JSON',
headers: {
"cache-control": "no-cache"
},
url: "{$link->getAdminLink('AdminCarts')|addslashes}",
dataType: 'JSON',
cache: false,
data: {
id_cart_booking: idBookingCart,
room_demands: JSON.stringify(roomDemands),
action: 'changeRoomDemands',
ajax: true
},
success: function(response) {
if (response.status) {
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(txtExtraDemandErr);
var idBookingCart = $(this).closest('.room_demand_block').find('.id_room_type_demand').attr('id_cart_booking');
$.ajax({
type: 'POST',
dataType: 'JSON',
headers: {
"cache-control": "no-cache"
},
url: "{$link->getAdminLink('AdminCarts')|addslashes}",
dataType: 'JSON',
cache: false,
data: {
id_cart_booking: idBookingCart,
room_demands: JSON.stringify(roomDemands),
action: 'changeRoomDemands',
ajax: true
},
success: function(response) {
if (response.status) {
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(txtExtraDemandErr);
}
}
}
});
});
}
});
$(document).on('click', '.change_room_type_service_product', function() {

View File

@@ -1754,7 +1754,7 @@
if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) {
$(this).val(1);
}
updateServiceProducts($(this));
updateAdditionalServices($(this));
});
$(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) {
@@ -1764,7 +1764,7 @@
}
});
function updateServiceProducts(element)
function updateAdditionalServices(element)
{
var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail');
var qty = $(element).val();
@@ -1785,6 +1785,9 @@
},
success: function(jsonData) {
if (!jsonData.hasError) {
if (jsonData.service_panel) {
$('#room_type_service_product_desc').replaceWith(jsonData.service_panel);
}
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(jsonData.errors);
@@ -1931,12 +1934,14 @@
},
success: function(jsonData) {
if (!jsonData.hasError) {
$('#room_type_service_product_desc').replaceWith(jsonData.service_panel);
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(jsonData.errors);
if (jsonData.service_panel) {
$('#room_type_service_product_desc').replaceWith(jsonData.service_panel);
}
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(jsonData.errors);
}
}
}
});
} else {

View File

@@ -4692,7 +4692,7 @@ class AdminOrdersControllerCore extends AdminController
// get room type additional demands
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct)) {
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
foreach ($roomTypeServiceProducts as $key => $product) {
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
unset($roomTypeServiceProducts[$key]);
@@ -4702,7 +4702,6 @@ class AdminOrdersControllerCore extends AdminController
}
}
$this->context->smarty->assign($smartyVars);
}
$extraDemandsTpl = $this->context->smarty->fetch(
@@ -4740,7 +4739,7 @@ class AdminOrdersControllerCore extends AdminController
// get room type additional demands
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct)) {
if ($roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
foreach ($roomTypeServiceProducts as $key => $product) {
if (in_array($product['id_product'], array_column($additionalServices['additional_services'], 'id_product'))) {
unset($roomTypeServiceProducts[$key]);
@@ -4756,7 +4755,6 @@ class AdminOrdersControllerCore extends AdminController
_PS_ADMIN_DIR_.'/themes/default/template/controllers/orders/_room_services_block.tpl'
);
return $servicesTpl;
}
public function processRenderFacilitiesBlock($idOrder, $idProduct, $dateFrom, $dateTo, $idRoom, $orderEdit)
@@ -4859,6 +4857,15 @@ class AdminOrdersControllerCore extends AdminController
$response['hasError'] = true;
$response['errors'] = $this->l('cannot order multiple quanitity for this service');
}
$objHotelBookingDetail = new HotelBookingDetail($objRoomTypeServiceProductOrderDetail->id_htl_booking_detail);
$response['service_panel']= $servicesBlock = $this->processRenderServicesPanel(
$objOrderDetail->id_order,
$objHotelBookingDetail->id_product,
$objHotelBookingDetail->date_from,
$objHotelBookingDetail->date_to,
$objHotelBookingDetail->id_room,
true
);
} else {
$response['hasError'] = true;
$response['errors'] = $this->l('Additional service not found');

View File

@@ -422,7 +422,6 @@ $(document).ready(function()
});
$(document).on('change', '.demand_adv_option_block .id_option', function(e) {
debugger
var option_selected = $(this).find('option:selected');
var extra_demand_price = option_selected.attr("optionPrice")
extra_demand_price = parseFloat(extra_demand_price);