-
Notifications
You must be signed in to change notification settings - Fork 641
/
donate.html
378 lines (335 loc) · 11.2 KB
/
donate.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Donation Form - Wildguard</title>
<!-- Bootstrap CSS -->
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Oswald:[email protected]&display=swap"
rel="stylesheet"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Oswald:[email protected]&display=swap"
rel="stylesheet"
/>
<!--importing library for downloading receipt in pdf format -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.2/html2pdf.bundle.js"></script>
<!-- Custom CSS -->
<style>
body {
background-image: url('assets/images/bg\ form.jpg');
background-size: cover;
background-position: center;
font-family: Arial, sans-serif;
padding-top: 150px;
padding-right: 150px;
}
#name-error {
display: none;
color: #ff3737;
font-size: 12px;
font-weight: bold;
padding: 5px;
border-radius: 5px;
background-color: white;
border: 1px solid #ff3737;
}
#name-error i {
margin-right: 5px;
}
.form-container {
max-width: 650px;
margin: 0 auto;
padding: 30px;
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.8);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
h2 {
font-family: 'Oswald', sans-serif;
font-weight: bold;
color: #1f8c3a;
margin-bottom: 20px;
text-align: center;
}
label {
font-weight: 600;
color: #495057;
}
.form-control,
.form-check-label {
font-size: 2rem;
}
#recurringOptions {
margin-top: -10px;
}
button[type='submit'] {
font-family: 'Inter', sans-serif;
background-color: #1f8c3a;
border-color: #1f8c3a;
}
button[type='submit']:hover {
background-color: #09c031;
}
.donation-summary {
display: none;
background-color: #ffffff;
border: 1px solid #c3e6cb;
padding: 20px;
border-radius: 10px;
}
.donation-summary h4 {
color: #1f8c3a;
}
#print {
border: 1px solid black;
}
</style>
</head>
<body>
<div class="container form-container">
<h2>Support Wildguard - Donate Today !</h2>
<form id="donationForm">
<!-- Donation Type -->
<div class="form-group">
<label for="donationType">Donation Type:</label>
<select
class="form-control"
id="donationType"
name="donationType"
required
>
<option value="one-time">One-Time Donation</option>
<option value="recurring">Recurring Donation</option>
</select>
</div>
<!-- Donation Amount -->
<div class="form-group">
<label for="amount">Donation Amount (USD):</label>
<input
type="number"
class="form-control"
id="amount"
name="amount"
min="1"
placeholder="Enter amount"
required
/>
</div>
<!-- Recurring Options -->
<div class="form-group" id="recurringOptions" style="display: none">
<label for="frequency">Choose Frequency:</label>
<select class="form-control" id="frequency" name="frequency">
<option value="monthly">Monthly</option>
<option value="quarterly">Quarterly</option>
<option value="yearly">Yearly</option>
</select>
</div>
<!-- Payment Method -->
<div class="form-group">
<label for="paymentMethod">Payment Method:</label>
<select
class="form-control"
id="paymentMethod"
name="paymentMethod"
required
>
<option value="credit-card">Credit Card</option>
<option value="paypal">PayPal</option>
<option value="bank-transfer">Bank Transfer</option>
</select>
</div>
<!-- Personal Info -->
<div class="form-group">
<label for="name">Full Name:</label>
<input
type="text"
class="form-control"
id="name"
name="name"
pattern="[a-zA-Z\s]+"
title="Please enter your full name using only alphabetic characters and spaces"
placeholder="Enter your full name"
required
/>
<div
id="name-error"
style="display: none; color: red; font-size: 12px"
>
Invalid format! Please enter your full name using only alphabetic
characters and spaces.
</div>
</div>
<div class="form-group">
<label for="email">Email Address:</label>
<input
type="email"
class="form-control"
id="email"
name="email"
placeholder="Enter your email"
required
/>
</div>
<!-- Anonymous Donation -->
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="anonymous"
name="anonymous"
/>
<label class="form-check-label" for="anonymous">
Donate anonymously
</label>
</div>
<!-- Submit Button -->
<button type="submit" class="btn btn-primary mt-3 btn-block">
Submit Donation
</button>
</form>
<!-- Donation Summary -->
<div class="donation-summary mt-5" id="donationSummary">
<h4>Thank you for your support!</h4>
<p>
<strong>Type:</strong>
<span id="summaryType"></span>
</p>
<p>
<strong>Amount:</strong>
$
<span id="summaryAmount"></span>
</p>
<p id="summaryFrequencyContainer" style="display: none">
<strong>Frequency:</strong>
<span id="summaryFrequency"></span>
</p>
<p>
<strong>Payment Method:</strong>
<span id="summaryPaymentMethod"></span>
</p>
<p>
<strong>Name:</strong>
<span id="summaryName"></span>
</p>
<p>
<strong>Email:</strong>
<span id="summaryEmail"></span>
</p>
<p>
<strong>Anonymous:</strong>
<span id="summaryAnonymous"></span>
</p>
<button type="button" id="print" class="btn">Download Receipt</button>
</div>
</div>
<!-- Bootstrap JS & jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
window.onload = function () {
document.getElementById('print').addEventListener('click', () => {
// Target the specific divs you want to print
const a = document.getElementById('donationSummary').cloneNode(true);
// Remove the "Download Receipt" button from the cloned element
const downloadButton = a.querySelector('#print');
if (downloadButton) {
downloadButton.remove();
}
var opt = {
margin: 0.7,
filename: 'receipt.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' },
};
// Get current date and time in the specified formats
var now = new Date();
var dateString = now
.toLocaleDateString('en-GB', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
})
.split('/')
.join('-');
var timeString = now.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
hour12: true,
});
const content = `
<div style="text-align: center;margin-bottom: -15px; font-family: Ubuntu;font-weight: bold; font-size:xx-large;">Receipt</div>
<div style="position: absolute; top: 10px; right: 10px; font-size: xx-small;">
<div>${dateString} ${timeString}</div>
</div>
<p>____________________________________________________________________________________________</p>
<div>${a.innerHTML}</div>
<p> ____________________________________________________________________________________________</p>
`;
html2pdf().from(content).set(opt).save();
});
};
$('#donationType').on('change', function () {
if ($(this).val() === 'recurring') {
$('#recurringOptions').slideDown();
} else {
$('#recurringOptions').slideUp();
}
});
// Form submission
$('#donationForm').on('submit', function (event) {
event.preventDefault();
// Get form values
const donationType = $('#donationType').val();
const amount = $('#amount').val();
const frequency = $('#frequency').val();
const paymentMethod = $('#paymentMethod').val();
const name = $('#name').val();
const email = $('#email').val();
const isAnonymous = $('#anonymous').is(':checked') ? 'Yes' : 'No';
// Populate summary
$('#summaryType').text(
donationType === 'recurring' ? 'Recurring' : 'One-Time'
);
$('#summaryAmount').text(amount);
$('#summaryPaymentMethod').text(
paymentMethod.charAt(0).toUpperCase() + paymentMethod.slice(1)
);
$('#summaryName').text(name);
$('#summaryEmail').text(email);
$('#summaryAnonymous').text(isAnonymous);
if (donationType === 'recurring') {
$('#summaryFrequencyContainer').show();
$('#summaryFrequency').text(
frequency.charAt(0).toUpperCase() + frequency.slice(1)
);
} else {
$('#summaryFrequencyContainer').hide();
}
// Display the donation summary
$('#donationSummary').slideDown();
});
</script>
<!-- Name validation alert script -->
<script>
$('#name').on('input', function () {
var nameInput = $(this).val();
if (!nameInput.match(/^[a-zA-Z\s]+$/)) {
$('#name-error').show();
} else {
$('#name-error').hide();
}
});
</script>
</body>
</html>