Changed around line 1
+ // Sample data (to be replaced with actual API calls)
+ const inventoryData = [
+ { product: 'Green Tea', quantity: 120, expiry: '2023-12-01', status: 'Good' },
+ { product: 'Black Tea', quantity: 80, expiry: '2023-11-15', status: 'Warning' },
+ { product: 'Herbal Tea', quantity: 50, expiry: '2023-10-30', status: 'Critical' }
+ ];
+
+ // Update dashboard values
+ document.getElementById('total-stock').textContent = inventoryData.reduce((sum, item) => sum + item.quantity, 0);
+ document.getElementById('expiring-soon').textContent = inventoryData.filter(item => item.status !== 'Good').length;
+ document.getElementById('usage-forecast').textContent = '1200 units/month';
+
+ // Populate inventory table
+ const tableBody = document.getElementById('inventory-table');
+ inventoryData.forEach(item => {
+ const row = document.createElement('tr');
+ row.innerHTML = `
+
${item.product} | +
${item.quantity} | +
${item.expiry} | +
${item.status} | + `;
+ tableBody.appendChild(row);
+ });
+
+ // Chart.js implementation for expiry forecast
+ const ctx = document.getElementById('expiry-chart').getContext('2d');
+ new Chart(ctx, {
+ type: 'line',
+ data: {
+ labels: ['Oct', 'Nov', 'Dec', 'Jan'],
+ datasets: [{
+ label: 'Expiring Products',
+ data: [15, 10, 25, 30],
+ borderColor: '#4CAF50',
+ tension: 0.1
+ }]
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ scales: {
+ y: {
+ beginAtZero: true
+ }
+ }
+ }
+ });