@extends('layouts.admin.theme')

@section('title', env('APP_NAME') . ' :: Logs')

@section('content')

    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
            <h5 class="my-2">Auditoria</h5>

            <div class="ms-auto">
                  <a href="{{ route('admin.curriculos.listaCadastros') }}" class="btn btn-secondary btn-lg px-4">
                    <i class="bi bi-x-circle me-1"></i> Voltar
                </a>
            </div>
        </div>

        <div class="card-body">
            <form method="GET" action="{{ route('admin.curriculos.logs') }}" class="mb-4">
                <div class="row g-2">
                    <div class="col-md-4">
                        <input type="text" name="busca" value="{{ request('busca') }}" class="form-control"
                            placeholder="Buscar por nome, matrícula ou ação ...">
                    </div>

                    <div class="col-md-3">
                        <input type="date" name="inicio" value="{{ request('inicio') }}" class="form-control"
                            placeholder="Data início">
                    </div>

                    <div class="col-md-3">
                        <input type="date" name="fim" value="{{ request('fim') }}" class="form-control"
                            placeholder="Data fim">
                    </div>

                    <div class="col-md-2 d-flex gap-2">
                        <button class="btn btn-primary w-100" type="submit">Buscar</button>
                        <a href="{{ route('admin.curriculos.logs') }}" class="btn btn-outline-secondary w-100">Limpar</a>
                    </div>
                </div>
            </form>
            
            <table class="table table-striped">
                @include('components.tables._thead', [
                    'thead' => ['Chave Primária', 'Matrícula', 'Usuário', 'Ação', 'Módulo de Operação', 'Tabela', 'Id do Item', 'Detalhes', 'Data']
                ])
                <tbody>
                    @foreach ($logs as $log)
                        <tr>
                            <td>{{ $log->id }}
                            </td>
                            <td>{{ $log->user->matriculation }}
                            </td>
                            <td>{{ $log->user->firstName . ' ' . $log->user->lastName }}
                            </td>
                            <td>{{ $log->action }}</td>
                            <td>{{ $log->module }}</td>
                            <td> {{ $log->model }} </td>
                            <td> {{ $log->model_id }} </td>
                            <td>{{ $log->details }}</td>
                            <td>{{ $log->created_at->format('d/m/Y H:i:s') }}
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>

@endsection
