-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_orders.php
More file actions
196 lines (172 loc) · 7.6 KB
/
Copy pathadmin_orders.php
File metadata and controls
196 lines (172 loc) · 7.6 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
<?php
session_start();
include 'DBConn.php';
// --- SECURITY GATE ---
// Matching the session logic used in your admin_dashboard.php
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
header("Location: admin_login.php");
exit();
}
// Optimized Query: Joins orders with order_items to count total pieces per order
$order_query = "SELECT o.id, o.total_amount, o.status, o.order_date, o.user_id,
(SELECT SUM(quantity) FROM order_items WHERE order_id = o.id) as total_items
FROM orders o
ORDER BY o.order_date DESC";
$orders = mysqli_query($conn, $order_query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Order Logs | Pastimes® Admin</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 {
--bg-pure: #000000;
--card-bg: #080808;
--border-dim: #222;
--accent-blue: #0678eb;
--text-muted: #888;
}
body {
background-color: var(--bg-pure);
color: #fff;
font-family: 'Inter', sans-serif;
letter-spacing: -0.2px;
}
.page-header {
border-bottom: 1px solid var(--border-dim);
padding-bottom: 20px;
margin-bottom: 40px;
}
.fw-black { font-weight: 900; letter-spacing: 1px; }
/* Table Styling for Visibility */
.order-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
/* Increased contrast on headers */
.order-table thead th {
text-transform: uppercase;
font-size: 11px;
font-weight: 800;
letter-spacing: 2px;
color: #aaa;
padding: 15px;
}
.order-row { background: var(--card-bg); transition: 0.3s; }
.order-row:hover { background: #111; }
.order-row td {
padding: 22px 15px;
border-top: 1px solid var(--border-dim);
border-bottom: 1px solid var(--border-dim);
vertical-align: middle;
color: #eee;
}
/* Border Radius Effect for Rows */
.order-row td:first-child { border-left: 1px solid var(--border-dim); }
.order-row td:last-child { border-right: 1px solid var(--border-dim); }
/* Status Badges */
.status-badge {
font-size: 10px;
text-transform: uppercase;
padding: 5px 12px;
border: 1px solid #333;
letter-spacing: 1px;
font-weight: 800;
display: inline-block;
}
.status-pending { color: #ffcc00; border-color: #ffcc00; }
.status-completed { color: #00ff88; border-color: #00ff88; }
.status-delivered { color: #00ff88; border-color: #00ff88; }
.status-processed { color: var(--accent-blue); border-color: var(--accent-blue); }
.status-shipped { color: var(--accent-blue); border-color: var(--accent-blue); }
.empty-state {
border: 1px dashed var(--border-dim);
padding: 100px 0;
text-align: center;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 2px;
font-size: 11px;
}
/* Custom Button */
.btn-manifest {
border: 1px solid #444;
color: #fff;
font-size: 10px;
border-radius: 0;
font-weight: 800;
padding: 8px 18px;
text-decoration: none;
transition: 0.2s;
}
.btn-manifest:hover {
background: #fff;
color: #000;
}
</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;">Order Logs</h2>
<p style="color: var(--text-muted); font-size: 11px; margin-top: 5px; text-transform: uppercase; letter-spacing: 1px;">
<i class="fa-solid fa-clock me-1"></i> System Time: <?php echo date('Y-m-d H:i'); ?> | Midrand HQ Status: <span style="color: #00ff88;">Online</span>
</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>
<?php if ($orders && mysqli_num_rows($orders) > 0): ?>
<div class="table-responsive">
<table class="order-table">
<thead>
<tr>
<th>Reference</th>
<th>Timestamp</th>
<th>Volume</th>
<th>Valuation</th>
<th>Status</th>
<th class="text-end">Management</th>
</tr>
</thead>
<tbody>
<?php while($row = mysqli_fetch_assoc($orders)): ?>
<tr class="order-row">
<td class="fw-black" style="color: var(--accent-blue); font-size: 14px;">
#PT-<?php echo str_pad($row['id'], 3, '0', STR_PAD_LEFT); ?>
</td>
<td>
<div style="font-size: 13px; font-weight: 700;"><?php echo date('d M Y', strtotime($row['order_date'])); ?></div>
<div style="color: var(--text-muted); font-size: 10px;"><?php echo date('H:i', strtotime($row['order_date'])); ?></div>
</td>
<td>
<span style="font-size: 13px; font-weight: 600;"><?php echo $row['total_items'] ?? 0; ?> Pieces</span>
</td>
<td class="fw-black" style="font-size: 15px;">
<span style="color: var(--text-muted); font-size: 11px; font-weight: 400;">R</span> <?php echo number_format($row['total_amount'], 2); ?>
</td>
<td>
<span class="status-badge status-<?php echo strtolower($row['status']); ?>">
<?php echo strtoupper($row['status']); ?>
</span>
</td>
<td class="text-end">
<a href="view_order.php?orderID=<?php echo $row['id']; ?>" class="btn-manifest">
<i class="fa-solid fa-file-contract me-1"></i> MANIFEST
</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="empty-state">
<i class="fa-solid fa-box-open mb-3 d-block" style="font-size: 32px; color: #222;"></i>
No active transactions found in the database.
</div>
<?php endif; ?>
</div>
</body>
</html>