@extends('usuarios.funcionarios.master.layout2')
{{-- @extends('usuarios.funcionarios.admin.menu') --}}
{{-- @extends('usuarios.funcionarios.usuario.menu') --}}

@section('conteudo')
<script src="{{asset('js/jquery.dataTables.min.js') }}"></script>
<nav class="navbar navbar-expand-lg   navbar-dark bg-success" aria-label="Main navigation">
  <div class="container-fluid">


    <div class="navbar-collapse offcanvas-collapse" id="navbarsExampleDefault">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">


      </ul>

    </div>
  </div>
</nav>
<nav class="w-100 d-none overflow-auto">

    {{ $devicesAlloweds=\App\Models\Dispositivo::where('user_id',$id)->where('estado','permitido')->get()}}
    {{ $devicesBloqueds=\App\Models\Dispositivo::where('user_id',$id)->where('estado','barrado')->get()}}
    {{ $devicesPend=\App\Models\Dispositivo::where('user_id',$id)->where('estado','solicitado')->get()}}
     {{ $all=0 }}
    {{ $permitidos=0 }}
    {{ $barrados=0 }}
       {{ $pendentes=0 }}
    @foreach($devicesAlloweds as  $devAl)
        {{ $permitidos++ }}
    @endforeach
    {{ $all+=$permitidos }}
    @foreach($devicesBloqueds as  $devAl)
    {{ $barrados++ }}
    @endforeach
    {{ $all+=$barrados }}

</nav>
<div class="nav-scroller  bg-light shadow-sm">
  <nav class="nav nav-underline " aria-label="Secondary navigation">
    <a class="nav-link btn btn-light shadow-sm border btn-sm m-3" href="">
        Todos
        <span class="badge bg-light text-dark rounded-pill align-text-bottom">{{ $all }}</span>
    </a>
    <a class="nav-link btn btn-light shadow-sm border btn-sm m-3" href="">
    Permitidos
    <span class="badge bg-light text-dark rounded-pill align-text-bottom">{{ $permitidos }}</span>
    </a>
    <a class="nav-link btn btn-light shadow-sm border btn-sm m-3" href="">
        Pendentes
        <span class="badge bg-light text-dark rounded-pill align-text-bottom">{{ $pendentes }}</span>
    </a>

    <a class="nav-link btn btn-light shadow-sm border btn-sm m-3" href="">
      Barrados
      <span class="badge bg-light text-dark rounded-pill align-text-bottom">{{ $barrados }}</span>
    </a>
  </nav>
</div>

