-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadExitPage.php
262 lines (242 loc) · 10 KB
/
loadExitPage.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
require_once("config.php");
require("Library.php");
//---select data-----
$sql = "SELECT count(*) as A FROM vote";
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$sql = "SELECT count(*) as A FROM mahasiswa, akun WHERE mahasiswa.NPM = akun.USERNAME and validasi = 1 and akun.admin = 0";
$stmt = $db->prepare($sql);
$stmt->execute();
$jumlahMhs = $stmt->fetch(PDO::FETCH_ASSOC);
$koneksi = mysqli_connect("localhost", "root", "", "pemilu");
$noUrut = mysqli_query($koneksi, "SELECT * FROM VOTE GROUP BY NO_URUT");
$count = mysqli_query($koneksi, "SELECT COUNT(NO_URUT) as A FROM VOTE GROUP BY NO_URUT");
$angkatan = mysqli_query($koneksi, "SELECT mahasiswa.angkatan as angkatan from vote join mahasiswa WHERE mahasiswa.npm = vote.NPM GROUP By Angkatan");
$countAngkatan = mysqli_query($koneksi, "SELECT COUNT(Angkatan) as FrekuensiAngkatan from vote join mahasiswa WHERE mahasiswa.npm = vote.NPM GROUP By Angkatan");
$jurusan = mysqli_query($koneksi, "SELECT mahasiswa.Jurusan from vote join mahasiswa WHERE mahasiswa.npm = vote.NPM GROUP By Jurusan");
$countJurusan = mysqli_query($koneksi, "SELECT COUNT(Jurusan) as FrekuensiJurusan from vote join mahasiswa WHERE mahasiswa.npm = vote.NPM GROUP By Jurusan");
$No = array();
?>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body class="bg-primary">
<!-- Earnings (Monthly) Card Example -->
<div class="mt-5">
<div class="card border-left-success shadow ">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">Jumlah Suara Masuk</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo number_format(($result["A"] / $jumlahMhs["A"] * 100), 2, ".", "") . "%"; ?></div>
</div>
<div class="col-auto">
<i class="fas fa-user-check fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<div class='row justify-content-around align-items-around' style='margin-bottom:50px;'>
<?php
$Lib = new Library();
//mengambil data dari tabel kandidat
$show = $Lib->showKandidatVote();
while (($data = $show->fetch(PDO::FETCH_OBJ)) && ($b = mysqli_fetch_array($count))) {
$no[] = $b['A'];
?>
<?php
//select dari table mahasiswa untuk mengambil data kandidat dari mahasiswa
$showData = $Lib->showPerson($data->NPM);
$dataMhs = $showData->fetch(PDO::FETCH_OBJ);
?>
<!-- Card Example -->
<div class="col-xl col-md-6 mt-4">
<div class="card border-left-primary shadow">
<div class="card-body pb-0 pt-0">
<div class="row no-gutters align-items-center">
<div class="col-6 pl-3">
<div class="h1 font-weight-bold text-primary text-uppercase mb-1">#<?php echo $data->NO_URUT ?></div>
<div class="h7 font-weight-bold text-secondary text-uppercase mb-1"><?php echo $dataMhs->Nama ?></div>
<div class="h3 mb-0 font-weight-bold text-gray-800"><?php echo number_format($b['A']*100/$jumlahMhs['A'],2,'.','') ?>%</div>
</div>
<div class="col-6">
<div class="chart-pie w-5 pr-3 pl-3">
<canvas id="myPieChart<?php echo $data->NO_URUT ?>"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }; ?>
<?php
?>
<!-- Page level plugins -->
<script src="vendor/chart.js/Chart.min.js"></script>
<script>
// Set new default font family and font color to mimic Bootstrap's default styling
Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#858796';
var ctx = document.getElementById("myPieChart1");
ctx.height = 50;
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [ "A", "null"],
datasets: [{
label: '# of Votes',
data: [<?php echo number_format($no[0]*100/$jumlahMhs['A'],2,'.','') ?>, 100-<?php echo number_format($no[0]*100/$jumlahMhs['A'],2,'.','') ?>],
backgroundColor: ['#4e73df'],
hoverBackgroundColor: ['#4e73df'],
hoverBorderColor: "rgba(234, 236, 244, 1)",
borderWidth: 0
}]
},
options: {
animation: {
duration : 0,
},
responsive: true,
maintainAspectRatio: false,
tooltips: {
backgroundColor: "rgba(0,0,0,0)",
bodyFontColor: "rgba(255,255,255,0)",
borderColor: 'rgba(255,255,255,0)',
borderWidth: 1,
xPadding: 15,
yPadding: 15,
displayColors: false,
caretPadding: 10,
},
legend: {
display: false,
fullWidth : false,
position : 'bottom',
boxWidth : '1000',
padding : 30,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
},
layout: {
padding: {
left: 0,
right: 0,
top: 0,
bottom: 0
}
},
cutoutPercentage: 80,
},
});
var ctx = document.getElementById("myPieChart2");
ctx.height = 50;
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [ "A", "null"],
datasets: [{
label: '# of Votes',
data: [<?php echo number_format($no[1]*100/$jumlahMhs['A'],2,'.','') ?>, 100-<?php echo number_format($no[1]*100/$jumlahMhs['A'],2,'.','') ?>],
backgroundColor: ['#4e73df'],
hoverBackgroundColor: ['#4e73df'],
hoverBorderColor: "rgba(234, 236, 244, 1)",
borderWidth: 0
}]
},
options: {
animation: {
duration : 0,
},
responsive: true,
maintainAspectRatio: false,
tooltips: {
backgroundColor: "rgba(0,0,0,0)",
bodyFontColor: "rgba(255,255,255,0)",
borderColor: 'rgba(255,255,255,0)',
borderWidth: 1,
xPadding: 15,
yPadding: 15,
displayColors: false,
caretPadding: 10,
},
legend: {
display: false,
fullWidth : false,
position : 'bottom',
boxWidth : '1000',
padding : 30,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
},
layout: {
padding: {
left: 0,
right: 0,
top: 0,
bottom: 0
}
},
cutoutPercentage: 80,
},
});
var ctx = document.getElementById("myPieChart3");
ctx.height = 50;
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [ "A", "null"],
datasets: [{
label: '# of Votes',
data: [<?php echo number_format($no[2]*100/$jumlahMhs['A'],2,'.','') ?>, 100-<?php echo number_format($no[2]*100/$jumlahMhs['A'],2,'.','') ?>],
backgroundColor: ['#4e73df'],
hoverBackgroundColor: ['#4e73df'],
hoverBorderColor: "rgba(234, 236, 244, 1)",
borderWidth: 0
}]
},
options: {
animation: {
duration : 0,
},
responsive: true,
maintainAspectRatio: false,
tooltips: {
backgroundColor: "rgba(0,0,0,0)",
bodyFontColor: "rgba(255,255,255,0)",
borderColor: 'rgba(255,255,255,0)',
borderWidth: 1,
xPadding: 15,
yPadding: 15,
displayColors: false,
caretPadding: 10,
},
legend: {
display: false,
fullWidth : false,
position : 'bottom',
boxWidth : '1000',
padding : 30,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
},
layout: {
padding: {
left: 0,
right: 0,
top: 0,
bottom: 0
}
},
cutoutPercentage: 80,
},
});
</script>
</body>
</html>