-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobal.js
executable file
·182 lines (142 loc) · 5.05 KB
/
global.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
jQuery(document).ready(function($) {
$('#wc_szamlazz_generate').click(function(e) {
e.preventDefault();
var r = confirm("Biztosan létrehozod a számlát?");
if (r != true) {
return false;
}
var nonce = $(this).data('nonce');
var order = $(this).data('order');
var button = $('#wc-szamlazz-generate-button');
var note = $('#wc_szamlazz_invoice_note').val();
var deadline = $('#wc_szamlazz_invoice_deadline').val();
var completed = $('#wc_szamlazz_invoice_completed').val();
var request = $('#wc_szamlazz_invoice_request').is(':checked');
if(request) {
request = 'on';
} else {
request = 'off';
}
var data = {
action: 'wc_szamlazz_generate_invoice',
nonce: nonce,
order: order,
note: note,
deadline: deadline,
completed: completed,
request: request
};
button.block({message: null, overlayCSS: {background: '#fff url(' + wc_szamlazz_params.loading + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
$.post( ajaxurl, data, function( response ) {
//Remove old messages
$('.wc-szamlazz-message').remove();
var responseText = response;
//Generate the error/success messages
if(responseText.data.error) {
button.before('<div class="wc-szamlazz-error error wc-szamlazz-message"></div>');
} else {
button.before('<div class="wc-szamlazz-success updated wc-szamlazz-message"></div>');
}
//Get the error messages
var ul = $('<ul>');
$.each(responseText.data.messages, function(i,value){
var li = $('<li>')
li.append(value);
ul.append(li);
});
$('.wc-szamlazz-message').append(ul);
//If success, hide the button
if(!responseText.data.error) {
button.slideUp();
button.before(responseText.data.link);
}
button.unblock();
});
});
$('#wc_szamlazz_options').click(function(){
$('#wc_szamlazz_options_form').slideToggle();
return false;
});
$('#wc_szamlazz_already').click(function(e) {
e.preventDefault();
var note = prompt("Számlakészítés kikapcsolása. Mi az indok?", "Ehhez a rendeléshez nem kell számla.");
if (!note) {
return false;
}
var nonce = $(this).data('nonce');
var order = $(this).data('order');
var button = $('#wc-szamlazz-generate-button');
var data = {
action: 'wc_szamlazz_already',
nonce: nonce,
order: order,
note: note
};
button.block({message: null, overlayCSS: {background: '#fff url(' + wc_szamlazz_params.loading + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
$.post( ajaxurl, data, function( response ) {
//Remove old messages
$('.wc-szamlazz-message').remove();
var responseText = response;
//Generate the error/success messages
if(responseText.data.error) {
button.before('<div class="wc-szamlazz-error error wc-szamlazz-message"></div>');
} else {
button.before('<div class="wc-szamlazz-success updated wc-szamlazz-message"></div>');
}
//Get the error messages
var ul = $('<ul>');
$.each(responseText.data.messages, function(i,value){
var li = $('<li>')
li.append(value);
ul.append(li);
});
$('.wc-szamlazz-message').append(ul);
//If success, hide the button
if(!responseText.data.error) {
button.slideUp();
button.before(responseText.data.link);
}
button.unblock();
});
});
$('#wc_szamlazz_already_back').click(function(e) {
e.preventDefault();
var r = confirm("Biztosan visszakapcsolod a számlakészítés ennél a rendelésnél?");
if (r != true) {
return false;
}
var nonce = $(this).data('nonce');
var order = $(this).data('order');
var button = $('#wc-szamlazz-generate-button');
var data = {
action: 'wc_szamlazz_already_back',
nonce: nonce,
order: order
};
$('#szamlazz_already_div').block({message: null, overlayCSS: {background: '#fff url(' + wc_szamlazz_params.loading + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
$.post( ajaxurl, data, function( response ) {
//Remove old messages
$('.wc-szamlazz-message').remove();
var responseText = response;
//Generate the error/success messages
if(responseText.data.error) {
button.before('<div class="wc-szamlazz-error error wc-szamlazz-message"></div>');
} else {
button.before('<div class="wc-szamlazz-success updated wc-szamlazz-message"></div>');
}
//Get the error messages
var ul = $('<ul>');
$.each(responseText.data.messages, function(i,value){
var li = $('<li>')
li.append(value);
ul.append(li);
});
$('.wc-szamlazz-message').append(ul);
//If success, show the button
if(!responseText.data.error) {
button.slideDown();
}
$('#szamlazz_already_div').unblock().slideUp();
});
});
});