@extends('layouts.main')

@section('breadcrumbs')
    {{ Breadcrumbs::render(request()->route()->getName()) }}
@endsection
@section('content')
    @include('lpj::assetsku.includenya')
    <div class="w-full grid gap-5 lg:gap-7.5 mx-auto">

        @if (Auth::user()->hasAnyRole(['senior-officer', 'administrator','DD Appraisal']))
            @include('lpj::component.detail-jaminan', [
                'backLink' => 'otorisator.show',
                'id' => $permohonan->id,
                'type' => 'Paparan',
            ])
        @else
            @include('lpj::component.detail-jaminan', [
                'backLink' => 'penilai.show',
                'id' => $permohonan->id,
                'title' => 'Paparan dokument',
            ])
        @endif
        @include('lpj::penilai.components.foto-lampiran')


        <div class="card">
            <div class="card-header bg-agi-50 uppercase">
                Kertas Kerja
            </div>
            <div class="card-body flex items-center justify-between">
                @php
                    $url = '';
                    $fileName = '';
                    if ($penilai && $penilai->kertas_kerja) {
                        $url = asset('storage/' . $penilai->kertas_kerja);
                        $fileName = basename($penilai->kertas_kerja);
                    }
                @endphp

                @if ($penilai && $penilai->kertas_kerja)
                    <button type="button" class="btn btn-primary" onclick="window.open('{{ $url }}', '_blank')">
                        <i class="ki-outline ki-cloud-download"></i>
                        Lihat Kertas Kerja</button>

                    <p class="text-2sm text-gray-700">{{ $fileName }}</p>
                @else
                    <p class="text-2sm text-gray-700">Belum ada kertas kerja</p>
                @endif
            </div>
        </div>

        <div class="card">
            <div class="card-header bg-agi-50">
                <h3 class="card-title uppercase">
                    Total Nilai Jaminan
                </h3>
            </div>
            <div class="card-body grid gap-2.5">

                @php
                    $labelNilai = [
                        'bangunan' => 'Luas Bangunan',
                        'tanah' => 'Luas Tanah',
                        'apartement-kantor' => 'Luas Apartemen/Kantor',
                        'alat-berat' => 'Luas Alat Berat',
                        'mesin' => 'Luas Mesin',
                        'kendaraan' => 'Luas Kendaraan',
                        'pesawat' => 'Luas Pesawat',
                        'kapal' => 'Luas Kapal',
                    ];

                    // if (strcasecmp($jenisAset, 'RUKO/RUKAN') === 0) {
                    //     $labelNilai['bangunan'] = 'Luas Unit';
                    //     unset($labelNilai['tanah']);
                    // }
                @endphp
                @foreach ($labelNilai as $key => $label)
                    @if (isset($lpjData['luas_' . $key]))
                    <div class="flex grid-col-3 gap-2.5 w-full">
                        <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
                            <label for="province" class="form-label max-w-56">
                                {{ $label }}
                            </label>
                            <label for="province" class="form-label max-w-56">
                                {{ $lpjData['luas_' . $key] ?? '' }}
                            </label>
                        </div>
                        <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
                            <label for="province" class="form-label max-w-56">
                                {{ $lpjData['nilai_' . $key . '_1'] ?? '' }}
                            </label>
                        </div>
                        <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
                            <label for="province" class="form-label max-w-56">
                                {{ $lpjData['nilai_' . $key . '_2'] ?? '' }}
                            </label>
                        </div>
                    @endif
                @endforeach
            </div>
        </div>


        <div class="card">
            <div class="card-header bg-agi-50">
                <h3 class="card-title uppercase">
                    Informasi dan pembanding
                </h3>
            </div>
            @include('lpj::penilai.components.informasi-pembanding')
        </div>
    </div>
@endsection
