@extends('layouts.dashboard')

@section('content')
    <section class="container all-container">
        <div class="header-titulo">
            Usuarios
        </div>
        <div class="card mb-3">
            <div class="card-header title-buscador-container">
                <div class="title">
                    <div class="icon-titulo">
                    </div>
                </div>
                <div class="tabla-buscador">
                    <div class="barra-container">
                        <a role="button" href="{{ route('register') }}" class="btn btn-secondary btn-agregar"  data-toggle="tooltip" data-placement="bottom" title="Crear usuario">
                            <i class="fas fa-user-plus"></i>
                        </a>
                        <input type="text" id="myInput" class="form-control" placeholder="Buscar">
                        <select class="form-control pagination-option" url2="{{ route('user')}}" url="{{ route('users')}}" id="filtroUsuarios" onchange="filtrarUsuariosServidor(this.value)">
                            <option value="" class="text-muted">Buscar por rol..</option>
                            <option value="todos">Todos</option>
                            <option value="cliente">Clientes</option>
                            <option value="admin">Administradores</option>
                            <option value="desarrollador">Desarrolladores</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <div class="table-container">
                    <table class="table table-hover table-bordered text-center">
                        <thead>
                        <tr class="table-active">
                            <th>Nombre</th>
                            <th>Apellido</th>
                            <th>Correo</th>
                            <th>Rol</th>
                            <th>Estado</th>
                            <th class="w15"><i class="fas fa-ruler"></i></th>
                        </tr>
                        </thead>
                        <tbody id="myTable">
                            @foreach($users as $user)
                                <tr style="cursor:pointer;z-index:-99" onclick="window.location='{{ route("user",[$user->id]) }}'">
                                    <td>{{ucfirst($user->name)}}</td>
                                    <td>{{ucfirst($user->surname)}}</td>
                                    <td>{{$user->email}}</td>
                                    <td>{{ucfirst($user->role)}}</td>
                                    <td>{{$user->estado}}</td>
                                    <td>{{App\aplicacion::countApp($user->id)}}</td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="card-footer small text-muted" id="paginador">
                {{$users->links()}}
            </div>
        </div>
    </section>
    <style>        
        #mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.userLink {color:#1c8dff;}
    </style>
	<script  src="{{ asset('js/admin.js') }}"> </script>  
	<script src="{{ asset('js/sweetalert.min.js') }}"></script>
	<script src="{{ asset('js/user.js') }}"></script>
	<link  media="all" rel="stylesheet" type="text/css" href="{{ asset('css/general.css') }}">

@endsection