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


// cambio en los estatus
if(isset($_POST['clave_receta'])){
    $clave_receta= $_POST['clave_receta'];
    $query=query("SELECT A.id 'ID', A.rec_nombre 'REC_NOMBRE', A.rec_clave 'REC_CLAVE', A.rec_costo 'REC_COSTO', A.rec_estatus 'REC_ESTATUS' FROM receta A WHERE id='$clave_receta'");
    $datos=mysqli_fetch_assoc($query);
}else{
    $datos="";
}

$salida = "";
if($datos != ""){ 
    if($query->num_rows > 0){
        $salida.="<div class='row'>
        <div class='col-md-4'>
            <label class='form-label'>Clave de mi Receta</label>
            <input type='hidden' class='form-control' name='id_receta' value='".$datos['ID']."'>
            <div class='input-group input-group-outline mb-3'>
                <input type='text' class='form-control' name='rec_clave' value='".$datos['REC_CLAVE']."'>
            </div>
        </div>
        <div class='col-md-8'>
            <label class='form-label'>Nombre de mi receta</label>
            <div class='input-group input-group-outline mb-3'>
                <input type='text' class='form-control' name='rec_nombre' value='".$datos['REC_NOMBRE']."' required>
            </div>
        </div>
    </div>
    <div class='row'>
        <div class='col-md-4'>
            <label class='form-label'>Estatus</label>
            <div class='input-group input-group-outline mb-3'>
                <select class='form-control' name='rec_estatus'>
                    <option value='".$datos['REC_ESTATUS']."' selected>".$datos['REC_ESTATUS']."</option>
                    <option value='Alta'>Alta</option>
                    <option value='Baja'>Baja</option>
                    <option value='Caducado'>Caducado</option>
                </select>
            </div>
        </div>
        <div class='col-md-8'>
            <label class='form-label'>Costo de la receta</label>
            <div class='input-group input-group-outline mb-3'>
                <input type='text' class='form-control' name='costo_receta' value='".$datos['REC_COSTO']."' disabled>
            </div>
        </div>
    </div>";
    }
}
    else{
        $salida.="
        <div class='row'>
        <div class='col-md-4'>
            <div class='input-group input-group-outline mb-3'>
                <label class='form-label'>Clave de mi Receta</label>
                <input type='text' class='form-control' name='rec_clave' disabled>
            </div>
        </div>
        <div class='col-md-8'>
            <div class='input-group input-group-outline mb-3'>
                <label class='form-label'>Nombre de mi receta</label>
                <input type='text' class='form-control' name='rec_nombre'>
            </div>
        </div>
    </div>
    <div class='row'>
        <div class='col-md-4'>
            <div class='input-group input-group-outline mb-3'>
                <select class='form-control' name='rec_estatus'>
                    <option selected> Estatus </option>
                    <option value='1'>Alta</option>
                    <option value='2'>Baja</option>
                    <option value='3'>Caducado</option>
                </select>
            </div>
        </div>
        <div class='col-md-8'>
            
            <div class='input-group input-group-outline mb-3'>
                <label class='form-label'>Costo de la receta</label>
                <input type='text' class='form-control' name='costo_receta' value=''>
            </div>
        </div>
    </div>";
    }
echo $salida;
?>