-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
292 lines (250 loc) · 11.6 KB
/
Copy pathindex.html
File metadata and controls
292 lines (250 loc) · 11.6 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Soft UI – Casino Voucher Generator</title>
<style>
body { font-family: 'Segoe UI', sans-serif; background: #ecf0f3; padding: 15px; display: flex; justify-content: center; }
.container { display: flex; gap: 20px; flex-wrap: wrap; }
.form-section, .preview-section { background: #ecf0f3; padding: 20px; border-radius: 20px; box-shadow: 7px 7px 15px #c5c7c9, -7px -7px 15px #fff; }
.form-section { width: 350px; }
.preview-section { width: 350px; }
h2 { text-align: center; font-size: 1.3em; margin-bottom: 15px; color: #333; }
label { display: block; margin: 6px 0 3px; font-size: 0.85em; color: #555; }
input, select, textarea, button { width: 100%; padding: 10px; border-radius: 12px; border: none; background: #ecf0f3; box-shadow: inset 3px 3px 6px #c5c7c9, inset -3px -3px 6px #fff; font-size: 0.85em; margin-bottom: 10px; color: #333; }
textarea { height: 300px; resize: none; }
button { background: linear-gradient(145deg, #56ab2f, #a8e063); box-shadow: 3px 3px 6px #c5c7c9, -3px -3px 6px #fff; color: white; font-weight: bold; cursor: pointer; border: none; transition: transform 0.15s ease, box-shadow 0.15s ease; }
button:hover { transform: scale(1.05); box-shadow: 4px 4px 8px #b5b7b9, -4px -4px 8px #fff; }
button:active { transform: scale(0.97); box-shadow: inset 2px 2px 4px #c5c7c9, inset -2px -2px 4px #fff; }
.stats { background: #ecf0f3; padding: 10px; border-radius: 12px; box-shadow: inset 3px 3px 6px #c5c7c9, inset -3px -3px 6px #fff; font-size: 0.85em; color: #333; margin-bottom: 10px; }
#bkWarning { font-size: 0.8em; color: red; margin-top: -6px; margin-bottom: 8px; display: none; }
</style>
</head>
<body>
<div class="container">
<div class="form-section">
<h2>Voucher Generator</h2>
<label>Template Type:</label>
<select id="templateType" onchange="toggleFieldsAndClear()">
<option value="On Loss">On Loss</option>
<option value="On Deposit">On Deposit</option>
</select>
<label>Currency:</label>
<select id="currency">
<option>INR</option><option>BRL</option><option>XOF</option><option>MYR</option><option>ARS</option><option>USD</option><option>XAF</option><option>RUB</option><option>TRY</option><option>AED</option><option>KZT</option><option>AMD</option><option>KES</option><option>CLP</option>
</select>
<label for="presetPeriod" id="presetPeriodLabel">Select Period:</label>
<select id="presetPeriod" onchange="setPresetPeriod()">
<option value="">Custom</option>
<option value="lastMonth">Last 1 Month</option>
</select>
<label>BK Income Period Start:</label>
<input type="date" id="startDate">
<label>BK Income Period End:</label>
<input type="date" id="endDate">
<label>Last Voucher Activated:</label>
<input type="date" id="lastVoucherDate">
<div id="lossFields">
<label>Deposit:</label>
<input type="number" id="deposit" oninput="checkBkIncome()">
<label>Withdrawal:</label>
<input type="number" id="withdrawal" oninput="checkBkIncome()">
<label>BK Income:</label>
<input type="number" id="bkIncome" oninput="checkBkIncome()">
<div id="bkWarning">⚠ BK Income is different from Deposit - Withdrawal</div>
</div>
<div id="depositFields" style="display:none">
<label>Deposit:</label>
<input type="number" id="depositOnly">
</div>
<label>System Bonus:</label>
<input type="number" id="systemBonus">
<label>Voucher Amount (%):</label>
<input type="number" id="percentage" value="10">
<button onclick="generateTemplate()">Generate Template</button>
<button id="copyBtn" onclick="copyTemplate()">Copy</button>
<button onclick="countVoucher()">Count Voucher</button>
</div>
<div class="preview-section">
<textarea id="output" readonly></textarea>
<div class="stats" id="stats">Total Vouchers: 0</div>
<label>Voucher Provided Amount:</label>
<input type="number" id="providedAmount">
<select id="providedCurrency">
<option>INR</option><option>BRL</option><option>XOF</option><option>MYR</option><option>ARS</option><option>USD</option><option>XAF</option><option>RUB</option><option>TRY</option><option>AED</option><option>KZT</option><option>AMD</option><option>KES</option><option>CLP</option>
</select>
<button onclick="countProvidedVoucher()">Count Provided Voucher</button>
<div class="stats" id="providedStats">Total Provided Vouchers: 0</div>
<div class="stats" id="combinedStats">Combined Income (Created + Provided):</div>
</div>
</div>
<script>
// -------------------------------------------
// AUTO SAVE (Form + Stats)
// -------------------------------------------
function saveData() {
const fields = document.querySelectorAll("input, select, textarea");
let data = {};
fields.forEach(f => data[f.id] = f.value);
localStorage.setItem("voucherData", JSON.stringify(data));
}
function saveStats() {
localStorage.setItem("voucherStats", JSON.stringify(voucherStats));
localStorage.setItem("providedStatsData", JSON.stringify(providedStatsData));
}
// -------------------------------------------
// AUTO LOAD (Form + Stats)
// -------------------------------------------
function loadData() {
let saved = localStorage.getItem("voucherData");
if (!saved) return;
let data = JSON.parse(saved);
for (let id in data) {
if (document.getElementById(id)) {
document.getElementById(id).value = data[id];
}
}
}
function loadStats() {
const vs = localStorage.getItem("voucherStats");
const ps = localStorage.getItem("providedStatsData");
if (vs) voucherStats = JSON.parse(vs);
if (ps) providedStatsData = JSON.parse(ps);
updateStats();
}
window.addEventListener("input", saveData);
window.addEventListener("change", saveData);
window.onload = function () {
loadData();
loadStats();
};
// -------------------------------------------
let voucherStats = {};
let providedStatsData = {};
function setPresetPeriod() {
const preset = document.getElementById('presetPeriod').value;
if (preset === 'lastMonth') {
const end = new Date();
const start = new Date();
start.setMonth(start.getMonth() - 1);
document.getElementById('startDate').value = start.toISOString().slice(0,10);
document.getElementById('endDate').value = end.toISOString().slice(0,10);
}
}
function toggleFieldsAndClear() {
const type = document.getElementById('templateType').value;
document.getElementById('lossFields').style.display = (type === 'On Loss') ? 'block' : 'none';
document.getElementById('depositFields').style.display = (type === 'On Deposit') ? 'block' : 'none';
document.querySelectorAll('#deposit, #withdrawal, #bkIncome, #depositOnly, #systemBonus, #percentage')
.forEach(el => el.value = '');
document.getElementById('startDate').value = '';
document.getElementById('endDate').value = '';
}
function checkBkIncome() {
const deposit = parseFloat(document.getElementById('deposit').value) || 0;
const withdrawal = parseFloat(document.getElementById('withdrawal').value) || 0;
const bkIncome = parseFloat(document.getElementById('bkIncome').value) || 0;
document.getElementById('bkWarning').style.display =
Math.abs(bkIncome - (deposit - withdrawal)) > 0.01 ? 'block' : 'none';
}
function formatDate(dateTimeStr) {
if (!dateTimeStr) return '';
if (dateTimeStr.includes('T')) {
const [datePart, timePart] = dateTimeStr.split('T');
const [year, month, day] = datePart.split('-');
const [hour, minute] = timePart.split(':');
return `${day}-${month}-${year} ${hour}:${minute}`;
} else {
const [year, month, day] = dateTimeStr.split('-');
return `${day}-${month}-${year}`;
}
}
function generateTemplate() {
const type = document.getElementById('templateType').value;
const currency = document.getElementById('currency').value;
const startDate = formatDate(document.getElementById('startDate').value);
const endDate = formatDate(document.getElementById('endDate').value);
const lastVoucherDateValue = document.getElementById('lastVoucherDate').value;
const lastVoucherDate = lastVoucherDateValue ? formatDate(lastVoucherDateValue) : 'N/A';
const deposit = type === 'On Loss'
? (parseFloat(document.getElementById('deposit').value) || 0)
: (parseFloat(document.getElementById('depositOnly').value) || 0);
const withdrawal = parseFloat(document.getElementById('withdrawal')?.value) || 0;
const bkIncome = parseFloat(document.getElementById('bkIncome')?.value) || 0;
const systemBonus = parseFloat(document.getElementById('systemBonus').value) || 0;
const percentage = parseFloat(document.getElementById('percentage').value) || 10;
let voucherAmount =
(type === 'On Loss') ? (bkIncome * percentage) / 100 : (deposit * percentage) / 100;
if (systemBonus >= 1000)
voucherAmount = Math.max(0, voucherAmount - systemBonus);
const approxVoucher = Math.round(voucherAmount);
let template =
`Type of Bonus: Manual
Reason for Providing: ${type}
BK Income Period: [${startDate}] – [${endDate}]
Last Voucher Activated: [${lastVoucherDate}]
`;
if (type === 'On Loss') {
template += `Deposit: ${deposit} ${currency}
Withdrawal: ${withdrawal} ${currency}
BK Income: ${bkIncome} ${currency}
System Bonus: ${systemBonus} ${currency}
Voucher Amount: ${approxVoucher} ${currency}`;
} else {
template += `Deposit: ${deposit} ${currency}
System Bonus: ${systemBonus} ${currency}
Voucher Amount: ${approxVoucher} ${currency}`;
}
document.getElementById('output').value = template;
}
function copyTemplate() {
document.getElementById('output').select();
document.execCommand('copy');
}
function countVoucher() {
const currency = document.getElementById('currency').value;
const output = document.getElementById('output').value;
if (output.trim() === '') return;
const lastLine = output.split('\n').pop();
const amount = parseFloat(lastLine.replace(/[^0-9.]/g, '')) || 0;
if (!voucherStats[currency]) voucherStats[currency] = { count: 0, total: 0 };
voucherStats[currency].count++;
voucherStats[currency].total += amount;
updateStats();
saveStats();
}
function countProvidedVoucher() {
const currency = document.getElementById('providedCurrency').value;
const amount = parseFloat(document.getElementById('providedAmount').value) || 0;
if (!providedStatsData[currency]) providedStatsData[currency] = { count: 0, total: 0 };
providedStatsData[currency].count++;
providedStatsData[currency].total += amount;
updateStats();
saveStats();
}
function updateStats() {
let createdStatsHTML =
Object.entries(voucherStats)
.map(([cur, data]) =>
`(${cur}) Total Vouchers: ${data.count}, Total Amount: ${data.total.toFixed(2)} ${cur}`
).join('<br>');
let providedStatsHTML =
Object.entries(providedStatsData)
.map(([cur, data]) =>
`(${cur}) Total Provided Vouchers: ${data.count}, Total Provided Amount: ${data.total.toFixed(2)} ${cur}`
).join('<br>');
let combinedHTML =
Object.keys({ ...voucherStats, ...providedStatsData })
.map(cur => {
const createdTotal = voucherStats[cur]?.total || 0;
const providedTotal = providedStatsData[cur]?.total || 0;
return `(${cur}) Combined Income: ${(createdTotal + providedTotal).toFixed(2)} ${cur}`;
}).join('<br>');
document.getElementById('stats').innerHTML = createdStatsHTML || 'Total Vouchers: 0';
document.getElementById('providedStats').innerHTML = providedStatsHTML || 'Total Provided Vouchers: 0';
document.getElementById('combinedStats').innerHTML = combinedHTML || 'Combined Income (Created + Provided): 0';
}
</script>
</body>
</html>