@php $reviewerRole = $reviewerRole ?? null; $validationRoute = $validationRoute ?? null; $isReviewerView = (bool) ($reviewerRole && $validationRoute); $statusBadge = [ 'belum_dikirim' => 'secondary', 'menunggu' => 'warning text-dark', 'revisi' => 'danger', 'disetujui' => 'success', ]; $statusLabel = [ 'belum_dikirim' => 'Belum Dikirim', 'menunggu' => 'Menunggu Validasi', 'revisi' => 'Direvisi', 'disetujui' => 'Disetujui', ]; $reviewerStatusLabel = [ 'belum_dikirim' => 'Belum Dikirim', 'menunggu' => 'Menunggu Validasi', 'revisi' => 'Direvisi', 'disetujui' => 'Disetujui', ]; $summaryBadge = [ 'Belum Lengkap' => 'secondary', 'Menunggu Validasi Dokumen' => 'warning text-dark', 'Perlu Revisi Dokumen' => 'danger', 'Siap Ajukan Seminar' => 'success', 'Seminar Sudah Diajukan' => 'success', ]; $documents = [ 'laporan_hasil_magang' => [ 'title' => 'Laporan Hasil Magang', 'history_title' => 'Riwayat Laporan Hasil Magang', 'path' => $kelayakan->laporan_hasil_magang, 'original_name' => $kelayakan->laporan_hasil_magang_original_name, 'preview' => 'Lihat', 'download' => 'Download', 'empty' => 'Laporan Hasil Magang belum dikirim.', ], 'produk_magang' => [ 'title' => 'Produk Magang', 'history_title' => 'Riwayat Produk Magang', 'path' => $kelayakan->produk_magang, 'original_name' => $kelayakan->produk_magang_original_name, 'preview' => 'Lihat', 'download' => 'Download', 'link' => $kelayakan->produk_magang_link, 'empty' => 'Produk Magang belum dikirim.', ], 'draft_jurnal' => [ 'title' => 'Draft Jurnal', 'history_title' => 'Riwayat Draft Jurnal', 'path' => $kelayakan->draft_jurnal, 'original_name' => $kelayakan->draft_jurnal_original_name, 'preview' => 'Lihat', 'download' => 'Download', 'empty' => 'Draft Jurnal belum dikirim.', ], ]; $roleLabels = ['dosen' => 'Dosen Pembimbing', 'pembimbing_lapangan' => 'Pembimbing Lapangan']; $validationFor = function (string $documentKey, string $role) use ($kelayakan) { return $kelayakan->documentValidations ->where('document_key', $documentKey) ->where('reviewer_role', $role) ->first(); }; $historyLabel = function ($history) use ($documents) { if ($history->document_key && isset($documents[$history->document_key])) { return $documents[$history->document_key]['title']; } return 'Kelayakan Lama'; }; $isMahasiswaHistory = fn($history) => strcasecmp((string) $history->role_pemberi, 'Mahasiswa') === 0; $submittedAtFor = function (string $documentKey, bool $hasDocument) use ($kelayakan) { if (! $hasDocument) { return null; } $history = $kelayakan->catatanHistories ->where('document_key', $documentKey) ->first(fn($item) => strcasecmp((string) $item->role_pemberi, 'Mahasiswa') === 0); return $history?->created_at ?: ($kelayakan->submitted_at ?: $kelayakan->updated_at); }; $visibleHistoryFor = function (?string $documentKey = null) use ($kelayakan, $reviewerRole) { $reviewerHistoryRole = $reviewerRole === 'dosen' ? 'Dosen Pembimbing' : ($reviewerRole === 'pembimbing_lapangan' ? 'Pembimbing Lapangan' : null); return $kelayakan->catatanHistories ->filter(function ($history) use ($documentKey, $reviewerHistoryRole) { $sameDocument = $documentKey === null ? blank($history->document_key) : $history->document_key === $documentKey; if (! $sameDocument) { return false; } if (! $reviewerHistoryRole) { return true; } return strcasecmp((string) $history->role_pemberi, 'Mahasiswa') === 0 || strcasecmp((string) $history->role_pemberi, $reviewerHistoryRole) === 0; }) ->when($documentKey !== null && $kelayakan->wajibUploadUlang(), fn($histories) => $histories->filter(fn($history) => $history->created_at && $history->created_at->greaterThanOrEqualTo($kelayakan->reupload_required_at))) ->values(); }; $documentHistoryFor = function (string $documentKey) use ($visibleHistoryFor, $isMahasiswaHistory) { return $visibleHistoryFor($documentKey) ->filter(fn($history) => $isMahasiswaHistory($history)) ->sortBy('created_at') ->values(); }; $validationHistoryFor = function (?string $documentKey = null) use ($visibleHistoryFor, $isMahasiswaHistory) { return $visibleHistoryFor($documentKey) ->reject(fn($history) => $isMahasiswaHistory($history)) ->values(); }; $historiesWithoutDocument = $kelayakan->catatanHistories->filter(fn($history) => blank($history->document_key)); $statusRingkas = $kelayakan->statusRingkas(); $missingMessages = method_exists($kelayakan, 'missingDocumentMessages') ? $kelayakan->missingDocumentMessages() : []; @endphp @if($isReviewerView)
Validasi Dokumen Kelayakan
Judul Laporan Magang
{{ $kelayakan->pengajuan?->judul_laporan ?: 'Belum tersedia' }}
Uraian Output Magang
{{ $kelayakan->output_magang ?: 'Belum ada uraian output magang.' }}
@foreach($documents as $documentKey => $document) @php $hasDocument = $kelayakan->documentAvailable($documentKey); $currentValidation = $validationFor($documentKey, $reviewerRole); $reviewerHasApproved = ($currentValidation->status ?? 'menunggu') === 'disetujui'; $submittedAt = $submittedAtFor($documentKey, $hasDocument); $revisionId = 'revisi-' . $reviewerRole . '-' . $kelayakan->id . '-' . $documentKey; @endphp
{{ $document['title'] }}
@if($hasDocument)
Submitted: {{ $submittedAt ? $submittedAt->timezone(config('app.timezone'))->format('d/m/Y H:i') : '-' }}
@endif
@if($hasDocument) {{ $reviewerStatusLabel[$currentValidation->status ?? 'menunggu'] ?? 'Menunggu Validasi' }} @endif
@unless($hasDocument) Belum Dikirim @else
@if(!empty($document['path']))
File: {{ $document['original_name'] ?: basename($document['path']) }}
{{ $document['preview'] }} {{ $document['download'] }} @endif @if(!empty($document['link'])) Buka Link Produk @endif
@foreach($roleLabels as $role => $roleLabel) @php $validation = $validationFor($documentKey, $role); @endphp
{{ $roleLabel }} {{ $reviewerStatusLabel[$validation->status ?? 'menunggu'] ?? 'Menunggu' }}
@endforeach
@if($reviewerHasApproved)
Dokumen ini sudah Anda setujui.
@else
@csrf
@csrf
@endif @endunless
@endforeach
Riwayat Dokumen
@foreach($documents as $documentKey => $document) @php $histories = $documentHistoryFor($documentKey); $collapseId = 'reviewer-document-history-' . $kelayakan->id . '-' . $documentKey; @endphp

