<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

require '../../modelo/catalogo.php';

$response = array();

if (
    isset($_POST['id_catalogo'])
) {

    $id_catalogo = $_POST['id_catalogo'];

    $catalogo = Catalogo::mdlGetCatalogoById($id_catalogo);

    if (!$catalogo) {
        $response['response'] = 'error';
        $response['data'] = 'No se encontró el catalogo';
    } else {
        $response['response'] = 'success';
        $response['data'] = $catalogo;
    }

    echo json_encode($response);
    return;
} else {
    $response['response'] = 'error';
    $response['data'] = 'Datos incompletos';
    echo json_encode($response);
    return;
}
