<?php
session_start();
require_once __DIR__ . '/../../db/conexion.php';

header('Content-Type: application/json');

if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
  echo json_encode(['success' => false, 'message' => 'ID inválido']);
  exit;
}

$id = intval($_GET['id']);

$sql = "SELECT * FROM PlantillaSolicitMovim WHERE ID = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$res = $stmt->get_result();

if ($res->num_rows === 0) {
  echo json_encode(['success' => false, 'message' => 'No encontrado']);
  exit;
}

echo json_encode(['success' => true, 'data' => $res->fetch_assoc()]);
