forked from thirtybees/community-theme-default
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvatManagement.js
77 lines (69 loc) · 2.22 KB
/
vatManagement.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$(document).ready(function() {
vat_number();
vat_number_ajax();
$(document).on('input', '#company, #company_invoice', function() {
vat_number();
});
});
function vat_number() {
if ($('#company').length && ($('#company').val() != '')) {
vat_number_show();
} else {
vat_number_hide();
}
$('#vat-exemption').not(':checked').on('change', function() {
if (this.checked) {
$('#vat-exemption-hint').slideDown('slow');
} else {
$('#vat-exemption-hint').slideUp('fast');
}
});
if ($('#company_invoice').length && ($('#company_invoice').val() != ''))
$('#vat_number_block_invoice').show();
else
$('#vat_number_block_invoice').hide();
}
function vat_number_show() {
divs = $('#vat_area, #vat_number, #vat_number_block').filter(":hidden");
divs.slideDown('slow');
}
function vat_number_hide() {
divs = $('#vat_number, #vat_number_block').filter(":visible");
divs.slideUp('fast');
}
function vat_number_ajax() {
$(document).on('change', '#id_country', function() {
if ($('#company').length && !$('#company').val())
return;
if (typeof vatnumber_ajax_call !== 'undefined' && vatnumber_ajax_call)
$.ajax({
type: 'POST',
headers: {'cache-control': 'no-cache'},
url: baseDir + 'modules/vatnumber/ajax.php?id_country=' + parseInt($(this).val()) + '&rand=' + new Date().getTime(),
success: function(isApplicable) {
if (isApplicable == '1') {
vat_number_show();
} else {
vat_number_hide();
}
}
});
});
$(document).on('change', '#id_country_invoice', function() {
if ($('#company_invoice').length && !$('#company_invoice').val())
return;
if (typeof vatnumber_ajax_call !== 'undefined' && vatnumber_ajax_call)
$.ajax({
type: 'POST',
headers: {'cache-control': 'no-cache'},
url: baseDir + 'modules/vatnumber/ajax.php?id_country=' + parseInt($(this).val()) + '&rand=' + new Date().getTime(),
success: function(isApplicable) {
if (isApplicable == '1') {
$('#vat_area_invoice').show();
$('#vat_number_invoice').show();
} else
$('#vat_area_invoice').hide();
}
});
});
}