prepare($sql); if (!empty($params)) { $stmt->bind_param($types, ...$params); } $stmt->execute(); $result = $stmt->get_result(); $reports = []; while ($row = $result->fetch_assoc()) { $reports[] = $row; } $stmt->close(); return $reports; } // Function to get all products for filter dropdown function getAllProducts($conn) { $sql = "SELECT id_barang, nama_barang FROM barang ORDER BY nama_barang"; $result = $conn->query($sql); $products = []; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $products[] = $row; } } return $products; } // Function to get all categories for filter dropdown function getAllCategories($conn) { $sql = "SELECT id_jenis, nama_jenis FROM jenis_barang ORDER BY nama_jenis"; $result = $conn->query($sql); $categories = []; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $categories[] = $row; } } return $categories; } // Function to calculate summary statistics function calculateSummary($reports) { $summary = [ 'total_items' => 0, 'total_amount' => 0, 'total_reports' => count($reports), 'categories' => [] ]; $category_totals = []; foreach ($reports as $report) { $summary['total_items'] += $report['jumlah']; $total_value = $report['jumlah'] * $report['harga']; $summary['total_amount'] += $total_value; // Track by category $category = $report['nama_jenis']; if (!isset($category_totals[$category])) { $category_totals[$category] = [ 'count' => 0, 'amount' => 0 ]; } $category_totals[$category]['count'] += $report['jumlah']; $category_totals[$category]['amount'] += $total_value; } // Format category data for charts foreach ($category_totals as $category => $data) { $summary['categories'][] = [ 'name' => $category, 'count' => $data['count'], 'amount' => $data['amount'] ]; } return $summary; } // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Get data based on filters $reports = getReportData($conn, $start_date, $end_date, $filter_type, $filter_month, $filter_year, $product_id, $category_id); $products = getAllProducts($conn); $categories = getAllCategories($conn); $summary = calculateSummary($reports); // Close the database connection $conn->close(); // Format numbers for display function formatCurrency($number) { return 'Rp ' . number_format($number, 0, ',', '.'); } ?>
Total Laporan
Total Items
Total Nilai
Kategori
Filter Laporan
>
>
>
Distribusi Kategori
Nilai Per Kategori

Data Laporan

ID Tanggal Produk Kategori Jumlah Harga Satuan Total Nota
Tidak ada data laporan untuk periode ini.