|
|
|
|
@ -1,32 +1,51 @@ |
|
|
|
|
$(function() { |
|
|
|
|
|
|
|
|
|
var fix_float_input = function (e) { |
|
|
|
|
var el = $(this); |
|
|
|
|
var new_val = fix_float_string(el.val()); |
|
|
|
|
if (new_val != el.val()) |
|
|
|
|
el.val(new_val); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var calc_summa = function (e) { |
|
|
|
|
console.log('calc_summa'); |
|
|
|
|
|
|
|
|
|
var el = $(this); |
|
|
|
|
var qty = parseFloat(el.closest('tr.row').find('td.qty input').val()); |
|
|
|
|
var price = parseFloat(el.closest('tr.row').find('td.price input').val()); |
|
|
|
|
var total_price = qty * price; |
|
|
|
|
if (total_price) |
|
|
|
|
el.closest('tr.row').find('td.total_price input').val(total_price.toFixed(2)); |
|
|
|
|
} |
|
|
|
|
var total_price; |
|
|
|
|
|
|
|
|
|
total_price = (qty && price) ? qty * price : 0; |
|
|
|
|
|
|
|
|
|
if (total_price) { |
|
|
|
|
el.closest('tr.row').find('td.total_price input').val(total_price.toFixed(2)); |
|
|
|
|
} else { |
|
|
|
|
el.closest('tr.row').find('td.total_price input').val(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var calc_itogo_nds = function() { |
|
|
|
|
$('#itogo_nds_text').html('НДС ' + $('#id_nds_value option:selected').text()); |
|
|
|
|
var nds = parseFloat($('#id_nds_value').val()) * parseFloat($('#itogo').html()) / 100; |
|
|
|
|
$('#itogo_nds').html(nds.toFixed(2)); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
window.calc_itogo = function (e) { |
|
|
|
|
var itogo_sum = 0; |
|
|
|
|
$('#tbl_items').find('.total_price input:visible').each(function() { |
|
|
|
|
var itogo_sum_row = $(this).val() ? parseFloat($(this).val()) : 0; |
|
|
|
|
itogo_sum += itogo_sum_row; |
|
|
|
|
}) |
|
|
|
|
$('#itogo').html(itogo_sum.toFixed(2)); |
|
|
|
|
}); |
|
|
|
|
if (itogo_sum) { |
|
|
|
|
$('#itogo').html(itogo_sum.toFixed(2)); |
|
|
|
|
} else { |
|
|
|
|
$('#itogo').html(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
calc_itogo_nds(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
window.set_events = function set_events() { |
|
|
|
|
$("#tbl_items tr.row td.qty input").on('keyup', fix_float_input); |
|
|
|
|
$("#tbl_items tr.row td.price input").on('keyup', fix_float_input); |
|
|
|
|
@ -45,18 +64,13 @@ $(function() { |
|
|
|
|
$("#tbl_items tr.row td.price input").blur(window.calc_itogo); |
|
|
|
|
$("#tbl_items tr.row td.total_price input").blur(window.calc_itogo); |
|
|
|
|
|
|
|
|
|
//$('input[name=nds_type]').change(calc_itogo_nds);
|
|
|
|
|
$('#id_nds_value').change(calc_itogo_nds); |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//$("#tbl_items tr.row td.qty input").blur(calc_itogo_nds);
|
|
|
|
|
//$("#tbl_items tr.row td.price input").blur(calc_itogo_nds);
|
|
|
|
|
//$("#tbl_items tr.row td.total_price input").blur(calc_itogo_nds);
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
window.set_events(); |
|
|
|
|
window.calc_itogo(); |
|
|
|
|
calc_itogo_nds(); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fix_float_string(val) { |
|
|
|
|
|