@extends('layouts.main')

@section('breadcrumbs')
    {{ Breadcrumbs::render('laporan-admin-kredit-edit', $laporanAdminKredit) }}
@endsection

@section('content')
    <div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
        <div class="card border border-agi-100">
            <div class="card-header bg-agi-50 py-5">
                <h3 class="card-title">
                    Edit Laporan Admin Kredit
                </h3>
            </div>
            <div class="card-body">
                <form action="{{ route('laporan-admin-kredit.update', $laporanAdminKredit->id) }}" method="POST" class="grid gap-5">
                    @csrf
                    @method('PUT')

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                        <!-- Editable Fields -->
                        <div class="form-group">
                            <label for="kode_register_t24" class="form-label">Kode Register T24</label>
                            <input type="text" name="kode_register_t24" id="kode_register_t24" class="input" value="{{ $laporanAdminKredit->kode_register_t24 }}" required>
                        </div>

                        <div class="form-group">
                            <label for="cif" class="form-label">CIF</label>
                            <input type="text" name="cif" id="cif" class="input" value="{{ $laporanAdminKredit->debiture ? $laporanAdminKredit->debiture->cif : '' }}" required>
                        </div>

                        <!-- Read-only Information Fields -->
                        <div class="form-group">
                            <label class="form-label">Nama Debitur</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->debiture ? $laporanAdminKredit->debiture->name : '' }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Cabang</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->debiture ? $laporanAdminKredit->debiture->branch->name : '' }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Jenis Agunan</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->jenis_agunan }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Bukti Kepemilikan</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->bukti_kepemilikan }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Alamat Agunan</label>
                            <div class="textarea bg-gray-100 h-auto min-h-[70px] p-3">{{ $laporanAdminKredit->alamat_agunan }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Nama Pemilik</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->nama_pemilik }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Tanggal Kunjungan</label>
                            <div class="input bg-gray-100">{{ \Carbon\Carbon::parse($laporanAdminKredit->tanggal_kunjungan)->format('d-m-Y') }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Nilai Pasar Wajar</label>
                            <div class="input bg-gray-100">{{ number_format($laporanAdminKredit->nilai_pasar_wajar, 0, ',', '.') }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Nilai Likuidasi</label>
                            <div class="input bg-gray-100">{{ number_format($laporanAdminKredit->nilai_likuidasi, 0, ',', '.') }}</div>
                        </div>

                        <div class="form-group">
                            <label class="form-label">Nama Penilai</label>
                            <div class="input bg-gray-100">{{ $laporanAdminKredit->nama_penilai }}</div>
                        </div>
                    </div>

                    <div class="flex justify-end gap-3">
                        <a href="{{ route('laporan-admin-kredit.index') }}" class="btn btn-light">Cancel</a>
                        <button type="submit" class="btn btn-primary">Update</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
