@if(data_get($titleStyle, 'visible', true))
{{ str_replace(["\r\n","\n"], ' ', ($activity->name ?? 'Sertifikat PESERTA')) }}
@endif
@if(data_get($certificateSetting, 'name.visible', false))
{{ $userParticipant->name ?? '-' }}
@endif
@if(data_get($certificateSetting, 'email.visible', false))
{{ $userParticipant->email ?? '-' }}
@endif
@if(data_get($certificateSetting, 'no_hp.visible', false))
{{ $profileParticipant->no_hp ?? '-' }}
@endif
@if(data_get($certificateSetting, 'jenis_kelamin.visible', false))
{{ $profileParticipant->jenis_kelamin ?? '-' }}
@endif
@if(data_get($certificateSetting, 'pekerjaan.visible', false))
{{ $profileParticipant->pekerjaan ?? '-' }}
@endif
@if(data_get($certificateSetting, 'jabatan.visible', false))
{{ $profileParticipant->jabatan ?? '-' }}
@endif
@if(data_get($certificateSetting, 'alamat.visible', false))
{{ $profileParticipant->alamat ?? '-' }}
@endif
@if(data_get($certificateSetting, 'province.visible', false))
{{ $provinceParticipant ?? '-' }}
@endif
@if(data_get($certificateSetting, 'regency.visible', false))
{{ $regencyParticipant ?? '-' }}
@endif
@if(data_get($certificateSetting, 'district.visible', false))
{{ $districtParticipant ?? '-' }}
@endif
@if(data_get($certificateSetting, 'certificate_id.visible', false))
{{ $peserta->certificate_id ?? '-' }}
@endif
@if($photoBase64 && data_get($photoStyle, 'visible', true))
@endif
@php
// Mengambil posisi dan ukuran QR code
// PENTING: Di setting page, QR di-scale oleh JavaScript berdasarkan getCardScale()
// getCardScale() menghitung: scale = currentCardSize (yang di-render) / baseCardSize (defaultValue)
// actual_size adalah ukuran QR yang sudah di-scale untuk preview di setting page
// Di print, card menggunakan ukuran PENUH dari database dalam cm
// Untuk menyamakan ukuran QR di print dengan yang terlihat di setting:
// - Gunakan actual_size jika ada (ukuran yang benar-benar terlihat di setting)
// - Tapi actual_size adalah untuk card yang di-scale di preview, sedangkan di print card adalah ukuran penuh
// - Jadi perlu hitung balik: actual_size / scale_preview = size_input, lalu size_input * scale_print = ukuran di print
// - Tapi lebih mudah: gunakan actual_size dan kalikan dengan inverse scale preview
// - Atau lebih sederhana: jika card di print adalah baseCardSize, QR = actual_size * (baseCardSize / currentCardSize_preview)
// SOLUSI SEDERHANA: Gunakan size input langsung karena di print, card adalah ukuran penuh (100%)
// actual_size adalah untuk card yang di-scale di preview, jadi tidak relevan untuk print
$qrTop = data_get($qrStyle, 'top', 320);
$qrLeft = data_get($qrStyle, 'left', 90);
$qrSizeInput = data_get($qrStyle, 'size', 80);
$qrSizeActual = data_get($qrStyle, 'actual_size');
// Terapkan pengurangan 20px dari ukuran database untuk ukuran yang ditampilkan
$qrSize = max($qrSizeInput - 20, 0);
// DEBUG: Output nilai setting QR code
$debugQr = [
'top' => $qrTop,
'left' => $qrLeft,
'size_input' => $qrSizeInput,
'size_actual' => $qrSizeActual,
'size_used' => $qrSize,
'width_cm' => $widthCm,
'height_cm' => $heightCm,
'qrStyle_raw' => $qrStyle,
'certificateSetting_qr' => data_get($certificateSetting, 'qr', []),
];
@endphp
QR Debug:
Top: {{ $qrTop }}px
Left: {{ $qrLeft }}px
Size Input: {{ $qrSizeInput }}px
Size Actual: {{ $qrSizeActual ?? 'N/A' }}px
Size Used: {{ $qrSize }}px
Raw: {{ json_encode($qrStyle) }}
@php
$qrDataVal = route('activity.download-certificate', ['id' => $activity->id]) . '?show_certificate=1';
try {
$qrBinary = \SimpleSoftwareIO\QrCode\Facades\QrCode::format('png')->size(max($qrSize, 40))->generate((string) $qrDataVal);
$qrBase64 = base64_encode($qrBinary);
$qrSrc = 'data:image/png;base64,'.$qrBase64;
} catch (\Throwable $e) {
$qrSrc = 'https://api.qrserver.com/v1/create-qr-code/?size='.max($qrSize,40).'x'.max($qrSize,40).'&data='.urlencode((string) $qrDataVal);
}
@endphp