<?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";
	include "php_class/class_semesterpendek.php";
	
	$datasp = new DataSemesterPendek;
	$DataTransaksi = new DataTransaksi;
	$datagrup = new DataGrup;
	$DataMahasiswa = new DataMahasiswa;
	$DataTemplate = new DataTemplate;

	$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 type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></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);?>;
	
	$("#example3").dataTable();
	
	$('.context').click(function(e){
		var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});
	$('#setting').click(function(e){
   		$("#myModal").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-operator/'+ 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 +'';	
		}
	});
	
	$('#cetak').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'cetak-skripsi/'+ kode +'';
	});

  });
   
</script>
<section class="content-header">

  <h1>
   Transaksi
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="<?php echo $base?>data-transaksi">Data  Transaksi</a></li>
    <li class="active">Tambah Data Transaksi</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 
								$ids = $_SESSION["id"];	
								$tahun = $_POST["tahun"];
								$program = $_POST['program'];
								$tglawal = $_POST['tglawal'];
								$tglakhir = $_POST['tglakhir'];
								$semester = $_POST['semester'];
								if ($program == '122') {
									$program1 = 'R. Malam - Eksekutif';	
								} else{
									$program1 = 'Reguler';
									$program = '121';	
								}					

								if ($tglawal == "") {
									$tglawal = date('Y-m-d');
								}

								if ($tglakhir == "") {
									$tglakhir = date('Y-m-d');
								}

								if ($tahun == ""){
										$bulansmst = date('m');
										$bulansmst = substr($bulansmst, 1, 1); 
										if ($bulansmst > 8 and $bulansmst < 13){
												$dp = date('y');
												$bk = $dp - 1;
												$tahun = $bk.$dp;	
										}else if ($bulansmst < 8){
												$dp = date('y');
												$bk = $dp - 1;
												$tahun = $bk.$dp;	
										}else{
												$dp = date('y');
												$bk = $dp + 1;
												$tahun = $dp.$bk;	
										}
								}
								$tahundp = substr($tahun, 0, 2);
								$tahunbk = substr($tahun, 2, 2);
								
								$tahun1 = '20'.$tahundp."/20".$tahunbk;

								if ($semester == '1') {
									$semester1 = 'Ganjil';	
								} else {
									if ($semester == ''){
										$bulansmst = date('m');
										$bulansmst = substr($bulansmst, 1, 1); 
										if ($bulansmst > 8 and $bulansmst < 13){
											$semester = '1';
											$semester1 = 'Ganjil';	
										}else if ($bulansmst < 8){
											$semester = '1';
											$semester1 = 'Ganjil';	
										}else{
											$semester = '2';
											$semester1 = 'Genap';	
										}
									}else{
										$semester = '2';
										$semester1 = 'Genap';	
									}
								}
								
								$_SESSION['smprogram'] = $program;
								$_SESSION['smsemester'] = $semester;
								$_SESSION['smtahun'] = $tahun;
								

									echo "<H3 style='margin-bottom:15px;'>Program : ".$program1."</h3>";
									echo "<H5 style='margin-bottom:15px;'>Semester: ".$semester1."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Tahun Akademin: ".$tahun1."</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 id="example3" class="table table-bordered table-striped table-hover">
                             <thead>
                                <tr>
                                    <th>No</th>
                                    <th>Sandi Mata Kuliah</th>
                                    <th>Mata Kuliah</th>
                                    <th>Peserta</th>
                                    <th>Absen</th>
                                </tr>
                            </thead>
                            <tbody>
                            
                            <?php
                                $JumlahData = $datasp->get_matkul_sempek('', $a, 'jumlah', $program, $tahun, $semester);
                                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{
                                        $TotalAkhir = 0;
                                    for ($a=1;$a<=$JumlahData;$a++){
                                        $idmatakuliah = $datasp->get_matkul_sempek('idmatakuliah', $a, '', $program, $tahun, $semester);
										$kode = $datasp->get_matkul_sempek('kode', $a, '', $program, $tahun, $semester);
                                        $matakuliah = $datasp->get_matkul_sempek('matakuliah', $a, '', $program, $tahun, $semester);
										$peserta = $datasp->get_matkul_sempek('peserta', $a, '', $program, $tahun, $semester);
                                        
                                        echo "<tr class='odd gradeX'>";
                                        echo "<td>".$a."</td>";
										echo "<td>".$kode."</td>";
                                        echo "<td>".$matakuliah."</td>";
										echo "<td>".$peserta."</td>";
										echo "<td class='center'>
											  <a href='bagi-kelas/$idmatakuliah'><i class='glyphicon glyphicon-copy'></i> </button>
											  </td>";
                                        echo "</tr>";
                                    }
                                }
                            ?>
                            </tbody>
                          </table>
          			</div>
                    <div class="col-sm-12" style="margin-top:25px;">
                        <div align="right"><h1><div id="totaltrans"></div></h1></div>
                              <form action="<?php echo $base?>tabel-matkul-sempek.php" method="post" name="cmb" style="float:right" id="cmb" target="_blank">
                                        <input type="hidden" name="semester" value="<?php echo $semester?>" />
                                        <input type="hidden" name="program"  value="<?php echo $program ?>">
                                        <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>
             </div> 
         </div>
    </div>
</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">Setting</h4>
      </div>
      <div class="modal-body">
          <form action="<?php echo $base?>data-matkul-sempek" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">

            <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="121">Reguler</option>
                <option value="122">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>";	
				}
			?>
                    <?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{
                            	$upAngkatan = $angkatan + 1;
							}
							

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

                        }
                    ?>
                    

            </select>
            <select class="form-control" name="semester" style="margin-top:20px;">
            <?php 
				if ($semester != "") {
                	echo "<option value='".$semester."'>".$semester1."</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();
		});
	});
</script>
         
          <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="text" value="" id="kc">
                        <div align="center">
                        <p><button type="button" class="btn btn-default" id="nonaktif">Hapus Data</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>
