@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Novo Documento")
@section('content')

    <form action="{{ route('admin.validacaoDocumentos.store') }}" method="post" enctype="multipart/form-data">
        <div class="container mt-4">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow">
                        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center mb-3">
                            <h5 class="mb-0">Novo Documento</h5>
                        </div>
                        <div class="card-body">
                            @csrf
                            @include("errors.messageFlash")

                            <div class="mb-3">
                                <label for="categoria" class="form-label text-bold">Categoria: <span class="span-admin-create">*</span></label>
                                <input type="hidden" class="form-control @error('user_id') is-invalid @enderror" name="user_id" id="user_id" value="{{ old('user_id') }}">
                                <select class="form-control @error('categoria') is-invalid @enderror" name="categoria" id="categoria" required="true">
                                    @foreach(App\Enums\StatusTipoDocumentoEnum::cases() as $status)
                                        <option value="{{ $status->name }}" {{ old('categoria', false) ? 'selected' : '' }}>{{ $status->value }}</option>
                                    @endforeach
                                </select>
                                @error('categoria')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            
                            <div class="mb-3 text-wrap">
                                <label for="resumo" class="form-label text-bold">Resumo: <span class="span-admin-create">*</span></label>
                                <textarea class="form-control textarea-comments @error('resumo') is-invalid @enderror" style="height: 200px" name="resumo" id="resumo">{{ old('resumo') }}</textarea>
                                @error('resumo')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <div class="list-group mb-3">
                                    <a class="list-group-item list-group-item-action active" aria-current="true">
                                        <h5 class="mb-1">Solicitante</h5>
                                        <small class="text-warning" style="cursor: pointer">* Preencha todos os campos</small>
                                    </a>
                                    <div class="list-group-item list-group-item-action">
                                        <div class="mb-1">
                                            
                                            <div class="mb-3 mt-4 alert alert-info d-none" id="mensagemDocumento"></div>
                                            
                                            <div class="mb-3">
                                                <label for="type" class="form-label text-bold">CPF: <span class="span-admin-create">*</span></label>
                                                <div class="input-group">
                                                    <input type="text" class="form-control @error('cpf') is-invalid @enderror" name="cpf" id="cpf" autocomplete="off" value="{{ old('cpf') }}" oninput="javascript:aplicarMascaraCPF(this)" autocomplete="off" required="true">
                                                    <button class="btn btn-outline-secondary" type="button" id="btnConsultarCPFDocumentosValidacao" data-id="#cpf" data-url="{{ route("admin.validacaoDocumentos.checkUser") }}" onclick="javascript:consultarCPFDocumentosValidacao(this)">Buscar</button>
                                                </div>
                                                @error('nome')
                                                    <small class="text-danger text-bold">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <label for="matriculation" class="form-label text-bold">Matrícula:</label>
                                                <input type="text" class="form-control @error('matriculation') is-invalid @enderror" name="matriculation" id="matriculation" autocomplete="off" value="{{ old('matriculation') }}">
                                                @error('matriculation')
                                                    <small class="text-danger text-bold">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <label for="nome" class="form-label text-bold">Nome completo: <span class="span-admin-create">*</span></label>
                                                <input type="text" class="form-control @error('nome') is-invalid @enderror" name="nome" id="nome" autocomplete="off" value="{{ old('nome') }}" required="true">
                                                @error('cpf')
                                                    <small class="text-danger text-bold">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <label for="telefone" class="form-label text-bold">Telefone: <span class="span-admin-create">*</span></label>
                                                <input type="text" class="form-control @error('telefone') is-invalid @enderror" name="telefone" id="telefone" autocomplete="off" value="{{ old('telefone') }}" required="true">
                                            @error('telefone')
                                                    <small class="text-danger text-bold">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <label for="email" class="form-label text-bold">Email: <span class="span-admin-create">*</span></label>
                                                <input type="email" class="form-control @error('email') is-invalid @enderror" name="email" id="email" autocomplete="off" value="{{ old('email') }}" required="true">
                                            @error('email')
                                                    <small class="text-danger text-bold">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <label for="nacimento_at" class="form-label">Data de Nascimento: <span class="span-admin-create">*</span></label>
                                                <input type="date" class="form-control @error('nacimento_at') is-invalid @enderror" name="nacimento_at" id="nacimento_at" value="{{ old('nacimento_at') }}" required="true">
                                                @error('nacimento_at')
                                                    <small class="text-danger">{{ $message }}</small>
                                                @enderror
                                            </div>
                                            <div class="mb-3">
                                                <div class="form-check">
                                                    <input class="form-check-input" type="checkbox" name="isServidorPublico" id="isServidorPublico" {{ old('isServidorPublico', false) ? 'checked' : '' }}>
                                                    <label class="form-check-label" for="flexCheckDefault">
                                                    Selecione esta opação caso esta pessoa seja funcionário público.
                                                    </label>
                                                  </div>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    
                                </div>
                            </div>
                            
                            <div class="mb-3">
                                <label for="documento" class="form-label text-bold">Selecione um documento: <span class="span-admin-create">*</span></label>
                                <input type="file" class="form-control" name="documento" id="documento" accept="image/jpeg,image/jpg,image/png,image/gif,.pdf" />
                                @error('documento')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            
                            <div class="mb-3">
                                <label for="status" class="form-label text-bold">Status: <span class="span-admin-create">*</span></label>
                                <select class="form-control @error('status') is-invalid @enderror" name="status" id="status">
                                    @foreach(App\Enums\StatusEnum::cases() as $status)
                                        <option value="{{ $status->name }}">{{ $status->value }}</option>
                                    @endforeach
                                </select>
                                @error('status')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            @include('components.buttons._backAndSend', [
                                    'textBack' => 'Voltar', 
                                    'textSend' => 'Cadastrar', 
                                    'routeBack' => 'admin.validacaoDocumentos.index'
                                ]
                            )
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

@endsection