Compare commits

..

No commits in common. "a2c86b587bb7fe12d04656d7f142e8f5bc1ac066" and "ca11bae56cf26c6e7bda8369650c80289b3073bf" have entirely different histories.

4 changed files with 19 additions and 81 deletions

View file

@ -3,40 +3,10 @@
<head> <head>
<script src="https://unpkg.com/html5-qrcode"></script> <script src="https://unpkg.com/html5-qrcode"></script>
</head> </head>
<style>
#reader {
position: relative;
}
#qr-reader {
position: absolute;
width:800px;
left: 0px;
top: 0px;
}
#wave {
position: absolute;
left: 0px;
top: 0px;
visibility: hidden;
width:800px;
height: 640px;
background-color: #cccccc;
background-image: url('wave.gif');
background-repeat: no-repeat;
background-size: auto;
background-position: center;
}
</style>
<body> <body>
<H1>Osvobozená základní škola - Docházka</H1> <H1>Osvobozená základní škola - Docházka</H1>
<H2>Ukaž svoji školní průkazku</H2> <H2>Ukaž svoji školní průkazku</H2>
<div id="reader"> <div id="qr-reader" style="width:800px; background-color: #cccccc;"></div>
<div id="qr-reader" ></div>
<div id="wave"></div>
</div>
<script> <script>
@ -51,7 +21,7 @@
var at_school = JSON.parse(at_school_json); var at_school = JSON.parse(at_school_json);
console.log(at_school); console.log(at_school);
var result = "<ul>"; var result = "<ul>";
for(var i in at_school){ for (var i = 0; i < at_school.length; i++) {
result += "<li>"+ at_school[i] + "</li>"; result += "<li>"+ at_school[i] + "</li>";
} }
result += "</ul>"; result += "</ul>";
@ -59,16 +29,14 @@
return result; return result;
} }
function onScanSuccess(decodedText, decodedResult) { function onScanSuccess(decodedText, decodedResult) {
const card = JSON.parse(decodedText); // const card = JSON.parse(decodedText);
var fullname = card.name+" "+card.surname; // document.getElementById('qr-reader-results').textContent = card.salutation;
document.getElementById('qr-reader-results').textContent = fullname; document.getElementById('qr-reader-results').textContent = decodedText;
//document.getElementById('qr-reader-results').textContent = decodedText; html5QrcodeScanner.clear();
html5QrcodeScanner.pause();
document.getElementById('wave').style.visibility = "visible"; document.getElementById('wave').style.visibility = "visible";
var formData ={}; var formData ={};
formData.id=card.id; formData.id=33;
formData.name=fullname; formData.name=decodedText;
formData.direction=document.querySelector('input[name="entrance"]:checked').id; formData.direction=document.querySelector('input[name="entrance"]:checked').id;
formData.main=true; formData.main=true;
console.log(JSON.stringify(formData)); console.log(JSON.stringify(formData));
@ -78,13 +46,12 @@
}, },
body:JSON.stringify(formData) body:JSON.stringify(formData)
}).then(response => response.text()) }).then(response => response.text())
.then(data => document.getElementById('qr-reader-results').textContent = data); .then(data => document.querySelector("p.result").innerHTML = data);
//.then(data => document.querySelector("p.result").innerHTML = data);
setTimeout(() => { setTimeout(() => {
document.getElementById('qr-reader-results').textContent = "Načítám ..."; document.getElementById('qr-reader-results').textContent = "Načítám ...";
document.getElementById('wave').style.visibility = "hidden"; document.getElementById('wave').style.visibility = "hidden";
html5QrcodeScanner.resume(); html5QrcodeScanner.render(onScanSuccess);
get_at_school(); get_at_school();
}, 4000); }, 4000);
@ -101,7 +68,9 @@
</label> </label>
<H3>Kdo jsi? </H3> <H3>Kdo jsi? </H3>
<p id="qr-reader-results">Načítám ...</p> <p id="qr-reader-results">Načítám ...</p>
<p class="result"></p>
<H3>Kdo je ve škole</H3> <H3>Kdo je ve škole</H3>
<p id="at-school">Načítám ...</p> <p id="at-school">Načítám ...</p>
<img style = "visibility:hidden" id = "wave" src="giphy.webp"/>
</body> </body>
</html> </html>

View file

@ -29,16 +29,17 @@ $pozadavek = json_decode($postdata);
//check if student is already at school //check if student is already at school
//if not, add him to the list //if not, add him to the list
if ($pozadavek->direction == "P") { if ($pozadavek->direction == "P") {
if( !isset($at_school[$pozadavek->id])) { if( !in_array($pozadavek->name, $at_school)) {
$at_school[$pozadavek->id] = $pozadavek->name; $at_school[] = $pozadavek->name;
} else { } else {
echo $pozadavek->name." už je ve škole"; echo $pozadavek->name." už je ve škole";
return; return;
} }
} else { } else {
//if student is already at school, remove him from the list //if student is already at school, remove him from the list
if( isset($at_school[$pozadavek->id])) { if( in_array($pozadavek->name, $at_school)) {
unset($at_school[$pozadavek->id]); $key = array_search($pozadavek->name, $at_school);
unset($at_school[$key]);
} else { } else {
echo $pozadavek->name." není ve škole"; echo $pozadavek->name." není ve škole";
return; return;
@ -57,8 +58,8 @@ $pruchod = array(
"CteckaId" => "CAM1", "CteckaId" => "CAM1",
"Poznamka" => "" "Poznamka" => ""
); );
$payload = json_encode($pruchod); $payload = json_encode($pruchod)."<br>";
echo $pozadavek->name; echo $payload;
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url.$cesta); curl_setopt($ch, CURLOPT_URL, $url.$cesta);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

View file

@ -1,23 +0,0 @@
<?php
include '../src/osvobdoch_vars.php';
include '../src/osvobdoch_local_vars.php';
$metoda = "GET";
$cesta = "/api/dochazka/v2/pracovnici";
# cas "2016-09-30 11:54:12.637";
date_default_timezone_set('Europe/Prague');
$cas= date("Y-m-d H:i:s");
$data = $metoda ."+".$cesta . "+" . $cas . "+" . $apiheslo;
$hash = hash_hmac("sha1", $data, $key, $raw_output=false);
$auth = $apiuser . ":" . $hash;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url.$cesta);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $metoda);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"com.edookit.Time: ".$cas,
"com.edookit.Auth: ".$auth,
"com.edookit.Client: ".$id
));
$result = curl_exec($ch);
echo $result;
?>

View file

@ -1,9 +0,0 @@
!#/bin/bash
cat students.json | jq -c '.Zaci[]|{id: .PkZak, name: .Jmeno, surname: .Prijmeni }' | while read line; do
id=$(echo $line | jq -r '.id')
name=$(echo $line | jq -r '.name')
surname=$(echo $line | jq -r '.surname')
echo "Processing $name $surname "
qrencode -o "qrcodes/$id.png" $line
convert -size 1000x640 xc:white templates/background.png -geometry 500x460+0+200 -composite templates/logo.png -geometry 420x100+40+40 -composite -background transparent -fill black -size 420x240 -font templates/Quicksand-VariableFont_wght.ttf caption:"$name\n$surname" -geometry +40+220 -composite qrcodes/$id.png -geometry 420x420+540+140 -composite "cards/$name-$surname.png"
done