-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreports.html
More file actions
307 lines (294 loc) · 19.4 KB
/
reports.html
File metadata and controls
307 lines (294 loc) · 19.4 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
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>รายงาน — ProShip Easy</title>
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
* { font-family: 'Prompt', sans-serif; }
#sidebar { background: #2d1b69; min-height: 100vh; width: 240px; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; }
.nav-item { display:flex; align-items:center; gap:10px; padding:11px 18px; color:rgba(255,255,255,0.7); border-radius:10px; margin:2px 10px; cursor:pointer; transition:all 0.2s; font-size:0.9rem; }
.nav-item:hover { background:rgba(255,255,255,0.12); color:#fff; }
.nav-item.active { background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; }
.card { background:#fff; border-radius:14px; box-shadow:0 1px 6px rgba(0,0,0,0.07); border:1px solid #f0f0f0; }
.stat-card { transition: transform 0.2s, box-shadow 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.toast { position:fixed; bottom:24px; right:24px; z-index:9999; padding:12px 20px; border-radius:10px; color:#fff; font-size:0.875rem; font-weight:600; max-width:380px; box-shadow:0 4px 12px rgba(0,0,0,0.2); transition:opacity 0.3s; }
</style>
</head>
<body class="bg-gray-50">
<!-- Sidebar -->
<div id="sidebar">
<div class="p-4 border-b border-white/10">
<div class="flex items-center gap-3">
<div class="w-9 h-9 bg-white/20 rounded-xl flex items-center justify-center text-lg">📦</div>
<div><div class="text-white font-bold text-sm">ProShip Easy</div><div class="text-white/50 text-xs">Master Admin</div></div>
</div>
</div>
<div class="mt-3 space-y-0.5">
<div class="nav-item" onclick="window.location.href='master-dashboard.html'"><span>📊</span> หน้าหลัก</div>
<div class="nav-item" onclick="window.location.href='master-dashboard.html'"><span>🏢</span> สาขา</div>
<div class="nav-item" onclick="window.location.href='master-dashboard.html'"><span>💰</span> อนุมัติเติมเงิน</div>
<div class="nav-item active"><span>📈</span> รายงาน</div>
<div class="nav-item" onclick="window.location.href='settings.html'"><span>⚙️</span> ตั้งค่า</div>
</div>
<div class="absolute bottom-4 left-0 right-0 px-2">
<div class="nav-item" onclick="window.location.href='index.html'"><span>🚪</span> ออกจากระบบ</div>
</div>
</div>
<!-- Main -->
<div class="ml-[240px] min-h-screen">
<!-- Header -->
<div class="sticky top-0 z-40 bg-white border-b border-gray-200 px-6 py-3 flex items-center justify-between">
<div>
<h1 class="text-lg font-bold text-gray-800">รายงานและสถิติ</h1>
<p class="text-xs text-gray-400">วิเคราะห์ข้อมูลการขายและประสิทธิภาพ</p>
</div>
<div class="flex items-center gap-3">
<button onclick="exportReport()" class="border border-gray-300 text-gray-600 px-4 py-2 rounded-xl text-sm hover:bg-gray-50 flex items-center gap-2">
📊 ส่งออก Excel
</button>
<a href="master-dashboard.html" class="border border-gray-300 text-gray-600 px-3 py-2 rounded-xl text-sm hover:bg-gray-50">← กลับ</a>
</div>
</div>
<main class="p-6">
<!-- Filters -->
<div class="card p-4 mb-6">
<div class="flex flex-wrap gap-3 items-center">
<span class="text-sm text-gray-500 font-medium">ช่วงวันที่:</span>
<div class="flex items-center gap-2">
<input type="date" id="date-from" class="border border-gray-300 rounded-lg px-3 py-1.5 text-sm">
<span class="text-gray-400 text-sm">ถึง</span>
<input type="date" id="date-to" class="border border-gray-300 rounded-lg px-3 py-1.5 text-sm">
</div>
<button onclick="applyDateFilter()" class="bg-gradient-to-r from-purple-600 to-blue-600 text-white px-4 py-1.5 rounded-lg text-sm font-medium hover:opacity-90">
ค้นหา
</button>
<select id="filter-branch" class="border border-gray-300 rounded-xl px-3 py-2 text-sm ml-auto">
<option>ทุกสาขา</option>
<option>สาขาสยาม</option>
<option>สาขาลาดพร้าว</option>
<option>สาขาอุดมสุข</option>
<option>สาขาบางแค</option>
</select>
</div>
</div>
<!-- Summary Cards -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
<div class="card stat-card p-5">
<div class="flex items-center justify-between">
<div><p class="text-xs text-gray-500">สาขาทั้งหมด</p><p class="text-2xl font-bold text-blue-600 mt-1">4</p><p class="text-xs text-gray-400 mt-0.5">เปิดใช้งาน 3</p></div>
<div class="w-11 h-11 bg-blue-100 rounded-xl flex items-center justify-center text-2xl">🏪</div>
</div>
</div>
<div class="card stat-card p-5">
<div class="flex items-center justify-between">
<div><p class="text-xs text-gray-500">ออเดอร์รวม</p><p class="text-2xl font-bold text-purple-600 mt-1" id="total-orders">1,847</p><p class="text-xs text-green-500 mt-0.5">+8.2% จากเมื่อวาน</p></div>
<div class="w-11 h-11 bg-purple-100 rounded-xl flex items-center justify-center text-2xl">📦</div>
</div>
</div>
<div class="card stat-card p-5">
<div class="flex items-center justify-between">
<div><p class="text-xs text-gray-500">รายได้รวม</p><p class="text-2xl font-bold text-green-600 mt-1" id="total-revenue">฿87,230</p><p class="text-xs text-green-500 mt-0.5">+12.5% จากเมื่อวาน</p></div>
<div class="w-11 h-11 bg-green-100 rounded-xl flex items-center justify-center text-2xl">💰</div>
</div>
</div>
<div class="card stat-card p-5">
<div class="flex items-center justify-between">
<div><p class="text-xs text-gray-500">กำไรรวม</p><p class="text-2xl font-bold text-yellow-600 mt-1">฿45,120</p><p class="text-xs text-green-500 mt-0.5">+15.3% จากเมื่อวาน</p></div>
<div class="w-11 h-11 bg-yellow-100 rounded-xl flex items-center justify-center text-2xl">💎</div>
</div>
</div>
</div>
<!-- Charts -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<div class="card p-5">
<div class="flex items-center justify-between mb-4">
<h2 class="font-bold text-gray-800">รายได้รายวัน</h2>
<span class="text-xs text-gray-400" id="chart-range-label">7 วันล่าสุด</span>
</div>
<div style="height:240px"><canvas id="revenueChart"></canvas></div>
</div>
<div class="card p-5">
<div class="flex items-center justify-between mb-4">
<h2 class="font-bold text-gray-800">ออเดอร์ตามขนส่ง</h2>
<span class="text-xs text-gray-400" id="chart-range-label2">7 วันล่าสุด</span>
</div>
<div style="height:240px"><canvas id="carriersChart"></canvas></div>
</div>
</div>
<!-- Branch Table -->
<div class="card overflow-hidden mb-6">
<div class="px-5 py-4 border-b border-gray-100 flex items-center justify-between">
<h2 class="font-bold text-gray-800">ประสิทธิภาพแต่ละสาขา</h2>
<button onclick="exportReport()" class="text-sm text-purple-600 font-medium hover:text-purple-800">📊 ส่งออก →</button>
</div>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 text-xs text-gray-500 uppercase">
<tr>
<th class="px-5 py-3 text-left">สาขา</th>
<th class="px-5 py-3 text-left">ออเดอร์</th>
<th class="px-5 py-3 text-left">รายได้</th>
<th class="px-5 py-3 text-left">กำไร</th>
<th class="px-5 py-3 text-left">เติบโต</th>
<th class="px-5 py-3 text-left">ประสิทธิภาพ</th>
<th class="px-5 py-3 text-left">ใช้งานล่าสุด</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<tr class="hover:bg-gray-50">
<td class="px-5 py-4"><div class="flex items-center gap-3"><div class="w-9 h-9 bg-green-100 rounded-lg flex items-center justify-center font-bold text-green-600 text-sm">S</div><div><p class="font-medium">สาขาสยาม</p><p class="text-xs text-gray-400">24/7</p></div></div></td>
<td class="px-5 py-4 font-bold">623</td>
<td class="px-5 py-4 font-bold text-green-600">฿29,640</td>
<td class="px-5 py-4 text-green-600">฿15,230</td>
<td class="px-5 py-4"><span class="text-green-600 font-semibold">+18.5%</span></td>
<td class="px-5 py-4">
<div class="flex items-center gap-2">
<div class="w-20 bg-gray-200 rounded-full h-2"><div class="bg-green-500 h-2 rounded-full" style="width:95%"></div></div>
<span class="text-xs text-gray-600">95%</span>
</div>
</td>
<td class="px-5 py-4 text-gray-400 text-xs">2 นาทีที่แล้ว</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-5 py-4"><div class="flex items-center gap-3"><div class="w-9 h-9 bg-blue-100 rounded-lg flex items-center justify-center font-bold text-blue-600 text-sm">L</div><div><p class="font-medium">สาขาลาดพร้าว</p><p class="text-xs text-gray-400">08:00-20:00</p></div></div></td>
<td class="px-5 py-4 font-bold">469</td>
<td class="px-5 py-4 font-bold text-green-600">฿21,840</td>
<td class="px-5 py-4 text-green-600">฿11,650</td>
<td class="px-5 py-4"><span class="text-green-600 font-semibold">+12.3%</span></td>
<td class="px-5 py-4">
<div class="flex items-center gap-2">
<div class="w-20 bg-gray-200 rounded-full h-2"><div class="bg-blue-500 h-2 rounded-full" style="width:88%"></div></div>
<span class="text-xs text-gray-600">88%</span>
</div>
</td>
<td class="px-5 py-4 text-gray-400 text-xs">5 นาทีที่แล้ว</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-5 py-4"><div class="flex items-center gap-3"><div class="w-9 h-9 bg-orange-100 rounded-lg flex items-center justify-center font-bold text-orange-600 text-sm">U</div><div><p class="font-medium">สาขาอุดมสุข</p><p class="text-xs text-gray-400">09:00-21:00</p></div></div></td>
<td class="px-5 py-4 font-bold">433</td>
<td class="px-5 py-4 font-bold text-green-600">฿20,230</td>
<td class="px-5 py-4 text-green-600">฿10,120</td>
<td class="px-5 py-4"><span class="text-green-600 font-semibold">+8.7%</span></td>
<td class="px-5 py-4">
<div class="flex items-center gap-2">
<div class="w-20 bg-gray-200 rounded-full h-2"><div class="bg-orange-400 h-2 rounded-full" style="width:82%"></div></div>
<span class="text-xs text-gray-600">82%</span>
</div>
</td>
<td class="px-5 py-4 text-gray-400 text-xs">8 นาทีที่แล้ว</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-5 py-4"><div class="flex items-center gap-3"><div class="w-9 h-9 bg-gray-100 rounded-lg flex items-center justify-center font-bold text-gray-500 text-sm">B</div><div><p class="font-medium text-gray-500">สาขาบางแค</p><p class="text-xs text-gray-400">ปิดชั่วคราว</p></div></div></td>
<td class="px-5 py-4 text-gray-400">322</td>
<td class="px-5 py-4 text-gray-400">฿15,520</td>
<td class="px-5 py-4 text-gray-400">฿8,120</td>
<td class="px-5 py-4"><span class="text-gray-400">ปิด</span></td>
<td class="px-5 py-4">
<div class="flex items-center gap-2">
<div class="w-20 bg-gray-200 rounded-full h-2"><div class="bg-gray-400 h-2 rounded-full" style="width:75%"></div></div>
<span class="text-xs text-gray-400">75%</span>
</div>
</td>
<td class="px-5 py-4 text-gray-400 text-xs">3 ชั่วโมงที่แล้ว</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Bottom Insights -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="card p-5">
<h3 class="font-bold text-gray-800 mb-4">⏰ เวลาที่มีออเดอร์มากที่สุด</h3>
<div class="space-y-3">
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">09:00 – 12:00</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-blue-500 h-3 rounded-full" style="width:85%"></div></div><span class="text-sm font-medium text-gray-700">425</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">13:00 – 16:00</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-green-500 h-3 rounded-full" style="width:92%"></div></div><span class="text-sm font-medium text-gray-700">461</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">17:00 – 20:00</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-purple-500 h-3 rounded-full" style="width:78%"></div></div><span class="text-sm font-medium text-gray-700">389</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">06:00 – 09:00</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-yellow-400 h-3 rounded-full" style="width:35%"></div></div><span class="text-sm font-medium text-gray-700">175</span></div>
</div>
</div>
<div class="card p-5">
<h3 class="font-bold text-gray-800 mb-4">📍 จังหวัดปลายทางยอดนิยม</h3>
<div class="space-y-3">
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">กรุงเทพมหานคร</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-blue-500 h-3 rounded-full" style="width:95%"></div></div><span class="text-sm font-medium text-gray-700">1,156</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">นนทบุรี</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-green-500 h-3 rounded-full" style="width:45%"></div></div><span class="text-sm font-medium text-gray-700">231</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">สมุทรปราการ</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-purple-500 h-3 rounded-full" style="width:35%"></div></div><span class="text-sm font-medium text-gray-700">178</span></div>
<div class="flex items-center gap-3"><span class="text-sm text-gray-600 w-28">ปทุมธานี</span><div class="flex-1 bg-gray-200 rounded-full h-3"><div class="bg-orange-400 h-3 rounded-full" style="width:28%"></div></div><span class="text-sm font-medium text-gray-700">145</span></div>
</div>
</div>
</div>
</main>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Set default date range: last 7 days
const today = new Date();
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(today.getDate() - 6);
document.getElementById('date-to').value = today.toISOString().split('T')[0];
document.getElementById('date-from').value = sevenDaysAgo.toISOString().split('T')[0];
// Revenue chart
new Chart(document.getElementById('revenueChart').getContext('2d'), {
type: 'line',
data: {
labels: ['จัน','อัง','พุธ','พฤ','ศุกร์','เสาร์','อาทิ'],
datasets: [{
label: 'รายได้ (฿)',
data: [11500, 13200, 12800, 14100, 13900, 15200, 12450],
borderColor: '#667eea', backgroundColor: 'rgba(102,126,234,0.12)',
fill: true, tension: 0.4, pointBackgroundColor: '#667eea', pointRadius: 4,
}]
},
options: {
responsive: true, maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: {
y: { beginAtZero: true, ticks: { callback: v => '฿' + v.toLocaleString() } }
}
}
});
// Carriers doughnut
new Chart(document.getElementById('carriersChart').getContext('2d'), {
type: 'doughnut',
data: {
labels: ['Flash Express', 'J&T Express', 'Kerry Express', 'ไปรษณีย์ไทย'],
datasets: [{
data: [45, 28, 18, 9],
backgroundColor: ['#f97316','#ef4444','#22c55e','#3b82f6'],
borderWidth: 3, borderColor: '#fff',
}]
},
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: 'bottom' } } }
});
});
function applyDateFilter() {
const from = document.getElementById('date-from').value;
const to = document.getElementById('date-to').value;
if (!from || !to) { showToast('กรุณาเลือกวันที่เริ่มต้นและสิ้นสุด', 'warning'); return; }
if (from > to) { showToast('วันที่เริ่มต้นต้องไม่เกินวันที่สิ้นสุด', 'warning'); return; }
const fromFmt = new Date(from).toLocaleDateString('th-TH', { day:'numeric', month:'short' });
const toFmt = new Date(to).toLocaleDateString('th-TH', { day:'numeric', month:'short' });
document.getElementById('chart-range-label').textContent = fromFmt + ' – ' + toFmt;
document.getElementById('chart-range-label2').textContent = fromFmt + ' – ' + toFmt;
showToast('แสดงข้อมูล ' + fromFmt + ' – ' + toFmt, 'info');
}
function exportReport() {
showToast('กำลังส่งออกรายงาน...', 'info');
setTimeout(() => showToast('✅ ส่งออกสำเร็จ! ไฟล์บันทึกใน Downloads', 'success'), 1500);
}
function showToast(msg, type = 'info') {
const colors = { success:'#16a34a', error:'#dc2626', info:'#2563eb', warning:'#d97706' };
const t = document.createElement('div');
t.className = 'toast'; t.textContent = msg;
t.style.background = colors[type]; t.style.opacity = '0';
document.body.appendChild(t);
setTimeout(() => t.style.opacity = '1', 10);
setTimeout(() => { t.style.opacity = '0'; setTimeout(() => t.remove(), 350); }, 3000);
}
</script>
</body>
</html>