diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 9027ebea2..939ff2eda 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -38,7 +38,6 @@ var id_lang = ''; //var txt_show_carts = '{l s='Show carts and orders for this customer.' js=1}'; //var txt_hide_carts = '{l s='Hide carts and orders for this customer.' js=1}'; - var defaults_order_state = new Array(); var customization_errors = false; var pic_dir = '{$pic_dir}'; var currency_format = 5; @@ -46,9 +45,6 @@ var currency_blank = false; var priceDisplayPrecision = {$smarty.const._PS_PRICE_DISPLAY_PRECISION_|intval}; - {foreach from=$defaults_order_state key='module' item='id_order_state'} - defaults_order_state['{$module}'] = '{$id_order_state}'; - {/foreach} $(document).ready(function() { $('#customer').typeWatch({ @@ -63,12 +59,6 @@ wait: 750, callback: function(){ searchProducts(); } }); - $('#payment_module_name').change(function() { - var id_order_state = defaults_order_state[this.value]; - if (typeof(id_order_state) == 'undefined') - id_order_state = defaults_order_state['other']; - $('#id_order_state').val(id_order_state); - }); $("#id_address_delivery").change(function() { updateAddresses(); }); @@ -674,14 +664,36 @@ $(cart_row).find('.cart_line_total_price').html(data.total_price); } - function updateCartSummaryData(summaryData) { + function updateCartSummaryData(jsonSummary) { $('#total_rooms').html(formatCurrency(parseFloat(jsonSummary.summary.total_rooms + jsonSummary.summary.total_extra_demands + jsonSummary.summary.total_additional_services + jsonSummary.summary.total_additional_services_auto_add), currency_format, currency_sign, currency_blank)); - $('#total_vouchers').html(formatCurrency(parseFloat(summaryData.summary.total_discounts_tax_exc), currency_format, currency_sign, currency_blank)); + $('#total_vouchers').html(formatCurrency(parseFloat(jsonSummary.summary.total_discounts_tax_exc), currency_format, currency_sign, currency_blank)); $('#total_convenience_fees').html(formatCurrency(parseFloat(jsonSummary.summary.convenience_fee), currency_format, currency_sign, currency_blank)); $('#total_without_taxes').html(formatCurrency(parseFloat(jsonSummary.summary.total_price_without_tax - jsonSummary.summary.convenience_fee), currency_format, currency_sign, currency_blank)); // $('#total_service_products').html(formatCurrency(parseFloat(jsonSummary.summary.total_service_products), currency_format, currency_sign, currency_blank)); - $('#total_taxes').html(formatCurrency(parseFloat(summaryData.summary.total_tax), currency_format, currency_sign, currency_blank)); - $('#total_with_taxes').html(formatCurrency(parseFloat(summaryData.summary.total_price), currency_format, currency_sign, currency_blank)); + $('#total_taxes').html(formatCurrency(parseFloat(jsonSummary.summary.total_tax), currency_format, currency_sign, currency_blank)); + $('#total_with_taxes').html(formatCurrency(parseFloat(jsonSummary.summary.total_price), currency_format, currency_sign, currency_blank)); + + $('#payment_amount').val(jsonSummary.summary.total_price); + if (jsonSummary.summary.is_advance_payment_active) { + $('#advance_payment_amount').html(formatCurrency(parseFloat(jsonSummary.summary.advance_payment_amount_ti), currency_format, currency_sign, currency_blank)); + $('#advance_payment_amount_block').show(); + } else { + $('#advance_payment_amount_block').hide(); + } + + // toggle payment fields + let isFreeOrder = false; + if (jsonSummary.summary.is_advance_payment_active && jsonSummary.summary.advance_payment_amount_with_tax == 0) { + isFreeOrder = true; + } else if (jsonSummary.summary.total_price == 0) { + isFreeOrder = true; + } + + if (isFreeOrder) { + $('#send_email_to_customer, [name="is_full_payment"], #payment_amount, #payment_type, #payment_module_name, #payment_transaction_id').closest('.form-group').hide(200); + } else { + $('#send_email_to_customer, [name="is_full_payment"], #payment_amount, #payment_type, #payment_module_name, #payment_transaction_id').closest('.form-group').show(200); + } } function displayQtyInStock(id) @@ -1609,9 +1621,19 @@ $(document).on('change', 'input[name="is_full_payment"]', function() { if (parseInt($('input[name="is_full_payment"]:checked').val())) { - $('#payment_amount').closest('.form-group').hide(200); + $('#payment_amount').attr('disabled', true); } else { - $('#payment_amount').closest('.form-group').show(200); + $('#payment_amount').attr('disabled', false); + } + }); + + $(document).on('keyup', '#payment_amount', function() { + let paymentAmount = parseFloat($('#payment_amount').val().trim()); + + if (paymentAmount != 0) { + $('#payment_type, #payment_transaction_id').closest('.form-group').show(200); + } else { + $('#payment_type, #payment_transaction_id').closest('.form-group').hide(200); } }); @@ -2102,7 +2124,7 @@ -
+ {l s='Advance payment amount: '} + {displayPrice price=$advance_payment_amount_ti currency=$currency->id} +
+