first commit
This commit is contained in:
61
templates/tickets/scanner-view.php
Normal file
61
templates/tickets/scanner-view.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<div id="scanner" style="width: 100%; overflow-x: hidden;"></div>
|
||||
<div class="container">
|
||||
<div id="result"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
const html5QrCode = new Html5Qrcode("scanner");
|
||||
|
||||
const qrCodeSuccessCallback = (decodedText, decodedResult) => {
|
||||
// document.getElementById('result').innerHTML = '<span class="result">' + decodedResult + '</span>';
|
||||
getData(decodedText);
|
||||
};
|
||||
|
||||
const config = {
|
||||
fps: 10,
|
||||
qrbox: {
|
||||
width: 250,
|
||||
height: 250
|
||||
}
|
||||
};
|
||||
|
||||
html5QrCode.start({
|
||||
facingMode: "environment"
|
||||
}, config, qrCodeSuccessCallback);
|
||||
|
||||
const getData = (hash) => {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/scanner/scanner_get_data/',
|
||||
data: {
|
||||
scannerData: hash,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('#result').html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('body').on('click', '#btn-used', function() {
|
||||
var order_id = $("#order-id").val();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/scanner/use_ticket/',
|
||||
data: {
|
||||
order_id: order_id,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
if (response.useStatus == true) {
|
||||
alert("Status zmieniono na 'Wykorzystany'")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user