<table>
    {{-- JUDUL --}}
    <tr>
        <th colspan="7" style="font-size:16px; font-weight:bold;">
            LAPORAN REKAP KEHADIRAN SISWA
        </th>
    </tr>

    {{-- MAPEL --}}
    <tr>
        <td colspan="7">
            Mata Pelajaran :
            {{ request('jadwal_id') ? $jadwals->firstWhere('jadwal_id', request('jadwal_id'))->mapel->nama_mapel ?? '-' : '-' }}
        </td>
    </tr>

    {{-- KELAS --}}
    <tr>
        <td colspan="7">
            Kelas :
            {{ request('jadwal_id') ? $jadwals->firstWhere('jadwal_id', request('jadwal_id'))->kelas->nama_kelas ?? '-' : '-' }}
        </td>
    </tr>


    {{-- GURU --}}
    <tr>
        <td colspan="7">
            Guru :
            {{ $user->guru->nama_guru ?? '-' }}
        </td>
    </tr>

    {{-- TANGGAL --}}
    <tr>
        <td colspan="7">
            Tanggal :
            {{ \Carbon\Carbon::parse($tanggal)->translatedFormat('d F Y') }}
        </td>
    </tr>

    <tr></tr>

    {{-- HEADER TABLE --}}
    <tr>
        <th>No</th>
        <th>NIS</th>
        <th>Nama Siswa</th>
        <th>Hadir</th>
        <th>Sakit</th>
        <th>Izin</th>
        <th>Alfa</th>
    </tr>

    @php
        $grandH = 0;
        $grandS = 0;
        $grandI = 0;
        $grandA = 0;
    @endphp

    @foreach($items as $index => $item)

        @php
            $grandH += $item->total_hadir;
            $grandS += $item->total_sakit;
            $grandI += $item->total_izin;
            $grandA += $item->total_alfa;
        @endphp

        <tr>
            <td>{{ $index + 1 }}</td>
            <td>'{{ $item->nis }}</td>
            <td>{{ $item->nama_siswa }}</td>
            <td>{{ $item->total_hadir }}</td>
            <td>{{ $item->total_sakit }}</td>
            <td>{{ $item->total_izin }}</td>
            <td>{{ $item->total_alfa }}</td>
        </tr>

    @endforeach

    {{-- TOTAL --}}
    <tr>
        <td colspan="3"><strong>TOTAL</strong></td>
        <td><strong>{{ $grandH }}</strong></td>
        <td><strong>{{ $grandS }}</strong></td>
        <td><strong>{{ $grandI }}</strong></td>
        <td><strong>{{ $grandA }}</strong></td>
    </tr>
</table>