{{-- PDF Preview Card with Inline Annotation (SCROLL MODE - semua halaman ditumpuk & bisa di-scroll) --}} @php $nodeStorageUrl = config('services.node_api.storage_url', env('NODE_STORAGE_URL')); $pdfUrls = [ 'original' => !empty($surat['file_current']) ? $nodeStorageUrl . '/' . $surat['file_current'] : null, 'annotated' => !empty($surat['file_annotated']) ? $nodeStorageUrl . '/' . $surat['file_annotated'] : null, 'numbered' => !empty($surat['file_numbered']) ? $nodeStorageUrl . '/' . $surat['file_numbered'] : null, ]; $userId = auth()->id(); $status = $surat['status'] ?? ''; // Sebelum — Eloquent method, Sesudah — cek array + status $isCreator = $userId === ($surat['created_by'] ?? null); $canApprove = $status === 'pending_approval' && collect($surat['approvals'] ?? []) ->where('approver_id', $userId) ->where('status', 'pending') ->isNotEmpty(); $canSign = $status === 'pending_signature' && ($surat['final_signer_id'] ?? null) == $userId; $canForwardPaurmin = $status === 'pending_paurmin_forward'; $canForwardKasmin = $status === 'pending_kasmin_forward'; $canApproveAsWapang = $status === 'pending_wapang_approval'; $canSignPangwapang = $status === 'pending_pangwapang_signature' && ($surat['final_signer_id'] ?? null) == $userId; $canAnnotate = $canApprove || $canSign || $canForwardPaurmin || $canForwardKasmin || $canApproveAsWapang || $canSignPangwapang; $isSignerMode = ($canSign || $canSignPangwapang) && !$canApprove && !$canForwardPaurmin && !$canForwardKasmin && !$canApproveAsWapang; // Tentukan PDF yang ditampilkan if (!empty($surat['file_numbered'])) { $pdfToShow = 'numbered'; $pdfVersionLabel = 'Versi Final (dengan Nomor Surat)'; $annotatedTabLabel = 'Ditandatangani'; } elseif (!empty($surat['file_annotated'])) { $pdfToShow = 'annotated'; if (!empty($surat['signed_at'])) { $pdfVersionLabel = 'Versi Ditandatangani'; $annotatedTabLabel = 'Ditandatangani'; } elseif ($isSignerMode) { $pdfVersionLabel = 'Tanda Tangan'; $annotatedTabLabel = 'Tanda Tangan'; } else { $pdfVersionLabel = 'Anotasi/Koreksi'; $annotatedTabLabel = 'Anotasi/Koreksi'; } } else { $pdfToShow = 'current'; $pdfVersionLabel = 'Versi Asli'; $annotatedTabLabel = 'Anotasi/Koreksi'; } $canAnnotateOnCurrentPdf = ($canForwardPaurmin || $canForwardKasmin || $canSignPangwapang || $canSign) ? ($pdfToShow === 'current' || $pdfToShow === 'annotated') : ($pdfToShow === 'current'); @endphp @push('styles') @endpush
Dokumen Surat @if($pdfToShow === 'numbered') {{ $pdfVersionLabel }} @elseif($pdfToShow === 'annotated') {{ $pdfVersionLabel }} @endif
@if(!empty($surat['file_current']) || !empty($surat['file_annotated']) || !empty($surat['file_numbered'])) Download @endif
{{-- Toggle between versions (if multiple exist) --}} @if((!empty($surat['file_annotated']) && !empty($surat['file_current'])) || !empty($surat['file_numbered']))
@if(!empty($surat['file_numbered'])) @endif @if(!empty($surat['file_annotated'])) @endif
@endif {{-- Reorderable wrapper for tablet - toolbar moves to bottom --}}
{{-- Annotation Toolbar (for approvers/signers/PAURMIN/KASMIN) --}} @if($canAnnotate && $canAnnotateOnCurrentPdf)
@if($isSignerMode) {{-- SIGNER MODE: Simplified toolbar - only pen with black color, thin stroke --}} {{-- Mobile --}}
{{-- Hidden inputs with fixed values --}}
{{-- Desktop --}}
{{-- Hidden input with fixed black color --}}
@else {{-- APPROVER MODE: Full toolbar with all tools --}} {{-- Mobile: 2 rows layout --}}
{{-- Row 1: Drawing Tools --}}
{{-- Row 2: Color, Size, Actions --}}
{{-- Desktop: Single row layout --}}
{{-- Drawing Tools --}}
{{-- Color & Size --}}
{{-- Actions --}}
@endif
@endif {{-- Info banner for creator when there's annotation --}} @if($isCreator && ($pdfToShow !== 'current'))
Dokumen ini telah diberikan koreksi/anotasi oleh atasan. Silakan periksa anotasi dan upload revisi jika diperlukan.
@endif
@if(!empty($surat['file_current']) || !empty($surat['file_annotated'])) {{-- PDF halaman akan digenerate di sini oleh JS (multi-canvas, ditumpuk & di-scroll) --}} {{-- Loading --}}

Memuat PDF...

@else

Tidak ada file yang tersedia

@endif
{{-- Page Indicator - Outside container at bottom (sekarang scroll-based) --}} @if(!empty($surat['file_current']) || !empty($surat['file_annotated'])) @endif
{{-- End of pdf-preview-reorderable wrapper --}}
{{-- Text Input Modal for Annotation --}} @push('scripts') @endpush