<?php

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

require '../../modelo/proveedor.php';

$response = array();

if (!isset($_POST['id_proveedor'])) {
    $response['response'] = 'error';
    $response['data'] = 'Datos incompletos';
    echo json_encode($response);
    return;
}

$id_proveedor = $_POST['id_proveedor'];

$proveedor = Proveedor::mdlGetProveedorById($id_proveedor);

if (!$proveedor) {
    $response['response'] = 'error';
    $response['data'] = 'No se encontró el proveedor.';
    echo json_encode($response);
    return;
}

$response['response'] = 'success';
$response['data'] = $proveedor;

echo json_encode($response);