diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index d61b54c..0a4ae02 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -74,11 +74,6 @@ document.addEventListener('DOMContentLoaded', () => { Verify --}} - - - - - {{-- --}} {{-- --}} {{-- @@ -875,14 +870,36 @@ function cameraCapture() { }); const detectedText = result.data.text.trim(); - // alert("Detected Text:\n" + (detectedText || "[No text detected]")); - // Extract serial numbers (digits only) - const matches = detectedText.match(/\d+/g) || []; - this.serialNumbers = matches.slice(0, 4); // take first 4 serials + // const matches = detectedText.match(/\d+/g) || []; + + // const serialRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i; + // const match = detectedText.match(serialRegex); + + // this.serialNumbers = matches.slice(0, 4); // take first 4 serials + const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i; + const match = detectedText.match(serialWithLabelRegex); + + if (match && match[1]) { + //Scenario Found "Serial No" + this.serialNumbers = [match[1].trim()]; + console.log("Serial with Label:", this.serialNumbers[0]); + } + else + { + //Extract first 4 numbers + const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || []; + this.serialNumbers = generalNums.slice(0, 4); + + if (this.serialNumbers.length == 0) { + alert("No serial numbers detected!"); + return; + } + + console.log("Serial Numbers List:", this.serialNumbers); + } + this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers); - //this.$refs.serialInput.value = JSON.stringify(this.serialNumbers); alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value); - // ✅ Save to Laravel Session using POST API fetch('/save-serials-to-session', { method: 'POST', credentials: 'same-origin', @@ -937,7 +954,6 @@ function cameraCapture() { } }, - async retakePhoto() { this.photoTaken = false; this.$refs.snapshot.classList.add('hidden');