-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusersetting.php
238 lines (193 loc) · 7.23 KB
/
usersetting.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
<!DOCTYPE html>
<html lang="en">
<!-- ======= Sidebar ======= -->
<?php
include ('components/header.php');
include ('components/sidebar.php');
$admin = query("SELECT * FROM user WHERE role = 'admin'");
$cashier = query("SELECT * FROM user WHERE role = 'cashier'");
$customer = query("SELECT * FROM user WHERE role = 'customer'");
if (!isset($_SESSION['username'])){
header("Location: login.php");
} elseif(isset($_SESSION['username'])){
if($_SESSION['role'] === 'customer'){
header("Location: dashboarduser.php");
} elseif ($_SESSION['role'] === 'cashier'){
header("Location: dashboardcashier.php");
}
}
$user = query("SELECT * FROM user");
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$num_per_page = 04;
$start_from = ($page-1)*04;
$user= query("SELECT * FROM user LIMIT $start_from,$num_per_page");
// foreach ($products as $product);
$admin= query("SELECT * FROM user WHERE role = 'admin' LIMIT $start_from,$num_per_page");
$cashier= query("SELECT * FROM user WHERE role = 'cashier' LIMIT $start_from,$num_per_page");
$customer= query("SELECT * FROM user WHERE role = 'customer' LIMIT $start_from,$num_per_page");
$q= query("SELECT * FROM user LIMIT $start_from,$num_per_page");
$pr_query = "select * from user ";
$pr_result = mysqli_query($conn,$pr_query);
$total_record = mysqli_num_rows($pr_result );
$total_page = ceil($total_record/$num_per_page);
?>
<!-- End Sidebar-->
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
<a href="index.html" class="logo d-flex align-items-center">
<img src="assets/img/logo.png" alt="" />
<span class="d-none d-lg-block">PRES U Caffe</span>
</a>
<i class="bi bi-list toggle-sidebar-btn"></i>
</div>
<!-- End Search Bar -->
<nav class="header-nav ms-auto">
<ul class="d-flex align-items-center">
<li class="nav-item d-block d-lg-none">
<a class="nav-link nav-icon search-bar-toggle" href="#">
<i class="bi bi-search"></i>
</a>
</li>
<!--End Search Icon-->
<!-- End Profile Nav -->
</ul>
</nav>
<!-- End Icons Navigation -->
</header>
<main id="main" class="main">
<div class="pagetitle">
<h3>User Setting</h3>
</div>
<!-- End Page Titsle -->
<a href="adduser.php" type="button" class="btn btn-primary" data-mdb-toggle="modal" data-mdb-target="#exampleModal">
ADD
</a>
<!-- Recent Sales -->
<h4>Admin</h4>
<table class="table table-borderless datatable">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Phone Number</th>
<th scope="col">Action</th>
</tr>
</thead>
<!-- Button trigger modal -->
<!-- Modal -->
<tbody>
<?php foreach( $admin as $a) : ?>
<?php static $adminNum = 0; $adminNum++; ?>
<tr>
<th scope="row"><a href="#"> <?php echo $adminNum ?> </a></th>
<td> <?php echo $a['name'] ?></td>
<td> <?php echo $a['nohp'] ?></td>
<td>
<a href="edituser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-primary">Edit</button>
</a>
<a href="deleteuser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-danger">Delete</button>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h4>Worker</h4>
<table class="table table-borderless datatable">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Password</th>
<th scope="col">Job</th>
<th scope="col">Action</th>
</tr>
</thead>
<!-- Button trigger modal -->
<!-- Modal -->
<tbody>
<?php foreach( $cashier as $a) : ?>
<?php static $workerNum = 0; $workerNum++; ?>
<tr>
<th scope="row"><a href="#"> <?php echo $workerNum ?> </a></th>
<td> <?php echo $a['name'] ?></td>
<td> <?php echo $a['nohp'] ?></td>
<td> <?php echo $a['role'] ?></td>
<td>
<a href="edituser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-primary">Edit</button>
</a>
<a href="deleteuser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-danger">Delete</button>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h4>Customer</h4>
<table class="table table-borderless datatable">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Phone Number</th>
<th scope="col">Action</th>
</tr>
</thead>
<!-- Button trigger modal -->
<!-- Modal -->
<tbody>
<?php foreach( $customer as $a) : ?>
<?php static $customerNum = 0; $customerNum++; ?>
<tr>
<th scope="row"><a href="#"> <?php echo $customerNum ?> </a></th>
<td> <?php echo $a['name'] ?></td>
<td> <?php echo $a['nohp'] ?></td>
<td>
<a href="edituser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-primary">Edit</button>
</a>
<a href="deleteuser.php?id=<?php echo $a['id'] ?>">
<button type="button" class="btn btn-danger">Delete</button>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- End Recent Sales -->
<ul align="center" class="pagination">
<?php
if($page>1)
{
echo "<a href='usersetting.php?page=".($page-1)."' class='page-link'>Previous</a>";
}
for($i=1;$i<$total_page;$i++)
{
echo "<a href='usersetting.php?page=".$i."' class='page-link'>$i</a>";
}
if($i>$page)
{
echo "<a href='usersetting.php?page=".($page+1)."' class='page-link'>Next</a>";
}
?>
</ul>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<script src="assets/js/mdb.min.js.map"></script>
<script src="assets/js/mdb.min"></script>
</body>
</html>