-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_dashboard.php
More file actions
263 lines (240 loc) · 13.9 KB
/
admin_dashboard.php
File metadata and controls
263 lines (240 loc) · 13.9 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
<?php
// admin_dashboard.php - Admin Dashboard Overview
require_once 'auth_check.php';
require_admin(); // Only admins can access
// Get statistics safely
$result = $conn->query("SELECT COUNT(*) as count FROM diamonds");
$total_diamonds = $result ? $result->fetch_assoc()['count'] : 0;
$result = $conn->query("SELECT COUNT(*) as count FROM diamonds WHERE status = 'Available'");
$available_diamonds = $result ? $result->fetch_assoc()['count'] : 0;
$result = $conn->query("SELECT COUNT(*) as count FROM staff WHERE role = 'client'");
$total_clients = $result ? $result->fetch_assoc()['count'] : 0;
$result = $conn->query("SELECT COUNT(*) as count FROM staff WHERE role = 'client' AND status = 'Enable'");
$active_clients = $result ? $result->fetch_assoc()['count'] : 0;
$result = $conn->query("SELECT COUNT(*) as count FROM staff WHERE role = 'client' AND status = 'Pending'");
$pending_requests = $result ? $result->fetch_assoc()['count'] : 0;
// Check if invites table exists
$result = $conn->query("SHOW TABLES LIKE 'invites'");
if ($result && $result->num_rows > 0) {
$result = $conn->query("SELECT COUNT(*) as count FROM invites");
$total_invites = $result ? $result->fetch_assoc()['count'] : 0;
$result = $conn->query("SELECT COUNT(*) as count FROM invites WHERE used = 0 AND expires_at > NOW()");
$active_invites = $result ? $result->fetch_assoc()['count'] : 0;
} else {
$total_invites = 0;
$active_invites = 0;
}
// Recent activity
$recent_clients = $conn->query("SELECT id, client_name, name, user_id, status FROM staff WHERE role = 'client' ORDER BY id DESC LIMIT 5");
$recent_diamonds = $conn->query("SELECT id, stock_no, shape, size, color, clarity, status FROM diamonds ORDER BY id DESC LIMIT 5");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard - DS Diamonds</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<style>
body {
font-family: 'Inter', sans-serif;
}
.brand-font {
font-family: 'Sora', sans-serif;
}
.stat-card {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover {
transform: translateY(-4px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
</style>
</head>
<body class="bg-gray-50">
<?php include 'sidebar.php'; ?>
<div class="ml-64 p-6 max-w-[1400px]">
<!-- Header -->
<div class="mb-8 flex items-center justify-between">
<div>
<h1 class="text-4xl font-bold text-gray-800 brand-font mb-2">
<i class="fas fa-crown text-purple-600 mr-3"></i>Admin Dashboard
</h1>
<p class="text-gray-600">Welcome back, <?php echo h(get_user_name()); ?> • Administrator Panel</p>
</div>
<div class="flex gap-3">
<a href="diamond_add.php"
class="bg-gradient-to-r from-purple-600 to-pink-600 text-white px-6 py-3 rounded-lg font-semibold hover:shadow-lg transition flex items-center">
<i class="fas fa-plus-circle mr-2"></i>Add Diamond
</a>
</div>
</div>
<!-- Statistics Grid -->
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 mb-6">
<!-- Total Diamonds -->
<div class="stat-card bg-gradient-to-br from-purple-500 to-purple-700 rounded-xl p-6 text-white shadow-lg">
<div class="flex items-center justify-between mb-4">
<i class="fas fa-gem text-4xl opacity-80"></i>
</div>
<div class="text-5xl font-bold brand-font mb-2"><?php echo $total_diamonds; ?></div>
<div class="text-sm opacity-90 mb-1">Total Diamonds</div>
<div class="text-xs opacity-75 bg-white/10 inline-block px-3 py-1 rounded-full">
<?php echo $available_diamonds; ?> Available</div>
</div>
<!-- Total Clients -->
<div class="stat-card bg-gradient-to-br from-pink-500 to-rose-700 rounded-xl p-6 text-white shadow-lg">
<div class="flex items-center justify-between mb-4">
<i class="fas fa-users text-4xl opacity-80"></i>
</div>
<div class="text-5xl font-bold brand-font mb-2"><?php echo $total_clients; ?></div>
<div class="text-sm opacity-90 mb-1">Total Clients</div>
<div class="text-xs opacity-75 bg-white/10 inline-block px-3 py-1 rounded-full">
<?php echo $active_clients; ?> Active</div>
</div>
<!-- Pending Requests -->
<div
class="stat-card bg-gradient-to-br from-orange-500 to-amber-600 rounded-xl p-6 text-white shadow-lg relative overflow-hidden">
<?php if ($pending_requests > 0): ?>
<div class="absolute top-4 right-4">
<span class="flex h-3 w-3">
<span
class="animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"></span>
<span class="relative inline-flex rounded-full h-3 w-3 bg-white"></span>
</span>
</div>
<?php endif; ?>
<div class="flex items-center justify-between mb-4">
<i class="fas fa-user-clock text-4xl opacity-80"></i>
</div>
<div class="text-5xl font-bold brand-font mb-2"><?php echo $pending_requests; ?></div>
<div class="text-sm opacity-90 mb-1">Pending Requests</div>
<?php if ($pending_requests > 0): ?>
<a href="admin_client_requests.php"
class="text-xs mt-2 inline-block bg-white/20 px-3 py-1 rounded-full hover:bg-white/30 transition">
Review Now →
</a>
<?php else: ?>
<div class="text-xs opacity-75 bg-white/10 inline-block px-3 py-1 rounded-full">All Clear</div>
<?php endif; ?>
</div>
<!-- Active Invites -->
<div class="stat-card bg-gradient-to-br from-blue-500 to-indigo-700 rounded-xl p-6 text-white shadow-lg">
<div class="flex items-center justify-between mb-4">
<i class="fas fa-link text-4xl opacity-80"></i>
</div>
<div class="text-5xl font-bold brand-font mb-2"><?php echo $active_invites; ?></div>
<div class="text-sm opacity-90 mb-1">Active Invite Links</div>
<div class="text-xs opacity-75 bg-white/10 inline-block px-3 py-1 rounded-full">
<?php echo $total_invites; ?> Total</div>
</div>
</div>
<!-- Quick Actions -->
<div class="bg-white rounded-xl shadow-md p-5 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4 brand-font">Quick Actions</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
<a href="admin_clients.php"
class="flex items-center p-4 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-lg hover:shadow-lg transition border border-blue-100">
<i class="fas fa-users-cog text-2xl text-blue-600 mr-4"></i>
<span class="font-semibold text-gray-700">Manage Clients</span>
</a>
<a href="admin_client_requests.php"
class="flex items-center p-4 bg-gradient-to-br from-orange-50 to-amber-50 rounded-lg hover:shadow-lg transition border border-orange-100 relative">
<i class="fas fa-user-check text-2xl text-orange-600 mr-4"></i>
<span class="font-semibold text-gray-700">Client Requests</span>
<?php if ($pending_requests > 0): ?>
<span
class="absolute -top-2 -right-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded-full"><?php echo $pending_requests; ?></span>
<?php endif; ?>
</a>
<a href="diamond_master.php"
class="flex items-center p-4 bg-gradient-to-br from-purple-50 to-pink-50 rounded-lg hover:shadow-lg transition border border-purple-100">
<i class="fas fa-gem text-2xl text-purple-600 mr-4"></i>
<span class="font-semibold text-gray-700">All Diamonds</span>
</a>
</div>
</div>
<!-- Two Column Layout -->
<div class="grid md:grid-cols-2 gap-5">
<!-- Recent Clients -->
<div class="bg-white rounded-xl shadow-md p-5">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-bold text-gray-800 brand-font">Recent Clients</h2>
<a href="admin_clients.php" class="text-sm text-purple-600 hover:text-purple-800 font-semibold">
View All <i class="fas fa-arrow-right ml-1"></i>
</a>
</div>
<div class="space-y-2">
<?php
if ($recent_clients && $recent_clients->num_rows > 0):
while ($client = $recent_clients->fetch_assoc()): ?>
<div
class="flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-blue-50 transition cursor-pointer">
<div class="flex items-center">
<div
class="w-10 h-10 bg-gradient-to-br from-blue-400 to-indigo-500 rounded-full flex items-center justify-center text-white font-bold mr-3">
<?php echo strtoupper(substr($client['client_name'], 0, 1)); ?>
</div>
<div>
<div class="font-semibold text-gray-800"><?php echo h($client['client_name']); ?></div>
<div class="text-xs text-gray-500"><?php echo h($client['name']); ?></div>
</div>
</div>
<span
class="text-xs px-2 py-1 rounded-full <?php echo $client['status'] == 'Enable' ? 'bg-green-100 text-green-700' : 'bg-yellow-100 text-yellow-700'; ?>">
<?php echo $client['status'] == 'Enable' ? 'Active' : $client['status']; ?>
</span>
</div>
<?php endwhile;
else: ?>
<p class="text-gray-500 text-center py-4">No clients yet</p>
<?php endif; ?>
</div>
</div>
<!-- Recent Diamonds -->
<div class="bg-white rounded-xl shadow-md p-5">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-bold text-gray-800 brand-font">Recent Diamonds</h2>
<a href="diamond_master.php" class="text-sm text-purple-600 hover:text-purple-800 font-semibold">
View All <i class="fas fa-arrow-right ml-1"></i>
</a>
</div>
<div class="space-y-2">
<?php
if ($recent_diamonds && $recent_diamonds->num_rows > 0):
while ($diamond = $recent_diamonds->fetch_assoc()): ?>
<div
class="flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-purple-50 transition cursor-pointer">
<div class="flex items-center">
<div
class="w-10 h-10 bg-gradient-to-br from-purple-400 to-pink-500 rounded-full flex items-center justify-center text-white mr-3">
<i class="fas fa-gem"></i>
</div>
<div>
<div class="font-semibold text-gray-800"><?php echo h($diamond['stock_no']); ?></div>
<div class="text-xs text-gray-500">
<?php echo h($diamond['shape']); ?> • <?php echo h($diamond['size']); ?>ct •
<?php echo h($diamond['color']); ?>-<?php echo h($diamond['clarity']); ?>
</div>
</div>
</div>
<span
class="text-xs px-2 py-1 rounded-full <?php echo $diamond['status'] == 'Available' ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-700'; ?>">
<?php echo h($diamond['status']); ?>
</span>
</div>
<?php endwhile;
else: ?>
<p class="text-gray-500 text-center py-4">No diamonds yet</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</body>
</html>