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

$response = array("status" => "gagal", "pesan" => "Terjadi kesalahan sistem", "data" => array());

try {
    // SELECT dengan kategori_tx
    $query = "SELECT paket_id, paket_nm, kategori_tx, deskripsi_tx, fasilitas_tx, durasi_menit, normal_harga, thumbnail_foto 
              FROM mst_paket 
              WHERE active_st = 1 AND deleted_st = 0 
              ORDER BY paket_nm ASC";
              
    $stmt = $conn->prepare($query);
    $stmt->execute();
    $result = $stmt->get_result();

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

    if (count($data) > 0) {
        $response["status"] = "sukses";
        $response["pesan"] = "Data paket berhasil diambil";
        $response["data"] = $data;
    } else {
        $response["status"] = "sukses";
        $response["pesan"] = "Belum ada paket yang tersedia saat ini";
        $response["data"] = array();
    }

    $stmt->close();
} catch (Exception $e) {
    $response["pesan"] = "Error: " . $e->getMessage();
}

echo json_encode($response);
$conn->close();
?>