-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminPanel.php
361 lines (280 loc) · 18.1 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
<?php
session_start();
require "connection.php";
if (isset($_SESSION["au"])) {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Admin Panel | eShop</title>
<link rel="stylesheet" href="bootstrap.css" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
<link rel="icon" href="resource/logo.svg" />
</head>
<body style="background-color: #74EBD5; background-image: linear-gradient(90deg,#74EBD5 0%,#9FACE6 100%);" onload="reload();">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-lg-2">
<div class=" row">
<div class="col-12 align-items-start bg-dark">
<div class="row g-1 text-center">
<div class="col-12 mt-5">
<h4 class="text-white"><?php echo $_SESSION["au"]["fname"] . " " . $_SESSION["au"]["lname"]; ?></h4>
<hr class="border border-1 border-white" />
</div>
<div class="nav flex-column nav-pills me-3 mt-3" role="tablist" aria-orientation="vertical">
<nav class="nav flex-column">
<a class="nav-link active" aria-current="page" href="#">Dashboard</a>
<a class="nav-link" href="manageUsers.php">Manage Users</a>
<a class="nav-link" href="manageProduct.php">Manage Products</a>
</nav>
</div>
<div class="col-12 mt-5">
<hr class="border border-1 border-white" />
<a href="sellingHistory.php" class="text-white fw-bold text-decoration-none fs-3">Selling History</a>
<hr class="border border-1 border-white" />
</div>
<div class="col-12 mt-3 d-grid">
<label class="form-label fs-6 fw-bold text-white">From Date</label>
<input type="date" class="form-control" id="from"/>
<label class="form-label fs-6 fw-bold text-white">To Date</label>
<input type="date" class="form-control" id="to"/>
<a href="#" class="btn btn-primary mt-2" onclick="findSellings();">Search</a>
<hr class="border border-1 border-white" />
<label class="form-label fs-6 fw-bold text-white">Daily Sellings</label>
<hr class="border border-1 border-white" />
<hr class="border border-1 border-white" />
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-10">
<div class="row">
<div class="text-white fw-bold mb-1 mt-3">
<h2 class="fw-bold">Dashboard</h2>
</div>
<div class="col-12">
<hr />
</div>
<div class="col-12">
<div class="row g-1">
<div class="col-6 col-lg-4 px-1">
<div class="row g-1">
<div class="col-12 bg-primary text-white text-center rounded" style="height: 100px;">
<br />
<span class="fs-4 fw-bold">Daily Earnings</span>
<br />
<?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 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 & date
$pyear = $splitMonth[0]; //year
$pmonth = $splitMonth[1]; //month
if ($pyear == $thisyear) {
if ($pmonth == $thismonth) {
$b = $b + $invoice_data["total"];
$e = $e + $invoice_data["qty"];
}
}
}
?>
<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 bg-white text-center rounded" style="height: 100px;">
<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 bg-dark text-white text-center rounded" style="height: 100px;">
<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 bg-secondary text-white text-center rounded" style="height: 100px;">
<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 bg-success text-white text-center rounded" style="height: 100px;">
<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">
<div class="row g-1">
<div class="col-12 bg-danger text-white text-center rounded" style="height: 100px;">
<br />
<span class="fs-4 fw-bold">Total Members</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="col-12 bg-dark">
<div class="row">
<div class="col-12 col-lg-2 text-center my-3">
<label class="form-label fs-4 fw-bold text-white">Total Active Time</label>
</div>
<div class="col-12 col-lg-10 text-center my-3" id="time">
<!-- Time -->
</div>
</div>
</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 `images` 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">
<div class="row justify-content-center">
<img src="<?php echo $image_data["code"]; ?>" class="img-fluid img-thumbnail rounded-top" style="height: 250px;" />
</div>
</div>
<div class="col-12 text-center pb-2">
<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{
?>
<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>
<?php
}
?>
<div class="col-12">
<div class="first-place"></div>
</div>
</div>
</div>
<div class="offset-1 col-10 col-lg-4 my-3 rounded bg-body">
<div class="row g-1">
<?php
if ($freq_num > 0) {
$profile_rs = Database::search("SELECT * FROM `profile_image` WHERE
`user_email`='" . $product_data["user_email"] . "'");
$profile_data = $profile_rs->fetch_assoc();
$user_rs1 = Database::search("SELECT * FROM `user` WHERE `email`='" . $product_data["user_email"] . "'");
$user_data1 = $user_rs1->fetch_assoc();
?>
<div class="col-12 text-center">
<label class="form-label fs-4 fw-bold text-decoration-underline">Most Famouse Seller</label>
</div>
<div class="col-12 text-center shadow">
<img src="<?php echo $profile_data["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 $user_data1["fname"]." ".$user_data1["lname"]; ?></span><br />
<span class="fs-6"><?php echo $user_data1["email"]; ?></span><br />
<span class="fs-6"><?php echo $user_data1["mobile"]; ?></span>
</div>
<?php
} else {
?>
<div class="col-12 text-center">
<label class="form-label fs-4 fw-bold text-decoration-underline">Most Famouse Seller</label>
</div>
<div class="col-12 text-center shadow">
<img src="resource/profile_img/new_user.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">-----</span><br />
<span class="fs-6">----------</span>
</div>
<?php
}
?>
<div class="col-12">
<div class="first-place"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
<script src="bootstrap.bundle.js"></script>
</body>
</html>
<?php
} else {
echo ("You are not a valid user");
}
?>