@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

<nav hidden>
{{ $refCaixa=\App\Models\ReferenciaCaixa::where('estado','Concluido')
                                        ->where('cliente_id',$empresa_cliente_id)
                                        ->orderBy('usuario_id','asc')->get()}}
{{ $camposMapa = \App\Models\CampoMapa::where('origem','Geral')->orderBy('prioridade','Asc')->get()}}
</nav>

    <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-check bg-success"></i><h4> Listagem Indexação Finalizadas </h4></a>
                        </div>
                        <div class="d-inline">
                           
                      <br/>
                        </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="#">Indexação Finalizadas </a>
                            </li>
                            <li class="breadcrumb-item active" aria-current="page">listagem</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>
                                                    @foreach($camposMapa as $cMapa)
                                                    @if($cMapa->descricao=="Código da recolha")
                        
                                                    @elseif($cMapa->descricao=="C. Q.")
                                                    
                                                    @elseif($cMapa->nome=="funcionario_id")
                                                    
                                                    
                                                    @else
                                                    <th>{{$cMapa->nome}}</th>
                                                    @endif
                                                @endforeach
                                                <th>Funcionario</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr>
                                                @foreach($refCaixa as $refC)
                                                    <tr>
                                                        @foreach($camposMapa as $cMapa)
                                                           @php
                                                                $linhaIndex=\App\Models\LinhaIndexacao::where('campomapa_id',$cMapa->id)->where('referenciacaixa_id',$refC->id)->where('cliente_id',$empresa_cliente_id)->first();
                                                         @endphp                                                               
                                                        
                                                            @if($linhaIndex)
                                                                @if($cMapa->nome=='orgaoestrutura_id')
                                                                   @php
                                                                         $OE1=\App\Models\OrgaosDeEstrutura::where('id',$linhaIndex->conteudo)->first();
                                                                    @endphp 
                                                                    <td>{{$OE1->orgao}}</td>
                                                                @elseif($cMapa->nome=='departamento_id')
                                                                   @php
                                                                         $Dep= \App\Models\DepCliente::where('id',$linhaIndex->conteudo)->first();
                                                                    @endphp                                                                
                                                                    <td>{{$Dep->departamento}}</td>
                                                                @elseif($cMapa->nome=='seriedocumental_id')
                                                                   @php
                                                                         $SD1=\App\Models\ParametroDocumental::where('id',$linhaIndex->conteudo)->first();
                                                                  @endphp 
                                                                    <td>{{$SD1->seriedoc}}</td>
                                                                
                                                                @elseif($cMapa->prioridade>=15)
                                                                    <td>{{$linhaIndex->conteudo}}</td>
                                                                    <td>{{$linhaIndex->getUser->getPessoa->nome}}</td>
                                                                @else
                                                                    <td>{{$linhaIndex->conteudo}}</td>
                                                                @endif
                                                                
                                                                
                                                            @endif
                                                        
                                                        @endforeach
                                                    </tr>
                                                @endforeach
                                            </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