@extends('adminlte::page')

@section('title', 'Sejarah Semakan')

@section('content_header')
    <h1><i class="fas fa-history mr-2"></i>Sejarah Semakan</h1>
@stop

@section('content')
    <div class="card card-outline card-info">
        <div class="card-header">
            <h3 class="card-title"><i class="fas fa-history mr-1"></i> Sejarah Semakan Semua Tahun</h3>
        </div>
        <div class="card-body p-0">
            @if ($pengesahans->isEmpty())
                <div class="text-center py-5 text-muted">
                    <i class="fas fa-inbox fa-3x mb-3"></i>
                    <p>Tiada sejarah semakan.</p>
                </div>
            @else
                <table class="table table-hover table-striped mb-0">
                    <thead class="thead-light">
                        <tr>
                            <th>#</th>
                            <th>Tahun</th>
                            <th>Nama Pemohon</th>
                            <th>Kod Sekolah</th>
                            <th>Nama Sekolah</th>
                            <th>Jenis Sekolah</th>
                            <th class="text-center">Tarikh Hantar</th>
                            <th class="text-center">Status</th>
                            <th class="text-center">Tarikh Semakan</th>
                            <th>Catatan</th>
                            <th class="text-center">Tindakan</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($pengesahans as $i => $p)
                            <tr>
                                <td>{{ $i + 1 }}</td>
                                <td>{{ $p->tahun }}</td>
                                <td>{{ $p->user->name ?? '-' }}</td>
                                <td><span class="badge badge-primary">{{ $p->kod_sekolah }}</span></td>
                                <td>{{ $p->user->nama_sekolah ?? '-' }}</td>
                                <td><span class="badge badge-info">{{ $p->jenis_sekolah ?? '-' }}</span></td>
                                <td class="text-center">
                                    {{ $p->dihantar_pada ? $p->dihantar_pada->format('d/m/Y H:i') : '-' }}
                                </td>
                                <td class="text-center">
                                    @if ($p->status === 'lulus')
                                        <span class="badge badge-success">Diluluskan</span>
                                    @elseif ($p->status === 'ditolak')
                                        <span class="badge badge-danger">Ditolak</span>
                                    @endif
                                </td>
                                <td class="text-center">
                                    {{ $p->disemak_pada ? $p->disemak_pada->format('d/m/Y H:i') : '-' }}
                                </td>
                                <td>{{ Str::limit($p->catatan, 50) ?? '-' }}</td>
                                <td class="text-center">
                                    <a href="{{ route('checker.pengesahan.show', $p->id) }}" class="btn btn-sm btn-info">
                                        <i class="fas fa-eye mr-1"></i>Lihat
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            @endif
        </div>
    </div>
@stop
