@extends('layouts.main')

@section('breadcrumbs')
    {{ Breadcrumbs::render(request()->route()->getName()) }}
@endsection

@section('content')
    <div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
        <form method="POST" action="{{ isset($laporanExternal) ? route('laporan-external.update', $laporanExternal->id) : route('laporan-external.store') }}" enctype="multipart/form-data">
            @csrf
            @if(isset($laporanExternal))
                @method('PUT')
            @endif
            <div class="card border border-agi-100 pb-2.5">
                <div class="card-header bg-agi-50" id="basic_settings">
                    <h3 class="card-title">
                        {{ isset($laporanExternal) ? 'Edit' : 'Tambah' }} Laporan External
                    </h3>
                    <div class="flex items-center gap-2">
                        <a href="{{ route('laporan-external.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
                    </div>
                </div>
                <div class="card-body grid gap-5">
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Permohonan ID</label>
                        <input type="hidden" name="permohonan_id" value="{{ $laporanExternal->permohonan_id ?? "" }}">
                        <div class="flex flex-wrap items-baseline w-full">
                            <strong>{{ $permohonan->nomor_registrasi }}</strong>
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Nomor Laporan</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('nomor_laporan') border-danger bg-danger-light @enderror" type="text" name="nomor_laporan" value="{{ old('nomor_laporan', $laporanExternal->nomor_laporan ?? '') }}">
                            @error('nomor_laporan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Tanggal Final Laporan</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('tgl_final_laporan') border-danger bg-danger-light @enderror" type="date" name="tgl_final_laporan" value="{{ old('tgl_final_laporan', $laporanExternal->tgl_final_laporan ?? '') }}">
                            @error('tgl_final_laporan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Nilai Pasar</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('nilai_pasar') border-danger bg-danger-light @enderror" type="number" name="nilai_pasar" value="{{ old('nilai_pasar', $laporanExternal->nilai_pasar ?? '') }}">
                            @error('nilai_pasar')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Likuidasi</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_likuidasi') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_likuidasi" value="{{ old('indikasi_nilai_likuidasi', $laporanExternal->indikasi_nilai_likuidasi ?? '') }}">
                            @error('indikasi_nilai_likuidasi')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Pasar Tanah</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_pasar_tanah') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_pasar_tanah" value="{{ old('indikasi_nilai_pasar_tanah', $laporanExternal->indikasi_nilai_pasar_tanah ?? '') }}">
                            @error('indikasi_nilai_pasar_tanah')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Estimasi Harga Tanah</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('estimasi_harga_tanah') border-danger bg-danger-light @enderror" type="number" name="estimasi_harga_tanah" value="{{ old('estimasi_harga_tanah', $laporanExternal->estimasi_harga_tanah ?? '') }}">
                            @error('estimasi_harga_tanah')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Estimasi Harga Bangunan</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('estimasi_harga_bangunan') border-danger bg-danger-light @enderror" type="number" name="estimasi_harga_bangunan" value="{{ old('estimasi_harga_bangunan', $laporanExternal->estimasi_harga_bangunan ?? '') }}">
                            @error('estimasi_harga_bangunan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Pasar Bangunan</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_pasar_bangunan') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_pasar_bangunan" value="{{ old('indikasi_nilai_pasar_bangunan', $laporanExternal->indikasi_nilai_pasar_bangunan ?? '') }}">
                            @error('indikasi_nilai_pasar_bangunan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>

                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Pasar Sarana Pelengkap</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_pasar_sarana_pelengkap') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_pasar_sarana_pelengkap" value="{{ old('indikasi_nilai_pasar_sarana_pelengkap', $laporanExternal->indikasi_nilai_pasar_sarana_pelengkap ?? '') }}">
                            @error('indikasi_nilai_pasar_sarana_pelengkap')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Pasar Mesin</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_pasar_mesin') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_pasar_mesin" value="{{ old('indikasi_nilai_pasar_mesin', $laporanExternal->indikasi_nilai_pasar_mesin ?? '') }}">
                            @error('indikasi_nilai_pasar_mesin')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">Indikasi Nilai Pasar Kendaraan/Alat Berat</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('indikasi_nilai_pasar_kendaraan_alat_berat') border-danger bg-danger-light @enderror" type="number" name="indikasi_nilai_pasar_kendaraan_alat_berat" value="{{ old('indikasi_nilai_pasar_kendaraan_alat_berat', $laporanExternal->indikasi_nilai_pasar_kendaraan_alat_berat ?? '') }}">
                            @error('indikasi_nilai_pasar_kendaraan_alat_berat')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">File Resume</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('file_resume') border-danger bg-danger-light @enderror" type="file" name="file_resume">
                            @if(isset($laporanExternal) && $laporanExternal->file_resume)
                                <p class="mt-2">File saat ini: <p class="mt-2">File saat ini: <a href="storage/{{ $laporanExternal->file_resume }}" download="{{ $laporanExternal->file_resume }}" target="_blank" class="badge badge-sm badge-outline">
                                        {{ basename($laporanExternal->file_resume) }} <i class="ki-filled ki-cloud-download"></i>
                                    </a></p></p>
                            @endif
                            @error('file_resume')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">File Laporan</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input class="input @error('file_laporan') border-danger bg-danger-light @enderror" type="file" name="file_laporan">
                            @if(isset($laporanExternal) && $laporanExternal->file_laporan)
                                <p class="mt-2">File saat ini: <a href="storage/{{ $laporanExternal->file_laporan }}" download="{{ $laporanExternal->file_laporan }}" target="_blank" class="badge badge-sm badge-outline">
                                        {{ basename($laporanExternal->file_laporan) }} <i class="ki-filled ki-cloud-download"></i>
                                    </a></p>
                            @endif
                            @error('file_laporan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                            @enderror
                        </div>
                    </div>

                </div>
                <div class="card-footer flex justify-end">
                    <button type="submit" class="btn btn-primary">{{ isset($laporanExternal) ? 'Update' : 'Simpan' }}</button>
                </div>
            </div>
        </form>
    </div>
@endsection
