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

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // Ambil data promo yang belum di-soft delete
    $query = "SELECT * FROM mst_promo WHERE deleted_st = 0 ORDER BY promo_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 promo", "data" => []]);
    }
}
$conn->close();
?>