<?php
	include "php_class/class_mysql.php";
	include "php_class/class_template.php";
	include "php_class/class_mahasiswa.php";
	include "php_class/class_grup.php";
	include "php_class/class_transaksi.php";
	$DataTransaksi = new DataTransaksi;
	$datagrup = new DataGrup;
	$DataMahasiswa = new DataMahasiswa;
	$DataTemplate = new DataTemplate;
?>
<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-7" >
							<?php 
								$ids = $_POST['idkg'];	
								$program = $_POST['program'];
								$tahun = $_POST['tahun'];
								$semeter = $_POST['semester'];
								
								if ($ids == ""){
									if ($xcode == ""){
										$ids = 'G0004';
									}else {
										$ids = $xcode;
									}
								}
								
								if ($program == '122') {
									$program1 = 'Reguler';	
								} else {
									$program1 = 'Non Reguler';
									$program = '121';	
								}						
								
								if ($tahun == '1314') {
									$tahun1 = '2013/2014';	
								} else if ($tahun == '1415') {
									$tahun1 = '2014/2015';
								} else if ($tahun == '1516') {
									$tahun1 = '2015/2016';	
								} else {
									$tahun1 = '2016/2017';
									$tahun = '1617';
								}
								
								if ($semeter == '1') {
									$semeter1 = 'Ganjil';	
								} else {
									$semeter = '2';
									$semeter1 = 'Genap';	
								}
								
								
								$NamaGrup = $datagrup->get_grup_single_by_id('Des', $ids);
								if ($ids != "") {
									echo "<H3 style='margin-bottom:15px;'>Kegiatan : ".$NamaGrup."</h3>";
									echo "<H5 style='margin-bottom:15px;'>Program : ".$program1."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Tahun Akademin: ".$tahun1."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Semester : ".$semeter1."</h5>";
								}
							?>
                        </div>
                        <div class="col-sm-5">
            <button type="submit" class="btn btn-primary" id="setting" style="margin-top:20px; float:right"> <i class="glyphicon glyphicon glyphicon glyphicon-edit" style="padding-right:4px;"></i>Pilih Kegiatan</button>
                        </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>
                </tr>
            </thead>
            <tbody>
            <?php
				$tgl = $_POST['tgl'];
				$tgl = substr($tgl, 0, 10);
            	$JumlahData = $DataMahasiswa->get_mahasiswa_by_tgl_pd('',$a,'jumlah', $tgl);
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
				echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$KodeMahasiswa = $DataMahasiswa->get_mahasiswa_by_tgl_pd('NoPendaftaran',$a,'', $tgl);
						$Nama = $DataMahasiswa->get_mahasiswa_by_tgl_pd('Nama',$a,'', $tgl);
						$Jurusan = $DataMahasiswa->get_mahasiswa_by_tgl_pd('Jurusan',$a,'', $tgl);
						
						echo "<tr>";
						echo "<td>".$KodeMahasiswa."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$Jurusan."</td>";
					echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->

</section>
 
    	
<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(){
	$("#example1").dataTable();
	
  });
</script>

<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">Daftar Mahasiswa</h4>
      </div>
      <div class="modal-body">
          <form action="<?php echo $base?>data-transaksi-all" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">
            <label class="control-label">Pilih Tanggal Transaksi</label>
            <div class="input-group date form_date" data-date="" data-date-format="dd-mm-yyyy" data-link-field="tglspk" style="margin-bottom:20px;">
                <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=""/>
                <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>
            <select class="form-control" name="idkg" style="margin-bottom:20px;">
            <?php 
				if ($ids != "") {
                	echo "<option value='".$ids."'>".$NamaGrup."</option>";
				}else{
					echo "<option value=''>-Pilih Kegiatan-</option>";	
				}
			?>

                    <?php 
                        $JumlahData = $datagrup->get_grup_all('',$a,'jumlah');	
                            for ($a=1;$a<=$JumlahData;$a++){
                            $id = $datagrup->get_grup_all('idGrup',$a,'');
                            $Nama = $datagrup->get_grup_all('Des', $a, '');
                        echo "<option value=".$id.">".$Nama."</option>";
                        }
                    ?>
            </select>

            <select class="form-control" name="program"  style="margin-bottom:20px;">
            <?php 
				if ($program1 != "") {
                	echo "<option value='".$program."'>".$program1."</option>";
				}else{
					echo "<option value=''>-Pilih Program-</option>";	
				}
			?>
                <option value="122">Reguler</option>
                <option value="121">Non Reguler</option>
            </select>
            <select class="form-control" name="tahun"  style="margin-top:20px;">
            <?php 
				if ($tahun != "") {
                	echo "<option value='".$tahun."'>".$tahun1."</option>";
				}else{
					echo "<option value=''>-Pilih Tahun Akademik-</option>";	
				}
			?>
            
                <option value="1314">2013/2014</option>
                <option value="1415">2014/2015</option>
                <option value="1516">2015/2016</option>
                <option value="1617">2016/2017</option>

            </select>
            <select class="form-control" name="semester" style="margin-top:20px;">
            <?php 
				if ($semeter != "") {
                	echo "<option value='".$semeter."'>".$semeter1."</option>";
				}else{
					echo "<option value=''>-Pilih Semester-</option>";	
				}
			?>
                <option value="1">Ganjil</option>
                <option value="2">Genap</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();
		});
	});
