{{-- @php
    header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
    header("Content-Disposition: attachment; filename=daftar-proposal-seleksi-internal.xls");  //File name extension was wrong
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false);
@endphp --}}
{{-- <!DOCTYPE html>
<html>
    <body> --}}
<table border="1">
    <thead>
        <tr>
            <td style="border: 1px solid #000000; text-align: center;"><strong>No</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Kode Kelompok</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Kategori PMW</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Fak.</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Nama</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>NIM</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Ketua/Anggota</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Email Ketua</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Judul Proposal</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Dosen Pembimbing</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Email Dosen Pembimbing</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Link Proposal</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Link Video</strong></td>
            @if ($jenis_monev == 'Seleksi Monev Internal I')
                <td style="border: 1px solid #000000; text-align: center;"><strong>Link Laporan Kemajuan</strong></td>
                <td style="border: 1px solid #000000; text-align: center;"><strong>Link Laporan Lainnya</strong></td>
            @else
                <td style="border: 1px solid #000000; text-align: center;"><strong>Link Laporan Akhir</strong></td>
                <td style="border: 1px solid #000000; text-align: center;"><strong>Link Laporan Anggaran</strong></td>
            @endif
            <td style="border: 1px solid #000000; text-align: center;"><strong>Status {{ $jenis_monev }}</strong></td>
            <td style="border: 1px solid #000000; text-align: center;"><strong>Nilai Akhir</strong></td>
        </tr>
    </thead>
    <tbody>
        @php
            $no = 1;
            $tempKode = '';
        @endphp
        @foreach ($list_proposal as $proposal)
            {{-- @if($tempKode != $proposal['kode']) --}}
                <tr>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $no++ }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['kode'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['jenis'] }}</th>
                    @foreach ($proposal['detil'] as $res => $val)
                        @if($res == 0)
                            <th style="border: 1px solid #000000;">{{ $val['fak'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['nama'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['nim'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['keanggotaan'] }}</th>
                        @endif
                    @endforeach
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['email_ketua'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['judul'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['dospem'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['email_dospem'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                        {!! $proposal['link'] ? "<a href='{$proposal['link']}' target='_blank'>Link</a>" : '<p style="font-style: italic;">N/A</p>' !!}
                    </th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                        @if (Str::contains($proposal['video'] ?? '', ['https', 'http', 'www', '.com']))
                            <a href="{{ $proposal['video'] }}" target="_blank">Link</a>
                        @else
                            <p style="font-style: italic;">N/A</p>
                        @endif
                    </th>
                    @if ($jenis_monev == 'Seleksi Monev Internal I')
                        <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                            {!! $proposal['kemajuan'] ? "<a href='{$proposal['laporan']}' target='_blank'>Link</a>" : '<p style="font-style: italic;">N/A</p>' !!}
                        </th>
                        <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                            {!! $proposal['laporan_lain'] ? "<a href='{$proposal['laporan_lain']}' target='_blank'>Link</a>" : '<p style="font-style: italic;">N/A</p>' !!}
                        </th>
                    @elseif ($jenis_monev == 'Seleksi Monev Internal II')
                        <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                            {!! $proposal['akhir'] ? "<a href='{$proposal['laporan']}' target='_blank'>Link</a>" : '<p style="font-style: italic;">N/A</p>' !!}
                        </th>
                        <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">
                            {!! $proposal['laporan_anggaran'] ? "<a href='{$proposal['laporan_anggaran']}' target='_blank'>Lihat Detail</a>" : '<p style="font-style: italic;">N/A</p>' !!}
                        </th>
                    @endif
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['status'] }}</th>
                    <th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['rata'] }}</th>
                </tr>
            {{-- @else --}}
                @foreach ($proposal['detil'] as $res => $val)
                    @if($res != 0)
                        <tr valign="top">
                            <th style="border: 1px solid #000000;">{{ $val['fak'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['nama'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['nim'] }}</th>
                            <th style="border: 1px solid #000000;">{{ $val['keanggotaan'] }}</th>
                        </tr>
                    @endif
                @endforeach
            {{-- @endif --}}
            @php
                // $tempKode = $proposal['kode'];
            @endphp
        @endforeach
    </tbody>
</table>
    {{-- </body>
</html> --}}