-
Notifications
You must be signed in to change notification settings - Fork 1
/
status-vercode-list.php
490 lines (478 loc) · 24 KB
/
status-vercode-list.php
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
<?php
// we will only start the session with session_start() IF the session isn"t started yet //
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
?>
<?php
// including the conn.php to establish connection with database //
include "conn.php";
?>
<?php
// the number of page table that we will be receiving //
if (isset($_GET["page"])) {
$page = $_GET["page"];
} else {
$page = "1";
}
// if there's no input data then we will treat the variable as 0, as there's no indication of extra page needed //
if (($page == "") || $page == "1") {
$page_count = 0;
} else {
// we will multiply the input data by 10, which will result changes in SQL query like "LIMIT 10, 10" or "LIMIT 20, 10" //
$page_count = (($page - 1) * 10);
}
echo '
<!-- Scrollable Table Style -->
<link rel="stylesheet" type="text/css" href="vendor/Table_Fixed_Header/Table_Fixed_Header/vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/Table_Fixed_Header/Table_Fixed_Header/vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/Table_Fixed_Header/Table_Fixed_Header/vendor/perfect-scrollbar/perfect-scrollbar.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/Table_Fixed_Header/Table_Fixed_Header/css/util.css">
<link rel="stylesheet" type="text/css" href="vendor/Table_Fixed_Header/Table_Fixed_Header/css/main.css">
<form method="post" action="">
<div class="row x_title">
<div class="col-md-6">
<h3>Verification Code<small>';
echo ' Status </small></h3>
</div>
</div>
<div class="row x_title">
<div class="col-md-6">
<h3>Active Codes <small>';
echo '</small></h3>
</div>
<div class="container-table100">
<div class="wrap-table100">
<div class="table100 ver1 m-b-110">
<div class="table100-head">
<table class="reg-table">
<thead>
<tr class="row100 head">
<th class="cell100 column1">No.</th>
<th class="cell100 column2">Ver. Code</th>
<th class="cell100 column3">Registration Date</th>
<th class="cell100 column4">Privilege</th>
<th class="cell100 column5">Active</th>
</tr>
</thead>
</table>
</div>
<div class="table100-body js-pscroll">
<table class="reg-table">
<tbody>';
// Begin to bring in the data from the database //
$REGUSER = "SELECT * FROM verification_code
WHERE code_active = '1'
ORDER BY registered_date DESC
LIMIT $page_count,10";
$result = $con->query($REGUSER);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Converting time to 12AM/PM format //
$register_date = $row['registered_date'];
$register_date = date('d/m/y h:i A', strtotime($register_date));
echo '
<tr class="row100 body">
<td class="cell100 column1 reg-table-td" style="min-width:100%; min-height:100%;">
<label class="regid-container">
<input required type="checkbox" class="regid-chkbox" name="verid[]" onclick="checkRequired()" value="'.$row["verification_id"].'">
<span class="checkmark"></span>
</label>
</td>
<td class="cell100 column2 reg-table-td" style="min-width:100%; min-height:100%;"> '.$row["verification_code"].' </td>
<td class="cell100 column3 reg-table-td" style="min-width:100%; min-height:100%;"> '.$register_date.' </td>
<td class="cell100 column4 reg-table-td" style="min-width:100%; min-height:100%;"> ';
if ($row["code_status"] == 0) {
echo "STUDENT";
} else if ($row["code_status"] == 1) {
echo "CASHIER";
} else if ($row["code_status"] == 2) {
echo "ADMIN";
} else {
echo "-";
}
echo ' </td>
<td class="cell100 column5 reg-table-td" style="min-width:100%; min-height:100%;"> ';
if ($row["code_active"] == 0) {
echo "N";
} else if ($row["code_active"] == 1) {
echo "Y";
} else {
echo "-";
}
echo '</td>
</tr>
';
}
} else {
echo '
<tr class="row100 body">
<td class="cell100 column1 reg-table-td"> - </td>
<td class="cell100 column2 reg-table-td"> - </td>
<td class="cell100 column3 reg-table-td"> - </td>
<td class="cell100 column4 reg-table-td"> - </td>
<td class="cell100 column5 reg-table-td"> - </td>
</tr>
';
}
echo
'
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
';
// Showing the codes that already been used //
echo '
<div class="row x_title">
<div class="col-md-6">
<h3>Inactive Codes <small>';
echo '</small></h3>
</div>
<div class="container-table100">
<div class="wrap-table100">
<div class="table100 ver1 m-b-110">
<div class="table100-head">
<table class="reg-table">
<thead>
<tr class="row100 head">
<th class="cell100 column1">No.</th>
<th class="cell100 column2">Ver. Code</th>
<th class="cell100 column3">Registration Date</th>
<th class="cell100 column4">Privilege</th>
<th class="cell100 column5">Active</th>
</tr>
</thead>
</table>
</div>
<div class="table100-body js-pscroll">
<table class="reg-table">
<tbody>';
// Begin to bring in the data from the database //
$REGUSER = "SELECT * FROM verification_code
WHERE code_active = '0'
ORDER BY registered_date DESC
LIMIT $page_count,10";
$result = $con->query($REGUSER);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Converting time to 12AM/PM format //
$register_date = $row['registered_date'];
$register_date = date('d/m/y h:i A', strtotime($register_date));
echo '
<tr class="row100 body">
<td class="cell100 column1 reg-table-td" style="min-width:100%; min-height:100%;">
<label class="regid-container">
<input required type="checkbox" class="regid-chkbox" name="verid[]" onclick="checkRequired()" value="'.$row["verification_id"].'">
<span class="checkmark"></span>
</label>
</td>
<td class="cell100 column2 reg-table-td" style="min-width:100%; min-height:100%;"> '.$row["verification_code"].' </td>
<td class="cell100 column3 reg-table-td" style="min-width:100%; min-height:100%;"> '.$register_date.' </td>
<td class="cell100 column4 reg-table-td" style="min-width:100%; min-height:100%;"> ';
if ($row["code_status"] == 0) {
echo "STUDENT";
} else if ($row["code_status"] == 1) {
echo "CASHIER";
} else if ($row["code_status"] == 2) {
echo "ADMIN";
} else {
echo "-";
}
echo ' </td>
<td class="cell100 column5 reg-table-td" style="min-width:100%; min-height:100%;"> ';
if ($row["code_active"] == 0) {
echo "N";
} else if ($row["code_active"] == 1) {
echo "Y";
} else {
echo "-";
}
echo '</td>
</tr>
';
}
} else {
echo '
<tr class="row100 body">
<td class="cell100 column1 reg-table-td"> - </td>
<td class="cell100 column2 reg-table-td"> - </td>
<td class="cell100 column3 reg-table-td"> - </td>
<td class="cell100 column4 reg-table-td"> - </td>
<td class="cell100 column5 reg-table-td"> - </td>
</tr>
';
}
echo
'
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
';
// creating the page number based on the list's number, if its over 10 records then create 1 page //
// we first find how many records in the verification codes list //
// since we have two types of data: Active and Inactive, we have to find both of them and compare them, then take the highest value out of all //
// first we find the value of Active ones //
$TOTVERA = "SELECT COUNT(*) AS TOTAL_VERA FROM verification_code
WHERE code_active = '1'";
$TOTVERAQ = mysqli_query($con, $TOTVERA);
if (mysqli_num_rows($TOTVERAQ) < 1) {
// only 1 page needed //
$total_vera = "1";
} else {
// count how many pages are needed //
if ($row = mysqli_fetch_array($TOTVERAQ)) {
$total_vera = $row["TOTAL_VERA"];
// then we divide the number of total verification codes record by 10, then round up, i.e. 1.1 > 2; since any extra records will required 1 new page //
$total_vera = ($total_vera / 10);
$total_vera = ceil($total_vera);
}
}
// after we got the value from the Active tables then we proceeds to find the value of the Inactives //
$TOTVERI = "SELECT COUNT(*) AS TOTAL_VERI FROM verification_code
WHERE code_active = '0'";
$TOTVERIQ = mysqli_query($con, $TOTVERI);
if (mysqli_num_rows($TOTVERIQ) < 1) {
// only 1 page needed //
$total_veri = "1";
} else {
// count how many pages are needed //
if ($row = mysqli_fetch_array($TOTVERIQ)) {
$total_veri = $row["TOTAL_VERI"];
// then we divide the number of total verification codes record by 10, then round up, i.e. 1.1 > 2; since any extra records will required 1 new page //
$total_veri = ($total_veri / 10);
$total_veri = ceil($total_veri);
}
}
// now checking which category got the highest value //
if ($total_vera > $total_veri) {
$page_numb = $total_vera;
} else if ($total_vera < $total_veri) {
$page_numb = $total_veri;
} else {
// if its neither then both variables got the same value //
$page_numb = $total_vera;
}
// now creating the page numbers //
echo '<div class="center">
<div class="pagination" id="page-div">
<a class="page" onclick="verTableS(this)" name="table-page" value="';
// if the current $_GET['page'] number is not more than 2 then it has no value, but 1 //
if ($page < 2) {
$previous_page = 1;
echo $previous_page;
} else {
$previous_page = ($page - 1);
echo ($page - 1);
}
echo '" id="page-'.$previous_page.'">«</a>
<a class="page page-number';
// highlight the current page number if the $_GET["page"] is the current page //
if ($page == 1) {
echo ' active';
}
echo '" onclick="verTableS(this)" name="table-page" id="page-1" value="1"> 1 </a>';
for ($n = 2; $n <= $page_numb; $n++) {
echo '<a class="page page-number';
// highlight the current page number if the $_GET["page"] is the current page //
if ($page == $n) {
echo ' active';
}
echo '" onclick="verTableS(this)" name="table-page" id="page-'.$n.'" value="'.$n.'">'.$n.'</a>';
}
echo '<a class="page" name="table-page" onclick="verTableS(this)" value="';
// By default $next_page if no value and the total records division is no more than 1 then the value of it is 1 //
if (empty($next_page) && ($page_numb > 1)) {
$next_page = 2;
} else if (empty($next_page) && ($page_numb < 2)) {
$next_page = 1;
}
// if the total records division is not more than 2, then it has no value, but 1 //
if ($page_numb < 2) {
$next_page = 1;
echo $next_page;
} else {
if ($page == $page_numb) {
// if the current $_GET['page'] reached its limit then we will make the value the maximum one //
$next_page = $page;
echo $next_page;
} else {
$next_page = ($page + 1);
echo ($page + 1);
}
}
echo '" id="page-'.$next_page.'">»</a>
</div>
</div>';
// showing the options of action //
echo '
<!-- Verification Form\'s Style -->
<link rel="stylesheet" href="vendor/login-sign-in/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<!-- Verification Form\'s Script -->
<script src="vendor/login-sign-in/js/index.js"></script>
<div class="verification-form">
<div class="">
<div class="">
<div class="logmod__container">
<ul class="logmod__tabs">
<li data-tabtar="lgm-1" id="ver-action-dis" class="verification-action current"><a onclick="switchFormDisA()">Disable</a></li>
<li data-tabtar="lgm-2" id="ver-action-res" class="verification-action"><a onclick="switchFormResA()">Enable</a></li>
<li data-tabtar="lgm-3" id="ver-action-del" class="verification-action"><a onclick="switchFormDelA()">Delete</a></li>
<li data-tabtar="lgm-4" id="ver-action-reg" class="verification-action"><a onclick="switchFormRegA()">Register</a></li>
</ul>
<div class="logmod__tab-wrapper">
<div class="logmod__tab lgm-1 show" id="ver-form-dis">
<form method="POST" action="">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your information to verify and <strong>disable the record.</strong></span>
</div>
<div class="logmod__form">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-account-code-dis">Account Code*</label>
<input required class="string optional" name="dis-acccode" maxlength="8" minlength="8" id="user-account-code-dis" placeholder="Account Code" type="password" size="8" />
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw-dis">Password *</label>
<input required class="string optional first-pw" name="dis-pw" maxlength="255" id="user-pw-dis" onkeyup="check_verlist_dis();" placeholder="Password" type="password" size="50" />
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat-dis">Repeat password *</label>
<input required class="string optional" name="dis-pw-repeat" maxlength="255" id="user-pw-repeat-dis" onkeyup="check_verlist_dis();" placeholder="Repeat password" type="password" size="50" />
<span class="hide-password" id="toggle-pw-dis" onclick="togglePassDisA();">SHOW</span>
</div>
</div>
<div class="simform__actions">
<input disabled class="sumbit" name="submit-list-disA" style="font-family:oswald!important;" type="submit" id="submit-dis" value="Confirm Removal" />
<div id="error-message-dis" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By disabling the records, you are here and agree our <a class="special" onclick="return false;" role="link">Terms & Conditions</a></span>
</div>
</div>
</div>
<!-- Did not change any of the class from RESET to suit ENABLE (except input names) due to there is no need for such changes to improve the functionality -->
<div class="logmod__tab lgm-2" id="ver-form-res">
<form method="POST" action="">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your information to verify and <strong>enable the code.</strong></span>
</div>
<div class="logmod__form">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-account-code-res">Account Code*</label>
<input class="string optional" name="enable-acccode" maxlength="8" minlength="8" id="user-account-code-res" placeholder="Account Code" type="password" size="8" />
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw-res">Password *</label>
<input class="string optional first-pw" name="enable-pw" maxlength="255" id="user-pw-res" onkeyup="check_verlist_res();" placeholder="Password" type="password" size="50" />
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat-res">Repeat password *</label>
<input class="string optional" name="enable-pw-repeat" maxlength="255" id="user-pw-repeat-res" onkeyup="check_verlist_res();" placeholder="Repeat password" type="password" size="50" />
<span class="hide-password" id="toggle-pw-res" onclick="togglePassResA();">SHOW</span>
</div>
</div>
<div class="simform__actions">
<input disabled class="sumbit" name="submit-list-enableS" style="font-family:oswald!important;" type="submit" id="submit-res" value="Enable Code" />
<div id="error-message-res" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By enabling the verification code, you are here and agree our <a class="special" onclick="return false;" role="link">Terms & Conditions</a></span>
</div>
</div>
</div>
<div class="logmod__tab lgm-2" id="ver-form-del">
<form method="POST" action="">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your information to verify and <strong>delete the code.</strong></span>
</div>
<div class="logmod__form">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-account-code-del">Account Code*</label>
<input class="string optional" name="del-acccode" maxlength="8" minlength="8" id="user-account-code-del" placeholder="Account Code" type="password" size="8" />
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw-del">Password *</label>
<input class="string optional first-pw" name="del-pw" maxlength="255" id="user-pw-del" onkeyup="check_verlist_del();" placeholder="Password" type="password" size="50" />
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat-del">Repeat password *</label>
<input class="string optional" name="del-pw-repeat" maxlength="255" id="user-pw-repeat-del" onkeyup="check_verlist_del();" placeholder="Repeat password" type="password" size="50" />
<span class="hide-password" id="toggle-pw-del" onclick="togglePassDelA();">SHOW</span>
</div>
</div>
<div class="simform__actions">
<input disabled class="sumbit" name="submit-list-delA" style="font-family:oswald!important;" type="submit" id="submit-del" value="Confirm Deletion" />
<div id="error-message-del" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By deleting the verification code, you are here and agree our <a class="special" onclick="return false;" role="link">Terms & Conditions</a></span>
</div>
</div>
</div>
<div class="logmod__tab lgm-2" id="ver-form-reg">
<form method="POST" action="">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your information to verify and <strong>register a new verification code.</strong></span>
</div>
<div class="logmod__form">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-account-code-reg">Account Code*</label>
<input class="string optional" name="reg-acccode" maxlength="8" minlength="8" id="user-account-code-reg" placeholder="Account Code" type="password" size="8" />
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw-reg">Password *</label>
<input class="string optional first-pw" name="reg-pw" maxlength="255" id="user-pw-reg" onkeyup="check_verlist_reg();" placeholder="Password" type="password" size="50" />
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat-reg">Repeat password *</label>
<input class="string optional" name="reg-pw-repeat" maxlength="255" id="user-pw-repeat-reg" onkeyup="check_verlist_reg();" placeholder="Repeat password" type="password" size="50" />
<span class="hide-password" id="toggle-pw-reg" onclick="togglePassRegA();">SHOW</span>
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="vercode-role">ROLE *</label>
<select class="role-select" id="vercode-role" name="vercode-role" style="width:30vw; height:4vh;">
<option value="" selected disabled>ROLE</option>
<option value="2">ADMIN</option>
<option value="1">CASHIER</option>
<option value="0">STUDENT</option>
</select>
</div>
<div class="input string optional">
<label class="string optional" for="vercode-new">Verification Code *</label>
<input class="string optional" name="vercode-new" id="vercode-new" placeholder="Verification Code" type="text" minlength="8" maxlength="8" size="8" />
<span class="hide-password" id="generate_random" onclick="generate_randomA();">GENERATE</span>
</div>
</div>
<div class="simform__actions">
<input disabled class="sumbit" name="submit-list-regA" style="font-family:oswald!important;" type="submit" id="submit-reg" value="Confirm Registration" />
<div id="error-message-reg" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By registering the new verification code, you are here and agree our <a class="special" onclick="return false;" role="link">Terms & Conditions</a></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>';
?>