@extends('layouts.dashboard')

@section('content')
    <section class="container all-container">
        <div class="header-titulo">
            Modulos
        </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('agregarModulos') }}" class="btn btn-secondary btn-agregar"  data-toggle="tooltip" data-placement="bottom" title="Crear Modulo">
                            <i class="fas fa-plus"></i>
                        </a>
                        <input type="text" id="myInput" class="form-control" placeholder="Buscar">
                        <select class="form-control pagination-option" url="{{ route('modulos')}}" url2="{{ route('modulo') }}" id="appSelect" onchange="filtrarModulosServidor(this.value)">
                                <option value="">-Filtrar por app</option>
                                <option value="Todos">Todos</option>
                            @foreach($aplicaciones as $aplicacion)
                                <option value="{{$aplicacion->id}}">{{$aplicacion->nombre}}</option>
                            @endforeach 
                        </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>Descripcion</th>
                            <th>Aplicacion</th>
                            <th>Fecha</th>
                            <th><i class="fab fa-wpforms"></i></th>
                        </tr>
                        </thead>
                        <tbody id="myTable">
                            @if($Allmodulos == '[]')
                                <tr>
                                    <td colspan="5"><span class="text-muted">No hay Modulos</span></td>
                                </tr>
                            @endif
                            @foreach($modulos as $modulo) 
                                <tr style="cursor:pointer;z-index:-99" onclick="window.location='{{ route("modulo",[$modulo->id]) }}'">
                                    <td>{{ucfirst($modulo->nombre)}}</td>
                                    <td>{{$modulo->Descripcion}}</td>
                                    <td>{{$modulo->app_name}}</td>
                                    <td>{{$modulo->updated_at}}</td>
                                    <td>{{$modulo->formC}}</td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="card-footer small text-muted" id="paginador">
                {{$modulos->links()}}                    
            </div>
        </div>
    </section>
    <style>        
        #mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.modulosLink {color:#1cff2f;}
    </style>
	<script src="{{ asset('js/modulo.js') }}"></script>
	<script src="{{ asset('js/user.js') }}"></script>
	<link  media="all" rel="stylesheet" type="text/css" href="{{ asset('css/general.css') }}">

@endsection