0.4, // Lower stock is more urgent (40% importance) 'price_value' => 0.3, // Higher price might indicate higher priority (30% importance) 'turnover_rate' => 0.3 // Higher turnover rate means faster selling (30% importance) ]; // Check if form was submitted with custom weights $weights = $default_weights; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_weights'])) { $weights = [ 'stock_level' => floatval($_POST['weight_stock']), 'price_value' => floatval($_POST['weight_price']), 'turnover_rate' => floatval($_POST['weight_turnover']) ]; // Normalize weights to ensure they sum to 1 $total = array_sum($weights); if ($total > 0) { foreach ($weights as $key => $value) { $weights[$key] = $value / $total; } } else { $weights = $default_weights; } } // Get restocking priorities using TOPSIS $restock_priorities = restockWithTOPSIS($conn, $weights); // Check if any error occurred $error_message = ""; if (isset($restock_priorities['error'])) { $error_message = $restock_priorities['error']; $restock_priorities = []; } // Calculate total products and those needing restocking (stock < 10) $total_products = count($restock_priorities); $low_stock_count = 0; foreach ($restock_priorities as $product) { if ($product['stok'] < 10) { $low_stock_count++; } } // Get current date and time $current_date = date('Y-m-d H:i:s'); // Page title $page_title = "Analisis Restok dengan Metode TOPSIS"; ?>
Prioritas | ID Barang | Nama Barang | Stok Saat Ini | Harga | Skor TOPSIS | Aksi |
---|---|---|---|---|---|---|
Rp |