Spaces:
Running
Running
Update ui.js
Browse files
ui.js
CHANGED
|
@@ -4,6 +4,8 @@ import { appState } from './state.js';
|
|
| 4 |
import { attachAllListeners } from './events.js';
|
| 5 |
import { getMonthlyProductionSummary, getMonthlyMaterialUsage } from './reportService.js';
|
| 6 |
|
|
|
|
|
|
|
| 7 |
let productionChart = null;
|
| 8 |
let inventoryChart = null;
|
| 9 |
|
|
@@ -146,7 +148,7 @@ function renderInventoryStatusChart() {
|
|
| 146 |
let okCount = 0, warningCount = 0, criticalCount = 0;
|
| 147 |
appState.materials.forEach(m => {
|
| 148 |
if (m.currentStock <= m.reorderPoint) criticalCount++;
|
| 149 |
-
else if (
|
| 150 |
else okCount++;
|
| 151 |
});
|
| 152 |
|
|
@@ -226,11 +228,16 @@ function renderInventory() {
|
|
| 226 |
if (!container) return;
|
| 227 |
container.innerHTML = '';
|
| 228 |
appState.materials.forEach(material => {
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
| 230 |
let statusColor = 'var(--accent-green)';
|
| 231 |
-
if (
|
| 232 |
-
if (material.currentStock <= material.reorderPoint) statusColor = 'var(--accent-red)';
|
| 233 |
-
|
|
|
|
|
|
|
| 234 |
container.insertAdjacentHTML('beforeend', cardHTML);
|
| 235 |
});
|
| 236 |
}
|
|
@@ -268,8 +275,8 @@ function renderReorderList() {
|
|
| 268 |
header.insertAdjacentHTML('beforeend', poButton);
|
| 269 |
|
| 270 |
itemsToReorder.forEach(item => {
|
| 271 |
-
const needed = item.
|
| 272 |
-
const itemHTML = `<li class="p-3 rounded-md text-sm flex justify-between items-center" style="background-color: #f6e05e20;"><div class="flex-grow"><span class="font-semibold">${item.name}</span><span class="text-xs text-secondary block">Stock: ${item.currentStock} / ${item.reorderPoint}
|
| 273 |
list.insertAdjacentHTML('beforeend', itemHTML);
|
| 274 |
});
|
| 275 |
}
|
|
|
|
| 4 |
import { attachAllListeners } from './events.js';
|
| 5 |
import { getMonthlyProductionSummary, getMonthlyMaterialUsage } from './reportService.js';
|
| 6 |
|
| 7 |
+
// ... (keep showToast, animateValue, renderKpiCards, renderCharts, renderModals, renderReport, renderProductInputs, renderProductionLog - they are unchanged) ...
|
| 8 |
+
|
| 9 |
let productionChart = null;
|
| 10 |
let inventoryChart = null;
|
| 11 |
|
|
|
|
| 148 |
let okCount = 0, warningCount = 0, criticalCount = 0;
|
| 149 |
appState.materials.forEach(m => {
|
| 150 |
if (m.currentStock <= m.reorderPoint) criticalCount++;
|
| 151 |
+
else if (m.currentStock <= m.reorderPoint * 1.5) warningCount++; // Warning if stock is < 150% of reorder point
|
| 152 |
else okCount++;
|
| 153 |
});
|
| 154 |
|
|
|
|
| 228 |
if (!container) return;
|
| 229 |
container.innerHTML = '';
|
| 230 |
appState.materials.forEach(material => {
|
| 231 |
+
// New progress bar logic: "Healthy" is 2x the reorder point.
|
| 232 |
+
const healthyStockLevel = material.reorderPoint * 2;
|
| 233 |
+
const stockHealth = Math.min((material.currentStock / healthyStockLevel) * 100, 100);
|
| 234 |
+
|
| 235 |
let statusColor = 'var(--accent-green)';
|
| 236 |
+
if (material.currentStock <= material.reorderPoint * 1.5) statusColor = 'var(--accent-yellow)';
|
| 237 |
+
if (material.currentStock <= material.reorderPoint) statusColor = 'var(--accent-red)';
|
| 238 |
+
|
| 239 |
+
// Removed the MAX display and the edit-max-stock icon
|
| 240 |
+
const cardHTML = `<div class="dashboard-card p-4 border-l-4" style="border-left-color: ${statusColor}" data-material-name="${material.name}"><div class="flex justify-between items-start mb-1"><h3 class="font-medium text-sm">${material.name}</h3><div class="text-xs text-secondary flex items-center gap-3"><span class="font-semibold">Reorder at: ${material.reorderPoint}</span><i class="fas fa-plus-circle icon-btn restock-icon" title="Restock"></i></div></div><div class="flex justify-between items-baseline mb-2"><div class="text-2xl font-bold">${material.currentStock}</div><span class="text-sm text-secondary">${material.unit}</span></div><div class="w-full bg-dark rounded-full h-1.5"><div class="h-1.5 rounded-full" style="width: ${stockHealth}%; background-color: ${statusColor};"></div></div><div class="restock-form mt-2 hidden"></div></div>`;
|
| 241 |
container.insertAdjacentHTML('beforeend', cardHTML);
|
| 242 |
});
|
| 243 |
}
|
|
|
|
| 275 |
header.insertAdjacentHTML('beforeend', poButton);
|
| 276 |
|
| 277 |
itemsToReorder.forEach(item => {
|
| 278 |
+
const needed = item.reorderPoint; // Suggested order qty is now the reorder point itself
|
| 279 |
+
const itemHTML = `<li class="p-3 rounded-md text-sm flex justify-between items-center" style="background-color: #f6e05e20;"><div class="flex-grow"><span class="font-semibold">${item.name}</span><span class="text-xs text-secondary block">Stock: ${item.currentStock} / Reorder: ${item.reorderPoint}</span></div><div class="text-right"><span class="font-bold">Order: ${needed}</span><span class="text-xs text-secondary ml-1">${item.unit}</span></div></li>`;
|
| 280 |
list.insertAdjacentHTML('beforeend', itemHTML);
|
| 281 |
});
|
| 282 |
}
|