<?php
$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 60; URL=$url1");
session_start();
	if($_SESSION['status']!="admin"){
		header("location:../logout.php");
	}

include("header.php"); // memanggil file header.php
include("koneksi.php"); // memanggil file koneksi.php untuk koneksi ke database
?>
<script type="text/javascript" src="chartjs/Chart.js"></script>
	<div class="container">
		<div class="content">
			<h2>Statistik Pemilihan Ketua OSIS</h2>
			
			<div style="width: 800px;margin: 0px auto;">
		<canvas id="myChart"></canvas>
	</div>
			<script>
		var ctx = document.getElementById("myChart").getContext('2d');
		var myChart = new Chart(ctx, {
			type: 'bar',
			data: {
				labels: ["no 1", "no 2", "no 3", "no 4", "no 5", "no 6"],
				datasets: [{
					label: '',
					data: [
					<?php 
					$akl = mysqli_query($koneksi,"select * from vote where pilihan='1' and status='BERHASIL'");
					echo mysqli_num_rows($akl);
					?>, 
					<?php 
					$otp = mysqli_query($koneksi,"select * from vote where pilihan='2' and status='BERHASIL'");
					echo mysqli_num_rows($otp);
					?>, 
					<?php 
					$bdp = mysqli_query($koneksi,"select * from vote where pilihan='3' and status='BERHASIL'");
					echo mysqli_num_rows($bdp);
					?>, 
					<?php 
					$pht = mysqli_query($koneksi,"select * from vote where pilihan='4' and status='BERHASIL'");
					echo mysqli_num_rows($pht);
					?>,
					<?php 
					$upw = mysqli_query($koneksi,"select * from vote where pilihan='5' and status='BERHASIL'");
					echo mysqli_num_rows($upw);
					?>,
					<?php 
					$mm = mysqli_query($koneksi,"select * from vote where pilihan='6' and status='BERHASIL'");
					echo mysqli_num_rows($mm);
					?>
					],
					backgroundColor: [
					'rgba(255, 99, 132, 0.2)',
					'rgba(54, 162, 235, 0.2)',
					'rgba(255, 206, 86, 0.2)',
					'rgba(75, 192, 192, 0.2)',
					'rgba(99, 255, 158, 0.2)',
					'rgba(255, 99, 250, 0.2)'
					],
					borderColor: [
					'rgba(255,99,132,1)',
					'rgba(54, 162, 235, 1)',
					'rgba(255, 206, 86, 1)',
					'rgba(75, 192, 192, 1)',
					'rgba(99, 255, 158, 1)',
					'rgba(255, 99, 250, 1)'
					],
					borderWidth: 1
				}]
			},
			options: {
				scales: {
					yAxes: [{
						ticks: {
							beginAtZero:true
						}
					}]
				}
			}
		});
	</script>
	
		
		<p>
</br>		
			<h2>Statistik Pemilih</h2>
			<h3></h3>
			<div style="width: 800px;margin: 0px auto;">
		<canvas id="myChart2"></canvas>
	</div>
			<script>
		var ctx = document.getElementById("myChart2").getContext('2d');
		var myChart2 = new Chart(ctx, {
			type: 'pie',
			data: {
				labels: ["Sudah Vote", "Belum Vote"],
				datasets: [{
					label: '',
					data: [
					<?php 
					$laki = mysqli_query($koneksi,"select * from vote where status='BERHASIL'");
					echo mysqli_num_rows($laki);
					?>, 
					<?php 
					$perempuan = mysqli_query($koneksi,"select * from vote where status='PENDING'");
					echo mysqli_num_rows($perempuan);
					?>
					],
					backgroundColor: [
					'rgba(54, 162, 235, 0.2)',
					'rgba(255, 99, 132, 0.2)',
					'rgba(255, 206, 86, 0.2)',
					'rgba(75, 192, 192, 0.2)'
					],
					borderColor: [
					'rgba(54, 162, 235, 1)',
					'rgba(255,99,132,1)',
					'rgba(255, 206, 86, 1)',
					'rgba(75, 192, 192, 1)'
					],
					borderWidth: 1
				}]
			},
			options: {
				scales: {
					yAxes: [{
						ticks: {
							beginAtZero:true
						}
					}]
				}
			}
		});
	</script>
	
	<p>
</br>		
	
			
		</div> <!-- /.table-responsive -->
		</div> <!-- /.content -->
	</div> <!-- /.container -->
				
				
				<!--<a href="data.php" data-toggle="tooltip" title="Lihat Data Siswa" class="btn btn-info" role="button"><span class="glyphicon glyphicon-list"></span> Lihat Data Siswa</a>
-->				
<!-- <a href="tambahsss.php" data-toggle="tooltip" title="Tambah Data Siswa" class="btn btn-success" role="button"><span class="glyphicon glyphicon-user"></span> Tambah Data</a> -->
			</div> <!-- /.jumbotron -->
		</div> <!-- /.content -->
	</div>
	<!-- End container -->
<?php 
include("footer.php"); // memanggil file footer.php
?>