Perbaikan scanner

This commit is contained in:
pand03
2026-02-13 10:45:47 +07:00
parent 4321bc1fdd
commit d67c4d1d01

View File

@@ -1,8 +1,4 @@
@if (Auth::check())
@extends('layouts.master')
@else
@extends('layouts.apps')
@endif
@section('styles')
<!-- CSS untuk Efek Ceklist -->
@@ -100,18 +96,10 @@
{{ $data->no_pol }}
<input type="hidden" name="no_transaksi" value="{{ $data->no_pol }}">
@else
<div id="reader" style="width:300px;"></div>
<div id="reader" style="width:150px; height=100px;"></div>
<input type="text"
id="barcode_result"
name="barcode_result"
class="form-control mt-3"
placeholder="Hasil scan muncul disini">
{{-- <input type="file"
name="foto_kamera"
accept="image/*"
capture="environment"
class="form-control mb-2"> --}}
{{-- <input type="text" id="barcode_result" name="barcode_result" class="form-control mt-3" placeholder="Hasil scan muncul disini"> --}}
<input type="file" id="barcode_result" name="foto_kamera" accept="image/*" capture="environment" class="form-control mb-2" placeholder="Hasil scan muncul disini">
@endif
</div>
</div>
@@ -210,21 +198,25 @@ class="btn btn-primary px-4 shadow-sm">
<script>
function onScanSuccess(decodedText) {
document.getElementById('barcode_result').value = decodedText;
html5QrcodeScanner.clear();
// Optional: auto kirim ke server
fetch("{{ route('apps.scan') }}", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-TOKEN": "{{ csrf_token() }}"
},
body: JSON.stringify({ code: decodedText })
})
.then(res => res.json())
.then(data => {
console.log(data);
});
// Redirect ke URL
window.location.href = "/apps/" + decodedText;
// document.getElementById('barcode_result').value = decodedText;
// // Optional: auto kirim ke server
// fetch("{{ route('apps.scan') }}", {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// "X-CSRF-TOKEN": "{{ csrf_token() }}"
// },
// body: JSON.stringify({ code: decodedText })
// })
// .then(res => res.json())
// .then(data => {
// console.log(data);
// });
}
let html5QrcodeScanner = new Html5QrcodeScanner(