-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.html
348 lines (337 loc) · 18.2 KB
/
configuration.html
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.9.17/css/aui.min.css" media="all">
<script src="https://ac-getting-started.atlassian.net/atlassian-connect/all.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//aui-cdn.atlassian.com/aui-adg/5.9.17/js/aui.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<style type="text/css">
form.aui .checkbox .error,
form.aui .field-group .error,
form.aui .group .error,
form.aui .radio .error{
display: inline-block !important;
width: 100%;
}
label.error{
clear: none !important;
text-align: left !important;
color: #de350b !important;
}
</style>
</head>
<body class="aui-page-focused aui-page-focused-xlarge">
<div id="page">
<section id="content">
<header class="aui-page-header">
<div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h2>PayPal For Jira configuration page</h2>
<p id="custom-message">This is an example configuration page for board ID: {{id}} with board type: {{type}}.</p>
</div>
</div>
</header>
<div class="aui-page-panel">
<div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<form class="aui" id="aui-frm" enctype="multipart/form-data">
<div class="aui-group">
<div class="aui-item">
<h3>Business Information</h3>
<fieldset>
<div class="field-group">
<label for="fname">First Name<span class="aui-icon icon-required"> required</span></label>
<input class="text" type="text" id="fname" name="fname" title="first name" autocomplete="off" tabindex="1" autofocus>
</div>
<div class="field-group">
<label for="lname">Last Name<span class="aui-icon icon-required"> required</span></label>
<input class="text" type="text" id="lname" name="lname" title="last name" autocomplete="off" tabindex="2">
</div>
<div class="field-group">
<label for="company_name">Company Name<span class="aui-icon icon-required"> required</span></label>
<input class="text" type="text" id="company_name" name="company_name" title="company name" autocomplete="off" tabindex="3">
</div>
<div class="field-group">
<label for="email_address">Email Address<span class="aui-icon icon-required"> required</span></label>
<input class="text" type="text" id="email_address" name="email_address" title="first name" autocomplete="off" tabindex="4">
</div>
<div class="field-group">
<label for="phone_number">Phone Number<span class="aui-icon icon-required"> required</span></label>
<input class="text" type="text" id="phone_number" name="phone_number" title="phone number" autocomplete="off" tabindex="5">
</div>
<div class="field-group">
<label for="address">Address</label>
<textarea class="textarea" rows="3" cols="10" name="address" id="address" tabindex="6"></textarea>
</div>
</fieldset>
</div>
<div class="aui-item">
</div>
</div>
<div class="aui-group">
<div class="aui-item">
<h3>Default Value Setters</h3>
<fieldset>
<div class="field-group">
<label for="shipping_amount">Shipping Amount</label>
<input class="text" type="text" id="shipping_amount" name="shipping_amount" title="shipping amount" tabindex="7">
</div>
<div class="field-group">
<label for="tax">Tax Rate</label>
<input class="text short-field" type="text" id="tax_name" name="tax_name" title="tax name" placeholder="Name" tabindex="8">
<input class="text short-field" type="number" id="tax_amount" name="tax_amount" title="tax amount" placeholder="Amount" min="0" max="100" step="0.01" tabindex="9">%
</div>
<div class="field-group">
<label for="note_to_recipient">Note to Recipient</label>
<textarea class="textarea" rows="3" cols="10" name="note_to_recipient" id="note_to_recipient" tabindex="10"></textarea>
</div>
<div class="field-group">
<label for="terms_conditions">Terms and Conditions</label>
<textarea class="textarea" rows="3" cols="10" name="terms_conditions" id="terms_conditions" tabindex="11"></textarea>
</div>
<div class="field-group">
<label for="uploadFile">Logo for Invoice</label>
<input class="upfile" type="file" id="uploadAttachment" name="attachFiles[]" title="upload file" accept="image/jpeg,image/png">
<div class="description">The logo must not be larger than 250 pixels wide by 90 pixels high.</div>
<input type="hidden" name="logo_url" id="logo_url" />
</div>
<div class="field-group">
<label for="save_log_chk">Save API logs</label>
<input type="checkbox" name="save_log_chk" id="save_log_chk" />
<a href="" id="delete_logs" style="float: right;">Delete logs</a>
<input type="hidden" name="save_log" id="save_log" value="off" />
</div>
</fieldset>
<div id="aui-message-bar" style="margin-top: 20px"></div>
<div class="buttons-container">
<div class="buttons">
<input class="button submit" type="submit" value="Save" id="save">
<a class="cancel" href="#">Cancel</a>
</div>
</div>
</div>
<div class="aui-item"></div>
</div>
</form>
</section>
</div>
</div>
</section>
</div>
<script>
AJS.$(document).ready(function () {
AJS.$(document).on('click', '#delete_logs', function () {
if(confirm("Are you sure you want to delete existing logs?")){
AJS.$.ajax({
url: 'clear_logs.php',
dataType: 'json',
cache: false,
contentType: false,
processData: false,
data: '',
type: 'post',
success: function (response) {
}
});
return false;
}
else{
return false;
}
});
var config = '';
AJS.$.ajax({
url: 'fetch_json.php',
dataType: 'json',
cache: false,
contentType: false,
processData: false,
data: '',
type: 'post',
success: function (response) {
if(response.success === 'true'){
config = response.data;
AJS.$('#fname').val(config.fname);
AJS.$('#lname').val(config.lname);
AJS.$('#company_name').val(config.company_name);
AJS.$('#email_address').val(config.email_address);
AJS.$('#phone_number').val(config.phone_number);
AJS.$('#address').val(config.address);
AJS.$('#logo_url').val(config.logo_url);
AJS.$('#shipping_amount').val(config.shipping_amount);
AJS.$('#tax_name').val(config.tax_name);
AJS.$('#tax_amount').val(config.tax_amount);
AJS.$('#note_to_recipient').val(config.note_to_recipient);
AJS.$('#terms_conditions').val(config.terms_conditions);
if(config.save_logs == 'on'){
AJS.$('#save_log').val('on');
AJS.$('#save_log_chk').prop('checked', true);
}
else{
AJS.$('#save_log').val('off');
AJS.$('#save_log_chk').prop('checked', false);
}
}
},
error: function (response) {
console.log(response);
}
});
AJS.$(document).on('change', '#save_log_chk', function () {
if (AJS.$(this).is(':checked')) {
AJS.$('#save_log').val('on');
AJS.$('#save_log_chk').prop('checked', true);
} else {
AJS.$('#save_log').val('off');
AJS.$('#save_log_chk').prop('checked', false);
}
});
var urls = '';
AJS.$(document).on('change', '#uploadAttachment', function () {
var form_data = new FormData();
var ins = document.getElementById('uploadAttachment').files.length;
form_data.append('from_config','yes');
for (var x = 0; x < ins; x++) {
form_data.append("files[]", document.getElementById('uploadAttachment').files[x]);
}
AJS.$.ajax({
url: 'uploads.php',
dataType: 'json',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function (response) {
urls = response;
AJS.$.each(urls.files,function(index,value){
AJS.$('#logo_url').val(value.url);
});
},
error: function (response) {
console.log(response);
}
});
});
AJS.$(document).on('click', '#save', function (e) {
e.preventDefault();
if (AJS.$("#aui-frm").valid()) {
$.ajax({
type: 'POST',
url: 'create_json.php',
beforeSend: function () {
},
complete: function () {
},
data: {
form_data : AJS.$("#aui-frm").serialize()
},
dataType: "json",
success: function (result) {
if (result.success == 'true') {
AJS.messages.success({
title: 'Success',
body: '<p>Settings saved successfully.</p>'
});
}
else{
AJS.messages.error({
title: 'Error',
body: '<p>Error saving data. Please try again.</p>'
});
}
}
});
}
else{
AJS.$([document.documentElement, document.body]).animate({
scrollTop: $("#fname").offset().top
}, 500);
}
});
AJS.$("#aui-frm").validate({
rules: {
fname:{
required: true,
nameregex : true,
maxlength : 260
},
lname:{
required: true,
nameregex : true,
maxlength : 260
},
company_name:{
required: true,
maxlength : 260,
noSpace : true
},
email_address:{
required: true,
check_email: true,
maxlength: 260
},
phone_number:{
required: true,
opphonenumber : true
},
shipping_amount:{
ppriceValidator : true
},
tax_name:{
maxlength: 100
}
},
messages: {
fname: {
required: 'First name is required.',
nameregex: 'Please enter a valid name.',
maxlength: 'First name can not be longer than {0} characters.'
},
lname: {
required: 'Last name is required.',
nameregex: 'Please enter a valid name.',
maxlength: 'Last name can not be longer than {0} characters.'
},
company_name: {
required: 'Company name is required.',
maxlength: 'Company name can not be longer than {0} characters.',
noSpace : 'Please enter a valid company name.'
},
email_address: {
required: "Email address is required.",
check_email: "Please enter a valid email address.",
maxlength: "Email address can not be longer than {0} characters."
},
phone_number:{
required: 'Phone number is required.',
},
shipping_amount:{
ppriceValidator : 'Please enter a valid shipping amount.'
},
tax_name:{
maxlength:"Tax name can not be longer than {0} characters."
}
}
});
AJS.$.validator.addMethod("nameregex", function(value, element) {
return this.optional( element ) || /^[a-zA-Z]+$/.test( value );
}, 'Please enter a valid name.');
AJS.$.validator.addMethod("check_email", function(value, element) {
return this.optional( element ) || /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i.test( value );
}, 'Please enter a valid email address.');
AJS.$.validator.addMethod("opphonenumber", function(value, element) {
return this.optional( element ) || /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/.test( value );
}, 'Please enter a valid phone number.');
AJS.$.validator.addMethod("ppriceValidator", function(value, element) {
return this.optional( element ) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test( value );
}, 'Please enter a valid amount.');
AJS.$.validator.addMethod("noSpace", function(value, element) {
return value.indexOf(" ") < 0 && value != "";
}, "Please enter a valid value.");
});
</script>
</body>
</html>