@extends('layout.main')
@section('body')
    @php
        $menu = 'Data Riwayat';
        $pageTitle = 'Hasil Riwayat';
    @endphp

    @include('layout.navbar')
    @include('layout.sidebar')

    {{-- Main Content --}}
    <div class="main-container">
        <div class="pd-ltr-20 xs-pd-20-10">
            <div class="min-height-200px">
                <div class="page-header">
                    <div class="row">
                        <div class="col-md-6 col-sm-12">
                            <div class="title">
                                <h4>{{ $menu }}</h4>
                            </div>
                            <nav aria-label="breadcrumb" role="navigation">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
                                    @if (isset($pageTitle))
                                        <li class="breadcrumb-item active" aria-current="page">{{ $pageTitle }}</li>
                                    @else
                                        <li class="breadcrumb-item active" aria-current="page"></li>
                                    @endif
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
                <div class="card-box mb-30">
                    <div class="pd-20">
                        <h4 class="text-blue h4 mb-0">Hasil Riwayat Penilaian</h4>
                    </div>
                    <div class="card-header d-flex align-items-center">
                    <form class="form-inline ml-auto" action="{{ route('riwayat.hasil') }}" method="GET">
                        <div class="input-group">
                            <input type="search" class="form-control" name="search" placeholder="Search">
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="submit">
                                    <i class="icon dw dw-search"></i>
                                </button>
                            </div>
                        </div>
                    </form>
                    </div>
                    <form method="POST" action="">
                        @csrf
                        <div class="pb-10">
                            <div class="table-responsive">
                                <table class="data-table table stripe hover nowrap">
                                    <thead>
                                        <tr>
                                            <th>No</th>
                                            <th>Nama</th>
                                            <th>Pilihan Ekstrakurikuler</th>
                                            <th>Nilai Akhir</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @forelse ($logs as $index => $log)
                                            <tr>
                                                <td>{{ $index + $logs->firstItem() }}</td>
                                                <td>{{ $log->user->name }}</td>
                                                <td>{{ $log->extracuricullar->nama }}</td>
                                                <td>{{ $log->final_score }}</td>
                                            </tr>
                                        @empty
                                            <tr>
                                                <td colspan="5" class="text-center">Tidak ada data.</td>
                                            </tr>
                                         @endforelse
                                    </tbody>
                                </table>
                                <div>
                                    <div style="display: flex; justify-content: space-between; align-items: center; margin: 0 20px;">
                                        <div style="font-size: 14px;">
                                            Showing data {{ $logs->firstItem() }} to {{ $logs->lastItem() }} of {{ $logs->total() }} entries
                                        </div>
                                        <div style="font-size: 14px;">{{ $logs->links() }}</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="footer-wrap pd-20 mb-20 card-box">
                <strong>Sistem Pendukung Keputusan Pemilihan Ekstrakurikuler Metode SMARTER</strong>
            </div>
        </div>
    </div>
@endsection
