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 {