{{-- 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
Memuat PDF...
Tidak ada file yang tersedia