Changeset 79fff4f for interfejs/store-owner.html
- Timestamp:
- 02/22/26 22:32:07 (7 months ago)
- Branches:
- finki-main, main
- Children:
- 6fea37e, 81bc7da
- Parents:
- 4dff800
- File:
-
- 1 edited
-
interfejs/store-owner.html (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
interfejs/store-owner.html
r4dff800 r79fff4f 18 18 <li><a href="products.html">Products</a></li> 19 19 <li><a href="#" id="dashboard-link" class="active">Store Owner</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> … … 457 459 document.getElementById('owner-name').textContent = `${user.firstName} ${user.lastName || ''}`; 458 460 461 // Logout functionality 462 document.getElementById('logout-link').addEventListener('click', async (e) => { 463 e.preventDefault(); 464 await logout(); 465 }); 466 459 467 // Load stores 460 468 const stores = user.stores || []; … … 484 492 document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); 485 493 document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active')); 494 486 495 btn.classList.add('active'); 487 496 document.getElementById(`${btn.dataset.tab}-tab`).classList.add('active'); … … 558 567 const response = await fetch(`/api/store-products?storeId=${storeId}`); 559 568 const data = await response.json(); 569 560 570 const tbody = document.getElementById('products-list'); 561 571 562 572 if (data.success && data.products.length > 0) { 563 573 tbody.innerHTML = data.products.map(product => ` 564 <tr>565 <td>${product.code}</td>566 <td>${product.description.substring(0, 30)}${product.description.length > 30 ? '...' : ''}</td>567 <td>$${parseFloat(product.price).toFixed(2)}</td>568 <td>${product.availability}</td>569 <td>${product.category_name || 'General'}</td>570 <td>571 <button class="btn-small" onclick="editProduct('${product.code}')">Edit</button>572 <button class="btn-small" style="background: var(--danger);" onclick="deleteProduct('${product.code}', '${storeId}')">Delete</button>573 </td>574 </tr>575 `).join('');574 <tr> 575 <td>${product.code}</td> 576 <td>${product.description.substring(0, 30)}${product.description.length > 30 ? '...' : ''}</td> 577 <td>$${parseFloat(product.price).toFixed(2)}</td> 578 <td>${product.availability}</td> 579 <td>${product.category_name || 'General'}</td> 580 <td> 581 <button class="btn-small" onclick="editProduct('${product.code}')">Edit</button> 582 <button class="btn-small" style="background: var(--danger);" onclick="deleteProduct('${product.code}', '${storeId}')">Delete</button> 583 </td> 584 </tr> 585 `).join(''); 576 586 } else { 577 587 tbody.innerHTML = '<tr><td colspan="6">No products found</td></tr>'; … … 587 597 const response = await fetch(`/api/store-orders?storeId=${storeId}`); 588 598 const data = await response.json(); 599 589 600 const tbody = document.getElementById('orders-list'); 590 601 … … 593 604 const total = order.items ? order.items.reduce((sum, item) => 594 605 sum + (item.price * item.quantity), 0) : 0; 606 595 607 return ` 596 <tr>597 <td>${order.order_num}</td>598 <td>${order.first_name} ${order.last_name}</td>599 <td>${new Date(order.order_date).toLocaleDateString()}</td>600 <td><span class="status-badge status-${order.status}">${order.status}</span></td>601 <td>$${total.toFixed(2)}</td>602 <td>603 <button class="btn-small" onclick="viewOrder('${order.order_num}')">View</button>604 </td>605 </tr>606 `;608 <tr> 609 <td>${order.order_num}</td> 610 <td>${order.first_name} ${order.last_name}</td> 611 <td>${new Date(order.order_date).toLocaleDateString()}</td> 612 <td><span class="status-badge status-${order.status}">${order.status}</span></td> 613 <td>$${total.toFixed(2)}</td> 614 <td> 615 <button class="btn-small" onclick="viewOrder('${order.order_num}')">View</button> 616 </td> 617 </tr> 618 `; 607 619 }).join(''); 608 620 } else { … … 619 631 const response = await fetch(`/api/store-employees?storeId=${storeId}`); 620 632 const data = await response.json(); 633 621 634 const tbody = document.getElementById('employees-list'); 622 635 623 636 if (data.success && data.employees.length > 0) { 624 637 tbody.innerHTML = data.employees.map(emp => ` 625 <tr>626 <td>${emp.id}</td>627 <td>${emp.first_name} ${emp.last_name}</td>628 <td>${emp.email}</td>629 <td>${emp.date_of_hire || 'N/A'}</td>630 <td><span class="status-badge">${emp.permission_type || 'EMPLOYEE'}</span></td>631 <td>632 <button class="btn-small" onclick="editEmployee('${emp.id}')">Edit</button>633 <button class="btn-small" style="background: var(--danger);" onclick="deleteEmployee('${emp.id}', '${storeId}')">Delete</button>634 </td>635 </tr>636 `).join('');638 <tr> 639 <td>${emp.id}</td> 640 <td>${emp.first_name} ${emp.last_name}</td> 641 <td>${emp.email}</td> 642 <td>${emp.date_of_hire || 'N/A'}</td> 643 <td><span class="status-badge">${emp.permission_type || 'EMPLOYEE'}</span></td> 644 <td> 645 <button class="btn-small" onclick="editEmployee('${emp.id}')">Edit</button> 646 <button class="btn-small" style="background: var(--danger);" onclick="deleteEmployee('${emp.id}', '${storeId}')">Delete</button> 647 </td> 648 </tr> 649 `).join(''); 637 650 } else { 638 651 tbody.innerHTML = '<tr><td colspan="6">No employees found</td></tr>'; … … 661 674 `<option value="${cat.category_id}">${cat.name}</option>` 662 675 ).join(''); 676 663 677 document.getElementById('category-parent').innerHTML = '<option value="">None (Top Level Category)</option>' + parentOptions; 664 678 } … … 787 801 document.getElementById('add-product-form').reset(); 788 802 loadProducts(storeId); 803 789 804 // Switch to products tab 790 805 document.querySelector('[data-tab="products"]').click(); … … 839 854 document.getElementById('add-employee-form').reset(); 840 855 loadEmployees(storeId); 856 841 857 // Switch to employees tab 842 858 document.querySelector('[data-tab="employees"]').click(); … … 1061 1077 1062 1078 document.getElementById('report-results').innerHTML = ` 1063 <div class="dashboard-section">1064 <h4>Generating Report...</h4>1065 <div class="loading">Please wait</div>1066 </div>1067 `;1079 <div class="dashboard-section"> 1080 <h4>Generating Report...</h4> 1081 <div class="loading">Please wait</div> 1082 </div> 1083 `; 1068 1084 1069 1085 try { … … 1084 1100 if (data.success) { 1085 1101 document.getElementById('report-results').innerHTML = ` 1086 <div class="dashboard-section">1087 <h4>Report Generated Successfully</h4>1088 <p><strong>Report ID:</strong> ${data.reportId}</p>1089 <p><strong>Period:</strong> ${data.report.period}</p>1090 <p><strong>Date Range:</strong> ${data.report.startDate} to ${data.report.endDate}</p>1091 <p><strong>Type:</strong> ${data.report.type}</p>1092 <p><strong>Generated:</strong> ${new Date(data.report.generatedAt).toLocaleString()}</p>1093 <button class="btn-small" onclick="downloadReport('${data.reportId}')">Download Report</button>1094 </div>1095 `;1102 <div class="dashboard-section"> 1103 <h4>Report Generated Successfully</h4> 1104 <p><strong>Report ID:</strong> ${data.reportId}</p> 1105 <p><strong>Period:</strong> ${data.report.period}</p> 1106 <p><strong>Date Range:</strong> ${data.report.startDate} to ${data.report.endDate}</p> 1107 <p><strong>Type:</strong> ${data.report.type}</p> 1108 <p><strong>Generated:</strong> ${new Date(data.report.generatedAt).toLocaleString()}</p> 1109 <button class="btn-small" onclick="downloadReport('${data.reportId}')">Download Report</button> 1110 </div> 1111 `; 1096 1112 } else { 1097 1113 document.getElementById('report-results').innerHTML = ` 1098 <div class="dashboard-section">1099 <p class="error">Failed to generate report: ${data.message}</p>1100 </div>1101 `;1114 <div class="dashboard-section"> 1115 <p class="error">Failed to generate report: ${data.message}</p> 1116 </div> 1117 `; 1102 1118 } 1103 1119 } catch (error) { 1104 1120 console.error('Error generating report:', error); 1105 1121 document.getElementById('report-results').innerHTML = ` 1106 <div class="dashboard-section">1107 <p class="error">An error occurred while generating the report</p>1108 </div>1109 `;1122 <div class="dashboard-section"> 1123 <p class="error">An error occurred while generating the report</p> 1124 </div> 1125 `; 1110 1126 } 1111 1127 }
Note:
See TracChangeset
for help on using the changeset viewer.
