<?php

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");

require "../config/database.php";
require "../helpers/response.php";

$totalSPPG =
$conn->query("SELECT COUNT(*) as total FROM sppg")
->fetch_assoc()['total'];

$totalSekolah =
$conn->query("SELECT COUNT(*) as total FROM sekolah")
->fetch_assoc()['total'];

$totalPenerima =
$conn->query("SELECT SUM(jumlah_penerima) as total FROM sppg")
->fetch_assoc()['total'];

response(true, "Dashboard berhasil diambil", [
    "total_sppg" => $totalSPPG,
    "total_sekolah" => $totalSekolah,
    "total_penerima" => $totalPenerima
]);
?>