Skip to content

Commit

Permalink
Merge pull request #941 from shreesh-webkul/gli-1753
Browse files Browse the repository at this point in the history
Added: Admin can add custom price for facilities and services while editing order
  • Loading branch information
rohit053 authored Mar 18, 2024
2 parents c1962e5 + ed84aab commit 8cd1d29
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@
{if isset($extraDemands) && $extraDemands}
{foreach $extraDemands as $roomDemand}
{foreach $roomDemand['extra_demands'] as $demand}
<tr>
<tr data-id_booking_demand="{$demand['id_booking_demand']}">
<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='/ night'}
{/if}
<div class="input-group">
<span class="input-group-addon">{$currencySign}</span>
<input type="text" class="form-control unit_price" value="{Tools::ps_round($demand['unit_price_tax_excl'], 2)}">
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
<span class="input-group-addon">{l s='/ night'}</span>
{/if}
</div>
</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>
Expand Down Expand Up @@ -74,7 +77,7 @@
<th></th>
<th>{l s='Name'}</th>
<th>{l s='Option'}</th>
<th class="text-right">{l s='Price'}</th>
<th class="text-right">{l s='Unit Price'}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -103,12 +106,21 @@
{/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_tax_excl'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price_tax_excl']|escape:'html':'UTF-8'}{else if isset($demand['adv_option']) && $demand['adv_option']}{convertPrice price = $demand['adv_option'][$demand['adv_option']|@key]['price_tax_excl']}{else}{convertPrice price = $demand['price_tax_excl']|escape:'html':'UTF-8'}{/if}
</span>
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
{l s='/ night'}
{/if}

<div class="input-group">
<span class="input-group-addon">{$currencySign}</span>
{if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price_tax_excl'])}
{assign var=demand_price value=$demand['adv_option'][$selected_adv_option]['price_tax_excl']}
{else if isset($demand['adv_option']) && $demand['adv_option']}
{assign var=demand_price value=$demand['adv_option'][$demand['adv_option']|@key]['price_tax_excl']}
{else}
{assign var=demand_price value=$demand['price_tax_excl']}
{/if}
<input type="text" class="form-control unit_price" value="{Tools::ps_round($demand_price, 2)}" data-id-product="{$product['id_product']}">
{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}
<span class="input-group-addon">{l s='/ night'}</span>
{/if}
</div>
</td>
</tr>
{/foreach}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th></th>
<th class="fixed-width-md">{l s='Quantity'}</th>
<th class="fixed-width-sm"></th>
<th class="fixed-width-sm">{l s='Quantity'}</th>
<th>{l s='Unit Price'}</th>
<th>{l s='Total Price'}</th>
<th class="text-right">{l s='Action'}</th>
Expand All @@ -41,7 +41,7 @@
<tbody>
{if isset($additionalServices) && $additionalServices}
{foreach $additionalServices['additional_services'] as $service}
<tr class="room_demand_block">
<tr class="room_demand_block" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}">
<td>
<div>{$service['name']|escape:'html':'UTF-8'}</div>
</td>
Expand All @@ -53,10 +53,10 @@
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
</td>
<td class="col-sm-4">
<td>
{if $service['allow_multiple_quantity']}
<div class="qty_container">
<input type="number" class="form-control qty" min="1" data-max-quantity="{$service['max_quantity']}" 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'}">
<input type="number" class="form-control qty" min="1" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}">
<p style="display:{if $service['quantity'] > $service['max_quantity']}block{else}none{/if}; margin-top: 4px;">
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$service['max_quantity']}</span>
</p>
Expand All @@ -66,10 +66,16 @@
{/if}
</td>
<td>
{displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency}
{if $service['product_price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
<div class="input-group">
<span class="input-group-addon">{$currencySign}</span>
<input type="text" class="form-control unit_price" value="{Tools::ps_round($service['unit_price_tax_excl'], 2)}" data-id-product="{$product['id_product']}">
{if Product::PRICE_CALCULATION_METHOD_PER_DAY == $service.product_price_calculation_method}
<span class="input-group-addon">{l s='/ night'}</span>
{/if}
</div>
{* {if $service['product_price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
{l s='/ night'}
{/if}
{/if} *}
</td>
<td>{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}</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>
Expand All @@ -93,9 +99,9 @@
<tr>
<th></th>
<th>{l s='Name'}</th>
<th></th>
<th class="fixed-width-md">{l s='Quantity'}</th>
<th class="text-right">{l s='Price'}</th>
<th class="fixed-width-sm"> </th>
<th class="fixed-width-sm">{l s='Quantity'}</th>
<th>{l s='Unit Price'}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -125,10 +131,13 @@
{/if}
</td>
<td class="text-right">
{convertPrice price=$product['price_tax_exc']}
{if $product['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
{l s='/ night'}
{/if}
<div class="input-group">
<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>
{/if}
</div>
</td>
</tr>
{/foreach}
Expand Down
107 changes: 97 additions & 10 deletions admin/themes/default/template/controllers/orders/helpers/view/view.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1834,11 +1834,11 @@
});
$(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) {
var qty_wntd = $(this).val();
if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) {
$(this).val(1);
}
updateAdditionalServices($(this));
updateAdditionalServices($(this).closest('tr'));
});
$(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .unit_price', function(e) {
updateAdditionalServices($(this).closest('tr'));
});
$(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) {
Expand All @@ -1848,6 +1848,52 @@
}
});
function updateAdditionalServices(element)
{
var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail');
if ($(element).find('.qty').length) {
var qty = $(element).find('.qty').val();
if (qty == '' || !$.isNumeric(qty) || qty < 1) {
$(element).find('.qty').val(1);
qty = 1;
}
} else {
var qty = 1;
}
var unit_price = $(element).find('.unit_price').val();
if ($.isNumeric(qty)) {
$.ajax({
type: 'POST',
headers: {
"cache-control": "no-cache"
},
url: "{$link->getAdminLink('AdminOrders')|addslashes}",
dataType: 'JSON',
cache: false,
data: {
id_room_type_service_product_order_detail: id_room_type_service_product_order_detail,
qty: qty,
unit_price: unit_price,
action: 'updateRoomAdditionalServices',
ajax: true
},
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);
}
}
});
}
}
$(document).on('submit', '#add_room_services_form', function(e) {
e.preventDefault();
var form_data = new FormData(this);
Expand Down Expand Up @@ -1889,7 +1935,8 @@
$(this).closest('#room_extra_demand_content').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()
'id_option': $(this).closest('.room_demand_block').find('.id_option').val(),
'unit_price': $(this).closest('.room_demand_block').find('.unit_price').val()
});
});
Expand All @@ -1905,15 +1952,17 @@
data: {
id_htl_booking: idHtlBooking,
room_demands: JSON.stringify(roomDemands),
action: 'EditRoomExtraDemands',
action: 'addRoomExtraDemands',
ajax: true
},
success: function(jsonData) {
if (jsonData.success) {
if (!jsonData.hasError) {
showSuccessMessage(txtExtraDemandSucc);
if (jsonData.facilities_panel) {
$('#room_type_demands_desc').replaceWith(jsonData.facilities_panel);
}
} else if (jsonData.errors) {
showErrorMessage(jsonData.errors);
} else {
showErrorMessage(txtSomeErr);
}
Expand All @@ -1925,6 +1974,44 @@
}
});
{* edit room extra demand*}
$(document).on('focusout', '#rooms_type_extra_demands .room_ordered_demands .unit_price', function(e) {
updateRoomDemand($(this).closest('tr'));
});
function updateRoomDemand(element)
{
var id_booking_demand = $(element).data('id_booking_demand');
var unit_price = $(element).find('.unit_price').val();
$.ajax({
type: 'POST',
headers: {
"cache-control": "no-cache"
},
url: "{$link->getAdminLink('AdminOrders')|addslashes}",
dataType: 'JSON',
cache: false,
data: {
id_booking_demand: id_booking_demand,
unit_price: unit_price,
action: 'updateRoomExtraDemands',
ajax: true
},
success: function(jsonData) {
if (!jsonData.hasError) {
if (jsonData.facilities_panel) {
$('#room_type_demands_desc').replaceWith(jsonData.facilities_panel);
}
showSuccessMessage(txtExtraDemandSucc);
} else {
showErrorMessage(jsonData.errors);
}
}
});
}
{* Delete ordered room booking demand *}
$(document).on('click', '.del-order-room-demand', function(e) {
e.preventDefault();
Expand Down Expand Up @@ -2005,8 +2092,8 @@
var option_selected = $(this).find('option:selected');
var extra_demand_price = option_selected.attr("optionPrice")
extra_demand_price = parseFloat(extra_demand_price);
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);
// extra_demand_price = formatCurrency(extra_demand_price, currency_format, currency_sign, currency_blank);
$(this).closest('.room_demand_block').find('.unit_price').val(extra_demand_price);
});
$('#mySwappigModal').on('hidden.bs.modal', function (e)
Expand Down
Loading

0 comments on commit 8cd1d29

Please sign in to comment.