<?php 
session_start();
	if($_SESSION['level']!="rekab"){
		header("location:../index.html");
	}
include("header.php"); // memanggil file header.php
include("koneksi.php"); // memanggil file koneksi.php untuk koneksi ke database
$id_author = $_SESSION['id'];
$kelas_siswa = $_SESSION['kelas'];
?>

	<div class="container">
		<div class="content">
			<h2>Selamat datang <b><?php echo $_SESSION['nama']; ?></b> di Aplikasi MPLS berbasis Daring</b></p></h2>
			<hr />
			<P> DI BAWAH INI ADALAH DAFTAR SISWA YANG STATUSNYA BELUM DI VERIFIKASI ATAU MASIH ANTRI </P>

											
			<div class="table-responsive">
				<table class="table table-striped table-hover">
				<tr>
				<th>
			<!-- bagian ini untuk memfilter data berdasarkan kelompok -->
			<form class="form-inline" method="get">
				<div class="form-group">
					<select name="filter" class="form-control" onchange="form.submit()">
						<option value="1">Filter Kelas</option>
						<?php $filter = (isset($_GET['filter']) ? strtolower($_GET['filter']) : NULL);  ?>
						<option value="X AKL 1" <?php if($filter == 'X AKL 1'){ echo 'selected'; } ?>>X AKL 1</option>
						<option value="X AKL 2" <?php if($filter == 'X AKL 2'){ echo 'selected'; } ?>>X AKL 2</option>
						<option value="X AKL 3" <?php if($filter == 'X AKL 3'){ echo 'selected'; } ?>>X AKL 3</option>
						<option value="X AKL 4" <?php if($filter == 'X AKL 4'){ echo 'selected'; } ?>>X AKL 4</option>
						<option value="X OTP 1" <?php if($filter == 'X OTP 1'){ echo 'selected'; } ?>>X OTP 1</option>
						<option value="X OTP 2" <?php if($filter == 'X OTP 2'){ echo 'selected'; } ?>>X OTP 2</option>
						<option value="X OTP 3" <?php if($filter == 'X OTP 3'){ echo 'selected'; } ?>>X OTP 3</option>
						<option value="X BDP 1" <?php if($filter == 'X BDP 1'){ echo 'selected'; } ?>>X BDP 1</option>
						<option value="X BDP 2" <?php if($filter == 'X BDP 2'){ echo 'selected'; } ?>>X BDP 2</option>
						<option value="X BDP 3" <?php if($filter == 'X BDP 3'){ echo 'selected'; } ?>>X BDP 3</option>
						<option value="X BDP 4" <?php if($filter == 'X BDP 4'){ echo 'selected'; } ?>>X BDP 4</option>
						<option value="X UPW" <?php if($filter == 'X UPW'){ echo 'selected'; } ?>>X UPW</option>
						<option value="X PHT 1" <?php if($filter == 'X PHT 1'){ echo 'selected'; } ?>>X PHT 1</option>
						<option value="X PHT 2" <?php if($filter == 'X PHT 2'){ echo 'selected'; } ?>>X PHT 2</option>
						<option value="X MM" <?php if($filter == 'X MM'){ echo 'selected'; } ?>>X MM</option>                    
						
					</select>
				</div>
			</form> <!-- end filter -->
			</th>
			
			<br />
			<!-- memulai tabel responsive -->
			<div class="table-responsive">
				<table class="table table-striped table-hover">
					<tr>
						<th>No</th>
						<th>Materi</th>
						<th>Nama</th>
						<th>Kelas</th>
						<th>Status</th>
									
						
						
						
					</tr>
					<?php
					if($filter){
						$sql = mysqli_query($koneksi, "SELECT * FROM kegiatan WHERE kelas='$filter' and status='ANTRI' ORDER BY nama ASC "); // query jika filter dipilih
					}
					else {
						$sql = mysqli_query($koneksi, "SELECT * FROM kegiatan where status='S' ORDER BY nama ASC"); // jika tidak ada filter maka tampilkan semua entri
					}
					if(mysqli_num_rows($sql) == 0){ 
						echo '<tr><td colspan="14">Silakan Pilih Kelas Di Atas.</td></tr>'; // jika tidak ada entri di database maka tampilkan 'Data Tidak Ada.'
					}else{ // jika terdapat entri maka tampilkan datanya
						$no = 1; // mewakili data dari nomor 1
						while($row = mysqli_fetch_assoc($sql)){ // fetch query yang sesuai ke dalam array
							echo '

							<tr>
								<td>'.$no.'</td>
								<td>'.$row['kegiatan'].'</td>
								<td>'.$row['nama'].'</td>
								<td>'.$row['kelas'].'</td>
								<td>'.$row['status'].'</td>
								<!--<td><a href="list_kegiatan.php?id='.$row['id'].'" class="btn btn-success">LIHAT</span></td>
								
								
								<td>'.$row['kegiatan'].'</td>
								<td>'.$row['uraian'].'</td>
								<td>';
								if($row['status'] == 'BERHASIL'){
									echo '<a class ="btn btn-primary">BERHASIL</span>';
								}
								else if ($row['status'] == 'ANTRI' ){
									echo '<a href="edit.php?id='.$row['id'].'" class="btn btn-warning">VERIFIKASI</span>';
								}
								else if ($row['status'] == 'PENDING' ){
									echo '<a class="btn btn-danger">PENDING</span>';
								}

									echo '</td>
								
								</td> -->
								
							</tr>
							';
							$no++; // mewakili data kedua dan seterusnya <a href="password.php?id_peminat='.$row['id_peminat'].'" title="Ganti Password" data-toggle="tooltip" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></a>
						}
					}
					?>
				</table>

 

			</div> <!-- /.table-responsive -->


		</div> <!-- /.content -->
	</div> <!-- /.container -->


<?php 
include("footer.php"); // memanggil file footer.php
?>


