<?php
    session_start();
    if (!isset($_SESSION['user_login_status']) AND $_SESSION['user_login_status'] != 1) {
        header("location: login.php");
        exit;
    }

    require_once ("config/db.php");
    require_once ("config/conexion.php");
    
    $active_registros="active"; 
    $title="Gestión de Usuarios | Niño Burger";
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <?php include("head.php");?>
    <style>
        .panel-info { border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
        .panel-heading { padding: 15px 20px !important; border-top-left-radius: 8px !important; border-top-right-radius: 8px !important; }
        .table thead th { background-color: #f8f9fa; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
        .btn-round { border-radius: 20px; padding-left: 20px; padding-right: 20px; }
        @media (max-width: 768px) { .btn-group.pull-right { float: none !important; width: 100%; margin-bottom: 15px; } .btn-block-xs { width: 100%; } }
    </style>
</head>
<body>
    <?php include("navbar.php"); ?>

    <div class="container-fluid">
        <div class="row">
            <div class="col-md-11 col-md-offset-0 center-block" style="float: none; margin: 0 auto;">
                
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <div class="btn-group pull-right">
                            <button type='button' class="btn btn-success btn-round" data-toggle="modal" data-target="#myModal">
                                <span class="glyphicon glyphicon-plus"></span> Nuevo Usuario
                            </button>
                        </div>
                        <h4><i class='glyphicon glyphicon-user'></i> Equipo de Trabajo</h4>
                    </div>

                    <div class="panel-body">
                        <?php
                            include("modal/registro_usuarios.php");
                            include("modal/editar_usuarios.php");
                            include("modal/cambiar_password.php");
                        ?>
                        
                        <div class="well" style="background: #fff; border: 1px solid #eee;">
                            <form class="form-horizontal" role="form" id="datos" method="post">
                                <div class="row">
                                    <div class="col-md-4 col-sm-6">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                            <input type="text" class="form-control" id="q" placeholder="Buscar por nombre..." onkeyup='load(1);'>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-4 col-sm-6">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
                                            <select class="form-control" id="est" onchange='load(1);'>
                                                <?php if ($_SESSION['estado'] != NULL) { 
                                                    $almacen = $_SESSION['estado'];
                                                    $sql_t = mysqli_query($con, "SELECT * FROM tiendas WHERE id_tienda='$almacen'");
                                                    while($d = mysqli_fetch_array($sql_t)) { ?>
                                                        <option value="<?php echo $d['id_tienda']; ?>"><?php echo $d['nombre']; ?></option>
                                                <?php } } else { ?>
                                                    <option value="">Todas las sedes</option>
                                                    <?php 
                                                    $sql_t = mysqli_query($con, "SELECT * FROM tiendas");
                                                    while($d = mysqli_fetch_array($sql_t)) { ?>
                                                        <option value="<?php echo $d['id_tienda']; ?>"><?php echo $d['nombre']; ?></option>
                                                <?php } } ?>
                                            </select>
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-2" id="loader_container">
                                        <div id="loader"></div>
                                    </div>
                                </div>
                            </form>
                        </div>

                        <div id="resultados"></div><div class='outer_div'></div></div>
                </div>
            </div>
        </div>
    </div>

    <?php include("footer.php"); ?>
    <script type="text/javascript" src="js/usuarios.js?v=3"></script>
</body>
</html>