+
+
+
+
+
+
+
HEAVY EQUIPMENT • RKM SYSTEM
+
{{ $category->name ?? $category->unit_category ?? 'ALAT BERAT' }}
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ KODE UNIT:
+
+
+
+ NO. POLISI:
+ -
+
+
+ MEREK & TIPE:
+ -
+
+
+ LOKASI KERJA:
+ -
+
+
+
+
+
+
+
+ Scan QR ini menggunakan kamera HP untuk membuka formulir operasional unit.
+
+
+
+
+
+
+
+
-
HEAVY EQUIPMENT • RKM SYSTEM
-
{{ $category->name ?? $category->unit_category ?? 'ALAT BERAT' }}
+
HEAVY EQUIPMENT • RKM SYSTEM
+
{{ $category->name ?? $category->unit_category ?? 'ALAT BERAT' }}
-
@@ -834,19 +926,19 @@
KODE UNIT:
-
+
NO. POLISI:
- -
+ -
MEREK & TIPE:
- -
+ -
LOKASI KERJA:
- -
+ -
@@ -857,13 +949,13 @@
-
+
Scan QR ini menggunakan kamera HP untuk membuka formulir operasional unit.
-
@@ -871,23 +963,64 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -900,6 +1033,12 @@
Tes Form
+
+
@@ -1144,11 +1283,86 @@
});
// =========================================================================
- // MODAL & STIKER QR CODE HEAVY EQUIPMENT (PRINT & CANVAS PNG DOWNLOAD)
+ // MODAL STIKER QR CODE HEAVY EQUIPMENT (DUAL ORIENTATION: LANDSCAPE & PORTRAIT)
// =========================================================================
let currentQrCode = '';
let currentQrBase64 = '';
let currentSubTitle = '';
+ let currentOrientation = 'landscape'; // Default Landscape
+
+ function setStickerOrientation(orient) {
+ currentOrientation = orient === 'portrait' ? 'portrait' : 'landscape';
+ const isLand = currentOrientation === 'landscape';
+
+ // Update active tab buttons
+ const tabLand = document.getElementById('btnTabLandscape');
+ const tabPort = document.getElementById('btnTabPortrait');
+ if (tabLand && tabPort) {
+ if (isLand) {
+ tabLand.className = "px-3 py-1.5 rounded-lg transition text-slate-800 bg-white shadow-2xs border border-slate-200/60 font-bold flex items-center space-x-1.5 cursor-pointer";
+ tabPort.className = "px-3 py-1.5 rounded-lg transition text-slate-500 hover:text-slate-800 font-semibold flex items-center space-x-1.5 cursor-pointer";
+ } else {
+ tabPort.className = "px-3 py-1.5 rounded-lg transition text-slate-800 bg-white shadow-2xs border border-slate-200/60 font-bold flex items-center space-x-1.5 cursor-pointer";
+ tabLand.className = "px-3 py-1.5 rounded-lg transition text-slate-500 hover:text-slate-800 font-semibold flex items-center space-x-1.5 cursor-pointer";
+ }
+ }
+
+ // Update Card Dialog Width
+ const dialog = document.getElementById('qrModalDialog');
+ if (dialog) {
+ if (isLand) {
+ dialog.classList.remove('max-w-lg');
+ dialog.classList.add('max-w-2xl', 'sm:max-w-3xl');
+ } else {
+ dialog.classList.remove('max-w-2xl', 'sm:max-w-3xl');
+ dialog.classList.add('max-w-lg');
+ }
+ }
+
+ // Toggle Area Visible
+ const areaLand = document.getElementById('printableStickerAreaLandscape');
+ const areaPort = document.getElementById('printableStickerAreaPortrait');
+ if (areaLand && areaPort) {
+ if (isLand) {
+ areaLand.classList.remove('hidden');
+ areaPort.classList.add('hidden');
+ } else {
+ areaLand.classList.add('hidden');
+ areaPort.classList.remove('hidden');
+ }
+ }
+
+ // Update main button labels
+ const printLabel = document.getElementById('btnMainPrintLabel');
+ if (printLabel) printLabel.textContent = isLand ? 'Cetak Landscape' : 'Cetak Potrait';
+ const downloadLabel = document.getElementById('btnMainDownloadLabel');
+ if (downloadLabel) downloadLabel.textContent = isLand ? 'Unduh Landscape (PNG)' : 'Unduh Potrait (PNG)';
+ }
+
+ function toggleQrDropdown(id, event) {
+ if (event) event.stopPropagation();
+ const el = document.getElementById(id);
+ if (!el) return;
+ const isHidden = el.style.display === 'none' || el.classList.contains('hidden');
+ closeAllQrDropdowns();
+ if (isHidden) {
+ el.style.display = 'block';
+ el.classList.remove('hidden');
+ }
+ }
+
+ function closeAllQrDropdowns() {
+ const p = document.getElementById('printDropdownMenu');
+ if (p) { p.style.display = 'none'; p.classList.add('hidden'); }
+ const d = document.getElementById('downloadDropdownMenu');
+ if (d) { d.style.display = 'none'; d.classList.add('hidden'); }
+ }
+
+ document.addEventListener('click', function(e) {
+ if (!e.target.closest('#printDropdownContainer') && !e.target.closest('#downloadDropdownContainer')) {
+ closeAllQrDropdowns();
+ }
+ });
function openQrModal(code, brand, plate, location, url, subTitle, instruction, btn) {
currentQrCode = code;
@@ -1157,35 +1371,42 @@
if (!modal) return;
// Ambil SVG QR Code dari data attribute button
- const container = document.getElementById('modalQrCodeContainer');
const base64Svg = btn ? btn.getAttribute('data-qr-base64') : '';
currentQrBase64 = base64Svg || '';
- if (container && base64Svg) {
+ let decodedSvg = '';
+ if (base64Svg) {
try {
- container.innerHTML = atob(base64Svg);
+ decodedSvg = atob(base64Svg);
} catch(e) {
console.error('Error decoding QR SVG:', e);
}
}
- const elCode = document.getElementById('modalQrCodeText');
- const elPlate = document.getElementById('modalQrPlateText');
- const elBrand = document.getElementById('modalQrBrandText');
- const elLocation = document.getElementById('modalQrLocationText');
- const elUrl = document.getElementById('modalQrUrlDisplay');
- const elSub = document.getElementById('modalQrSubTitle');
- const elInstr = document.getElementById('modalQrInstructionText');
- const testLink = document.getElementById('modalQrTestLink');
+ // Set semua container SVG (Landscape & Portrait)
+ document.querySelectorAll('.modal-qr-container').forEach(c => {
+ if (decodedSvg) c.innerHTML = decodedSvg;
+ });
- if (elCode) elCode.textContent = code;
- if (elPlate) elPlate.textContent = plate || '-';
- if (elBrand) elBrand.textContent = brand || '-';
- if (elLocation) elLocation.textContent = location || '-';
- if (elUrl) elUrl.textContent = url;
- if (elSub) elSub.textContent = currentSubTitle;
- if (elInstr && instruction) elInstr.innerHTML = `
Scan QR ini menggunakan kamera HP untuk ${instruction.replace(/^Scan QR ini menggunakan kamera HP untuk\s*/i, '')}`;
+ // Set semua field teks di Landscape & Portrait
+ document.querySelectorAll('.modal-qr-code-text').forEach(el => el.textContent = code);
+ document.querySelectorAll('.modal-qr-code-badge').forEach(el => el.textContent = code);
+ document.querySelectorAll('.modal-qr-plate-text').forEach(el => el.textContent = plate || '-');
+ document.querySelectorAll('.modal-qr-brand-text').forEach(el => el.textContent = brand || '-');
+ document.querySelectorAll('.modal-qr-location-text').forEach(el => el.textContent = location || '-');
+ document.querySelectorAll('.modal-qr-url').forEach(el => el.textContent = url);
+ document.querySelectorAll('.modal-qr-sub-title').forEach(el => el.textContent = currentSubTitle);
+
+ const cleanInstruction = instruction ? instruction.replace(/^Scan QR ini menggunakan kamera HP untuk\s*/i, '') : 'membuka formulir operasional unit.';
+ document.querySelectorAll('.modal-qr-instruction-text').forEach(el => {
+ el.innerHTML = `
Scan QR ini menggunakan kamera HP untuk ${cleanInstruction}`;
+ });
+
+ const testLink = document.getElementById('modalQrTestLink');
if (testLink) testLink.href = url;
+ // Buka selalu dengan default Landscape
+ setStickerOrientation('landscape');
+
modal.classList.remove('hidden');
document.documentElement.classList.add('modal-open');
document.body.classList.add('modal-open');
@@ -1198,13 +1419,40 @@
document.documentElement.classList.remove('modal-open');
document.body.classList.remove('modal-open');
}
+ closeAllQrDropdowns();
+ }
+
+ function printSticker(orient) {
+ orient = orient || currentOrientation;
+ setStickerOrientation(orient);
+ closeAllQrDropdowns();
+
+ document.body.setAttribute('data-print-mode', orient);
+
+ let styleEl = document.getElementById('dynamicPrintOrientationStyle');
+ if (!styleEl) {
+ styleEl = document.createElement('style');
+ styleEl.id = 'dynamicPrintOrientationStyle';
+ document.head.appendChild(styleEl);
+ }
+ styleEl.innerHTML = `@page { size: ${orient}; margin: 8mm; }`;
+
+ setTimeout(() => {
+ window.print();
+ }, 50);
}
function printQrSticker() {
- window.print();
+ printSticker(currentOrientation);
}
- function downloadQrCode() {
+ // =========================================================================
+ // UNDUH STIKER QR: Pure Canvas API (Landscape & Portrait)
+ // =========================================================================
+ function downloadQrCode(orient) {
+ orient = orient || currentOrientation;
+ closeAllQrDropdowns();
+
const code = (currentQrCode || 'UNIT').toUpperCase().replace(/[^A-Z0-9_-]/g, '');
const btnEl = document.getElementById('btnDownloadSticker');
const originalBtnHtml = btnEl ? btnEl.innerHTML : '';
@@ -1214,18 +1462,18 @@
btnEl.innerHTML = '
Memproses...';
}
- const plate = document.getElementById('modalQrPlateText')?.textContent?.trim() || '-';
- const brand = document.getElementById('modalQrBrandText')?.textContent?.trim() || '-';
- const locationText = document.getElementById('modalQrLocationText')?.textContent?.trim() || '-';
- const urlText = document.getElementById('modalQrUrlDisplay')?.textContent?.trim() || '';
- const subTitleText = document.getElementById('modalQrSubTitle')?.textContent?.trim() || 'HEAVY EQUIPMENT • RKM SYSTEM';
- const categoryText = document.getElementById('modalQrCategoryText')?.textContent?.trim() || '';
+ const plate = document.querySelector('.modal-qr-plate-text')?.textContent?.trim() || '-';
+ const brand = document.querySelector('.modal-qr-brand-text')?.textContent?.trim() || '-';
+ const locationText = document.querySelector('.modal-qr-location-text')?.textContent?.trim() || '-';
+ const urlText = document.querySelector('.modal-qr-url')?.textContent?.trim() || '';
+ const subTitleText = document.querySelector('.modal-qr-sub-title')?.textContent?.trim() || currentSubTitle || 'HEAVY EQUIPMENT • RKM SYSTEM';
+ const categoryText = document.querySelector('.modal-qr-category-text')?.textContent?.trim() || '';
let svgDataUri = '';
if (currentQrBase64) {
svgDataUri = 'data:image/svg+xml;base64,' + currentQrBase64;
} else {
- const svgEl = document.querySelector('#modalQrCodeContainer svg');
+ const svgEl = document.querySelector('.modal-qr-container svg');
if (svgEl) {
const raw = new XMLSerializer().serializeToString(svgEl);
svgDataUri = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(raw)));
@@ -1240,18 +1488,7 @@
const qrImg = new Image();
qrImg.onload = function() {
- const W = 1200;
- const H = 1500;
- const PAD = 50;
- const CW = W - PAD * 2;
- const CH = H - PAD * 2;
- const R = 55;
- const CX = PAD;
- const CY = PAD;
-
const canvas = document.createElement('canvas');
- canvas.width = W;
- canvas.height = H;
const ctx = canvas.getContext('2d');
function roundRect(x, y, w, h, r) {
@@ -1267,180 +1504,388 @@
ctx.closePath();
}
- // 1. Background Luar
- ctx.fillStyle = '#ffffff';
- ctx.fillRect(0, 0, W, H);
+ if (orient === 'landscape') {
+ // ==========================================
+ // CANVAS LANDSCAPE: 1600 x 1000 px
+ // ==========================================
+ const W = 1600;
+ const H = 1000;
+ const PAD = 40;
+ const CW = W - PAD * 2; // 1520
+ const CH = H - PAD * 2; // 920
+ const R = 45;
+ const CX = PAD;
+ const CY = PAD;
- // 2. Bingkai Stiker
- roundRect(CX, CY, CW, CH, R);
- ctx.fillStyle = '#ffffff';
- ctx.fill();
- ctx.strokeStyle = '#0f172a';
- ctx.lineWidth = 5;
- ctx.stroke();
+ canvas.width = W;
+ canvas.height = H;
- // 3. Kop Perusahaan
- const headerCenterX = W / 2;
- let curY = CY + 52;
+ // Background Luar
+ ctx.fillStyle = '#ffffff';
+ ctx.fillRect(0, 0, W, H);
- ctx.textAlign = 'center';
- ctx.fillStyle = '#1b5e20';
- ctx.font = '800 26px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText('PT KERINCI MERANGIN HIDRO', headerCenterX, curY);
+ // Bingkai Stiker
+ roundRect(CX, CY, CW, CH, R);
+ ctx.fillStyle = '#ffffff';
+ ctx.fill();
+ ctx.strokeStyle = '#0f172a';
+ ctx.lineWidth = 5;
+ ctx.stroke();
- curY += 40;
- ctx.fillStyle = '#0f172a';
- ctx.font = '900 32px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText(subTitleText, headerCenterX, curY);
+ // Kop Header
+ let curY = CY + 48;
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#1b5e20';
+ ctx.font = '800 24px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('PT KERINCI MERANGIN HIDRO', CX + 35, curY);
- curY += 30;
- ctx.fillStyle = '#64748b';
- ctx.font = '700 22px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText(categoryText + ' \u2022 RKM SYSTEM', headerCenterX, curY);
+ curY += 38;
+ ctx.fillStyle = '#0f172a';
+ ctx.font = '900 32px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(subTitleText, CX + 35, curY);
- // Garis Pembatas Kop
- curY += 22;
- ctx.strokeStyle = '#0f172a';
- ctx.lineWidth = 3;
- ctx.beginPath();
- ctx.moveTo(CX + 35, curY);
- ctx.lineTo(CX + CW - 35, curY);
- ctx.stroke();
+ curY += 28;
+ ctx.fillStyle = '#64748b';
+ ctx.font = '700 20px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(categoryText ? (categoryText + ' \u2022 RKM SYSTEM') : 'HEAVY EQUIPMENT \u2022 RKM SYSTEM', CX + 35, curY);
- // 4. QR Code
- const qrSize = 580;
- const qrBoxPadding = 22;
- const qrBoxSize = qrSize + qrBoxPadding * 2;
- const qrBoxX = (W - qrBoxSize) / 2;
- curY += 28;
- const qrBoxY = curY;
- const qrX = (W - qrSize) / 2;
- const qrY = qrBoxY + qrBoxPadding;
+ // Big Code Badge on top right
+ ctx.font = '800 34px monospace';
+ const codeWidth = ctx.measureText(code).width;
+ const badgePad = 22;
+ const badgeW = codeWidth + badgePad * 2;
+ const badgeH = 56;
+ const badgeX = CX + CW - 35 - badgeW;
+ const badgeY = CY + 35;
+ roundRect(badgeX, badgeY, badgeW, badgeH, 16);
+ ctx.fillStyle = '#ecfdf5';
+ ctx.fill();
+ ctx.strokeStyle = '#a7f3d0';
+ ctx.lineWidth = 2.5;
+ ctx.stroke();
+ ctx.fillStyle = '#1b5e20';
+ ctx.textAlign = 'center';
+ ctx.fillText(code, badgeX + badgeW / 2, badgeY + 40);
- roundRect(qrBoxX, qrBoxY, qrBoxSize, qrBoxSize, 32);
- ctx.fillStyle = '#ffffff';
- ctx.fill();
- ctx.strokeStyle = '#cbd5e1';
- ctx.lineWidth = 3;
- ctx.stroke();
+ // Garis Pembatas Header
+ curY += 24;
+ ctx.strokeStyle = '#0f172a';
+ ctx.lineWidth = 3;
+ ctx.beginPath();
+ ctx.moveTo(CX + 35, curY);
+ ctx.lineTo(CX + CW - 35, curY);
+ ctx.stroke();
- ctx.drawImage(qrImg, qrX, qrY, qrSize, qrSize);
+ // Body: 2 Kolom (Kiri QR Code, Kanan Info & Panduan)
+ const bodyY = curY + 28;
+ const colLeftW = 580;
+ const colRightX = CX + 35 + colLeftW + 40;
+ const colRightW = CW - 70 - colLeftW - 40;
- // 5. Info Box Detail Unit
- curY = qrBoxY + qrBoxSize + 30;
- const infoX = CX + 40;
- const infoW = CW - 80;
- const infoH = 370;
- const infoR = 28;
+ // Left: QR Code Box
+ const qrBoxSize = 540;
+ const qrBoxX = CX + 35 + (colLeftW - qrBoxSize) / 2;
+ roundRect(qrBoxX, bodyY, qrBoxSize, qrBoxSize, 28);
+ ctx.fillStyle = '#ffffff';
+ ctx.fill();
+ ctx.strokeStyle = '#cbd5e1';
+ ctx.lineWidth = 3;
+ ctx.stroke();
- roundRect(infoX, curY, infoW, infoH, infoR);
- ctx.fillStyle = '#f8fafc';
- ctx.fill();
- ctx.strokeStyle = '#e2e8f0';
- ctx.lineWidth = 2;
- ctx.stroke();
+ // Draw QR Code
+ const qrDrawPadding = 18;
+ ctx.drawImage(qrImg, qrBoxX + qrDrawPadding, bodyY + qrDrawPadding, qrBoxSize - qrDrawPadding * 2, qrBoxSize - qrDrawPadding * 2);
- const rowLeft = infoX + 30;
- const rowRight = infoX + infoW - 30;
- let rowY = curY + 54;
+ // URL below QR Code
+ ctx.textAlign = 'center';
+ ctx.fillStyle = '#94a3b8';
+ ctx.font = '400 20px monospace';
+ ctx.fillText(urlText, qrBoxX + qrBoxSize / 2, bodyY + qrBoxSize + 36);
+
+ // Right: Info Box
+ const infoBoxH = 430;
+ roundRect(colRightX, bodyY, colRightW, infoBoxH, 24);
+ ctx.fillStyle = '#f8fafc';
+ ctx.fill();
+ ctx.strokeStyle = '#e2e8f0';
+ ctx.lineWidth = 2;
+ ctx.stroke();
+
+ let rowY = bodyY + 62;
+ const rowLeft = colRightX + 30;
+ const rowRight = colRightX + colRightW - 30;
+
+ function drawInfoRow(label, value, isBadge, badgeColor, badgeBg, badgeBorder) {
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#64748b';
+ ctx.font = '700 24px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(label, rowLeft, rowY);
+
+ if (isBadge) {
+ ctx.font = '700 26px monospace';
+ const tw = ctx.measureText(value).width;
+ const bx = rowRight - tw - 26;
+ roundRect(bx, rowY - 30, tw + 26, 40, 10);
+ ctx.fillStyle = badgeBg;
+ ctx.fill();
+ ctx.strokeStyle = badgeBorder;
+ ctx.lineWidth = 2;
+ ctx.stroke();
+ ctx.fillStyle = badgeColor;
+ ctx.textAlign = 'left';
+ ctx.fillText(value, bx + 13, rowY);
+ } else {
+ ctx.textAlign = 'right';
+ ctx.fillStyle = '#0f172a';
+ if (value.length > 25) {
+ ctx.font = '700 22px "Plus Jakarta Sans", Arial, sans-serif';
+ } else {
+ ctx.font = '700 25px "Plus Jakarta Sans", Arial, sans-serif';
+ }
+ ctx.fillText(value, rowRight, rowY);
+ }
+
+ rowY += 18;
+ ctx.strokeStyle = '#e2e8f0';
+ ctx.lineWidth = 1.5;
+ ctx.beginPath();
+ ctx.moveTo(rowLeft, rowY);
+ ctx.lineTo(rowRight, rowY);
+ ctx.stroke();
+
+ rowY += 70;
+ }
+
+ drawInfoRow('KODE UNIT:', code, true, '#1b5e20', '#ecfdf5', '#a7f3d0');
+ drawInfoRow('NO. POLISI:', plate, true, '#78350f', '#fffbeb', '#fde68a');
+ drawInfoRow('MEREK & TIPE:', brand, false);
- function drawInfoRow(label, value, isBadge, badgeColor, badgeBg, badgeBorder) {
ctx.textAlign = 'left';
ctx.fillStyle = '#64748b';
ctx.font = '700 24px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText(label, rowLeft, rowY);
+ ctx.fillText('LOKASI KERJA:', rowLeft, rowY);
+ ctx.textAlign = 'right';
+ ctx.fillStyle = '#334155';
+ ctx.font = '700 25px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(locationText, rowRight, rowY);
- if (isBadge) {
- ctx.font = '700 26px monospace';
- const tw = ctx.measureText(value).width;
- const bx = rowRight - tw - 28;
- roundRect(bx, rowY - 30, tw + 28, 40, 10);
- ctx.fillStyle = badgeBg;
- ctx.fill();
- ctx.strokeStyle = badgeBorder;
- ctx.lineWidth = 2;
- ctx.stroke();
- ctx.fillStyle = badgeColor;
- ctx.fillText(value, bx + 14, rowY);
- } else {
- ctx.textAlign = 'right';
- ctx.fillStyle = '#0f172a';
- if (value.length > 25) {
- ctx.font = '700 22px "Plus Jakarta Sans", Arial, sans-serif';
- } else {
- ctx.font = '700 26px "Plus Jakarta Sans", Arial, sans-serif';
- }
- ctx.fillText(value, rowRight, rowY);
- }
-
- rowY += 18;
- ctx.strokeStyle = '#e2e8f0';
- ctx.lineWidth = 1.5;
- ctx.beginPath();
- ctx.moveTo(rowLeft, rowY);
- ctx.lineTo(rowRight, rowY);
+ // Right: Instruction Banner below Info Box
+ const banY = bodyY + infoBoxH + 20;
+ const banH = 100;
+ roundRect(colRightX, banY, colRightW, banH, 20);
+ ctx.fillStyle = '#ecfdf5';
+ ctx.fill();
+ ctx.strokeStyle = '#a7f3d0';
+ ctx.lineWidth = 2;
ctx.stroke();
- rowY += 64;
+ roundRect(colRightX + 20, banY + 20, 60, 60, 16);
+ ctx.fillStyle = '#1b5e20';
+ ctx.fill();
+ ctx.fillStyle = '#ffffff';
+ roundRect(colRightX + 32, banY + 40, 36, 26, 6);
+ ctx.fill();
+ ctx.fillStyle = '#1b5e20';
+ ctx.beginPath();
+ ctx.arc(colRightX + 50, banY + 53, 7, 0, Math.PI * 2);
+ ctx.fill();
+
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#1e293b';
+ ctx.font = '600 20px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('Scan QR ini menggunakan kamera HP untuk membuka', colRightX + 96, banY + 42);
+ ctx.font = '400 20px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('formulir pemeriksaan kelaikan unit & operasional.', colRightX + 96, banY + 72);
+
+ } else {
+ // ==========================================
+ // CANVAS PORTRAIT: 1200 x 1500 px
+ // ==========================================
+ const W = 1200;
+ const H = 1500;
+ const PAD = 50;
+ const CW = W - PAD * 2;
+ const CH = H - PAD * 2;
+ const R = 55;
+ const CX = PAD;
+ const CY = PAD;
+
+ canvas.width = W;
+ canvas.height = H;
+
+ // 1. Background Luar
+ ctx.fillStyle = '#ffffff';
+ ctx.fillRect(0, 0, W, H);
+
+ // 2. Bingkai Stiker
+ roundRect(CX, CY, CW, CH, R);
+ ctx.fillStyle = '#ffffff';
+ ctx.fill();
+ ctx.strokeStyle = '#0f172a';
+ ctx.lineWidth = 5;
+ ctx.stroke();
+
+ // 3. Kop Perusahaan
+ const headerCenterX = W / 2;
+ let curY = CY + 52;
+
+ ctx.textAlign = 'center';
+ ctx.fillStyle = '#1b5e20';
+ ctx.font = '800 26px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('PT KERINCI MERANGIN HIDRO', headerCenterX, curY);
+
+ curY += 40;
+ ctx.fillStyle = '#0f172a';
+ ctx.font = '900 32px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(subTitleText, headerCenterX, curY);
+
+ curY += 30;
+ ctx.fillStyle = '#64748b';
+ ctx.font = '700 22px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(categoryText ? (categoryText + ' \u2022 RKM SYSTEM') : 'HEAVY EQUIPMENT \u2022 RKM SYSTEM', headerCenterX, curY);
+
+ // Garis Pembatas Kop
+ curY += 22;
+ ctx.strokeStyle = '#0f172a';
+ ctx.lineWidth = 3;
+ ctx.beginPath();
+ ctx.moveTo(CX + 35, curY);
+ ctx.lineTo(CX + CW - 35, curY);
+ ctx.stroke();
+
+ // 4. QR Code
+ const qrSize = 580;
+ const qrBoxPadding = 22;
+ const qrBoxSize = qrSize + qrBoxPadding * 2;
+ const qrBoxX = (W - qrBoxSize) / 2;
+ curY += 28;
+ const qrBoxY = curY;
+ const qrX = (W - qrSize) / 2;
+ const qrY = qrBoxY + qrBoxPadding;
+
+ roundRect(qrBoxX, qrBoxY, qrBoxSize, qrBoxSize, 32);
+ ctx.fillStyle = '#ffffff';
+ ctx.fill();
+ ctx.strokeStyle = '#cbd5e1';
+ ctx.lineWidth = 3;
+ ctx.stroke();
+
+ ctx.drawImage(qrImg, qrX, qrY, qrSize, qrSize);
+
+ // 5. Info Box Detail Unit
+ curY = qrBoxY + qrBoxSize + 30;
+ const infoX = CX + 40;
+ const infoW = CW - 80;
+ const infoH = 370;
+ const infoR = 28;
+
+ roundRect(infoX, curY, infoW, infoH, infoR);
+ ctx.fillStyle = '#f8fafc';
+ ctx.fill();
+ ctx.strokeStyle = '#e2e8f0';
+ ctx.lineWidth = 2;
+ ctx.stroke();
+
+ const rowLeft = infoX + 30;
+ const rowRight = infoX + infoW - 30;
+ let rowY = curY + 54;
+
+ function drawInfoRow(label, value, isBadge, badgeColor, badgeBg, badgeBorder) {
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#64748b';
+ ctx.font = '700 24px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(label, rowLeft, rowY);
+
+ if (isBadge) {
+ ctx.font = '700 26px monospace';
+ const tw = ctx.measureText(value).width;
+ const bx = rowRight - tw - 28;
+ roundRect(bx, rowY - 30, tw + 28, 40, 10);
+ ctx.fillStyle = badgeBg;
+ ctx.fill();
+ ctx.strokeStyle = badgeBorder;
+ ctx.lineWidth = 2;
+ ctx.stroke();
+ ctx.fillStyle = badgeColor;
+ ctx.textAlign = 'left';
+ ctx.fillText(value, bx + 14, rowY);
+ } else {
+ ctx.textAlign = 'right';
+ ctx.fillStyle = '#0f172a';
+ if (value.length > 25) {
+ ctx.font = '700 22px "Plus Jakarta Sans", Arial, sans-serif';
+ } else {
+ ctx.font = '700 26px "Plus Jakarta Sans", Arial, sans-serif';
+ }
+ ctx.fillText(value, rowRight, rowY);
+ }
+
+ rowY += 18;
+ ctx.strokeStyle = '#e2e8f0';
+ ctx.lineWidth = 1.5;
+ ctx.beginPath();
+ ctx.moveTo(rowLeft, rowY);
+ ctx.lineTo(rowRight, rowY);
+ ctx.stroke();
+
+ rowY += 64;
+ }
+
+ drawInfoRow('KODE UNIT:', code, true, '#1b5e20', '#ecfdf5', '#a7f3d0');
+ drawInfoRow('NO. POLISI:', plate, true, '#78350f', '#fffbeb', '#fde68a');
+ drawInfoRow('MEREK & TIPE:', brand, false);
+
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#64748b';
+ ctx.font = '700 24px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('LOKASI KERJA:', rowLeft, rowY);
+ ctx.textAlign = 'right';
+ ctx.fillStyle = '#334155';
+ ctx.font = '700 26px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText(locationText, rowRight, rowY);
+
+ // 6. Banner Instruksi Scan
+ curY = curY + infoH + 22;
+ const banH = 104;
+ roundRect(infoX, curY, infoW, banH, 22);
+ ctx.fillStyle = '#ecfdf5';
+ ctx.fill();
+ ctx.strokeStyle = '#a7f3d0';
+ ctx.lineWidth = 2;
+ ctx.stroke();
+
+ roundRect(infoX + 20, curY + 22, 60, 60, 16);
+ ctx.fillStyle = '#1b5e20';
+ ctx.fill();
+
+ ctx.fillStyle = '#ffffff';
+ roundRect(infoX + 32, curY + 42, 36, 26, 6);
+ ctx.fill();
+ ctx.fillStyle = '#1b5e20';
+ ctx.beginPath();
+ ctx.arc(infoX + 50, curY + 55, 7, 0, Math.PI * 2);
+ ctx.fill();
+
+ ctx.textAlign = 'left';
+ ctx.fillStyle = '#1e293b';
+ ctx.font = '600 21px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('Scan QR ini menggunakan kamera HP untuk', infoX + 98, curY + 44);
+ ctx.font = '400 21px "Plus Jakarta Sans", Arial, sans-serif';
+ ctx.fillText('membuka formulir pemeriksaan kelaikan unit & operasional.', infoX + 98, curY + 76);
+
+ // 7. URL Footer
+ curY = curY + banH + 34;
+ ctx.textAlign = 'center';
+ ctx.fillStyle = '#94a3b8';
+ ctx.font = '400 21px monospace';
+ ctx.fillText(urlText, headerCenterX, curY);
}
- drawInfoRow('KODE UNIT:', code, true, '#1b5e20', '#ecfdf5', '#a7f3d0');
- drawInfoRow('NO. POLISI:', plate, true, '#78350f', '#fffbeb', '#fde68a');
- drawInfoRow('MEREK & TIPE:', brand, false);
-
- ctx.textAlign = 'left';
- ctx.fillStyle = '#64748b';
- ctx.font = '700 24px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText('LOKASI KERJA:', rowLeft, rowY);
- ctx.textAlign = 'right';
- ctx.fillStyle = '#334155';
- ctx.font = '700 26px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText(locationText, rowRight, rowY);
-
- // 6. Banner Instruksi Scan
- curY = curY + infoH + 22;
- const banH = 104;
- roundRect(infoX, curY, infoW, banH, 22);
- ctx.fillStyle = '#ecfdf5';
- ctx.fill();
- ctx.strokeStyle = '#a7f3d0';
- ctx.lineWidth = 2;
- ctx.stroke();
-
- roundRect(infoX + 20, curY + 22, 60, 60, 16);
- ctx.fillStyle = '#1b5e20';
- ctx.fill();
-
- ctx.fillStyle = '#ffffff';
- roundRect(infoX + 32, curY + 42, 36, 26, 6);
- ctx.fill();
- ctx.fillStyle = '#1b5e20';
- ctx.beginPath();
- ctx.arc(infoX + 50, curY + 55, 7, 0, Math.PI * 2);
- ctx.fill();
- ctx.fillStyle = '#ffffff';
- roundRect(infoX + 43, curY + 36, 14, 7, 2);
- ctx.fill();
-
- ctx.textAlign = 'left';
- ctx.fillStyle = '#1e293b';
- ctx.font = '600 21px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText('Scan QR ini menggunakan kamera HP untuk', infoX + 98, curY + 44);
- ctx.font = '400 21px "Plus Jakarta Sans", Arial, sans-serif';
- ctx.fillText('membuka formulir pemeriksaan kelaikan unit & operasional.', infoX + 98, curY + 76);
-
- // 7. URL Footer
- curY = curY + banH + 34;
- ctx.textAlign = 'center';
- ctx.fillStyle = '#94a3b8';
- ctx.font = '400 21px monospace';
- ctx.fillText(urlText, headerCenterX, curY);
-
- // Export PNG
+ const orientTitle = orient === 'landscape' ? 'Landscape' : 'Portrait';
const pngUrl = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.href = pngUrl;
- link.download = 'Stiker_QR_' + code + '.png';
+ link.download = 'Stiker_QR_' + code + '_' + orientTitle + '.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
@@ -1452,7 +1897,15 @@
alert('Gagal memuat gambar QR Code. Silakan coba lagi.');
if (btnEl) { btnEl.disabled = false; btnEl.innerHTML = originalBtnHtml; }
};
+
+ qrImg.src = svgDataUri;
}
+
+ document.addEventListener('keydown', function(e) {
+ if (e.key === 'Escape') {
+ closeQrModal();
+ }
+ });
-
@endsection
diff --git a/tests/Feature/QmaBarcodeTest.php b/tests/Feature/QmaBarcodeTest.php
index faee611..610ed1d 100644
--- a/tests/Feature/QmaBarcodeTest.php
+++ b/tests/Feature/QmaBarcodeTest.php
@@ -112,13 +112,20 @@ class QmaBarcodeTest extends TestCase
$response->assertSee(e($expectedUrl));
$response->assertSee('data-qr-base64', false);
- // 3. Modal Stiker QR Code
+ // 3. Modal Stiker QR Code (Dual Orientation: Landscape & Portrait)
$response->assertSee('qrVehicleModal');
- $response->assertSee('printableStickerArea');
+ $response->assertSee('printableStickerAreaLandscape');
+ $response->assertSee('printableStickerAreaPortrait');
+ $response->assertSee('btnTabLandscape');
+ $response->assertSee('btnTabPortrait');
+ $response->assertSee('Landscape');
+ $response->assertSee('Potrait');
$response->assertSee('TIMESHEET KENDARAAN OPERASIONAL');
$response->assertSee('LIGHT VEHICLE (LV) • RKM SYSTEM');
- $response->assertSee('Cetak Stiker');
- $response->assertSee('Unduh PNG');
+ $response->assertSee('Cetak Landscape');
+ $response->assertSee('Cetak Potrait');
+ $response->assertSee('Unduh Landscape (PNG)');
+ $response->assertSee('Unduh Potrait (PNG)');
$response->assertSee('Tes Form');
}
@@ -237,11 +244,18 @@ class QmaBarcodeTest extends TestCase
$expectedStandardUrl = url('/p2h/' . $unitStandard->code);
$response->assertSee(e($expectedStandardUrl));
- // Verifikasi Modal Stiker QR Code Heavy Equipment
+ // Verifikasi Modal Stiker QR Code Heavy Equipment (Dual Orientation: Landscape & Portrait)
$response->assertSee('qrVehicleModal');
- $response->assertSee('printableStickerArea');
- $response->assertSee('Cetak Stiker');
- $response->assertSee('Unduh PNG');
+ $response->assertSee('printableStickerAreaLandscape');
+ $response->assertSee('printableStickerAreaPortrait');
+ $response->assertSee('btnTabLandscape');
+ $response->assertSee('btnTabPortrait');
+ $response->assertSee('Landscape');
+ $response->assertSee('Potrait');
+ $response->assertSee('Cetak Landscape');
+ $response->assertSee('Cetak Potrait');
+ $response->assertSee('Unduh Landscape (PNG)');
+ $response->assertSee('Unduh Potrait (PNG)');
$response->assertSee('Tes Form');
}