From 7b6d7f6d8536df7bcceb0d0c5183d5d66e59743e Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Thu, 12 Feb 2026 13:09:30 +0700 Subject: [PATCH] fix: capture accessnumber in local variable for PDF fetch - Prevents null value in async PDF generation URL after val2 --- app/Views/shared/script_validation.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Views/shared/script_validation.php b/app/Views/shared/script_validation.php index 5819d14..93a7cd9 100644 --- a/app/Views/shared/script_validation.php +++ b/app/Views/shared/script_validation.php @@ -210,10 +210,12 @@ document.addEventListener('alpine:init', () => { headers: { "Content-Type": "application/json" }, body: JSON.stringify({ userid: `${userid}` }) }).then(response => response.json()).then(data => { + // Capture accessnumber before async operations + const currentAccessnumber = accessnumber; if (data.val === 2) { - this.showToast(`Validated (val2): ${accessnumber} - PDF queued`); + this.showToast(`Validated (val2): ${currentAccessnumber} - PDF queued`); // Trigger PDF auto-generation after val2 - fetch(`${BASEURL}/report/${accessnumber}/pdf`).then(res => res.json()).then(pdfData => { + fetch(`${BASEURL}/report/${currentAccessnumber}/pdf`).then(res => res.json()).then(pdfData => { if (pdfData.success) { console.log('PDF generation queued:', pdfData.jobId); } else {