-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
186 lines (168 loc) · 6.76 KB
/
admin.html
File metadata and controls
186 lines (168 loc) · 6.76 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Mink Luxe Admin Dashboard — manage bookings, users, and revenue." />
<title>Mink Luxe — Admin Dashboard</title>
<link rel="stylesheet" href="css/style.css" />
<style>
body::before {
display: none;
}
/* cleaner look for admin */
</style>
</head>
<body>
<div class="admin-layout">
<!-- Sidebar -->
<aside class="admin-sidebar">
<div class="sidebar-brand">
<a href="index.html"
style="display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-primary); justify-content: center;">
<img src="img/Mink Luxe (revamp).jpg" alt="Mink Luxe"
style="width: 36px; height: 36px; border-radius: 8px; object-fit: cover;" />
Mink <span style="color: var(--brand);">Luxe</span>
</a>
</div>
<nav>
<a href="admin.html" class="active">📊 Dashboard</a>
<a href="bookings.html">📅 Bookings</a>
<a href="index.html">🏠 Website</a>
</nav>
<div style="margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-subtle);">
<div id="adminUserInfo" style="font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.75rem;"></div>
<a href="logout.php" class="btn btn-outline btn-full"
style="font-size: 0.85rem; color: #a0a0a0; border-color: rgba(160,160,160,0.3);">
Logout
</a>
</div>
</aside>
<!-- Main Content -->
<main class="admin-main">
<div style="max-width: 1000px;">
<h1 class="mb-3 anim-fade-up">Dashboard Overview</h1>
<!-- Stats Cards -->
<div class="grid grid-3 gap-md mb-3 anim-fade-up delay-1" id="statsGrid">
<div class="stat-card">
<span class="stat-icon">📅</span>
<h3>Total Bookings</h3>
<div class="stat-value" id="statBookings">—</div>
</div>
<div class="stat-card">
<span class="stat-icon">👤</span>
<h3>This Month</h3>
<div class="stat-value" id="statMonthly">—</div>
</div>
<div class="stat-card">
<span class="stat-icon">⏳</span>
<h3>Pending</h3>
<div class="stat-value" id="statPending">—</div>
</div>
</div>
<!-- Recent Bookings Table -->
<div class="anim-fade-up delay-3">
<h2 class="mb-2">Recent Bookings</h2>
<div class="table-wrapper">
<table class="data-table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Service</th>
<th>Date</th>
<th>Time</th>
<th>Status</th>
</tr>
</thead>
<tbody id="bookingsList">
<tr id="loadingRow">
<td colspan="7" style="text-align: center; padding: 2rem; color: var(--text-secondary);">
Loading bookings...
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<script src="js/utils.js"></script>
<script>
// Show admin user info
const user = getLocalUser();
const userInfo = document.getElementById('adminUserInfo');
if (user && userInfo) {
userInfo.innerHTML = `
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 4px;">
<div style="width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-light)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; color: #fff;">
${(user.fullname || 'A').charAt(0).toUpperCase()}
</div>
<div>
<div style="font-weight: 600; color: var(--text-primary); font-size: 0.88rem;">${user.fullname || 'Admin'}</div>
<div style="font-size: 0.75rem;">${user.email || ''}</div>
</div>
</div>
`;
}
// Fetch bookings
async function loadBookings() {
try {
const res = await fetch('get_bookings.php');
if (!res.ok) throw new Error('Not authorized');
const bookings = await res.json();
const tbody = document.getElementById('bookingsList');
const loadingRow = document.getElementById('loadingRow');
if (bookings.error) {
loadingRow.innerHTML = `<td colspan="7" style="text-align: center; padding: 2rem; color: var(--text-secondary);">Please <a href="login.html">login</a> to view bookings.</td>`;
return;
}
// Update stats
document.getElementById('statBookings').textContent = bookings.length;
const now = new Date();
const thisMonth = bookings.filter(b => {
const d = new Date(b.date);
return d.getMonth() === now.getMonth() && d.getFullYear() === now.getFullYear();
});
document.getElementById('statMonthly').textContent = thisMonth.length;
const pending = bookings.filter(b => (b.status || 'Pending').toLowerCase() === 'pending');
document.getElementById('statPending').textContent = pending.length;
if (bookings.length === 0) {
loadingRow.innerHTML = `<td colspan="7" style="text-align: center; padding: 2rem; color: var(--text-secondary);">No bookings yet.</td>`;
return;
}
// Render rows
tbody.innerHTML = '';
bookings.forEach(b => {
const status = (b.status || 'Pending').toLowerCase();
const badgeClass = `badge badge-${status}`;
const row = document.createElement('tr');
row.innerHTML = `
<td>${escapeHtml(b.name)}</td>
<td>${escapeHtml(b.email)}</td>
<td>${escapeHtml(b.phone || '—')}</td>
<td>${escapeHtml(b.service)}</td>
<td>${escapeHtml(b.date)}</td>
<td>${escapeHtml(b.time)}</td>
<td><span class="${badgeClass}">${escapeHtml(b.status || 'Pending')}</span></td>
`;
tbody.appendChild(row);
});
} catch (err) {
const loadingRow = document.getElementById('loadingRow');
if (loadingRow) {
loadingRow.innerHTML = `<td colspan="7" style="text-align: center; padding: 2rem; color: var(--text-secondary);">Could not load bookings. <a href="login.html">Login</a> first.</td>`;
}
}
}
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
loadBookings();
</script>
</body>
</html>