-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
129 lines (117 loc) · 3.19 KB
/
dashboard.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php require_once('header.php'); ?>
<?php
if(!is_admin()) {
echo "<div class='alert alert-danger'>You must be an administrator to view this page!</div>";
die();
}
?>
<div class="page-heaer">
<h1>Dashboard</h1>
</div>
<?php
$db = new database();
$db->query("SELECT count(tbl_ticket.barcode) AS total,
(SELECT count(tbl_ticket.scanned) FROM tbl_ticket WHERE tbl_ticket.scanned = 1) AS scanned
FROM tbl_ticket;");
try {
$db->execute();
} catch (Exception $e) {
echo "Database error: ".$e->getMessage();
}
$stats = $db->single();
$percent = ($stats->scanned/$stats->total) * 100;
$db->query("SELECT count(tbl_log.id) AS invalid FROM scan_log WHERE tbl_log.what = 'IT';");
$db->execute();
$invalidCount = $db->single()->invalid;
$db->query("SELECT count(tbl_log.id) AS duplicates FROM scan_log WHERE tbl_log.what = 'AS';");
$db->execute();
$duplicates = $db->single()->duplicates;
$db->query("SELECT tbl_ticket.ticket,
COUNT(DISTINCT tbl_ticket.barcode) AS total,
SUM(CASE WHEN (tbl_ticket.scanned = 1) THEN 1 ELSE 0 END) AS num_scanned
FROM tbl_ticket
GROUP BY tbl_ticket.ticket");
$db->execute();
$typeBreakdown = $db->resultset();
?>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Total Tickets</h3>
</div>
<div class="panel-body">
<h1>
<?php echo $stats->total;?>
</h1>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Successful Scans</h3>
</div>
<div class="panel-body">
<h1>
<?php echo $stats->scanned;?>
</h1>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Invalid Scans</h3>
</div>
<div class="panel-body">
<h1>
<?php echo $invalidCount;?>
</h1>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title">Duplicate Scans</h3>
</div>
<div class="panel-body">
<h1>
<?php echo $duplicates;?>
</h1>
</div>
</div>
</div>
</div>
<h1>Overall Checkin Progress</h1>
<p>
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $percent;?>%;">
<span class="sr-only"><?php echo $percent;?>% Scanned</span>
<?php echo 100==$percent?'🎉🎉💯🎉🎉':''; ?>
</div>
</div>
</p>
<h1>Breakdown by ticket type</h1>
<table class="table table-condensed table-bordered table-striped">
<thead>
<tr>
<th>Type</th>
<th>Total Tickets</th>
<th>Number Scanned</th>
</tr>
</thead>
<tbody>
<?php foreach ($typeBreakdown as $type) :?>
<tr>
<th><?php echo $type->ticket;?></th>
<td><?php echo $type->total; ?></td>
<td><?php echo $type->num_scanned; ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php require_once('footer.php'); ?>