<?php 
require('../conexion.php');


if(isset($_POST['clave_materia'])){
    $clave_materia_prima= $_POST['clave_materia'];
    $query=query("SELECT A.id 'MAP_ID', A.map_clave 'CLAVE', A.map_nombre 'MAP_NOMBRE', A.map_entrada 'MAP_INGRESO', A.map_clasificacion 'MAP_CLASIFICACION', A.map_unidad_medida 'MAP_UNIDAD', A.map_fecha_entrada 'MAP_ENTRADA', A.map_costo_unico 'MAP_COSTO_U', A.map_existencia 'MAP_EXISTENCIA', A.map_costo_final 'MAP_COSTO_F', A.map_stock_minimo 'MAP_STOCK_MIN', A.map_perecedero 'MAP_PRED', A.map_fecha_perecer 'MAP_FECHA_PRED', A.map_estatus 'MAP_STATUS' FROM materia_prima A WHERE A.map_clave = '$clave_materia_prima'");
    $datos=mysqli_fetch_assoc($query);
}else{
    $datos="";
}
$datos2 = [
    $datos['CLAVE'],
    $datos['MAP_NOMBRE'],
    $datos['MAP_COSTO_U'],
    $datos['MAP_UNIDAD']
];
/*
$salida = "";
if($datos != ""){ 
    if($query->num_rows > 0){
        $salida.="<table class='table'>
            <thead style='background: #052659; color:#D5D8DC;'>
                <tr>
                    <th class='align-middle text-center' scope='col'>Clave</th>
                    <th class='align-middle text-center' scope='col'>Nombre</th>
                    <th class='align-middle text-center' scope='col'>Precio U.</th>
                    <th class='align-middle text-center' scope='col'>Unidad</th>
                    <th class='align-middle text-center' scope='col'>Cantidad</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <th>
                        <div class=' input-group-outline'>
                            <label class='form-label'>Comensal</label>
                            <input type='text' class='form-control' value='".$datos['CLAVE']."'>
                        </div>
                    </th>
                    <th>
                    
                        <div class='sizet input-group-outline'>
                            <label class='form-label'>Producto</label>
                            <input type='text' class='form-control' value='".$datos['MAP_NOMBRE']."'>
                        </div>
                    </th>
                    <th>
                        <div class=' input-group-outline'>
                            <label class='form-label'>Precio</label>
                            <input type='text' class='form-control' value='".$datos['MAP_COSTO_U']."'>
                        </div>
                    </th>
                    
                    <th>
                        <div class=' input-group-outline'>
                            <label class='form-label'>Unidad</label>
                            <input type='text' class='form-control' value='".$datos['MAP_UNIDAD']."'>
                        </div>
                    </th>

                    <th>
                    <div class=' input-group-outline'>
                        <label class='form-label'>Cantidad</label>
                        <input type='text' class='form-control' >
                    </div>
                </th>
                </tr>
            </tbody>
            </table>";
    }
}
    else{
        $salida.="<table class='table'>
            <thead style='background: #052659; color:#D5D8DC;'>
                <tr>
                    <th class='align-middle text-center' scope='col'>Clave</th>
                    <th class='align-middle text-center' scope='col'>Cantidad</th>
                    <th class='align-middle text-center' scope='col'>Nombre</th>
                    <th class='align-middle text-center' scope='col'>Precio U.</th>
                    <th class='align-middle text-center' scope='col'>Unidad</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <th>
                        <div class='input-group input-group-outline'>
                            <label class='form-label'>Comensal</label>
                            <input type='text' class='form-control'>
                        </div>
                    </th>
                    <th>
                        <div class='input-group input-group-outline'>
                            <label class='form-label'>Cantidad</label>
                            <input type='text' class='form-control'>
                        </div>
                    </th>
                    <th>
                        <div class='sizet input-group input-group-outline'>
                            <label class='form-label'>Producto</label>
                            <input type='text' class='form-control' >
                        </div>
                    </th>
                    <th>
                        <div class='input-group input-group-outline'>
                            <label class='form-label'>Descuento</label>
                            <input type='text' class='form-control'>
                        </div>
                    </th>
                    <th>
                        <div class='input-group input-group-outline'>
                            <label class='form-label'>Precio</label>
                            <input type='text' class='form-control' >
                        </div>
                    </th>
                </tr>
            </tbody>
            </table>";
    }
echo $salida;*/
$result = json_encode($datos2);
echo $result;
?>