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


$id_usuario= $_POST['id_usuario'];
$query=query("SELECT A.id 'ID', A.uss_nombre 'USS_NOMBRE', A.uss_apellidos 'USS_APELLIDOS', 
A.uss_direccion 'USS_DIRECCION', A.uss_ciudad 'CIUDAD', A.uss_estado 'ESTADO', A.uss_tel_1 'CEL', 
A.uss_tel_2 'TELEFONO', A.uss_rfc 'RFC', A.uss_edad 'EDAD', A.uss_fecha_ingreso 'FECHA_ING', 
case when (A.uss_roll='MESERO' or A.uss_roll='MESERA') then 'MESERO' ELSE A.uss_roll END 'USS_ROL', 
A.uss_estatus 'USS_ESTATUS', A.uss_usuario 'USUARIO', A.uss_pass 'PASSWORD', A.uss_activo_fin 'ACT_FIN' 
FROM usuarios A WHERE A.id = '$id_usuario'");
$i=0;
while($row = mysqli_fetch_assoc($query)){
    $rowdata[$i] = $row;
    $i++;
}

if ($i>0){
    $res =  json_encode($rowdata,JSON_UNESCAPED_UNICODE);
} else {
    $res =  '[{"ID":"0"}]';	
}
echo $res;
?>


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

if(isset($_POST['id_usuario'])){
    $id_usuario= $_POST['id_usuario'];
    $query=query("SELECT A.id 'ID', A.uss_nombre 'USS_NOMBRE', A.uss_apellidos 'USS_APELLIDOS', 
    A.uss_direccion 'USS_DIRECCION', A.uss_ciudad 'CIUDAD', A.uss_estado 'ESTADO', 
    A.uss_tel_1 'CEL', A.uss_tel_2 'TELEFONO', A.uss_rfc 'RFC', A.uss_edad 'EDAD', 
    A.uss_fecha_ingreso 'FECHA_ING', A.uss_roll 'USS_ROL', A.uss_estatus 'USS_ESTATUS', 
    A.uss_usuario 'USUARIO', A.uss_pass 'PASSWORD', A.uss_activo_fin 'ACT_FIN' FROM usuarios A WHERE A.id = '$id_usuario'");
    $datos=mysqli_fetch_assoc($query);
}else{
    $datos="";
}

$salida = "";
$is_checked = '';
if($datos != ""){
    if($query->num_rows > 0){
        $salida.="
    <div class='row'>
        <div class='col-md-4'>
            <label class='form-label'>Nombre </label>
            <div class='input-group input-group-outline mb-2'>
                <input type='hidden' class='form-control' name='id_usu' id='id_usu' value='".$datos['ID']."'>
                <input type='text' class='form-control' name='nombre_usu' id='nombre_usu' value='".$datos['USS_NOMBRE']."' required>
            </div>
        </div>
        <div class='col-md-8'>
            <label class='form-label'>Apellido(s)</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='apellido_usu' id='apellido_usu' value='".$datos['USS_APELLIDOS']."' >
            </div>
        </div>
        <div class='col-md-8'>
            <label class='form-label'>Dirección</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='direccion_usu' id='usu_direccion_usu' value='".$datos['USS_DIRECCION']."'>
            </div>
        </div>
        <div class='col-md-4'>
            <label class='form-label'>Ciudad</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='ciudad_usu' id='ciudad_usu' value='".$datos['CIUDAD']."'>
            </div>
        </div>
    </div>
    <div class='row'>
        <div class='col-md-4'>
            <label class='form-label'>Estado</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='estado_usu' id='estado_usu' value='".$datos['ESTADO']."'>
            </div>
        </div>
        <div class='col-md-4'>
            <label class='form-label'>Celular</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='celular_usu' id='celular_usu' value='".$datos['CEL']."' >
            </div>
        </div>
    
        <div class='col-md-4'>
            <label class='form-label'> Otro teléfono </label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='telefono_usu' id='telefono_usu' value='".$datos['TELEFONO']."' >
            </div>
        </div>
        <div class='col-md-4'>
            <label class='form-label'> RFC </label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='rfc_usu' id='rfc_usu' value='".$datos['RFC']."'>
            </div>
        </div>
    
        <div class='col-md-4'>
            <label class='form-label'> Edad</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='number' class='form-control' name='edad_usu' id='edad_usu' value='".$datos['EDAD']."'>
            </div>
        </div>
        <div class='col-md-4'>
            <label class='form-label'>Fecha de ingreso</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='fecha_ingreso_usu' id='fecha_ingreso_usu' value='".$datos['FECHA_ING']."' disabled>
            </div>
        </div>
    </div>
    <div class='row'>
        <div class='col-md-4'>
        
            <label class='form-label'>Rol</label>
            <div class='input-group input-group-outline mb-2'>
                <select class='form-control' name='rol_usu' id='rol_usu' required>
                    <option value='".$datos['USS_ROL']."' selected> ".$datos['USS_ROL']." </option>
                    <option value='MESERO'>Mesero</option>
                    <option value='ADMINISTRADOR'>Administrador</option>
                    <option value='GERENTE'>Gerente</option>
                    <option value='COCINA'>Cocinero</option>
                </select>
            </div>
        </div>
        
        <div class='col-md-4'>
            <label class='form-label'>Nick</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' name='nick_usu' id='nick_usu' value='".$datos['USUARIO']."' required>
            </div>
        </div>
        <div class='col-md-4'>
            <label class='form-label'>Clave númerica de acceso</label>
            <div class='input-group input-group-outline mb-2'>
                <input type='text' class='form-control' maxlength='4' name='clave_numerica_usu' id='clave_numerica_usu' value='".$datos['PASSWORD']."' required>
            </div>
        </div>
        
        <div class='col-md-4'>
            <label class='form-label'>Estatus</label>
            <div class='input-group input-group-outline mb-2'>
                <select class='form-control' name='estatus_usu' id='estatus_usu' >
                    <option value='".$datos['USS_ESTATUS']."' selected> ".$datos['USS_ESTATUS']." </option>
                    <option value='Alta'>Alta</option>
                    <option value='Baja'>Baja</option>
                    <option value='Caducado'>Caducado</option>
                </select>
            </div>
        </div>
        <div class='col-sm-5'>
            <div class='input-group input-group-outline' id='active_weekend' >
                <h6 for=''>¿Activo unicamente para fin de semana?</h6>
                <div class='form-check form-check-inline'>";
                if ($datos['ACT_FIN'] == 0) {
                    $is_checked = 'checked';
                }else{
                    $is_checked = '';
                }
                $salida.= "
                    <input class='form-check-input' type='radio' name='inlineRadioOptions' id='inlineRadio1' value='0' ".$is_checked." >";
                    $salida.= "
                    <label class='form-check-label'  for='inlineRadio1'>NO</label>
                </div>";
                if ($datos['ACT_FIN'] == 1) {
                    $is_checked = 'checked';
                }else{
                    $is_checked = '';
                }
                $salida.= "
                <div class='form-check form-check-inline'>
                    <input class='form-check-input' type='radio' name='inlineRadioOptions' id='inlineRadio2' value='1' ".$is_checked." >";
                    $salida.= "
                    <label class='form-check-label'  for='inlineRadio1'>SI</label>
                </div>
            </div>
        </div>
    </div>
    <div class='row'>
        <div class='col-md-4'>
            <div class='text-center'>
                <button type='submit' class='btn btn-lg bg-gradient-primary btn-lg w-100 mt-4 mb-0'>Editar</button>
            </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'>Nombre</label>
            <input type='text' class='form-control' name='nombre_usu' id='nombre_usu' value=''>
        </div>
    </div>
    <div class='col-md-8'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Apellidos</label>
            <input type='text' class='form-control' name='apellido_usu' id='apellido_usu' value=''>
        </div>
    </div>
</div>
<div class='row'>
    <div class='col-md-8'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Dirección</label>
            <input type='text' class='form-control' name='direccion_usu' id='direccion_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Ciudad</label>
            <input type='text' class='form-control' name='ciudad_usu' id='ciudad_usu' value=''>
        </div>
    </div>
    
    
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Estado</label>
            <input type='text' class='form-control' name='estado_usu' id='estado_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Celular</label>
            <input type='text' class='form-control' name='celular_usu' id='celular_usu' value=''>
        </div>
    </div>

    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Otro teléfono</label>
            <input type='text' class='form-control' name='telefono_usu' id='telefono_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>RFC</label>
            <input type='text' class='form-control' name='rfc_usu' id='rfc_usu' value=''>
        </div>
    </div>

    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Edad</label>
            <input type='text' class='form-control' name='edad_usu' id='edad_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Fecha de ingreso</label>
            <input type='text' class='form-control' name='fecha_ingreso_usu' id='fecha_ingreso_usu' value='' disabled>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <select class='form-control' name='rol_usu' id='rol_usu' value=''>
                <option selected> Roll </option>
                <option value='MESERO'>Mesero</option>
                <option value='ADMINISTRADOR'>Administrador</option>
                <option value='GERENTE'>Gerente</option>
                <option value='COCINA'>Cocinero</option>
            </select>
        </div>
    </div>
    
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Nick</label>
            <input type='text' class='form-control' name='nick_usu' id='nick_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <label class='form-label'>Clave númerica de acceso</label>
            <input type='text' class='form-control' maxlength='4' name='clave_numerica_usu' id='clave_numerica_usu' value=''>
        </div>
    </div>
    <div class='col-md-4'>
        <div class='input-group input-group-outline mb-3'>
            <select class='form-control' name='estatus_usu' id='estatus_usu' value=''>
                <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-sm-5 mx-3'>
            <div class='input-group input-group-outline' id='active_weekend' >
                <h6 for=''>¿Activo unicamente para fin de semana?</h6>
                <div class='form-check form-check-inline'>
                    <input class='form-check-input' type='radio' name='inlineRadioOptions' id='inlineRadio1' value='0' checked>
                    <label class='form-check-label'  for='inlineRadio1'>NO</label>
                </div>
                <div class='form-check form-check-inline'>
                    <input class='form-check-input' type='radio' name='inlineRadioOptions' id='inlineRadio2' value='1' >
                    <label class='form-check-label'  for='inlineRadio1'>SI</label>
                </div>
            </div>
        </div>
    
</div>";
} 
echo $salida; */
?>