<?php
header('Content-Type: application/json; charset=utf-8');

include '../connection.php';

$sql = "SELECT id, name, charge, description, duration FROM tbl_delivery_mode WHERE is_active = 1 ORDER BY id ASC";
$res = $conn->query($sql);

$modes = [];
if ($res && $res->num_rows > 0) {
    while ($row = $res->fetch_assoc()) {
        $modes[] = [
            'id' => (int)$row['id'],
            'name' => $row['name'],
            'charge' => (float)$row['charge'],
            'description' => $row['description'],
            'duration' => $row['duration'],
        ];
    }
}

echo json_encode(['success' => true, 'data' => $modes]);
$conn->close();
