<?php

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

require '../../modelo/conexion.php';
require '../../modelo/material_extra.php';
require '../usuario/decodeUsuario.php';

$response = array();

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

$id_material_extra = $_POST['id_material_extra'];

$material_extra = MaterialExtra::mdlGetMaterialExtra($id_material_extra);

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

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

echo json_encode($response);