170 lines
7.7 KiB
PHP
170 lines
7.7 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Scanner</title>
|
|
<script src="/js/html5-qrcode.min.js"></script>
|
|
<script src="/js/tailwind.js"></script>
|
|
<style>
|
|
img{
|
|
margin: auto
|
|
}
|
|
button{
|
|
padding: 10px!important;
|
|
margin: 15px!important;
|
|
border:none!important;
|
|
background: blue!important;
|
|
color: #fff!important;
|
|
font-size: 18px!important;
|
|
border-radius:8px
|
|
}
|
|
#html5-qrcode-button-camera-permission{
|
|
background: orange!important
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body class="container bg-gray-100 pt-6">
|
|
<div style="width: 90%; margin:auto">
|
|
<div id="scanapp_ad">
|
|
<div class="flex justify-center">
|
|
<div style="max-width: 100px; display: inline-block;">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 013.75 9.375v-4.5zM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 01-1.125-1.125v-4.5zM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0113.5 9.375v-4.5z" />
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 6.75h.75v.75h-.75v-.75zM6.75 16.5h.75v.75h-.75v-.75zM16.5 6.75h.75v.75h-.75v-.75zM13.5 13.5h.75v.75h-.75v-.75zM13.5 19.5h.75v.75h-.75v-.75zM19.5 13.5h.75v.75h-.75v-.75zM19.5 19.5h.75v.75h-.75v-.75zM16.5 16.5h.75v.75h-.75v-.75z" />
|
|
</svg>
|
|
</div>
|
|
<div style="display: inline-block; margin-left: 10px">
|
|
<strong>To scan hold a QR code inside the square</strong>
|
|
</div>
|
|
</div>
|
|
<div class="border-rounded m-auto mt-3" style="" id="reader"></div>
|
|
</div>
|
|
<!--Modal-->
|
|
<div class="modal opacity-0 transition-opacity ease-in duration-100 pointer-events-none fixed w-full h-full top-0 left-0 flex items-center justify-center">
|
|
<div class="modal-overlay absolute w-full h-full bg-gray-900 opacity-50"></div>
|
|
|
|
<div class="modal-container bg-white w-11/12 md:max-w-md mx-auto rounded shadow-lg z-50 overflow-y-auto">
|
|
|
|
<div class="modal-close absolute top-0 right-0 cursor-pointer flex flex-col items-center mt-4 mr-4 text-white text-sm z-50">
|
|
<svg class="fill-current text-white" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
|
|
<path d="M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z"></path>
|
|
</svg>
|
|
<span class="text-sm">(Esc)</span>
|
|
</div>
|
|
|
|
<!-- Add margin if you want to see some of the overlay behind the modal-->
|
|
<div class="modal-content py-8 text-left px-8">
|
|
<!--Title-->
|
|
<div class="pb-3">
|
|
<span class="text-gray-400">Name and surname: </span><span id="attender_name" class="text-xl font-bold"></span><br/><br/>
|
|
<span class="text-gray-400">Organization: </span><span id="attender_organization" class="text-xl font-bold"></span><br/><br/>
|
|
<span class="text-gray-400">Photo and video consent: </span><span id="attender_consent" class="text-xl font-bold"></span>
|
|
</div>
|
|
|
|
<!--Footer-->
|
|
<div class="flex justify-end pt-6">
|
|
<button type="button" class="modal-close px-4 bg-blue-500 p-3 rounded-lg text-white hover:bg-blue-400">Close</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
|
|
<script>
|
|
var modal_status = 0;
|
|
const overlay = document.querySelector(".modal-overlay");
|
|
overlay.addEventListener("click", toggleModal);
|
|
|
|
var closemodal = document.querySelectorAll(".modal-close");
|
|
for (var i = 0; i < closemodal.length; i++) {
|
|
closemodal[i].addEventListener("click", toggleModal);
|
|
modal_status = 0;
|
|
}
|
|
|
|
document.onkeydown = function (evt) {
|
|
evt = evt || window.event;
|
|
var isEscape = false;
|
|
if ("key" in evt) {
|
|
isEscape = evt.key === "Escape" || evt.key === "Esc";
|
|
} else {
|
|
isEscape = evt.keyCode === 27;
|
|
}
|
|
if (isEscape && document.body.classList.contains("modal-active")) {
|
|
toggleModal();
|
|
}
|
|
modal_status = 0;
|
|
};
|
|
|
|
function toggleModal() {
|
|
const body = document.querySelector("body");
|
|
const modal = document.querySelector(".modal");
|
|
modal.classList.toggle("opacity-0");
|
|
modal.classList.toggle("pointer-events-none");
|
|
body.classList.toggle("modal-active");
|
|
}
|
|
|
|
// function onScanSuccess(decodedText, decodedResult) {
|
|
// // Handle on success condition with the decoded text or result.
|
|
// console.log(`Scan result: ${decodedText}`, decodedResult);
|
|
// }
|
|
|
|
var html5QrcodeScanner = new Html5QrcodeScanner(
|
|
"reader", { fps: 10, qrbox: 250 });
|
|
html5QrcodeScanner.render(onScanSuccess);
|
|
|
|
var html5QrcodeScanner = new Html5QrcodeScanner(
|
|
"reader", { fps: 10, qrbox: 250 });
|
|
|
|
html5QrcodeScanner.render(onScanSuccess);
|
|
|
|
function onScanSuccess(decodedText, decodedResult) {
|
|
// Handle on success condition with the decoded text or result.
|
|
console.log(`Scan result: ${decodedText}`, decodedResult);
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/post-scan",
|
|
data: {
|
|
id: decodedText
|
|
},
|
|
success: function (response) {
|
|
if(response.success == true){
|
|
$('#attender_name').empty();
|
|
$('#attender_organization').empty();
|
|
$('#attender_consent').empty();
|
|
$('#attender_name').append(response.data.name);
|
|
$('#attender_organization').append(response.data.organization);
|
|
if(response.data.consent_form == 1){
|
|
$('#attender_consent').append("Allowed");
|
|
}
|
|
else{
|
|
$('#attender_consent').append("Declined");
|
|
}
|
|
if(!$("body").hasClass("modal-active")) {
|
|
toggleModal();
|
|
}
|
|
}
|
|
else{
|
|
alert("Internal server error");
|
|
}
|
|
},
|
|
dataType: "json"
|
|
});
|
|
}
|
|
|
|
function onScanError(errorMessage) {
|
|
// handle on error condition, with error message
|
|
}
|
|
|
|
var html5QrcodeScanner = new Html5QrcodeScanner(
|
|
"reader", { fps: 10, qrbox: 250 });
|
|
html5QrcodeScanner.render(onScanSuccess, onScanError);
|
|
</script>
|
|
</body>
|
|
</html>
|