<?php
	include "php_class/class_mysql.php";
	include "php_class/class_soal.php";
	include "php_class/class_mahasiswa.php";
	$DataSoal = new DataSoal;
	$DataMahasiswa = new DataMahasiswa;
?>
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
	
	$("#example1").dataTable();
		$("#setting").click(function(){
			$("#myModal").modal('show');
		});
	$('.context').click(function(e){
		var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});
	
	/*$('.context').bind('contextmenu', function(e){
		e.preventDefault();
    	var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});*/
	
	$('#editdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'query-delete-hasil-ujian/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-nonaktif-operator/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		window.location=''+base+'add-operator';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Hasil Ujian
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Data Hasil Ujian</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
     
      <div class="box">
        <div class="box-body">
			<div class="row">
                        <div class="col-sm-7" >
							<?php 
								$tahun = $_POST['tahun'];
					
								if ($tahun == ""){
									$tahun = date('y');
								}
									$cetakTahun = "20".$tahun;
									echo "<H3 style='margin-bottom:35px;'>Tahun Pendaftaran: ".$cetakTahun."</h3>";
							?>
                        </div>
                        <div class="col-sm-5">
            <button type="submit" class="btn btn-primary" id="setting" style="float:right; margin-bottom:35px;"> <i class="glyphicon glyphicon glyphicon glyphicon-edit" style="padding-right:4px;"></i>Pilih Tahun</button>
                        </div>
                    </div >
                  <div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No Pendaftaran</th>
                    <th>Nama Mahasiswa</th>
                    <th>Jurusan</th>
                    <th>Nilai</th>
                    <th>Keterangan</th>
                    <th>Tanggal</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataSoal->get_hasil_ujian('',$a,'jumlah', $tahun);
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$no = $DataSoal->get_hasil_ujian('id',$a,'', $tahun);
						$id = $DataSoal->get_hasil_ujian('NoPendaftaran',$a,'', $tahun);
						$Nama = $DataSoal->get_hasil_ujian('Nama', $a, '', $tahun);
						$Jurusan = $DataSoal->get_hasil_ujian('Jurusan', $a, '', $tahun);
						$Nilai = $DataSoal->get_hasil_ujian('Nilai',$a,'', $tahun);
						$Keterangan = $DataSoal->get_hasil_ujian('Keterangan',$a,'', $tahun);
						$tanggal = $DataSoal->get_hasil_ujian('tanggal',$a,'', $tahun);
						$b	= $b + 1;

						echo "<tr id='".$no."' class='odd gradeX context'>";
						echo "<td>".$id."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$Jurusan."</td>";
						echo "<td>".$Nilai."</td>";
						echo "<td>".$Keterangan."</td>";
						echo "<td>".$tanggal."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </div>
            <div class="col-sm-7" >
                    <?php
                        date_default_timezone_set('UTC');
                    ?>
                    <h4>Jumlah Mahasiswa : <?php echo $b?></h4>

            </div>
            <div class="col-sm-5">
                          <form action="<?php echo $base?>tabel-hasil-ujian.php" method="post" name="cmb" style="float:right" id="cmb" target="_blank">
                                <input type="hidden" name="tahun" value="<?php echo $tahun?>">
                                <button type="submit" class="btn btn-primary" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon-print"></i> Export Excel</button>
                         </form>   

            </div>
          <div id="menuklik" class="modal fade" role="dialog">
          	<div class="modal-dialog modal-sm">
                <div class="modal-content">
                	<div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h5 class="modal-title">Aksi</h5>
                    </div>
                  	<div class="modal-body">
                        <input type="hidden" value="" id="kodekunci">
                        <div align="center">
                        <p><button type="button" class="btn btn-default" id="editdata">Batalkan</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>
          
          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Setting Transaksi</h4>
      </div>
      <div class="modal-body">
          <form action="<?php echo $base?>data-hasil-ujian" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">
            <select class="form-control" name="tahun"  style="margin-top:20px;">
            <?php 
                	echo "<option value='".$tahun."'>".$cetakTahun."</option>";
			?>
                    <?php 
					
					
                        $JumlahData = $DataMahasiswa->get_tahun_pendaftaran('',$a,'jumlah');	
                            for ($a=1;$a<=$JumlahData;$a++){
                            $tahun = $DataMahasiswa->get_tahun_pendaftaran('tahun',$a,'');
							$cetakTahun = "20".$tahun;
                       		echo "<option value=".$tahun.">".$cetakTahun."</option>";

                        }
                    ?>
                    

            </select>
            <button type="submit" class="btn btn-primary" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon glyphicon-ok-circle"></i> OK</button>
         </form>   
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
	$(document).ready(function(){
		$('.pilih').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				kodeMhs = pecah[0];
				npm = pecah[1];
				nama = pecah[2];
				jurusan = pecah[3];
				alamat = pecah[4];
				
			$('#kodeMhs').val(kodeMhs);
			$('#NPM').val(npm);
			$('#nn').val(npm);
			$('#Nama').val(nama);
			$('#alamat').val(alamat);
			$('#jurusan').val(jurusan);
			$('#myModal').modal('hide')
			$('#Nama').focus();
		});
	});
