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