-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_tables.php
393 lines (373 loc) · 18 KB
/
show_tables.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
<?php
include('/xampp/htdocs/E-commerce/niceAdmin-main/Main/ConfigDB.php');
echo "test";
if (isset($_GET['delete_customer'])) {
$id = $_GET['delete_customer'];
$delete_q = "DELETE FROM customer WHERE id = $id";
$is_done = mysqli_query($connect_to_DB, $delete_q);
if ($is_done) header('location:show_tables.php');
else print_message("Failed To Delete Customer Data", "danger");
}
if (isset($_GET['delete_product'])) {
$id = $_GET['delete_product'];
$delete_q = "DELETE FROM product WHERE id = $id";
$is_done = mysqli_query($connect_to_DB, $delete_q);
if ($is_done) header('location:show_tables.php');
else print_message("Failed To Delete Product", "danger");
}
if (isset($_GET['delete_order'])) {
$id = $_GET['delete_order'];
$delete_q = "DELETE FROM orders WHERE id = $id";
$is_done = mysqli_query($connect_to_DB, $delete_q);
if ($is_done) header('location:show_tables.php');
else print_message("Failed To Delete Order Data", "danger");
}
if (isset($_GET['delete_section'])) {
$id = $_GET['delete_section'];
$delete_q = "DELETE FROM section WHERE id = $id";
$is_done = mysqli_query($connect_to_DB, $delete_q);
if ($is_done) header('location:show_tables.php');
else print_message("Failed To Delete Section", "danger");
}
if (isset($_GET['delete_admin'])) {
$id = $_GET['delete_admin'];
$delete_q = "DELETE FROM admin WHERE id = $id";
$is_done = mysqli_query($connect_to_DB, $delete_q);
if ($is_done) header('location:show_tables.php');
else print_message("Failed To Delete Section", "danger");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
<meta name="author" content="GeeksLabs">
<meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
<link rel="shortcut icon" href="img/favicon.png">
<title>Basic Table | Creative - Bootstrap 3 Responsive Admin Template</title>
<!-- Bootstrap CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- bootstrap theme -->
<link href="css/bootstrap-theme.css" rel="stylesheet">
<!--external css-->
<!-- font icon -->
<link href="css/elegant-icons-style.css" rel="stylesheet" />
<link href="css/font-awesome.min.css" rel="stylesheet" />
<!-- Custom styles -->
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet" />
<link rel="stylesheet" href="show.css">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<script src="js/lte-ie7.js"></script>
<![endif]-->
<!-- =======================================================
Theme Name: NiceAdmin
Theme URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/
Author: BootstrapMade
Author URL: https://bootstrapmade.com
======================================================= -->
</head>
<body>
<?php
include '/xampp/htdocs/E-commerce/niceAdmin-main/Nav_bar.php';
?>
<section>
<?php if ($_SESSION['admin_depart'] == 'JOKER' || $_SESSION['admin_depart'] == 'ADMIN' || $_SESSION['admin_depart'] == 'HR') : ?> <div class="table_customers">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">
Customers
</header>
<table class="table table-striped table-advance table-hover">
<tbody class="TEST">
<tr>
<th><i class="icon_profile"></i>ID</th>
<th><i class="icon_profile"></i>Full Name</th>
<th><i class="icon_mail_alt"></i>Email</th>
<th><i class="icon_pin_alt"></i>Adress</th>
<th><i class="icon_profile"></i>Image</th>
<th><i class="icon_mobile"></i>Phone</th>
<th><i class="icon_cogs"></i>Action</th>
</tr>
<?php
$select = "SELECT * FROM customer";
$cust_data = mysqli_query($connect_to_DB, $select);
foreach ($cust_data as $data) {
?>
<tr>
<td><?php echo $data['id'] ?> </td>
<td><?php echo $data['name'] ?></td>
<td><?php echo $data['email'] ?></td>
<td><?php echo $data['address'] ?></td>
<?php if ($data['cust_img'] != NULL) : ?>
<td><img width="100" height="100" src="Resources/<?php echo $data['cust_img'] ?>"></td>
<?php else : ?>
<td>N/A</td>
<?php endif; ?>
<td><?php echo $data['phone'] ?></td>
<td>
<?php if ($_SESSION['admin_depart'] != 'HR') : ?>
<div class="btn-group">
<a class="btn btn-primary" href="signup_customer.php?update=<?php echo $data['id'] ?>">Edit</a>
<!-- <a class="btn btn-success" href="#"><i class="icon_check_alt2"></i></a> -->
<a class="btn btn-danger" href="show_tables.php?delete_customer=<?php echo $data['id'] ?>" onclick="return confirm('Are You Sure ??')">Delete</a>
</div>
<?php else : ?>
<p>N/A</p>
<?php endif; ?>
</td>
<?php } ?>
</tbody>
</table>
</section>
</div>
</div>
<!-- page end-->
</section>
</section>
</div>
<?php endif; ?>
<?php if ($_SESSION['admin_depart'] == 'JOKER' || $_SESSION['admin_depart'] == 'LOG' || $_SESSION['admin_depart'] == 'ADMIN' || $_SESSION['admin_depart'] == 'HR') : ?>
<div class="table_product">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">
Products
</header>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th><i class="icon_cogs"></i>ID</th>
<th>Name Of Product</th>
<th>Pic Of Product</th>
<th>Description</th>
<th>Price</th>
<th><i class="icon_profile"></i>Admin</th>
<th>Section</th>
<th><i class="icon_cogs"></i> Action</th>
</tr>
<?php
$select = "SELECT *,admin.name AS Aname, section.name AS Sname, product.name AS ProductName ,product.id AS ProductID FROM product JOIN admin,section WHERE product.id_admin = admin.id AND product.id_section = section.id ";
$product_data = mysqli_query($connect_to_DB, $select);
foreach ($product_data as $data) {
?>
<tr>
<td><?php echo $data['ProductID'] ?> </td>
<?php if ($data['product_img'] != NULL) : ?>
<td><img width="100" height="100" src="Resources/Products/<?php echo $data['product_img'] ?>"></td>
<?php else : ?>
<td>N/A</td>
<?php endif; ?>
<td><?php echo $data['ProductName'] ?></td>
<td><?php echo $data['description'] ?></td>
<td><?php echo $data['price'] ?></td>
<td><?php echo $data['Aname'] ?></td>
<td><?php echo $data['Sname'] ?></td>
<td>
<?php if($_SESSION['admin_depart'] != 'HR') : ?>
<div class="btn-group">
<a class="btn btn-primary" href="add_product.php?update=<?php echo $data['ProductID'] ?>">Edit</a>
<a class="btn btn-danger" href="show_tables.php?delete_product=<?php echo $data['ProductID'] ?>" onclick="return confirm('Are You Sure ??')">Delete</a>
<!-- <a class="btn btn-success" href="create_order.php?create_order=<?php echo $data['ProductID'] ?>&productPrice=<?php echo $data['price'] ?>&productName=<?php echo $data['ProductName'] ?>"><i class="icon_check_alt2"></i>Order</a> -->
</div>
<?php else : ?>
<p>N/A</p>
<?php endif; ?>
</td>
<?php } ?>
</tbody>
</table>
</section>
</div>
</div>
<!-- page end-->
</section>
</section>
</div>
<?php endif; ?>
<?php if ($_SESSION['admin_depart'] == 'JOKER' || $_SESSION['admin_depart'] == 'LOG' || $_SESSION['admin_depart'] == 'ADMIN' || $_SESSION['admin_depart'] == 'HR') : ?>
<div class="table_orders">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">
Orders
</header>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th><i class="icon_cogs"></i>ID</th>
<th>Name of Product</th>
<th>No. of Item(s)</th>
<th>Description</th>
<th>Price</th>
<th><i class="icon_mobile"></i>Email of Customer</th>
<th><i class="icon_cogs"></i> Action</th>
</tr>
<?php
$select = "SELECT *,customer.email AS Email_customer , product.name AS Name_product, orders.id AS O_ID, orders.price AS O_Price FROM orders JOIN customer,product WHERE orders.id_customer = customer.id AND orders.id_product = product.id ";
$orders_data = mysqli_query($connect_to_DB, $select);
foreach ($orders_data as $data) {
?>
<tr>
<td><?php echo $data['O_ID'] ?> </td>
<td><?php echo $data['Name_product'] ?></td>
<td><?php echo $data['no_of_items'] ?></td>
<td><?php echo $data['description'] ?></td>
<td><?php echo $data['O_Price'] ?></td>
<td><?php echo $data['Email_customer'] ?></td>
<td>
<?php if ($_SESSION['admin_depart'] != 'HR'): ?>
<div class="btn-group">
<!-- <a class="btn btn-primary" href="add_section.php?update_order=">Edit</a> -->
<!-- <a class="btn btn-success" href="#"><i class="icon_check_alt2"></i></a> -->
<a class="btn btn-danger" href="show_tables.php?delete_order=<?php echo $data['O_ID'] ?>" onclick="return confirm('Are You Sure ??')">Delete</a>
</div>
<?php else : ?>
<p>N/A</p>
<?php endif; ?>
</td>
<?php } ?>
</tbody>
</table>
</section>
</div>
</div>
<!-- page end-->
</section>
</section>
</div>
<?php endif; ?>
<?php if ($_SESSION['admin_depart'] == 'JOKER' || $_SESSION['admin_depart'] == 'ADMIN' || $_SESSION['admin_depart'] == 'HR') : ?>
<div class="table_section">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<div class="row">
<div class="col">
<section class="panel">
<header class="panel-heading">
Sections
</header>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th><i class="icon_cogs"></i>ID</th>
<th>Name of section</th>
<th><i class="icon_profile"></i> Name of Admin</th>
<th><i class="icon_cogs"></i> Action</th>
</tr>
<?php
$select = "SELECT *, admin.name AS Admin_Name , section.name AS Section_Name, section.id AS SectionID FROM section JOIN admin WHERE section.id_admin = admin.id ";
$section_data = mysqli_query($connect_to_DB, $select);
foreach ($section_data as $data) {
?>
<tr>
<td><?php echo $data['SectionID'] ?> </td>
<td><?php echo $data['Section_Name'] ?></td>
<td><?php echo $data['Admin_Name'] ?></td>
<td>
<?php if ($_SESSION['admin_depart'] != 'HR') : ?>
<div class="btn-group">
<a class="btn btn-primary" href="add_section.php?update_section=<?php echo $data['SectionID'] ?>">Edit</a>
<!-- <a class="btn btn-success" href="#"><i class="icon_check_alt2"></i></a> -->
<a class="btn btn-danger" href="show_tables.php?delete_section=<?php echo $data['SectionID'] ?>" onclick="return confirm('Are You Sure ??')">Delete</a>
</div>
<?php else : ?>
<p>N/A</p>
<?php endif; ?>
</td>
<?php } ?>
</tbody>
</table>
</section>
</div>
</div>
<!-- page end-->
</section>
</section>
</div>
<?php endif; ?>
<?php if ($_SESSION['admin_depart'] == 'JOKER') : ?>
<div class="table_admin">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">
Admins
</header>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th><i class="icon_cogs"></i>ID</th>
<th><i class="icon_profile"></i>Admin's Name</th>
<th><i class="icon_profile"></i>Admin's Pic</th>
<th><i class="icon_cogs"></i>Action</th>
</tr>
<?php
$select = "SELECT * FROM admin";
$admin_data = mysqli_query($connect_to_DB, $select);
foreach ($admin_data as $data) {
?>
<tr>
<td><?php echo $data['id'] ?> </td>
<td><?php echo $data['name'] ?></td>
<?php if ($data['admin_img'] != NULL) : ?>
<td><img width="100" height="100" src="Resources/<?php echo $data['admin_img'] ?>"></td>
<?php else : ?>
<td>N/A</td>
<?php endif; ?>
<td>
<?php if ($_SESSION['admin_depart'] == 'JOKER' && $data['department'] != 'JOKER') : ?>
<div class="btn-group">
<!-- <a class="btn btn-primary" href="add_section.php?update_section=<?php echo $data['id'] ?>">Edit</a> -->
<!-- <a class="btn btn-success" href="#"><i class="icon_check_alt2"></i></a> -->
<a class="btn btn-danger" href="show_tables.php?delete_admin=<?php echo $data['id'] ?>" onclick="return confirm('Are You Sure ??')">Delete</a>
</div>
<?php else : ?>
<p>OWNER</p>
<?php endif; ?>
</td>
<?php } ?>
</tbody>
</table>
</section>
</div>
</div>
<!-- page end-->
</section>
</section>
</div>
<?php endif; ?>
<!--main content end-->
</section>
<!-- container section end -->
<!-- javascripts -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- nicescroll -->
<script src="js/jquery.scrollTo.min.js"></script>
<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
<!--custome script for all page-->
<script src="js/scripts.js"></script>
</body>
</html>