<?php
require_once 'conn.php';
checkLogin();

header('Content-Type: application/json');
$customer_id = isset($_GET['customer_id']) ? (int)$_GET['customer_id'] : 0;

$sql = "SELECT id, contact_name FROM customer_contact WHERE customer_id = $customer_id";

$result = mysqli_query($conn, $sql);

$contacts = [];
while ($row = mysqli_fetch_assoc($result)) {
    $contacts[] = [
        'id' => $row['id'],
        'contact_name' => textUncode($row['contact_name'])
    ];
}

echo json_encode($contacts);
?>