-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminPanel.php
422 lines (330 loc) · 20 KB
/
adminPanel.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
<?php
session_start();
include "connection.php";
if (isset($_SESSION["au"])) {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="Untree.co">
<link rel="shortcut icon" href="favicon.png">
<meta name="description" content="" />
<meta name="keywords" content="bootstrap, bootstrap4" />
<!-- Bootstrap CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<link href="css/tiny-slider.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<title>Admin Panel | Zen Mobiles</title>
</head>
<body>
<!-- Start Header/Navigation -->
<nav class="custom-navbar navbar navbar navbar-expand-md navbar-dark bg-dark" arial-label="Furni navigation bar">
<div class="container">
<a class="navbar-brand" href="home.php">Zen<span>.</span></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsFurni" aria-controls="navbarsFurni" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsFurni">
<ul class="custom-navbar-nav navbar-nav ms-auto mb-2 mb-md-0">
<li class="nav-item active">
<a class="nav-link" href="adminPanel.php">Dashboard</a>
</li>
<li><a class="nav-link" href="manageProducts.php">Products</a></li>
<li><a class="nav-link" href="manageUsers.php">Users</a></li>
</ul>
</div>
</div>
</nav>
<!-- End Header/Navigation -->
<!-- Start Hero Section -->
<div class="hero">
<div class="container">
<div class="row justify-content-between col-12">
<div class="col-lg-5">
<div class="intro-excerpt">
<h1>Dashboard</h1>
<p><a href="manageUsers.php" class="btn btn-secondary me-2">Manage Users</a>
<a href="manageProducts.php" class="btn btn-secondary me-2">Manage Products</a>
</p>
</div>
</div>
<div class="col-lg-7">
<div class="col-lg-12 ">
<div class="row">
<div class="col-12 col-lg-10 text-end my-3 justify-content-end offset-2">
<label class="col-12 col-lg-10 text-end my-3 form-label fs-4 fw-bold text-white">Total Active Time:</label>
<?php
$start_date = new DateTime("2024-05-09 07:00:00");
$tdate = new DateTime();
$tz = new DateTimeZone("Asia/Colombo");
$tdate->setTimezone($tz);
$end_date = new DateTime($tdate->format("Y-m-d H:i:s"));
$difference = $end_date->diff($start_date);
?>
<label class="form-label fs-4 fw-bold text-warning">
<?php
echo $difference->format('%Y') . " Years " . $difference->format('%m') . " Months " .
$difference->format('%d') . " Days " . $difference->format('%H') . " Hours " .
$difference->format('%i') . " Minutes " . $difference->format('%s') . " Seconds";
?>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Hero Section -->
<div class="container-fluid">
<div class="row">
<div class="col-12 col-lg-12">
<div class="row">
<div class="col-12 mt-4">
<div class="row g-1">
<div class="col-6 col-lg-4 px-1 shadow">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/sellingsmonthly.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Daily Earnings</span>
<?php
$today = date("Y-m-d");
$thismonth = date("m");
$thisyear = date("Y");
$a = "0";
$b = "0";
$c = "0";
$e = "0";
$f = "0";
$invoice_rs = Database::search("SELECT * FROM `invoice`");
$invoice_num = $invoice_rs->num_rows;
for ($x = 0; $x < $invoice_num; $x++) {
$invoice_data = $invoice_rs->fetch_assoc();
$f = $f + $invoice_data["qty"]; //total qty
$d = $invoice_data["date"];
$splitDate = explode(" ", $d); //separate the date from time
$pdate = $splitDate["0"]; //sold date
if ($pdate == $today) {
$a = $a + $invoice_data["total"];
$c = $c + $invoice_data["qty"];
}
$splitMonth = explode("-", $pdate); //separate date as year,month & day
$pyear = $splitMonth["0"]; //year
$pmonth = $splitMonth["1"]; //month
if ($pyear == $thisyear) {
if ($pmonth == $thismonth) {
$b = $b + $invoice_data["total"];
$e = $e + $invoice_data["qty"];
}
}
}
?>
<br />
<span class="fs-5">Rs. <?php echo $a; ?> .00</span>
</div>
</div>
</div>
<div class="col-6 col-lg-4 px-1">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/sellingdaily.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Monthly Earnings</span>
<br />
<span class="fs-5">Rs. <?php echo $b; ?> .00</span>
</div>
</div>
</div>
<div class="col-6 col-lg-4 px-1">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/daily income.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Today Sellings</span>
<br />
<span class="fs-5"><?php echo $c; ?> Items</span>
</div>
</div>
</div>
<div class="col-6 col-lg-4 px-1">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/monthincome.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Monthly Sellings</span>
<br />
<span class="fs-5"><?php echo $e; ?> Items</span>
</div>
</div>
</div>
<div class="col-6 col-lg-4 px-1">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/total sellings.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Total Sellings</span>
<br />
<span class="fs-5"><?php echo $f; ?> Items</span>
</div>
</div>
</div>
<div class="col-6 col-lg-4 px-1 shadow">
<div class="row g-1">
<div class="col-12 hero text-white text-center rounded">
<a href=""><img src="images/engagement.png" alt="" style="height: 200px;"></a>
<br />
<span class="fs-4 fw-bold">Total Engagements</span>
<br />
<?php
$user_rs = Database::search("SELECT * FROM `user`");
$user_num = $user_rs->num_rows;
?>
<span class="fs-5"><?php echo $user_num; ?> Members</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<hr />
</div>
<div class="offset-1 col-10 col-lg-4 my-3 rounded bg-body">
<div class="row g-1">
<div class="col-12 text-center">
<label class="form-label fs-4 fw-bold text-decoration-underline">Mostly Sold Item</label>
</div>
<?php
$freq_rs = Database::search("SELECT `product_id`,COUNT(`product_id`) AS `value_occurence` FROM `invoice`
WHERE `date` LIKE '%" . $today . "%' GROUP BY `product_id` ORDER BY `value_occurence` DESC LIMIT 1");
$freq_num = $freq_rs->num_rows;
if ($freq_num > 0) {
$freq_data = $freq_rs->fetch_assoc();
$product_rs = Database::search("SELECT * FROM `product` WHERE `id`='" . $freq_data["product_id"] . "'");
$product_data = $product_rs->fetch_assoc();
$image_rs = Database::search("SELECT * FROM `product_img` WHERE `product_id`='" . $freq_data["product_id"] . "'");
$image_data = $image_rs->fetch_assoc();
$qty_rs = Database::search("SELECT SUM(`qty`) AS `qty_total` FROM `invoice` WHERE
`product_id`='" . $freq_data["product_id"] . "' AND `date` LIKE '%" . $today . "%'");
$qty_data = $qty_rs->fetch_assoc();
?>
<div class="col-12 text-center shadow">
<img src="<?php echo $image_data["img_path"]; ?>" class="img-fluid rounded-top" style="height: 250px;" />
</div>
<div class="col-12 text-center my-3">
<span class="fs-5 fw-bold"><?php echo $product_data["title"]; ?></span><br />
<span class="fs-6"><?php echo $qty_data["qty_total"]; ?> items</span><br />
<span class="fs-6">Rs. <?php echo $qty_data["qty_total"] * $product_data["price"]; ?> .00</span>
</div>
<?php
} else {
?>
<!-- empty product -->
<div class="col-12 text-center shadow">
<img src="resource/empty.svg" class="img-fluid rounded-top" style="height: 250px;" />
</div>
<div class="col-12 text-center my-3">
<span class="fs-5 fw-bold">-----</span><br />
<span class="fs-6">--- items</span><br />
<span class="fs-6">Rs. ----- .00</span>
</div>
<!-- empty product -->
<?php
}
?>
<div class="col-12">
<div class="first-place"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Start Footer Section -->
<footer class="footer-section">
<div class="container relative">
<div class="row">
<div class="col-lg-8">
<div class="subscription-form">
<h3 class="d-flex align-items-center"><span class="me-1"><img src="images/envelope-outline.svg" alt="Image" class="img-fluid"></span><span>Subscribe to Newsletter</span></h3>
<form action="#" class="row g-3">
<div class="col-auto">
<input type="text" class="form-control" placeholder="Enter your name">
</div>
<div class="col-auto">
<input type="email" class="form-control" placeholder="Enter your email">
</div>
<div class="col-auto">
<button class="btn btn-primary">
<span class="fa fa-paper-plane"></span>
</button>
</div>
</form>
</div>
</div>
</div>
<div class="row g-5 mb-5">
<div class="col-lg-4">
<div class="mb-4 footer-logo-wrap"><a href="#" class="footer-logo">Zen<span>.</span></a></div>
<p class="mb-4">Welcome to Zen Mobiles, your go-to shop for the latest mobile phones. We offer a wide range of smartphones to fit every need and budget. Enjoy great prices and excellent customer service. Visit us today!</p>
<ul class="list-unstyled custom-social">
<li><a href="#"><span class="fa fa-brands fa-facebook-f"></span></a></li>
<li><a href="#"><span class="fa fa-brands fa-twitter"></span></a></li>
<li><a href="#"><span class="fa fa-brands fa-instagram"></span></a></li>
<li><a href="#"><span class="fa fa-brands fa-linkedin"></span></a></li>
</ul>
</div>
<div class="col-lg-8">
<div class="row links-wrap">
<div class="col-6 col-sm-6 col-md-3">
<ul class="list-unstyled">
<li><a href="about.php">About us</a></li>
<li><a href="services.php">Services</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div class="col-6 col-sm-6 col-md-3">
<ul class="list-unstyled">
<li><a href="#">Support</a></li>
<li><a href="#">Knowledge base</a></li>
<li><a href="#">Live chat</a></li>
</ul>
</div>
<div class="col-6 col-sm-6 col-md-3">
<ul class="list-unstyled">
<li><a href="#">Jobs</a></li>
<li><a href="#">Our team</a></li>
<li><a href="#">Leadership</a></li>
<li><a href="#">Privacy Policy</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="border-top copyright">
<div class="row pt-4">
<div class="col-lg-6">
<p class="mb-2 text-center text-lg-start">Copyright ©
<script>
document.write(new Date().getFullYear());
</script>. All Rights Reserved.
</div>
</div>
</div>
</div>
</footer>
<!-- End Footer Section -->
<script src="bootstrap.bundle.js"></script>
<script src="script.js"></script>
</body>
</html>
<?php
} else {
echo ("You are not a valid user.");
}
?>