<?php
include 'conexion.php';
include 'validar.php';
$consulta = $conectado->prepare("SELECT * FROM usuario");
$consulta->execute();
$todo = $consulta->get_result();

if (isset($_GET["id"])) {

    $id_obtenido = $_GET["id"];
    $query2 = "DELETE FROM usuario WHERE id=$id_obtenido";
    $eliminar = $conectado->prepare($query2);
    $eliminar->execute();
    header("location: usuarios.php");
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <meta charset="UTF-8">
    <title>Mi Página Web</title>
    <link rel="stylesheet" type="text/css" href="Estilos/index.css">
    <script src="https://unpkg.com/feather-icons"></script>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" 
    integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anony">
    <title></title>
    <style>

.chat-icon {
    position: fixed;
    bottom: 20px; /* Distancia desde la parte inferior */
    right: 20px; /* Distancia desde el lado derecho */
    background-color: #3056C4;
    color: #ffffff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chat-icon:hover {
    transform: scale(1.1); /* Efecto de escala al pasar el mouse */
}
table {
        margin-top:200px;
        margin-left:270px;
        width: 60%;
        border-collapse: collapse;
        margin-bottom: 120px;
        background-color: #fff;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    .baja{
        margin-top:200px;
    }
    th, td {
        padding: 12px;
        text-align: left;
        border-bottom: 1px solid #ddd;
    }
    th {
        background-color: #4CAF50;
        color: white;
    }
    tr:nth-child(even) {
        background-color: #f2f2f2;
    }
    tr:hover {
        background-color: #ddd;
    }
    table a {
        border: 1px solid;
        border-radius : 10px;
        padding: 9px;
        text-decoration: none;
        color: #4CAF50;
    }
    </style>
</head>
<body>
<?php  include 'menu2.php'; ?>

<table>
    <thead>
        <tr>
            <td><a href="agregar_usuario.php" class="baja">AGREGAR</a></td>
        </tr>
        <tr>
        
            <th>Nombre</th>
            <th>gmail</th>
            <th>Contraseña</th>
            <th>Tipo usario</th>
            <th>Boton de acciones</th>
        </tr>
    </thead>
    <tbody>
        
        <?php foreach ($todo as $valores) {?>
            
            <tr>
                <td><?php echo $valores["Nombre"]; ?></td>
                <td><?php echo $valores["gmail"]; ?></td>
                <td><?php echo $valores["contrasena"]; ?></td>
                <td><?php echo $valores["tipousuario"]; ?></td>
                <td><a href="editar_usuario.php?id=<?php echo $valores["id"]; ?>">editar</a><a href="usuarios.php?id=<?php echo $valores["id"]; ?>">eliminar</a></td>
                
            </tr>
         
        <?php } ?>

    </tbody>
</table> 
<div class="chat-icon">
    <?php include("boticon.php") ?>
    </div>
    
</body>
</html>