Changeset 79fff4f for interfejs/admin.html
- Timestamp:
- 02/22/26 22:32:07 (7 months ago)
- Branches:
- finki-main, main
- Children:
- 6fea37e, 81bc7da
- Parents:
- 4dff800
- File:
-
- 1 edited
-
interfejs/admin.html (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
interfejs/admin.html
r4dff800 r79fff4f 18 18 <li><a href="products.html">Products</a></li> 19 19 <li><a href="#" id="dashboard-link" class="active">Admin</a></li> 20 <li><a href="change-password.html" class="change-password-btn">🔑 Change Password</a></li> 21 <li><a href="#" id="logout-link">Logout</a></li> 20 22 </ul> 21 23 </nav> … … 201 203 document.addEventListener('DOMContentLoaded', async () => { 202 204 const user = await loadUserData(); 205 203 206 if (!user || user.userType !== 'admin') { 204 207 window.location.href = 'index.html'; … … 207 210 208 211 document.getElementById('admin-name').textContent = user.username || 'Administrator'; 212 213 // Logout functionality 214 document.getElementById('logout-link').addEventListener('click', async (e) => { 215 e.preventDefault(); 216 await logout(); 217 }); 209 218 210 219 // Tab switching … … 213 222 document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); 214 223 document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active')); 224 215 225 btn.classList.add('active'); 216 226 document.getElementById(`${btn.dataset.tab}-tab`).classList.add('active'); … … 271 281 272 282 const tbody = document.getElementById('users-list'); 283 273 284 if (data.success && data.users.length > 0) { 274 285 tbody.innerHTML = data.users.map(user => ` 275 <tr>276 <td>${user.id || user.client_id || 'N/A'}</td>277 <td>${user.firstName || user.first_name || user.username || 'N/A'} ${user.lastName || user.last_name || ''}</td>278 <td>${user.email || 'N/A'}</td>279 <td><span class="status-badge status-${user.user_type || user.userType || 'unknown'}">${user.user_type || user.userType || 'unknown'}</span></td>280 <td>281 <button class="btn-small" onclick="viewUser('${user.id || user.client_id}')">View</button>282 </td>283 </tr>284 `).join('');286 <tr> 287 <td>${user.id || user.client_id || 'N/A'}</td> 288 <td>${user.firstName || user.first_name || user.username || 'N/A'} ${user.lastName || user.last_name || ''}</td> 289 <td>${user.email || 'N/A'}</td> 290 <td><span class="status-badge status-${user.user_type || user.userType || 'unknown'}">${user.user_type || user.userType || 'unknown'}</span></td> 291 <td> 292 <button class="btn-small" onclick="viewUser('${user.id || user.client_id}')">View</button> 293 </td> 294 </tr> 295 `).join(''); 285 296 } else { 286 297 tbody.innerHTML = '<tr><td colspan="5">No users found</td></tr>'; … … 298 309 299 310 const tbody = document.getElementById('stores-list'); 311 300 312 if (data.success && data.stores.length > 0) { 301 313 tbody.innerHTML = data.stores.map(store => ` 302 <tr>303 <td>${store.store_id}</td>304 <td>${store.name}</td>305 <td>${store.store_email}</td>306 <td>${store.rating || '0.0'}</td>307 <td>308 <button class="btn-small" onclick="viewStore('${store.store_id}')">View</button>309 </td>310 </tr>311 `).join('');314 <tr> 315 <td>${store.store_id}</td> 316 <td>${store.name}</td> 317 <td>${store.store_email}</td> 318 <td>${store.rating || '0.0'}</td> 319 <td> 320 <button class="btn-small" onclick="viewStore('${store.store_id}')">View</button> 321 </td> 322 </tr> 323 `).join(''); 312 324 } else { 313 325 tbody.innerHTML = '<tr><td colspan="5">No stores found</td></tr>'; … … 325 337 326 338 const tbody = document.getElementById('orders-list'); 339 327 340 if (data.success && data.orders.length > 0) { 328 341 tbody.innerHTML = data.orders.map(order => ` 329 <tr>330 <td>${order.order_num}</td>331 <td>${order.first_name} ${order.last_name}</td>332 <td>${order.store_name}</td>333 <td>${new Date(order.order_date).toLocaleDateString()}</td>334 <td><span class="status-badge status-${order.status}">${order.status}</span></td>335 <td>$${parseFloat(order.total || 0).toFixed(2)}</td>336 </tr>337 `).join('');342 <tr> 343 <td>${order.order_num}</td> 344 <td>${order.first_name} ${order.last_name}</td> 345 <td>${order.store_name}</td> 346 <td>${new Date(order.order_date).toLocaleDateString()}</td> 347 <td><span class="status-badge status-${order.status}">${order.status}</span></td> 348 <td>$${parseFloat(order.total || 0).toFixed(2)}</td> 349 </tr> 350 `).join(''); 338 351 } else { 339 352 tbody.innerHTML = '<tr><td colspan="6">No orders found</td></tr>'; … … 362 375 // Mock report generation 363 376 document.getElementById('report-results').innerHTML = ` 364 <div class="dashboard-section">365 <h4>Generated Report: ${type}</h4>366 <p>Period: ${start} to ${end}</p>367 <div class="loading">Generating report...</div>368 </div>369 `;377 <div class="dashboard-section"> 378 <h4>Generated Report: ${type}</h4> 379 <p>Period: ${start} to ${end}</p> 380 <div class="loading">Generating report...</div> 381 </div> 382 `; 370 383 371 384 // Simulate report generation 372 385 setTimeout(() => { 373 386 document.getElementById('report-results').innerHTML = ` 374 <div class="dashboard-section">375 <h4>Report Results</h4>376 <p><strong>Total Records:</strong> 42</p>377 <p><strong>Summary:</strong> Sample report data for demonstration</p>378 <button class="btn-small" onclick="downloadReport()">Download Report</button>379 </div>380 `;387 <div class="dashboard-section"> 388 <h4>Report Results</h4> 389 <p><strong>Total Records:</strong> 42</p> 390 <p><strong>Summary:</strong> Sample report data for demonstration</p> 391 <button class="btn-small" onclick="downloadReport()">Download Report</button> 392 </div> 393 `; 381 394 }, 1500); 382 395 }
Note:
See TracChangeset
for help on using the changeset viewer.