<main class="container p-2">
  <div class="d-flex  bg-success align-items-center p-3 my-3 rounded shadow-sm">
    {{-- <img src="{{ asset('img/logo.png') }}" class="mr-4" width="80" alt="LOGO GESTDOC"> --}}
    <div class=" text-white ">
      <h1 class="h6 mb-0 ml-3   ">LISTA DE DISPOSITIVOS </h1>

    </div>
  </div>

  <div class="my-3 p-3 bg-success rounded shadow ">
    <h6 class="border-bottom text-white pb-2 mb-0">PERMITIDOS</h6>
    <br>
    <div class="list-group">
        <nav class="col-12 table-responsive">
            <table class="table  table-striped table-hover" id="permitidos">
                <thead>

                    <tr class="danger text-white">
                        <th>Id</th>
                        <th>SO</th>
                        <th>Versão</th>
                        <th>Browser</th>
                        <th>Versão do browser</th>
                        <th>Contas abertas</th>
                        <th>Contas fechadas</th>
                        <th>Mais</th>

                    </tr>

               </thead>
               <tbody>
                {{-- {{ $devAl->id  }} --}}
                    @foreach($devicesAlloweds as  $permitidos)

                    <tr class="danger text-white">
                        <th> <i class="fa fa-laptop"></i> {{ $permitidos->id  }}</th>
                        <th>{{ $permitidos->plataform  }}</th>
                        <th>{{ $permitidos->versaoPlataform  }}</th>
                        <th>{{ $permitidos->browser  }}</th>
                        <th>{{ $permitidos->versaoBrowser  }}</th>
                        <th>
                            <i class="fa fa-lock"></i>  {{ $acessos=\App\Models\Acesso::where('dispositivo_id',$permitidos->id)->where('sessao','aberta')->count()  }}

                        </th>
                        <th>
                            <i class="fa fa-lock"></i>  {{ $acessos=\App\Models\Acesso::where('dispositivo_id',$permitidos->id)->where('sessao','fechada')->count()  }}

                        </th>
                        <th>

                            <a href="{{ route('us.admin.funcionario.devices.barrar.device',$permitidos->id ) }}" class="btn btn-sm btn-light border-danger shadow"> Barrar</a>

                            <a href="{{ route('us.admin.funcionario.ass.devices',$permitidos->id ) }}" class="btn btn-sm btn-info border-warning shadow"> Ver acessos</a>
                        </th>
                    </tr>
                    @endforeach

               </tbody>
                <tfoot></tfoot>
            </table>
        </nav>
    </div>
    <br>
    <nav aria-label="Page navigation example">
        <ul class="pagination justify-content-end">

            {{-- {{ $devicesAllowed->links() }} --}}
        </ul>
      </nav>
    <small class="d-block text-end mt-3">
        {{-- <a href=" " class="btn btn-sm btn-outline-success "><i class="fa fa-eye"></i> Ver todos</a> --}}
      </small>
  </div>
  <div class="my-3 p-3 bg-info text-white rounded shadow ">
    <h6 class="border-bottom pb-2 mb-0">PENDENTES</h6>
    <br>
    <div class="list-group">
        <nav class="col-12 table-responsive">
            <table class="table  table-striped table-hover" >
                <thead>

                    <tr class="danger text-white">
                     <th>Id</th>
                      <th>SO</th>
                      <th>Versão</th>
                      <th>Browser</th>
                      <th>Versão do browser</th>
                      <th>Mais</th>

                    </tr>

               </thead>
               <tbody>
                {{-- {{ $devAl->id  }} --}}
                    @foreach($devicesPend as  $pendentes)

                    <tr class="danger text-white">
                        <th> <i class="fa fa-laptop"></i> {{ $pendentes->id  }}</th>
                        <th>{{ $pendentes->plataform  }}</th>
                        <th>{{ $pendentes->versaoPlataform  }}</th>
                        <th>{{ $pendentes->browser  }}</th>
                        <th>{{ $pendentes->versaoBrowser  }}</th>
                        <th>
                            <a href="{{ route('us.admin.funcionario.devices.aceitar.device',$pendentes->id) }}" class="btn btn-sm btn-info border-warning shadow"> <i class="fa fa-check"></i> Aceitar</a>
                            <a href="{{ route('us.admin.funcionario.devices.barrar.device',$pendentes->id) }}" class="btn btn-sm btn-info border-danger  shadow"> <i class="fa fa-user-times"></i> Barrar</a>
                        </th>
                    </tr>
                    @endforeach

               </tbody>
               <tfoot></tfoot>
            </table>
        </nav>
    </div>
  </div>


  <div class="my-3 p-3 bg-danger text-white rounded shadow ">
    <h6 class="border-bottom pb-2 mb-0">BARRADOS</h6>
    <br>
    <div class="list-group   ">
        <nav class="col-12 table-responsive">
            <table class="table  table-striped table-hover" id="barrados">
                <thead>

                    <tr class="danger text-white">
                     <th>Id</th>
                      <th>SO</th>
                      <th>Versão</th>
                      <th>Browser</th>
                      <th>Versão do browser</th>
                      <th>Recuperação</th>

                  </tr>

               </thead>
               <tbody>
                {{-- {{ $devAl->id  }} --}}
                    @foreach($devicesBloqueds as  $barrados)

                    <tr class="danger text-white">
                        <th> <i class="fa fa-laptop"></i> {{ $barrados->id  }}</th>
                        <th>{{ $barrados->plataform  }}</th>
                        <th>{{ $barrados->versaoPlataform  }}</th>
                        <th>{{ $barrados->browser  }}</th>
                        <th>{{ $barrados->versaoBrowser  }}</th>
                        <th>
                            <a href="{{ route('us.admin.funcionario.devices.recuperar.device',$barrados->id ) }}" class="btn btn-sm btn-info border-warning shadow"> Recuperar</a>

                        </th>

                    </tr>
                    @endforeach


               </tbody>
                <tfoot></tfoot>
            </table>
        </nav>
    </div>
  </div>
</main>

<script type="text/javascript">
    $(function() {



    });
  </script>
@endsection
