<?php

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

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

$response = array();

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

$activo = $_POST['activo'];

$proveedores = Proveedor::mdlGetProveedores($activo);

if (!$proveedores) {
    $response['response'] = 'error';
    $response['message'] = 'No se encontraron proveedores.';
    echo json_encode($response);
    return;
}

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

echo json_encode($response);