<?php
require_once 'includes/auth.php';
exigir_rol('propietario', 'admin', 'conserje');
require_once 'conexion.php';
header('Content-Type: application/json; charset=UTF-8');

$id = (int)($_GET['id_arrendatario'] ?? 0);

$stmt = $conn->prepare("SELECT nombre, rut FROM acompanantes WHERE id_arrendatario = ?");
$stmt->bind_param('i', $id);
$stmt->execute();
$res = $stmt->get_result();

$data = [];
while ($row = $res->fetch_assoc()) {
    $data[] = $row;
}
echo json_encode($data);
