@extends('layouts.master')
@section('css')
@endsection
@section('content')
<div class="flex-1 overflow-y-auto p-8 custom-scrollbar">
    <div class="p-8 bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden">
        <div class="flex justify-between items-center mb-5">
            <h5 class="text-lg text-slate-700 font-bold">Informasi Dataset</h5>
            <a href="{{route($route.'.index')}}" class="bg-blue-500 rounded py-2 px-3 text-white flex items-center"><i data-lucide="arrow-left" class="w-4 h-4 mr-2"></i><span>Kembali</span></a>
        </div>
        <hr>
        <div class="grid lg:grid-cols-2 gap-3 mb-3 mt-5">
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="building" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Instansi</b></div> 
                    <div class="text-xs">{{$item->instansi->name}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="database" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Sumber Data</b></div> 
                    <div class="text-xs">{{$item->tabelData->name}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="database" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Nama Dataset</b></div> 
                    <div class="text-xs">{{$item->name}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="database" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex items-center gap-3">
                    <div class="text-sm"><b>File</b></div> 
                    <div>
                        @if(@$item->tahun >= 2026)
                            <a href="{{url('opendata/dataset/download/'.encode_id(@$item->DatasetId))}}" class="p-1 bg-blue-500 rounded text-white flex items-center"><i data-lucide="download" class="w-4 h-4 mr-2"></i>Download File</a>
                        @else
                            <a href="{{asset('uploads/'.@$item->file)}}" class="p-1 bg-blue-500 rounded text-white flex items-center"><i data-lucide="download" class="w-4 h-4 mr-2"></i>Download File</a>
                        @endif
                    </div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="database" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Tahun Sistem SLHD</b></div> 
                    <div class="text-xs">{{$item->tahun}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="database" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Tahun Data</b></div> 
                    <div class="text-xs">{{@$item->tahun_data}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="info" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Deskripsi</b></div> 
                    <div class="text-xs">{{$item->deskripsi}}</div>
                </div>
            </div>
            <div class="flex flex-between gap-3 bg-gray-100 items-center p-2 rounded">
                <div class="p-2">
                    <i data-lucide="info" class="w-4 h-4 mr-2"></i>
                </div>
                <div class="flex flex-col">
                    <div class="text-sm"><b>Status</b></div> 
                    <div class="text-xs">
                        @if(@$item->status == 1)
                            <span class="p-1 w-full flex bg-emerald-500 text-white rounded" title="Valid">Valid</span>
                        @elseif(@$item->status == 0)
                            <span class="p-1 w-full flex bg-yellow-500 text-white rounded" title="Tidak Valid">Menunggu Verifikasi</span>
                        @elseif(@$item->status == 2)
                            <span class="p-1 w-full flex bg-red-500 text-white rounded" title="Tidak Valid">Verifikasi Ditolak</span>
                        @endif
                    </div>
                </div>
            </div>

        </div>
        <div class="grid lg-grid-cols-1 gap-3">
            
            <div class="flex  items-center p-2 rounded" style="overflow-x:auto;">
                <div class="w-full">
                    @if(@$item->tahun >= 2026)
                        <table id="table"
                            class="w-full border text-left border-collapse"
                            data-toggle="table"
                            data-search="false"
                            data-pagination="true"
                            data-page-size="10"
                            data-page-list="[10,25,50,100]"
                            data-side-pagination="server"
                            data-url="{{ route($route.'.gridDetail', ['id' => $keyId]) }}"
                            >
                            <thead class="bg-slate-100 border-b border-slate-100">
                                <tr>
                                    <th data-field="no" data-width="3%" class="text-[10px] border font-bold text-slate-900 text-center tengah">No</th>
                                    @foreach ($tabel as $k => $key)
                                        <th data-field="{{$key->order}}" class="text-[10px] border font-bold text-slate-900 text-center">{{ $key->name }}</th>
                                    @endforeach
                                </tr>
                            </thead>
                        </table>
                        
                    @else
                        <?php $data = json_decode($item->data); ?>
                        <table class="w-full text-left border-collapse" id="table"
                            data-toggle="table"
                            data-search="false"
                            data-pagination="true"
                            data-side-pagination="server"
                            data-url="{{ url('dataset/Griddetail2025?id='.@$item->DatasetId) }}"
                            >
                            <thead class="bg-slate-100 border-b border-slate-100">
                                <tr>
                                    @if (!empty($data))
                                        @foreach ($data[0] as $k => $key)
                                            <th data-field="{{$k}}" class="text-[10px] px-6 py-4 border font-bold text-slate-900">{{ ucwords(str_replace('_', ' ', $k)) }}</th>
                                        @endforeach
                                    @endif
                                </tr>
                            </thead>
                        </table>
                    @endif
                </div>
            </div>
            

            {{-- {!! $modelClass::legend() !!} --}}
        </div>
        @if((session('group_id') == 1) || (session('group_alias') == 'admin'))
            @if(@$item->status == 0)
                <hr class="mt-3">
                <h5 class="text-xl font-bold mt-3">Form Verifikasi Dataset</h5>
                <form action="{{ url('opendata/dataset/verifikasi/'.encode_id($item->DatasetId)) }}" method="POST">
                    {{ csrf_field() }}
                    <div class="mt-2">
                        <select name="verifikasi" class="w-full p-2 bg-white border" id="">
                            <option value="1">Verifikasi</option>
                            <option value="2">Tolak Verifikasi</option>
                        </select>
                    </div>
                    <div class="mt-2">
                        <textarea name="catatan" class="w-full p-2 bg-white border" id="" cols="30" rows="10" placeholder="Masukan Catatan"></textarea>
                    </div>
                    <div class="mt-2">
                        <button class="p-2 bg-blue-500 rounded text-white">Simpan</button>
                    </div>
                </form>
            @endif
        @endif
        @if(@$catatan)
        @if(($item->status == '2') || ($item->status == '1'))
            <hr class="mt-3">
            <h5 class="text-xl font-bold my-3">Catatan Verifikator</h5>
            {{-- @foreach ($catatan as $valCatatan)
                <div class="flex flex-col gap-3 bg-gray-100 p-2 mb-2 rounded">
                    <div class="text-[10px]">{{$valCatatan->created_at}}</div> 
                    <div class="text-sm">{{$valCatatan->catatan}}</div>
                </div>
            @endforeach --}}            
            <div class="flex flex-col gap-3 bg-gray-100 p-2 mb-2 rounded">
                <div class="text-[10px]">{{@$catatan->created_at}}</div> 
                <div class="text-sm">{{@$catatan->catatan}}</div>
            </div>
        @endif
        @endif
    </div>
</div>
@endsection
@section('js')
@endsection