Made update price synchronous to avoid dependency hell

This commit is contained in:
Raphaël Doursenaud 2013-11-21 18:00:27 +01:00
parent 7945011955
commit 302a230bf2

View File

@ -423,40 +423,45 @@ $(document).ready(function() {
}); });
function update_price(input, output) { function update_price(input, output) {
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', { $.ajax({
'amount': $('#' + input).val(), type: 'POST',
'output': output, url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php',
'tva_tx': $('#tva_tx').val() data: {
}, 'amount': $('#' + input).val(),
function(data) { 'output': output,
var addline=false; 'tva_tx': $('#tva_tx').val()
if (typeof data[output] != 'undefined') { },
// Hide price_ttc if no vat success: function(data) {
//if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) { var addline=false;
$('#' + output).val(data[output]); if (typeof data[output] != 'undefined') {
//} // Hide price_ttc if no vat
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) { //if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) {
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') { $('#' + output).val(data[output]);
var content = CKEDITOR.instances['product_desc'].getData(); //}
} else { if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) {
var content = $('#product_desc').val(); if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
} var content = CKEDITOR.instances['product_desc'].getData();
if (content.length > 0) { } else {
addline=true; var content = $('#product_desc').val();
} }
} else { if (content.length > 0) {
addline=true; addline=true;
} }
} else { } else {
$('#' + input).val(''); addline=true;
$('#' + output).val(''); }
} } else {
if (addline) { $('#' + input).val('');
$('#addlinebutton').removeAttr('disabled'); $('#' + output).val('');
} else { }
$('#addlinebutton').attr('disabled','disabled'); if (addline) {
} $('#addlinebutton').removeAttr('disabled');
}, 'json'); } else {
$('#addlinebutton').attr('disabled','disabled');
}
},
dataType: 'json',
async: false});
} }
function getVATRates(action, htmlname, idprod) { function getVATRates(action, htmlname, idprod) {