Merge pull request #1328 from csalvador/develop-fixAJAX
Develop fix ajax
This commit is contained in:
commit
e27d109f2d
@ -153,9 +153,9 @@ if (! empty($conf->margin->enabled)) {
|
|||||||
<?php
|
<?php
|
||||||
// Editor wysiwyg
|
// Editor wysiwyg
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
$nbrows=ROWS_2;
|
$nbrows=ROWS_2;
|
||||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||||
$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
||||||
$doleditor=new DolEditor('product_desc', GETPOST('product_desc'), '', 150, 'dolibarr_details', '', false, true, $enable, $nbrows, 70);
|
$doleditor=new DolEditor('product_desc', GETPOST('product_desc'), '', 150, 'dolibarr_details', '', false, true, $enable, $nbrows, 70);
|
||||||
$doleditor->Create();
|
$doleditor->Create();
|
||||||
?>
|
?>
|
||||||
@ -242,7 +242,6 @@ $(document).ready(function() {
|
|||||||
$('#service_duration_area').hide();
|
$('#service_duration_area').hide();
|
||||||
|
|
||||||
$('#idprod').change(function() {
|
$('#idprod').change(function() {
|
||||||
|
|
||||||
if ($(this).val() > 0) {
|
if ($(this).val() > 0) {
|
||||||
|
|
||||||
// Update vat rate combobox
|
// Update vat rate combobox
|
||||||
@ -260,11 +259,11 @@ $(document).ready(function() {
|
|||||||
if (typeof data != 'undefined') {
|
if (typeof data != 'undefined') {
|
||||||
$('#product_ref').val(data.ref);
|
$('#product_ref').val(data.ref);
|
||||||
$('#product_label').val(data.label);
|
$('#product_label').val(data.label);
|
||||||
|
$('#origin_tva_tx_cache').val(data.tva_tx);
|
||||||
$('#price_base_type').val(data.pricebasetype).trigger('change');
|
$('#price_base_type').val(data.pricebasetype).trigger('change');
|
||||||
$('#price_ht').val(data.price_ht).trigger('change');
|
$('#price_ht').val(data.price_ht).trigger('change');
|
||||||
$('#origin_price_ht_cache').val(data.price_ht);
|
$('#origin_price_ht_cache').val(data.price_ht);
|
||||||
//$('#origin_price_ttc_cache').val(data.price_ttc);
|
//$('#origin_price_ttc_cache').val(data.price_ttc);
|
||||||
$('#origin_tva_tx_cache').val(data.tva_tx);
|
|
||||||
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
|
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
|
||||||
//$('#price_base_type_area').show();
|
//$('#price_base_type_area').show();
|
||||||
$('#qty').val(data.qty);
|
$('#qty').val(data.qty);
|
||||||
@ -279,14 +278,11 @@ $(document).ready(function() {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$('#price_ttc').val('');
|
$('#price_ttc').val('');
|
||||||
|
|
||||||
// Restore vat rate combobox
|
// For compatibility with combobox
|
||||||
getVATRates('getSellerVATRates', 'tva_tx');
|
|
||||||
|
|
||||||
// For compatibility with combobox
|
|
||||||
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||||
$('#select_type').val('').removeAttr('disabled').trigger('change');
|
$('#select_type').val('').removeAttr('disabled').trigger('change');
|
||||||
$('#product_ref').val('');
|
$('#product_ref').val('');
|
||||||
@ -423,59 +419,66 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function update_price(input, output) {
|
function update_price(input, output) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php',
|
url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php',
|
||||||
data: {
|
data: {
|
||||||
'amount': $('#' + input).val(),
|
'amount': $('#' + input).val(),
|
||||||
'output': output,
|
'output': output,
|
||||||
'tva_tx': $('#tva_tx').val()
|
'tva_tx': $('#tva_tx').val()
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var addline=false;
|
var addline=false;
|
||||||
if (typeof data[output] != 'undefined') {
|
if (typeof data[output] != 'undefined') {
|
||||||
// Hide price_ttc if no vat
|
// Hide price_ttc if no vat
|
||||||
//if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) {
|
//if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) {
|
||||||
$('#' + output).val(data[output]);
|
$('#' + output).val(data[output]);
|
||||||
//}
|
//}
|
||||||
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) {
|
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) {
|
||||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||||
var content = CKEDITOR.instances['product_desc'].getData();
|
var content = CKEDITOR.instances['product_desc'].getData();
|
||||||
} else {
|
} else {
|
||||||
var content = $('#product_desc').val();
|
var content = $('#product_desc').val();
|
||||||
}
|
}
|
||||||
if (content.length > 0) {
|
if (content.length > 0) {
|
||||||
addline=true;
|
addline=true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addline=true;
|
addline=true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$('#' + input).val('');
|
$('#' + input).val('');
|
||||||
$('#' + output).val('');
|
$('#' + output).val('');
|
||||||
}
|
}
|
||||||
if (addline) {
|
if (addline) {
|
||||||
$('#addlinebutton').removeAttr('disabled');
|
$('#addlinebutton').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
$('#addlinebutton').attr('disabled','disabled');
|
$('#addlinebutton').attr('disabled','disabled');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: false});
|
async: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVATRates(action, htmlname, idprod) {
|
function getVATRates(action, htmlname, idprod) {
|
||||||
var productid = (idprod?idprod:0);
|
var productid = (idprod?idprod:0);
|
||||||
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/vatrates.php', {
|
$.ajax({
|
||||||
'action': action,
|
type: "POST",
|
||||||
'id': <?php echo $buyer->id; ?>,
|
url: '<?php echo DOL_URL_ROOT;?>/core/ajax/vatrates.php',
|
||||||
'productid': productid,
|
data: {
|
||||||
'htmlname': htmlname },
|
'action': action,
|
||||||
function(data) {
|
'id': <?php echo $buyer->id; ?>,
|
||||||
if (typeof data != 'undefined' && data.error == null) {
|
'productid': productid,
|
||||||
$("#" + htmlname).html(data.value).trigger('change');
|
'htmlname': htmlname
|
||||||
}
|
},
|
||||||
}, 'json');
|
success: function(data){
|
||||||
|
if (typeof data != 'undefined' && data.error == null) {
|
||||||
|
$("#" + htmlname).html(data.value).trigger('change');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataType: "json",
|
||||||
|
async: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if decription is not empty for free line
|
// Check if decription is not empty for free line
|
||||||
@ -524,7 +527,7 @@ $("#idprod").change(function() {
|
|||||||
$("#fournprice").empty();
|
$("#fournprice").empty();
|
||||||
$("#buying_price").show();
|
$("#buying_price").show();
|
||||||
if ($(this).val() > 0)
|
if ($(this).val() > 0)
|
||||||
{
|
{
|
||||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
|
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
var options = '';
|
var options = '';
|
||||||
@ -555,8 +558,8 @@ $("#idprod").change(function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'json');
|
'json');
|
||||||
} else {
|
} else {
|
||||||
$("#fournprice").hide();
|
$("#fournprice").hide();
|
||||||
$('#buying_price').val('');
|
$('#buying_price').val('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user