@extends('usuarios.clientes.master.layoutcliente')
@section('conteudo')
<script src="{{asset('js/jquery.dataTables.min.js') }}"></script>
{{-- SELECT STYLE --}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">
@php $i=1; @endphp

    <div class="container-fluid">
        <div class="page-header">
            <div class="row align-items-end">
                <div class="col-lg-8">
                    <div class="page-header-title">
                           <div class="card-body">
                            <a  href="#"><i class="ik ik-security bg-blue"></i><h4>Histórico de Acesso</h4></a>
                        </div>
                        <div class="d-inline">


                        </div>
                    </div>
                </div>
                <div class="col-lg-4">
                    <nav class="breadcrumb-container" aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="../index.html"><i class="ik ik-home"></i></a>
                            </li>
                            <li class="breadcrumb-item">
                                <a href="#">Listar</a>
                            </li>
                            <li class="breadcrumb-item active" aria-current="page">Acesso Clientes</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>


        @if(session()->has('sucessoFuncioanrio'))
        <script type="text/javascript">
                $(document).ready(function()
                    {
                    const Toast = Swal.mixin({
                                    toast: true,
                                    position: 'top-end',
                                    showConfirmButton: false,
                                    timer: 5500,
                                    timerProgressBar: false,

                                    });

                                    Toast.fire({
                                    icon: 'success',
                                    title: 'Eliminado com sucesso',
                                        });
                    });
        </script>
        @endif

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <div class="table-responsive">
                                    <table id="example1" class="table container  table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Nome</th>
                                                <th>Função</th>
                                                <th>Data Inicio Sessão</th>
                                                <th>Data Término Sessão</th>
                                                <th>Localização</th>
                                                <th>Dispositivo</th>
                                                <th>Navegaodor</th>
                                                <th>Sistema</th>
                                                 @can('clientes_view','editar funcionarios')
                                                <th>ver</th>
                                                @endcan
                                            </tr>
                                            </thead>
                                            <tbody>
                                                @if(isset($dados))
                                                @forelse($dados as $dado)
                                            <tr>
                                                <td>{{$i++}}</td>
                                                <td>{{\App\Models\User::find($dado->user_id)->getPessoa->nome}}</td>
                                                <td>{{\App\Models\User::find($dado->user_id)->getFuncionarioCliente->getCategoria->categoriacliente}}</td>
                                                <td>{{$dado->created_at}}</td>
                                                <td>{{$dado->updated_at}}</td>
                                                <td>{{$dado->regionName }}</td>
                                                <td>{{$dado->device}}</td>
                                                <td>{{$dado->browser}}</td>
                                                <td>{{$dado->plataform}}</td>
                                                @can('clientes_view','editar funcionarios')
                                                <td>
                                                    {{--<a href="{{route('us.admin.cliente.Gestfuncionario.funcionario.show',$dado->id)}}" class="btn btn-sm btn-outline-success"> <i class="fa fa-eye"></i></a>--}}

                                                        @php
                                                    //use Illuminate\Support\Facades\Crypt;

                                                    try {

                                                    $decrypted =Crypt::encryptString("1");

                                                    } catch (DecryptException $e) {
                                                        $decrypted=0;
                                                    }
                                                    @endphp
                                                    <form  action="{{route('us.admin.cliente.Gestfuncionario.funcionario.show')}}" method="post">
                                                        @csrf
                                                        <input type="text" value="{{$decrypted}}" hidden  name="meduIdFunciCode" >
                                                        <button  class="btn btn-sm btn-outline-success" type="submit"> <i class="fa fa-eye"></i></button>
                                                    </form>


                                                </td>
                                                @endcan
                                            </tr>
                                            @empty
                                            @endforelse
                                            @endif
                                            </tbody>

                                        <tfoot></tfoot>
                                    </table>


                        </div>
                    </div>
                </div>
            </div>

        </div>

</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/i18n/defaults-*.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>

<script>

    $(function () {
        $("#example1").DataTable();
        $('#example2').DataTable({
            "paging": true,
            "lengthChange": false,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
        });
    });
    </script>

    <script>
            $(function () {
                $("#tabela").DataTable();
                $('#example2').DataTable({
                    "paging": true,
                    "lengthChange": false,
                    "searching": false,
                    "ordering": true,
                    "info": true,
                    "autoWidth": true,
                });
            });

  </script>

@endsection
