<?php
// File: API_KONEKSI/admin/paket/list_paket.php
header('Content-Type: application/json');
include '../../config/koneksi.php';

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // Ambil semua paket yang belum dihapus (deleted_st = 0)
    $query = "SELECT * FROM mst_paket WHERE deleted_st = 0 ORDER BY paket_id DESC";
    $result = $conn->query($query);
    $data = [];

    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }

    if (count($data) > 0) {
        echo json_encode(["status" => "sukses", "pesan" => "Data ditemukan", "data" => $data]);
    } else {
        echo json_encode(["status" => "kosong", "pesan" => "Belum ada paket", "data" => []]);
    }
}
$conn->close();
?>