Fix: Update vat rate combobox
This commit is contained in:
parent
3cb93e90cd
commit
70c467e429
@ -32,6 +32,7 @@ require '../../main.inc.php';
|
|||||||
$id = GETPOST('id','int');
|
$id = GETPOST('id','int');
|
||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
$htmlname = GETPOST('htmlname','alpha');
|
$htmlname = GETPOST('htmlname','alpha');
|
||||||
|
$productid = (GETPOST('productid','int')?GETPOST('productid','int'):0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -51,7 +52,7 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
|
|||||||
|
|
||||||
$return=array();
|
$return=array();
|
||||||
|
|
||||||
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
|
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,$productid,0,'',true);
|
||||||
$return['num'] = $form->num;
|
$return['num'] = $form->num;
|
||||||
$return['error'] = $form->error;
|
$return['error'] = $form->error;
|
||||||
|
|
||||||
|
|||||||
@ -2741,6 +2741,10 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
|||||||
{
|
{
|
||||||
global $db,$mysoc;
|
global $db,$mysoc;
|
||||||
|
|
||||||
|
if (! class_exists('Product')) {
|
||||||
|
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
$ret=0;
|
$ret=0;
|
||||||
$found=0;
|
$found=0;
|
||||||
|
|
||||||
|
|||||||
@ -153,7 +153,7 @@ if (! empty($conf->margin->enabled)) {
|
|||||||
|
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php
|
<?php
|
||||||
if ($buyer->tva_assuj == "0") echo '<input type="hidden" name="np_tva_tx" value="0">0';
|
if ($buyer->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" value="0">0';
|
||||||
else echo $form->load_tva('tva_tx', (GETPOST('tva_tx')?GETPOST('tva_tx'):-1), $seller, $buyer);
|
else echo $form->load_tva('tva_tx', (GETPOST('tva_tx')?GETPOST('tva_tx'):-1), $seller, $buyer);
|
||||||
?>
|
?>
|
||||||
<input type="hidden" id="price_base_type" name="price_base_type" value="" />
|
<input type="hidden" id="price_base_type" name="price_base_type" value="" />
|
||||||
@ -229,6 +229,18 @@ $(document).ready(function() {
|
|||||||
$('#product_desc').focus();
|
$('#product_desc').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update vat rate combobox
|
||||||
|
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/vatrates.php', {
|
||||||
|
'action': 'getVATRate',
|
||||||
|
'id': <?php echo $buyer->id; ?>,
|
||||||
|
'productid': $(this).val(),
|
||||||
|
'htmlname': 'tva_tx' },
|
||||||
|
function(data) {
|
||||||
|
if (typeof data != 'undefined' && data.error == null) {
|
||||||
|
$("#tva_tx").html(data.value);
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
// For compatibility with combobox
|
// For compatibility with combobox
|
||||||
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||||
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php', {
|
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php', {
|
||||||
@ -258,6 +270,17 @@ $(document).ready(function() {
|
|||||||
$('#update_price_checkbox').removeAttr('checked');
|
$('#update_price_checkbox').removeAttr('checked');
|
||||||
$('#price_ttc').val('');
|
$('#price_ttc').val('');
|
||||||
|
|
||||||
|
// Update vat rate combobox
|
||||||
|
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/vatrates.php', {
|
||||||
|
'action': 'getVATRate',
|
||||||
|
'id': <?php echo $buyer->id; ?>,
|
||||||
|
'htmlname': 'tva_tx' },
|
||||||
|
function(data) {
|
||||||
|
if (typeof data != 'undefined' && data.error == null) {
|
||||||
|
$("#tva_tx").html(data.value);
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
// For compatibility with combobox
|
// 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');
|
||||||
@ -272,7 +295,6 @@ $(document).ready(function() {
|
|||||||
$('#update_desc_area').hide().trigger('hide');
|
$('#update_desc_area').hide().trigger('hide');
|
||||||
$('#update_price_area').hide().trigger('hide');
|
$('#update_price_area').hide().trigger('hide');
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -346,11 +368,13 @@ $(document).ready(function() {
|
|||||||
$('#update_price_area').bind('hide', function() {
|
$('#update_price_area').bind('hide', function() {
|
||||||
$('#price_ht').removeAttr('disabled');
|
$('#price_ht').removeAttr('disabled');
|
||||||
$('#price_ttc').removeAttr('disabled');
|
$('#price_ttc').removeAttr('disabled');
|
||||||
|
$('#tva_tx').removeAttr('disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#update_price_area').bind('show', function() {
|
$('#update_price_area').bind('show', function() {
|
||||||
$('#price_ht').attr('disabled', 'disabled');
|
$('#price_ht').attr('disabled', 'disabled');
|
||||||
$('#price_ttc').attr('disabled', 'disabled');
|
$('#price_ttc').attr('disabled', 'disabled');
|
||||||
|
$('#tva_tx').attr('disabled', 'disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#update_price_checkbox').change(function() {
|
$('#update_price_checkbox').change(function() {
|
||||||
@ -359,15 +383,14 @@ $(document).ready(function() {
|
|||||||
if ($('#tva_tx').val() > 0) {
|
if ($('#tva_tx').val() > 0) {
|
||||||
$('#price_ttc').removeAttr('disabled')
|
$('#price_ttc').removeAttr('disabled')
|
||||||
}
|
}
|
||||||
|
$('#tva_tx').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
$('#price_ht')
|
$('#price_ht')
|
||||||
.attr('disabled','disabled')
|
.attr('disabled','disabled')
|
||||||
.val($('#origin_price_ht_cache').val())
|
.val($('#origin_price_ht_cache').val())
|
||||||
.trigger('change');
|
.trigger('change');
|
||||||
$('#price_ttc')
|
$('#price_ttc').attr('disabled','disabled');
|
||||||
.attr('disabled','disabled');
|
$('#tva_tx').attr('disabled', 'disabled');
|
||||||
//.val($('#origin_price_ttc_cache').val())
|
|
||||||
//.trigger('change');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user