@forelse($histories as $history)
Versi {{ $loop->iteration }}
{{ $history->catatan ?: '-' }}
@if(!empty($history->file_original_name) || !empty($history->file_path))
File: {{ $history->file_original_name ?: basename($history->file_path) }}
@endif @if(!empty($history->produk_magang_link)) @endif
Oleh: {{ $history->nama_pemberi ?: $history->role_pemberi }}
Waktu: {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
@empty
Belum ada riwayat dokumen aktif.
@endforelse
@endforeach
Riwayat Validasi
@foreach($documents as $documentKey => $document) @php $histories = $validationHistoryFor($documentKey); $collapseId = 'reviewer-validation-history-' . $kelayakan->id . '-' . $documentKey; @endphp

@forelse($histories as $history)
{{ $historyLabel($history) }}
{{ $reviewerStatusLabel[$history->status_tindakan] ?? ucwords(str_replace('_', ' ', $history->status_tindakan)) }}
Oleh: {{ $history->nama_pemberi ?: $history->role_pemberi }}
Waktu: {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
Catatan: {{ $history->catatan ?: '-' }}
@empty
Belum ada riwayat validasi untuk dokumen ini.
@endforelse
@endforeach
@php $visibleOldHistories = ($kelayakan->wajibUploadUlang() || $reviewerRole === 'pembimbing_lapangan') ? collect() : $validationHistoryFor(null); @endphp @if($visibleOldHistories->isNotEmpty())
Riwayat Lama
@foreach($visibleOldHistories as $history)
Kelayakan Lama
{{ $reviewerStatusLabel[$history->status_tindakan] ?? ucwords(str_replace('_', ' ', $history->status_tindakan)) }}
Oleh: {{ $history->nama_pemberi ?: $history->role_pemberi }}
Waktu: {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
Catatan: {{ $history->catatan ?: '-' }}
@endforeach
@endif
@else
Ringkasan Status Kelayakan
Status dihitung dari ketersediaan dokumen dan enam validasi pembimbing.
Status Kelayakan: {{ $statusRingkas }}
@if($missingMessages !== [])
@foreach($missingMessages as $message)
{{ $message }}
@endforeach
@endif
Form / Dokumen Kelayakan
@foreach($documents as $documentKey => $document) @php $hasDocument = $kelayakan->documentAvailable($documentKey); @endphp
{{ $document['title'] }}
@unless($hasDocument)
{{ $document['empty'] }}
Belum Dikirim @endunless
@if(!empty($document['path'])) {{ $document['preview'] }} {{ $document['download'] }} @endif @if(!empty($document['link'])) Buka Link Produk @endif
@endforeach
Uraian Output Magang
{{ $kelayakan->output_magang ?: 'Belum ada uraian output magang.' }}
Status Validasi Dokumen
@foreach($documents as $documentKey => $document) @php $hasDocument = $kelayakan->documentAvailable($documentKey); $documentStatus = $kelayakan->documentValidationStatus($documentKey); @endphp
{{ $document['title'] }}
{{ $statusLabel[$documentStatus] ?? 'Belum Dikirim' }}
@if($hasDocument) @foreach($roleLabels as $role => $roleLabel) @php $validation = $validationFor($documentKey, $role); @endphp
{{ $roleLabel }} {{ $reviewerStatusLabel[$validation->status ?? 'menunggu'] ?? 'Menunggu' }}
@endforeach
Catatan Dosen Pembimbing:
{{ $validationFor($documentKey, 'dosen')?->catatan ?: 'Tidak ada catatan.' }}
Catatan Pembimbing Lapangan:
{{ $validationFor($documentKey, 'pembimbing_lapangan')?->catatan ?: 'Tidak ada catatan.' }}
@else
Dokumen belum dikirim, sehingga validasi pembimbing belum ditampilkan.
@endif
@endforeach
Riwayat Dokumen
@foreach($documents as $documentKey => $document) @php $histories = $documentHistoryFor($documentKey); @endphp
Riwayat Dokumen {{ $document['title'] }}
@forelse($histories as $history)
Versi {{ $loop->iteration }}
{{ $historyLabel($history) }}
{{ $history->nama_pemberi ?: $history->role_pemberi }}
{{ $history->role_pemberi }} - {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
Catatan:
{{ $history->catatan ?: '-' }}
@empty
Belum ada riwayat dokumen untuk dokumen ini.
@endforelse
@endforeach
Riwayat Validasi Dokumen
@foreach($documents as $documentKey => $document) @php $histories = $validationHistoryFor($documentKey); @endphp
{{ $document['history_title'] }}
@forelse($histories as $history)
{{ $historyLabel($history) }} {{ $statusLabel[$history->status_tindakan] ?? ucwords(str_replace('_', ' ', $history->status_tindakan)) }}
{{ $history->nama_pemberi ?: $history->role_pemberi }}
{{ $history->role_pemberi }} - {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
Catatan:
{{ $history->catatan ?: '-' }}
@empty
Belum ada riwayat validasi untuk dokumen ini.
@endforelse
@endforeach @php $oldValidationHistories = $kelayakan->wajibUploadUlang() ? collect() : $historiesWithoutDocument->reject(fn($history) => $isMahasiswaHistory($history)); @endphp @if($oldValidationHistories->isNotEmpty())
Riwayat Kelayakan Lama
@foreach($oldValidationHistories as $history)
Kelayakan Lama {{ $statusLabel[$history->status_tindakan] ?? ucwords(str_replace('_', ' ', $history->status_tindakan)) }}
{{ $history->nama_pemberi ?: $history->role_pemberi }}
{{ $history->role_pemberi }} - {{ optional($history->created_at)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
Catatan:
{{ $history->catatan ?: '-' }}
@endforeach
@endif
@endif