-
Notifications
You must be signed in to change notification settings - Fork 1
/
myProducts.php
372 lines (302 loc) · 19.6 KB
/
myProducts.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
<?php
session_start();
require "connection.php";
if (isset($_SESSION["u"])) {
$email = $_SESSION["u"]["email"];
$pageno;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Products | mkshop</title>
<link rel="stylesheet" href="bootstrap.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" />
<link rel="stylesheet" href="style.css" />
<link rel="icon" href="resourses/logo.svg" />
</head>
<body style="background-color: #E9EBEE;">
<div class="container-fluid">
<div class="row">
<!-- header -->
<div class="col-12 bg-primary">
<div class="row">
<div class="col-12 col-lg-4">
<div class="row">
<div class="col-12 col-lg-4 mt-1 mb-1 text-center">
<?php
$profile_img_rs = Database::search("SELECT * FROM `profile_img` WHERE
`users_email`='" . $email . "'");
if ($profile_img_rs->num_rows == 1) {
$profile_img_data = $profile_img_rs->fetch_assoc();
?>
<img src="<?php echo $profile_img_data["path"]; ?>" width="90px" height="90px" class="rounded-circle" />
<?php
} else {
?>
<img src="resourses/profile_img.svg" width="90px" height="90px" class="rounded-circle" />
<?php
}
?>
</div>
<div class="col-12 col-lg-8">
<div class="row text-center text-lg-start">
<div class="col-12 mt-0 mt-lg-4">
<span class="text-white fw-bold">
<?php echo $_SESSION["u"]["fname"] . " " . $_SESSION["u"]["lname"]; ?>
</span>
</div>
<div class="col-12">
<span class="text-black-50 fw-bold"><?php echo $email; ?></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-8">
<div class="row">
<div class="col-12 col-lg-10 mt-2 my-lg-4">
<h1 class="offset-4 offset-lg-2 text-white fw-bold">My Products</h1>
</div>
<div class="col-12 col-lg-2 mx-2 mb-2 my-lg-4 mx-lg-0 d-grid">
<button class="btn btn-warning fw-bold" onclick="window.location='addProduct.php'">Add Product</button>
</div>
</div>
</div>
</div>
</div>
<!-- header -->
<!-- body -->
<div class="col-12">
<div class="row">
<!-- filter -->
<div class="col-11 col-lg-2 mx-3 my-3 border border-primary rounded">
<div class="row">
<div class="col-12 mt-3 fs-5">
<div class="row">
<div class="col-12">
<label class="form-label fw-bold fs-3">Sort Products</label>
</div>
<div class="col-11">
<div class="row">
<div class="col-10">
<input type="text" placeholder="Search..." class="form-control" id="s" />
</div>
<div class="col-1 p-1">
<label class="form-label"><i class="bi bi-search fs-5"></i></label>
</div>
</div>
</div>
<div class="col-12">
<label class="form-label fw-bold">Active Time</label>
</div>
<div class="col-12">
<hr style="width: 80%;" />
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r1" id="n">
<label class="form-check-label" for="n">
Newest to oldest
</label>
</div>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r1" id="o">
<label class="form-check-label" for="o">
Oldest to newest
</label>
</div>
</div>
<div class="col-12 mt-3">
<label class="form-label fw-bold">By quantity</label>
</div>
<div class="col-12">
<hr style="width: 80%;" />
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r2" id="h">
<label class="form-check-label" for="h">
High to low
</label>
</div>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r2" id="l">
<label class="form-check-label" for="l">
Low to high
</label>
</div>
</div>
<div class="col-12 mt-3">
<label class="form-label fw-bold">By condition</label>
</div>
<div class="col-12">
<hr style="width: 80%;" />
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r3" id="b">
<label class="form-check-label" for="b">
Brandnew
</label>
</div>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="r3" id="u">
<label class="form-check-label" for="u">
Used
</label>
</div>
</div>
<div class="col-12 text-center mt-3 mb-3">
<div class="row g-2">
<div class="col-12 col-lg-6 d-grid">
<button class="btn btn-success fw-bold" onclick="sort(0);">Sort</button>
</div>
<div class="col-12 col-lg-6 d-grid">
<button class="btn btn-primary fw-bold" onclick="clearSort();">Clear</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- filter -->
<!-- product -->
<div class="col-12 col-lg-9 mt-3 mb-3 bg-white">
<div class="row" id="sort">
<div class="offset-1 col-10 text-center">
<div class="row justify-content-center">
<?php
if (isset($_GET["page"])) {
$pageno = $_GET["page"];
} else {
$pageno = 1;
}
$product_rs = Database::search("SELECT * FROM `product` WHERE `users_email`='" . $email . "'");
$product_num = $product_rs->num_rows;
$results_per_page = 2;
$number_of_pages = ceil($product_num / $results_per_page);
$page_results = ($pageno - 1) * $results_per_page;
$selected_rs = Database::search("SELECT * FROM `product` WHERE `users_email`='" . $email . "'
LIMIT " . $results_per_page . " OFFSET " . $page_results . " ");
$selected_num = $selected_rs->num_rows;
for ($x = 0; $x < $selected_num; $x++) {
$selected_data = $selected_rs->fetch_assoc();
?>
<!-- card -->
<div class="card mb-3 mt-3 col-12 col-lg-6">
<div class="row">
<div class="col-md-4 mt-4">
<?php
$product_img_rs = Database::search("SELECT * FROM `product_img` WHERE
`product_id`='" . $selected_data["id"] . "'");
$product_img_data = $product_img_rs->fetch_assoc();
?>
<img src="<?php echo $product_img_data["img_path"]; ?>" class="img-fluid rounded-start" />
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title fw-bold"><?php echo $selected_data["title"]; ?></h5>
<span class="card-text fw-bold text-primary">Rs. <?php echo $selected_data["price"]; ?> .00</span><br />
<span class="card-text fw-bold text-success"><?php echo $selected_data["qty"]; ?> Items left</span>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="<?php echo $selected_data["id"]; ?>" onchange="changeStatus(<?php echo $selected_data['id']; ?>);" <?php if ($selected_data["status_status_id"] == 2) { ?> checked <?php } ?> />
<label class="form-check-label fw-bold text-info" for="<?php echo $selected_data["id"]; ?>">
<?php if ($selected_data["status_status_id"] == 2) { ?>
Activate Product
<?php } else {
?>
Deactivate Product
<?php
} ?>
</label>
</div>
<div class="row">
<div class="col-12">
<div class="row g-1">
<div class="col-12 col-lg-6 d-grid">
<button class="btn btn-success fw-bold" onclick="sendId(<?php echo $selected_data['id']; ?>);">Update</button>
</div>
<div class="col-12 col-lg-6 d-grid">
<button class="btn btn-danger fw-bold">Delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- card -->
<?php
}
?>
</div>
</div>
<div class="offset-2 offset-lg-3 col-8 col-lg-6 text-center mb-3">
<nav aria-label="Page navigation example">
<ul class="pagination pagination-lg justify-content-center">
<li class="page-item">
<a class="page-link" href="
<?php if ($pageno <= 1) {
echo ("#");
} else {
echo "?page=" . ($pageno - 1);
} ?>
" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for ($y = 1; $y <= $number_of_pages; $y++) {
if ($y == $pageno) {
?>
<li class="page-item active">
<a class="page-link" href="<?php echo "?page=" . ($y); ?>"><?php echo $y; ?></a>
</li>
<?php
} else {
?>
<li class="page-item">
<a class="page-link" href="<?php echo "?page=" . ($y); ?>"><?php echo $y; ?></a>
</li>
<?php
}
}
?>
<li class="page-item">
<a class="page-link" href="
<?php if ($pageno >= $number_of_pages) {
echo ("#");
} else {
echo "?page=" . ($pageno + 1);
} ?>
" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- product -->
</div>
</div>
<!-- body -->
</div>
</div>
<script src="script.js"></script>
</body>
</html>
<?php
}
?>