-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_products.php
More file actions
295 lines (264 loc) · 11.5 KB
/
Copy pathadmin_products.php
File metadata and controls
295 lines (264 loc) · 11.5 KB
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
<?php
session_start();
include 'DBConn.php';
// --- STANDARDIZED SECURITY GATE ---
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
header("Location: admin_login.php");
exit();
}
// Delete Logic
if (isset($_GET['delete'])) {
$id = intval($_GET['delete']);
mysqli_query($conn, "DELETE FROM products WHERE id = $id");
header("Location: admin_products.php");
exit();
}
// --- COMMUNICATION SYSTEM: UPDATE LISTING QUALITY STATUS & COMMENTS ---
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_quality_status'])) {
$product_id = intval($_POST['product_id']);
$action_status = mysqli_real_escape_string($conn, $_POST['action_status']);
$admin_note = mysqli_real_escape_string($conn, $_POST['admin_note']);
mysqli_query($conn, "UPDATE products SET status = '$action_status', admin_note = '$admin_note' WHERE id = $product_id");
header("Location: admin_products.php");
exit();
}
$products = mysqli_query($conn, "SELECT * FROM products ORDER BY id DESC");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Inventory Management | Pastimes®</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700;900&display=swap');
:root {
--accent-blue: #0678eb;
--border-color: #222;
--bg-dark: #000;
--card-bg: #0a0a0a;
--text-dim: #aaa; /* Increased for visibility */
}
body {
background-color: var(--bg-dark);
color: #fff;
font-family: 'Inter', sans-serif;
letter-spacing: -0.2px;
}
/* Header Styling */
.page-header {
border-bottom: 1px solid var(--border-color);
padding-bottom: 20px;
margin-bottom: 40px;
}
.fw-black { font-weight: 900; letter-spacing: 1px; }
/* Modern Add Product Section */
.admin-card {
background: var(--card-bg);
border: 1px solid var(--border-color);
padding: 35px;
margin-bottom: 50px;
}
.form-label-custom {
font-size: 10px;
text-transform: uppercase;
font-weight: 800;
letter-spacing: 1.5px;
color: var(--text-dim); /* Brighter than #666 */
margin-bottom: 12px;
display: block;
}
.form-control-custom {
background: #000 !important;
border: 1px solid #333 !important;
color: #fff !important;
border-radius: 0 !important;
padding: 14px;
font-size: 13px;
transition: 0.3s;
}
.form-control-custom:focus {
border-color: var(--accent-blue) !important;
box-shadow: none;
}
/* Professional Inventory Table */
.inventory-table {
width: 100%;
border-collapse: separate;
border-spacing: 0 10px;
}
.inventory-table thead th {
text-transform: uppercase;
font-size: 11px;
font-weight: 800;
letter-spacing: 2px;
color: var(--text-dim); /* Brighter for visibility */
padding: 15px;
border-bottom: 1px solid var(--border-color);
}
.inventory-row {
background: #080808;
transition: 0.3s;
}
.inventory-row:hover {
background: #111;
}
.inventory-row td {
padding: 22px 15px;
border-top: 1px solid var(--border-color);
border-bottom: 1px solid var(--border-color);
vertical-align: middle;
color: #eee;
}
.inventory-row td:first-child { border-left: 1px solid var(--border-color); }
.inventory-row td:last-child { border-right: 1px solid var(--border-color); }
.prod-img-container {
width: 70px;
height: 85px;
background: #111;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #222;
}
.prod-img-container img {
width: 100%;
height: 100%;
object-fit: cover;
}
.price-tag { font-weight: 900; color: #fff; font-size: 15px; }
.btn-delete {
color: #ff3e3e;
font-size: 10px;
font-weight: 900;
text-transform: uppercase;
text-decoration: none;
letter-spacing: 1px;
transition: 0.3s;
border: 1px solid #ff3e3e44;
padding: 8px 15px;
}
.btn-delete:hover {
background: #ff3e3e;
color: #fff;
}
.btn-action {
background: var(--accent-blue);
color: #fff;
border-radius: 0;
font-size: 11px;
font-weight: 800;
text-transform: uppercase;
padding: 14px 25px;
border: none;
letter-spacing: 1px;
}
/* Communication System UI Additions */
.admin-note-input {
background: #000;
border: 1px solid #222;
color: #fff;
font-size: 11px;
padding: 6px;
border-radius: 0;
width: 100%;
}
.admin-note-input::placeholder { color: #444; }
.admin-note-input:focus { background: #000; border-color: #444; color: #fff; box-shadow: none; }
.btn-status-action { font-size: 9px; font-weight: 800; text-transform: uppercase; border-radius: 0; padding: 5px 10px; letter-spacing: 0.5px; }
</style>
</head>
<body>
<div class="container py-5">
<div class="d-flex justify-content-between align-items-end page-header">
<div>
<h2 class="fw-black m-0 text-uppercase" style="font-size: 2.5rem;">Inventory</h2>
<p style="color: var(--text-dim); font-size: 11px; margin-top: 5px; text-transform: uppercase; letter-spacing: 1px;">
Asset Management System | Midrand HQ
</p>
</div>
<a href="admin_dashboard.php" class="btn btn-outline-light btn-sm px-4" style="border-radius:0; font-size:10px; font-weight:800; letter-spacing: 1px;">BACK TO DASHBOARD</a>
</div>
<div class="admin-card">
<form action="process_product.php" method="POST" enctype="multipart/form-data" class="row g-4">
<div class="col-md-5">
<label class="form-label-custom">Product Identification</label>
<input type="text" name="product_name" class="form-control-custom w-100" placeholder="e.g. Pastimes Utility Jacket" required>
</div>
<div class="col-md-2">
<label class="form-label-custom">Valuation (ZAR)</label>
<input type="number" step="0.01" name="price" class="form-control-custom w-100" placeholder="0.00" required>
</div>
<div class="col-md-3">
<label class="form-label-custom">Asset Visual</label>
<input type="file" name="image_path" class="form-control-custom w-100" required>
</div>
<div class="col-md-2 d-flex align-items-end">
<button type="submit" class="btn btn-action w-100">Add to Archive</button>
</div>
</form>
</div>
<div class="table-responsive">
<table class="inventory-table">
<thead>
<tr>
<th width="100">Visual</th>
<th>Product Description</th>
<th>Category</th>
<th>Valuation</th>
<th width="280">Quality & Communication Log</th>
<th class="text-end">Management</th>
</tr>
</thead>
<tbody>
<?php if ($products && mysqli_num_rows($products) > 0): ?>
<?php while($row = mysqli_fetch_assoc($products)): ?>
<tr class="inventory-row">
<td>
<div class="prod-img-container">
<img src="<?php echo htmlspecialchars($row['image_path']); ?>" alt="Product">
</div>
</td>
<td>
<div class="fw-black text-uppercase" style="font-size: 14px;">
<?php echo htmlspecialchars($row['product_name']); ?>
</div>
<div style="color: var(--text-dim); font-size: 10px; margin-top: 4px;">UID: #PX-<?php echo str_pad($row['id'], 3, '0', STR_PAD_LEFT); ?></div>
</td>
<td>
<span class="badge border border-secondary text-uppercase" style="font-size: 9px; font-weight: 700; border-radius: 0; padding: 5px 10px; color: var(--text-dim);">
<?php echo htmlspecialchars($row['category'] ?? 'Apparel'); ?>
</span>
</td>
<td class="price-tag">
<span style="color: var(--text-dim); font-size: 11px; font-weight: 400;">R</span> <?php echo number_format($row['price'], 2); ?>
</td>
<td>
<form action="admin_products.php" method="POST" class="d-flex flex-column gap-2">
<input type="hidden" name="product_id" value="<?php echo $row['id']; ?>">
<input type="text" name="admin_note" class="form-control admin-note-input" placeholder="Add quality feedback comment..." value="<?php echo htmlspecialchars($row['admin_note'] ?? ''); ?>">
<div class="d-flex gap-1">
<button type="submit" name="action_status" value="approved" class="btn btn-outline-success btn-status-action flex-grow-1">Approve</button>
<button type="submit" name="action_status" value="rejected" class="btn btn-outline-warning btn-status-action flex-grow-1">Reject</button>
<input type="hidden" name="update_quality_status" value="1">
</div>
</form>
</td>
<td class="text-end">
<a href="?delete=<?php echo $row['id']; ?>" class="btn-delete" onclick="return confirm('PERMANENTLY remove asset from archive?')">
<i class="fa-solid fa-trash-can me-1"></i> Remove
</a>
</td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr><td colspan="6" class="text-center py-5 text-muted">No assets found in the archive.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>