<?php
	include "php_class/class_mysql.php";
	include "php_class/class_mahasiswa.php";
	$DataMahasiswa = new DataMahasiswa;
?>
<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<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();
	
	$('.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+'edit-mahasiswa/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-nonaktif-mahasiswa/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		window.location=''+base+'add-mahasiswa';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Mahasiswa
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Data Mahasiswa</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
     
      <div class="box">
        <div class="box-header">
           <div class="col-sm-5" >
             <div class="form-group">
             <form action="<?php echo $base?>data-mahasiswa-daftar-ulang" name="cmb" method="post">
                <label class="control-label">Pilih Tanggal Pendataran Ulang</label>
                <div class="input-group date form_date" data-date="" data-date-format="dd-mm-yyyy" data-link-field="tglspk">
                    <input required="required" class="form-control" type="text" value="" placeholder="pilih tanggal" >
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    <input type="hidden" id="tglspk" name="tgl" value="" onChange="cmb.submit();"/>
                    <script type="text/javascript">
                        $('.form_date').datetimepicker({
                            language:  'id',
                            weekStart: 1,
                            todayBtn:  1,
                            autoclose: 1,
                            todayHighlight: 1,
                            startView: 2,
                            minView: 2,
                            forceParse: 0
                        });
                    </script>  
                </div>
              </div>
 		    </div>
                       <div class="col-sm-7" >
				</div>
        </div><!-- /.box-header -->
        <div class="box-body">
        <div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>NPM</th>
                    <th>Nama</th>
                    <th>Jurusan</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
            <?php
				$tgl = $_POST['tgl'];
				$tgl = substr($tgl, 0, 10);
            	$JumlahData = $DataMahasiswa->get_mahasiswa_by_tgl_du('',$a,'jumlah', $tgl);
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataMahasiswa->get_mahasiswa_by_tgl_du('id',$a,'', $tgl);
						$KodeMahasiswa = $DataMahasiswa->get_mahasiswa_by_tgl_du('NPM',$a,'', $tgl);
						$Nama = $DataMahasiswa->get_mahasiswa_by_tgl_du('Nama',$a,'', $tgl);
						$Jurusan = $DataMahasiswa->get_mahasiswa_by_tgl_du('Jurusan',$a,'', $tgl);
						$isAktif = $DataMahasiswa->get_mahasiswa_by_tgl_du('isAktif',$a,'', $tgl);
						$kdJurusan =  substr($KodeMahasiswa, 2, 2);
						
						if ($kdJurusan == "31"){
							$Jurusan = "IESP";	
						}elseif ($kdJurusan == "32"){
							$Jurusan = "MANAJEMEN";
						} elseif ($kdJurusan == "33"){
							$Jurusan = "AKUNTANSI";	
						}
						
						
						if ($isAktif=='1'){
							$Status = 'Aktif';
						}else{
							$Status ='Non Aktif';
						}
						echo "<tr id='".$id."' class='odd gradeX context'>";
						echo "<td>".$KodeMahasiswa."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$Jurusan."</td>";
						echo "<td>".$Status."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </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">Edit Data</button></p>
                        <p><button type="button" class="btn btn-default" id="nonaktif">Non Aktif</button></p>
                        <p><button type="button" class="btn btn-primary" id="newdata"><i class='glyphicon glyphicon-plus-sign'></i> Tambah Data</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>
          
          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
