-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadminbarcode.php
72 lines (66 loc) · 1.88 KB
/
adminbarcode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
session_start();
if (!isset($_SESSION['adminuid'])){
header("Location:admin.php");
}
include 'config/dependencies.php';
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<?php
include 'assets/includes/head.php';
?>
<body>
<?php
include 'assets/includes/admin-barcode-nav.php';
?>
<?php
$database = new DB;
$handle = $database->connectToDb();
$query = " SELECT * FROM barcode WHERE adminuid = '{$_SESSION['adminuid']}'";
if ($result = $handle->query($query)){
$row = $result->fetch_array();
$day = date('d');
if ($row['date']!=$day){
$code = rand(1234,9999);
$query = "UPDATE barcode SET code = '{$code}', date = '{$day}' WHERE adminuid = '{$_SESSION['adminuid']}'";
$result = $handle->query($query);
}
else{
$code = $row['code'];
}
}
?>
<section class="section">
<div class="container">
<div class="columns">
<div class="column">
<br><br><br><br>
<div class="box">
<h1 class="title">Scan the barcode</h1>
<center>
<script type="text/javascript" src="assets/js/JsBarcode.code128.min.js">
</script>
<svg id="barcode" style="width:100%;height:200px;"></svg>
<script type="text/javascript">
JsBarcode("#barcode", "<?php echo $code; ?>", {
displayValue: false,
});
</script>
</div>
</div>
</div>
</div>
</section>
</body>
<script type="text/javascript">
function showModal(uid,graceId){
document.getElementById('uids').setAttribute("value",uid);
document.getElementById('gids').setAttribute("value",graceId);
document.getElementById('modal').classList = "modal is-active";
}
function closeModal(){
document.getElementById('modal').classList = "modal";
}
</script>
</html>