-
Notifications
You must be signed in to change notification settings - Fork 1
/
cashier-user-list.php
388 lines (374 loc) · 16 KB
/
cashier-user-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
<?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);
}
?>
<form method="POST" action="">
<!-- Title of the table -->
<!-- Cashier List: Active Section -->
<div class="row x_title">
<div class="col-md-6">
<h3>Cashier <small>Active </small></h3>
</div>
</div>
<?php
// in order to use multi-variable we have to first define it, otherwise it will show SYNTAX error //
$output_active = '';
// now we start to define the query //
$CASHIERA = "SELECT *
FROM user INNER JOIN cashier
ON user.user_id = cashier.user_id
WHERE user.status = 1 AND user.active = 1
LIMIT $page_count, 10";
$CASHIERAQ = mysqli_query($con, $CASHIERA);
$output_active .= '
<div class="">
<table class="table table-bordered">
<tr>
<th width="10%">NO.</th>
<th width="10%">ID</th>
<th width="20%">FIRST NAME</th>
<th width="20%">LAST NAME</th>
<th width="10%">GENDER</th>
<th width="15%">DOB</th>
<th width="15%">LAST LOGIN</th>
</tr>';
$rows = mysqli_num_rows($CASHIERAQ);
if($rows > 0) {
while($row = mysqli_fetch_array($CASHIERAQ)) {
// now defining the gender based on the value //
if (($row["gender"]) == 0) {
$gender = "MALE";
} else if (($row["gender"]) == 1) {
$gender = "FEMALE";
} else if (($row["gender"]) == 2) {
$gender = "OTHERS";
} else {
$gender = "-";
}
// converting datetime values into 12AM/PM //
$dob = date('d/m/y h:i A', strtotime($row["dob"]));
if ($row["last_login"] == NULL) {
$last_login = " - ";
} else {
$last_login = date('d/m/y h:i A', strtotime($row["last_login"]));
}
$output_active .= '
<tr>
<td>
<label class="regid-container">
<input required type="checkbox" class="regid-chkbox" name="userid[]" onclick="checkRequired()" value="'.$row["user_id"].'">
<span class="checkmark"></span>
</label>
</td>
<td>'.$row["user_id"].'</td>
<td class="first_name" data-id1="'.$row["user_id"].'" contenteditable>'.$row["first_name"].'</td>
<td class="last_name" data-id2="'.$row["user_id"].'" contenteditable>'.$row["last_name"].'</td>
<td class="gender" data-id3="'.$row["user_id"].'">'.$gender.'</td>
<td class="dob" data-id4="'.$row["user_id"].'">'.$dob.'</td>
<td class="last_login" data-id5="'.$row["user_id"].'">'.$last_login.'</td>
</tr>
';
}
} else {
$output_active .= '
<tr>
<td> - </td>
<td> - </td>
<td id="fname"> - </td>
<td id="lname"> - </td>
<td id="gender"> - </td>
<td id="dob"> - </td>
<td id="last_login"> - </td>
</tr>';
}
$output_active .= '</table>
</div>';
echo '<span id="result"></span>';
echo $output_active;
?>
<br>
<br>
<!-- Cashier List: Inctive Section -->
<div class="row x_title">
<div class="col-md-6">
<h3>Cashier <small>Inactive </small></h3>
</div>
</div>
<?php
// in order to use multi-variable we have to first define it, otherwise it will show SYNTAX error //
$output_inactive = '';
// now we start to define the query //
$CASHIERI = "SELECT *
FROM user INNER JOIN cashier
ON user.user_id = cashier.user_id
WHERE user.status = 1 AND user.active = 0
LIMIT $page_count, 10";
$CASHIERIQ = mysqli_query($con, $CASHIERI);
$output_inactive .= '
<div class="">
<table class="table table-bordered">
<tr>
<th width="10%">NO.</th>
<th width="10%">ID</th>
<th width="20%">FIRST NAME</th>
<th width="20%">LAST NAME</th>
<th width="10%">GENDER</th>
<th width="15%">DOB</th>
<th width="15%">LAST LOGIN</th>
</tr>';
$rows = mysqli_num_rows($CASHIERIQ);
if($rows > 0) {
while($row = mysqli_fetch_array($CASHIERIQ)) {
// now defining the gender based on the value //
if (($row["gender"]) == 0) {
$gender = "MALE";
} else if (($row["gender"]) == 1) {
$gender = "FEMALE";
} else if (($row["gender"]) == 2) {
$gender = "OTHERS";
} else {
$gender = "-";
}
// converting datetime values into 12AM/PM //
$dob = date('d/m/y h:i A', strtotime($row["dob"]));
if ($row["last_login"] == NULL) {
$last_login = " - ";
} else {
$last_login = date('d/m/y h:i A', strtotime($row["last_login"]));
}
$output_inactive .= '
<tr>
<td>
<label class="regid-container">
<input required type="checkbox" class="regid-chkbox" name="userid[]" onclick="checkRequired()" value="'.$row["user_id"].'">
<span class="checkmark"></span>
</label>
</td>
<td>'.$row["user_id"].'</td>
<td class="first_name" data-id1="'.$row["user_id"].'" contenteditable>'.$row["first_name"].'</td>
<td class="last_name" data-id2="'.$row["user_id"].'" contenteditable>'.$row["last_name"].'</td>
<td class="gender" data-id3="'.$row["user_id"].'">'.$gender.'</td>
<td class="dob" data-id4="'.$row["user_id"].'">'.$dob.'</td>
<td class="last_login" data-id5="'.$row["user_id"].'">'.$last_login.'</td>
</tr>
';
}
} else {
$output_inactive .= '
<tr>
<td> - </td>
<td> - </td>
<td id="fname"> - </td>
<td id="lname"> - </td>
<td id="gender"> - </td>
<td id="dob"> - </td>
<td id="last_login"> - </td>
</tr>';
}
$output_inactive .= '</table>
</div>';
echo $output_inactive;
?>
<br>
<br>
<center>
<span style="color:red;">*Note: You can click on the rows to edit the information of the user and update instantaneously.</span>
</center>
<?php
// 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 user 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 //
$TOTUSEA = "SELECT COUNT(*) AS TOT_USE_A FROM user
WHERE active = '1' AND status = '1'";
$TOTUSEAQ = mysqli_query($con, $TOTUSEA);
if (mysqli_num_rows($TOTUSEAQ) < 1) {
// only 1 page needed //
$total_usea = "1";
} else {
// count how many pages are needed //
if ($row = mysqli_fetch_array($TOTUSEAQ)) {
$total_usea = $row["TOT_USE_A"];
// then we divide the number of total user record by 10, then round up, i.e. 1.1 > 2; since any extra records will required 1 new page //
$total_usea = ($total_usea / 10);
$total_usea = ceil($total_usea);
}
}
// after we got the value from the Active tables then we proceeds to find the value of the Inactives //
$TOTUSEI = "SELECT COUNT(*) AS TOT_USE_I FROM user
WHERE active = '0' AND status = '1'";
$TOTUSEIQ = mysqli_query($con, $TOTUSEI);
if (mysqli_num_rows($TOTUSEIQ) < 1) {
// only 1 page needed //
$total_usei = "1";
} else {
// count how many pages are needed //
if ($row = mysqli_fetch_array($TOTUSEIQ)) {
$total_usei = $row["TOT_USE_I"];
// 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_usei = ($total_usei / 10);
$total_usei = ceil($total_usei);
}
}
// now checking which category got the highest value //
if ($total_usea > $total_usei) {
$page_numb = $total_usea;
} else if ($total_usea < $total_usei) {
$page_numb = $total_usei;
} else {
// if its neither then both variables got the same value //
$page_numb = $total_usea;
}
// now creating the page numbers //
echo '<div class="center">
<div class="pagination" id="page-div">
<a class="page" onclick="casTable(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="casTable(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="casTable(this)" name="table-page" id="page-'.$n.'" value="'.$n.'">'.$n.'</a>';
}
echo '<a class="page" name="table-page" onclick="casTable(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>';
?>
<!-- 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-2" id="ver-action-ena" class="verification-action current"><a onclick="switchFormEna()">Enable</a></li>
<li data-tabtar="lgm-1" id="ver-action-dis" class="verification-action"><a onclick="switchFormDis()">Disable</a></li>
</ul>
<div class="logmod__tab-wrapper">
<div class="logmod__tab lgm-1" 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 user.</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 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-del">Password *</label>
<input 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 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-dis-cas" style="font-family:oswald!important;" type="submit" id="submit-dis" value="Disable" />
<div id="error-message-dis" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By disabling the user, 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 show" id="ver-form-ena">
<form method="POST" action="">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your information to verify and <strong>enable the user.</strong></span>
</div>
<div class="logmod__form">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-account-code-ena">Account Code*</label>
<input required class="string optional" name="ena-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 required class="string optional first-pw" name="ena-pw" maxlength="255" id="user-pw-reg" onkeyup="check_reglist_r();" 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 required class="string optional" name="ena-pw-repeat" maxlength="255" id="user-pw-repeat-reg" onkeyup="check_reglist_r();" placeholder="Repeat password" type="password" size="50" />
<span class="hide-password" id="toggle-pw-reg" onclick="togglePassReg();">SHOW</span>
</div>
</div>
<div class="simform__actions">
<input disabled class="sumbit" name="submit-list-ena-cas" style="font-family:oswald!important;" type="submit" id="submit-r" value="Enable" />
<div id="error-message-r" style="font-size:17px;"></div>
<span class="simform__actions-sidetext">By enabling the user, 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>