@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Preposto da Empresa de Turismo")
@section('content')

    @php
        $filterParams = \App\Http\Resources\TurisAngra\EmpresasDeTurismo\EmpresaTurismoResource::listFilterParamsFromRequest(request());
    @endphp

    <div class="container mt-5">
        <div class="row">
            <div class="col-12">
                <div class="card shadow">

                    @php $headLine = "<i class='fa-solid fa-water'></i> Preposto da Empresa de Turismo"; @endphp

                        @include('components.buttons._headLineButtonsBackAdd', [
                            'headLine' => __($headLine),
                            'routeBack' => 'admin.empresasDeTurismo.index',
                            'routeBackParams' => $filterParams,
                            'nameBack' => __("Voltar"),
                            "permission" => "GERENCIADOR_DE_EMPRESAS_DE_TURISMO",
                        ])

                    <div class="card-body">

                        <form action="{{ route('admin.empresasDeTurismo.prepostoUpdate', [$empresaTurismo->id]) }}" method="post" enctype="multipart/form-data">
                            @include('admin.turisAngra.empresasDeTurismo.sections._filterHidden', ['filterParams' => $filterParams])
                            @include("errors.messageFlash")
                            @csrf
                            @method('post')

                            <div class="col-12">
                                <hr/>
                                <h3 class="text-primary">
                                    {{ $empresa->razaoSocial ?? '-' }} <br>
                                    {{ __("CNPJ: ") . ($empresa->cnpj ?? '-') }}
                                </h3>
                                <hr/>
                            </div>
                            <div class='row mb-3'>
                                <div class="col-sm-10 col-md-2">
                                    @php $index = 1; @endphp
                                    @include('components.tables._openPhoto',[
                                                'asset' => $preposto?->photo ?? "pmar/assets/img/icons/usuario.png",
                                                'alt' => $preposto?->name,
                                                'title' => $preposto?->name,
                                                'text' => 'Visualizar foto',
                                            ])
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-12 col-md-8">

                                <!-- Campo Nome completo do responsável legal -->
                                    @include('components.inputs._inputType',[
                                                "for" => null,
                                                "label" => "Nome completo do preposto",
                                                "name" => "fullName",
                                                "id" => null,
                                                "required" => true,
                                                "type" => null,
                                                "old" => old('fullName', $preposto?->name),
                                                "oninput" => "javascript:this.value = this.value.toLocaleUpperCase('pt-BR').replace(/[^\p{L}\s]+/gu, '').replace(/\s{2,}/g,' ').trimStart()",
                                                "readonly" => false,
                                                "small" => null,
                                            ])

                                </div>
                                <div class="col-sm-12 col-md-4">
                                <!-- Campo CPF do responsável legal -->
                                    @include('components.inputs._inputType',[
                                                "for" => null,
                                                "label" => "CPF do responsável legal",
                                                "name" => "cpf",
                                                "id" => null,
                                                "required" => true,
                                                "type" => null,
                                                "old" => old('cpf', $preposto?->cpf),
                                                "oninput" => "javascript:aplicarMascaraCPF(this)",
                                                "readonly" => false,
                                                "small" => null,
                                            ])

                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-12 col-md-4">

                                <!-- Campo Email do responsável legal -->
                                    @include('components.inputs._inputType',[
                                                "for" => null,
                                                "label" => "Email do responsável legal",
                                                "name" => "email",
                                                "id" => null,
                                                "required" => false,
                                                "type" => 'email',
                                                "old" => old('email', $preposto?->email),
                                                "oninput" => "javascript:this.value = this.value.toLowerCase()",
                                                "readonly" => false,
                                                "small" => null,
                                                "placeholder" => "nome@email.com",
                                            ])

                                </div>
                                <div class="col-sm-12 col-md-4">

                                <!-- Campo Telefone do responsável legal -->
                                    @include('components.inputs._inputType',[
                                                "for" => null,
                                                "label" => "Telefone do responsável legal",
                                                "name" => "phoneNumber",
                                                "id" => null,
                                                "required" => true,
                                                "type" => null,
                                                "old" => old('phoneNumber', $preposto?->phoneNumber),
                                                "oninput" => "javascript:aplicarMascaraTelefone(this)",
                                                "readonly" => false,
                                                "small" => null,
                                            ])


                                </div>
                                <div class="col-sm-12 col-md-4">

                                <!-- Campo Foto responsável legal-->
                                    @include('components.inputs._inputType',[
                                                "for" => null,
                                                "label" => "Foto responsável legal",
                                                "name" => "photo",
                                                "id" => null,
                                                "required" => false,
                                                "type" => 'file',
                                                "old" => null,
                                                "oninput" => null,
                                                "readonly" => true,
                                                "small" => null,
                                                "accept" => 'image/jpeg,image/jpg,image/png,image/gif',
                                            ])

                                </div>
                            </div>

                            <div class="row">
                                <div class="col-12">
                                    <div class="form-check mb-3">
                                        <input class="form-check-input" type="checkbox" name="resetPasswordCheckbox" onclick="javascript:resetPasswordUser(this)">
                                        <label class="form-check-label" for="resetPasswordCheckbox">{{ __("Deseja redefinir a senha deste usuário para a senha padrão?") }}</label>
                                    </div>
                                </div>
                                <div class="col-12">
                                    <div class="d-none" id="resetPasswordCheckbox">
                                    <!-- Campo Senha -->
                                        @include('components.inputs._inputType',[
                                            "for" => null,
                                            "label" => "Senha",
                                            "name" => "password",
                                            "id" => null,
                                            "required" => true,
                                            "type" => 'password',
                                            "old" => old('password', 'mudar123'),
                                            "oninput" => null,
                                            "readonly" => true,
                                            "small" => '* A senha padrão é: <strong>mudar123</strong><br>',
                                        ])
                                    </div>
                                </div>
                            </div>

                            @include('components.buttons._backAndSend', [
                                'textBack' => 'Voltar',
                                'textSend' => 'Salvar',
                                'routeBack' => 'admin.empresasDeTurismo.index'
                            ]
                        )
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection
