<?php
// backend/aspirantes/get_comentario_alta.php
require_once __DIR__ . '/../db/conexion.php';
header('Content-Type: application/json');

$aspirante_id = isset($_GET['aspirante_id']) ? intval($_GET['aspirante_id']) : 0;
if ($aspirante_id <= 0) {
    echo json_encode(['success' => false, 'comentario' => '', 'message' => 'ID inválido']);
    exit;
}

// Usar $conn global definido en conexion.php
if (!isset($conn) || !$conn) {
    echo json_encode(['success' => false, 'comentario' => '', 'message' => 'Error de conexión']);
    exit;
}

$stmt = $conn->prepare('SELECT Comentarios_altas FROM aspirantes WHERE id = ?');
$stmt->bind_param('i', $aspirante_id);
$stmt->execute();
$stmt->bind_result($comentario);
if ($stmt->fetch()) {
    echo json_encode(['success' => true, 'comentario' => $comentario]);
} else {
    echo json_encode(['success' => false, 'comentario' => '', 'message' => 'No encontrado']);
}
$stmt->close();
$conn->close();
