<?php
	include "php_class/class_mysql.php";
	include "php_class/class_skk.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;
	$Dataskk = new DataSkk;

	$id = $xcode;
?>
<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>
<script>
	$(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
		$("#setting").click(function(){
			$("#myModal").modal('show');
		});
		$('.context').click(function(e){
			var kode = $(this).attr('id');
			var noTrx = $(this).attr('noTrx');
			var nopendaftaran = $(this).attr('nopendaftaran');
			
			$('#kodekunci').val(kode);
			$('#noTrx').val(noTrx);
			$('#nopendaftaran').val(nopendaftaran);
			$("#menuklik").modal('show');
		});
		$("#Nama").click(function(){
			$("#myModal").modal('show');
		});
		$("#batal").click(function(){
			$('#form1').hide();
			$('#NPM').val() = '';
		});
		$("#AddTrans").click(function(){
			$("#myModal2").modal('show');
		});

		$('#cetak').click(function(){
			var kode = $('#kodekunci').val();
			window.location=''+base+'cetak-pendaftaran/'+ kode +'';
		});

		$('#cetak2').click(function(){
			var kode = $('#kodekunci').val();
			var noTrx = $('#noTrx').val();
			window.location=''+base+'cetak-daftar-ulang/'+ kode +'/'+ noTrx +'';
		});

		$('#delete').click(function(){
			var noTrx = $('#noTrx').val();
			var nopendaftaran = $('#nopendaftaran').val();
			if (confirm("Anda yakin menghapus data ini?")){
				window.location=''+base+'query-delete-pendaftaran/'+ noTrx +'/'+ nopendaftaran +'';	
			}
		});
		$('#NPM').keyup(function(e){
	  		if(e.keyCode == 13){
				var npm = $('#NPM').val();
				var action = '3';
				var program = $('#program').val();
				var tahun = $('#tahun').val();
				var semester = $('#semester').val();
				var idgrup = $('#idgrup').val();
				if (npm==''){
					$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">NPM Masih Kosong!</div></div>')			
				}else{
					$.ajax({
						type:"POST",
						data: "index=" + npm + "&program=" + program + "&tahun=" + tahun + "&semester=" + semester + "&grup=" + idgrup ,
						url:"<?php echo $base?>cek-npm.php",     
						success: function(data){
							var tampung = data;
							if(tampung!=404){
								$('#form1').show();
								var pecah=tampung.split(":");
								$('#Nama2').val(pecah[0]);
								$('#jurusan').val(pecah[1]);
								$('#alamat').val(pecah[2]);
								$('#kodeMhs').val(pecah[3]);
								$('#nn').val(pecah[4]);
								$('#Nama3').val(pecah[0]);
								status = pecah[5];
								statuskelas = pecah[6];
								
								if (statuskelas == "tidak") {
									$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Kelas dengan NPM yang diinput tidak sesuai!</div></div>')
								$('#simpan').hide();
								} else if (status == "ada") {
									$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Mahasiswa ini sudah melakukan pembayaran untuk transaksi ini!</div></div>')
								$('#simpan').hide();

								}else {
								$('.peringatan').html('<div id="warning"><div role="alert"></div></div>')
								$('#simpan').show();
								$('#simpan').focus();	
									}
							}else{
								$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Mahasiswa dengan NPM ini tidak ditemukan!</div></div>')
								$('#NPM').focus();	
								}
						}
					});
				}
			} 
		});

	});
</script>
<section class="content-header">
  <h1>
   Data SKK
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
  </ol>
</section>
<section class="content">
 	<div class="row">
    	<div class="row">
        	<div class="col-md-12">
            </div>
        </div>
    	<div class="col-md-12">
        	 <div class="box box-info">
                <div class="box-body">
					<div class="row">
                        <div class="col-sm-7" >
							<?php 
							$jurusan = $_POST['jurusan'];
							$cetakjurusan = $jurusan;
							$tahun = $_POST['tahun'];
							$Semester1 = $_POST['Semester1'];

									if ($jurusan == "31"){
										$cetakjurusan = "IESP";	
									}elseif ($jurusan == "32"){
										$cetakjurusan = "MANAJEMEN";
									} elseif ($jurusan == "33"){
										$cetakjurusan = "AKUNTANSI";	
									}else{
										$cetakjurusan = 'Semua';
									}			
								
								
								
								
								
									if ($Semester1 == ''){
										$cetakSemester = 'Semua';	
									}else {
										$cetakSemester = $Semester1;
										}
										
									echo "<H3 style='margin-bottom:15px;'>Jurusan : ".$cetakjurusan."</h3>";
									echo "<H5 style='margin-bottom:15px;'>Angkatan : ".$tahun."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Semester : ".$cetakSemester."</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>Setting</button>
                        </div>
                    </div >	 
                       <div class="table-responsive" style="margin-top:30px;">
                          <table  class="table table-striped">
                             <thead>
                                <tr>
                                    <th>NPM</th>
                                    <th>Nama Mahasiswa</th>
                                    <th>Semester</th>
				    <th>Tahun Akademik</th>
                                    <th>Total</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
								$JumlahData = $Dataskk->get_rekap('',$a,'jumlah', $tahun, $jurusan, $Semester1);
                                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 "</tr>";	
                                }else{
                                    
									for ($a=1;$a<=$JumlahData;$a++){
										$NPM = $Dataskk->get_rekap('NPM',$a,'', $tahun, $jurusan, $Semester1);
                                        					$Nama = $Dataskk->get_rekap('Nama',$a,'', $tahun, $jurusan, $Semester1);
										$Semester = $Dataskk->get_rekap('semester',$a,'', $tahun, $jurusan, $Semester1);
										$Total = $Dataskk->get_rekap('total',$a,'', $tahun, $jurusan, $Semester1);
										$tahunAkademik = $Dataskk->get_rekap('tahunAkademik',$a,'', $tahun, $jurusan, $Semester1);
                                        echo "<tr id='".$kunci."' noTrx = '".$no."' nopendaftaran = '".$NoPendaftaran."' class='odd gradeX'>";
                                        echo "<td>".$NPM."</td>";
                                        echo "<td>".$Nama."</td>";
										echo "<td>".$Semester."</td>";
										echo "<td>".$tahunAkademik."</td>";
										echo "<td>".$Total."</td>";

                                        echo "</tr>";
                                    }
                                }
                            ?>
                            </tbody>
                          </table>
          			</div>
                    <div class="col-sm-7" >
                    </div>
                    <div class="col-sm-5">
                      <form action="<?php echo $base?>tabel-rekap-skk.php" method="post" name="cmb" style="float:right" id="cmb" target="_blank">
                                <input type="hidden" name="tahun" value="<?php echo $tahun?>" />
                                <input type="hidden" name="jurusan" value="<?php echo $jurusan?>" />
                                <input type="hidden" name="Semester1" value="<?php echo $Semester1?>" />
                            <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>
             </div> 
        	 
         </div>
    </div>
</section>
          <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">
                        <input type="hidden" value="" id="noTrx">
                        <input type="hidden" value="" id="nopendaftaran">
                        <div align="center">
                        <?php if ($kegiatan1 == 'Pendaftaran Mahasiswa'){?>
                        <p><button type="button" class="btn btn-primary" id="cetak"><i class='glyphicon glyphicon-print'></i>Cetak</button></p>
                        <?php }else{ ?>
                        <p><button type="button" class="btn btn-primary" id="cetak2"><i class='glyphicon glyphicon-print'></i>Cetak</button></p>
                       	<?php } ?>
                        <p><button type="button" class="btn btn-primary" id="delete"><i class='glyphicon glyphicon-delete'></i>Batalkan</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>

    	
<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">Setting</h4>
      </div>
      <div class="modal-body">
          <form action="<?php echo $base?>data-rekap-skk" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">
            <div class="form-group">
                <label class="control-label">Jurusan</label>
                <select class="form-control" name="jurusan">
                <?php 
                    if ($jurusan != "") {
                        echo "<option value='".$jurusan."'>".$cetakjurusan."</option>";
                    }
                        echo "<option value=''>Semua</option>";	
                ?>
                    <option value="31">IESP</option>
                    <option value="33">AKUNTANSI</option>
                    <option value="32">MANAJEMEN</option>

                </select>
			</div>
            <div class="form-group">
                <label class="control-label">Tahun Akademik</label>
                <select class="form-control" name="tahun" >
                <?php 
                    if ($tahun != "") {
                        echo "<option value='".$tahun."'>".$tahun."</option>";
                    }
			echo "<option value=''>".$tahun."</option>";
                ?>
                    <?php 
					
					
                        $JumlahData = $DataMahasiswa->get_all_angkatan('',$a,'jumlah');	
                            for ($a=1;$a<=$JumlahData;$a++){
                            $angkatan = $DataMahasiswa->get_all_angkatan('angkatan',$a,'');
							if ($angkatan == '08'){
								$upAngkatan = '09';
							}else if ($angkatan == '07'){
								$upAngkatan = '08';
							}else if ($angkatan == '06'){
								$upAngkatan = '07';
							}else
{
                            	$upAngkatan = $angkatan + 1;
							}
							

							$tahun = $angkatan.$upAngkatan;
							$tahun1 = "20".$angkatan."/20".$upAngkatan;
                       		echo "<option value=".$tahun1.">".$tahun1."</option>";

                        }
                    ?>
                        
    
                </select>
                </div>
            <div class="form-group">
                <label class="control-label">SEMESTER</label>
                <select class="form-control" name="Semester1" >
					<?php if($Semester1 == ''){
                                echo "<option value=''>Semua</option>";
						}else{
                                echo "<option value=".$Semester1.">".$Semester1."</option>";
							} ?>
                            
                    <option value="">Semua</option>
					<option value="Ganjil">Ganjil</option>
					<option value="Genap">Genap</option>
                </select>
                </div>

                <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();
		});
	});

