<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php if ($ac == '') { ?>
<div class='row'>

        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-download"></i> Nilai Semester</h4></div>    
			  
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Transkip Nilai</a></li>
					</ul>					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						 <div class="col-md-8">
						<div class="panel panel-default">
                       		 <div class='alert alert-danger'>
               <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
                <i class='icon fa fa-info'></i>
                  Pastikaan Nomor Urut Mapel dan Kelompok Mapel Sudah di isi di Menu E Rapor. Jika belum diisi maka tidak muncul pada Pilih Mapel</b>          
							   </div>				
						<div class="box-body">
						<form id="formpengaturan" action='sandik_pk/proses.php'  method='post' class="form-horizontal" enctype='multipart/form-data'>
                          
							<div class="box-body box-pane">
							<label class="col-xs-12 control-label"></label>                  						
						     <div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Tingkat</label>
							<div class="col-sm-7">
							   <select id='level' name='level' class='form-control' required='true'>
                                      <option value=''>--Pilih Tingkat--</option>
                                       <?php $quem = mysqli_query($koneksi, "SELECT * FROM siswa GROUP BY level"); ?>
                                                <?php while ($m = mysqli_fetch_array($quem)) : ?>
                                                    <option value="<?= $m['level'] ?>"><?= $m['level'] ?></option>
                                                <?php endwhile ?>
                                                    </select>            
										   </div>
						            </div>
							<label class="col-xs-12 control-label"></label> 
							<div class="form-group-sm">
							<label class="col-sm-3 control-label">Kelas</label>
							<div class="col-sm-7">
							<select name='kelas' id="kelas" class='form-control'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							<label class="col-xs-12 control-label"></label> 	
			                   <div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Kelompok Mapel</label>
							<div class="col-sm-7">
							   <select id='kelompok' name='kelompok' class='form-control' required='true'>
                                      <option value=''>--Pilih Kelompok Mapel--</option>
                                       <?php $que = mysqli_query($koneksi, "SELECT * FROM mata_pelajaran WHERE kelompok<>'' GROUP BY kelompok"); ?>
                                                <?php while ($mT = mysqli_fetch_array($que)) : ?>
												 <?php
									              if($mT['kelompok']=='A'){
													$klp="A. Muatan Nasional";
												  }elseif($mT['kelompok']=='B'){
													$klp="B. Muatan Kewilayahan";
													}elseif($mT['kelompok']=='C1'){
													$klp="C1. Dasar Bidang Keahlian";
													}elseif($mT['kelompok']=='C2'){
													$klp="C2. Dasar Program Keahlian";
													}elseif($mT['kelompok']=='C3'){
													$klp="C3. Kompetensi Keahlian";
													}elseif($mT['kelompok']=='D'){
													$klp="D. Muatan Lokal";
												  }
									             ?>
                                                    <option value="<?= $mT['kelompok'] ?>"><?= $klp ?></option>
                                                <?php endwhile ?>
                                                    </select>            
										   </div>
						            </div>
							<label class="col-xs-12 control-label"></label>
							<div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Mapel</label>
							<div class="col-sm-7">
							<select name='mapel' id="mapel" class='form-control'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							<label class="col-xs-12 control-label"></label> 
                            <div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih KI / KD</label>
							<div class="col-sm-9">
							  <select name='kikd' class='form-control' required='true'>
                                                   <option value=''>--Pilih KI--</option>
                                                    <option value='KI3'>Pengetahuan</option>
                                                     <option value='KI4'>Keterampilan</option>
													  
                                                    </select>
							                        </div>
                                                </div>
							<label class="col-xs-12 control-label"></label>
								<div class="form-group-sm">
							<label class="col-sm-3 control-label">Semester</label>
							<div class="col-sm-9">
							<div class="input-group">
							  <select name='semester' class='form-control' required='true'>
                                                   <option value=''>--Pilih Semester--</option>
                                                    <option value='1'>1</option>
                                                     <option value='2'>2</option>
													  <option value='3'>3</option>
													   <option value='4'>4</option>
													    <option value='5'>5</option>
														 <option value='6'>6</option>
                                                    </select>
													 <span class="input-group-btn">
											   <button type='submit'  class='btn btn-sm  btn-default'><i class='fa fa-download' ></i><span> Download</span></button>
											  </span>
                                            </div>						          	 							
						            </div>
									  
                                       </div>
						            </div>	
								
									           </form>
								            
											</div>
										</div>
									</div>
								</div> 
                          		 <script>
				  $("#level").change(function() {
					var level = $(this).val();
					console.log(level);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=ambil_kelas", 
						data: "level=" + level, 
						success: function(response) { 
							$("#kelas").html(response);
						}
					});
				});			
        			   $("#kelompok").change(function() {
					var kelompok = $(this).val();
					console.log(kelompok);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=ambil_mapel", 
						data: "kelompok=" + kelompok, 
						success: function(response) { 
							$("#mapel").html(response);
						}
					});
				});				
			</script>
					 
			<div class="col-md-4">
						<div class="panel panel-default">
                     <div class='box-body'>
                        <div class='form-group-sm'>
                            <div class='row'>
                                <form id='formsiswa' enctype='multipart/form-data'>
                                    <div class='col-md-8'>
                                        <label>Pilih File</label>
                                        <input type='file' name='file' class='form-control' required='true' />
                                    </div>
                                    <div class='col-md-4'>
                                        <label>&nbsp;</label><br>
                                        <button type='submit' name='submit' class='btn-sm btn-success'><i class='fa fa-upload'></i> Import</button>
                                    </div>
									 <div class='col-md-7'>
                                        <label>&nbsp;</label><br>
                                      
                                    </div>
									<div class='col-md-12'>
                                        <label>&nbsp;</label><br>
                                        &nbsp;&nbsp;&nbsp;&nbsp;<a href="?pg=impornilai&ac=view" class='btn btn-primary btn-block'><i class='fa fa-eye'></i> View Nilai</a>
                                    </div>
                                </form>
                            </div>
                        </div>
						
						<div id='progressbox'></div>
                        <div id='hasilimport'></div>
                    	 </div>
						     </div>	
						         </div>
						            </div>	
									  
                                    
						
						
						 <script>
				  $("#levelQ").change(function() {
					var levelQ = $(this).val();
					console.log(levelQ);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=ambil_kelasQ", 
						data: "levelQ=" + levelQ, 
						success: function(response) { 
							$("#kelasQ").html(response);
						}
					});
				});						
			</script>
						
						<script>
    $('#formsiswa').on('submit', function(e) {
        e.preventDefault();
        $.ajax({
            type: 'post',
            url: 'sandik_pk/crud_nilai.php',
            data: new FormData(this),
            processData: false,
            contentType: false,
            cache: false,
            beforeSend: function() {
                $('#progressbox').html('<div><img src="<?= $homeurl ?>/dist/img/animasi1.gif" style="margin-left:100px"></div>');
                $('.progress-bar').animate({
                    width: "30%"
                }, 100);
            },
            success: function(response) {
                setTimeout(function() {
                    $('.progress-bar').css({
                        width: "100%"
                    });
                    setTimeout(function() {
                        $('#hasilimport').html(response);
						});
						setTimeout(function() {
                    window.location.reload();
                    }, 2000);
                }, 2000);
            }
        });
    });
</script>

		
		 
<?php } elseif ($ac == 'view') { ?>
<div class='row'>

        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-eye"></i> View Nilai Semester</h4></div>    
			  
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Transkip Nilai</a></li>
					</ul>					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class="col-md-2"></div>
						 <div class="col-md-8">
						<div class="panel panel-default">
                       		 <div class='alert alert-danger'>
               <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
                <i class='icon fa fa-info'></i>
                  Pastikaan Nomor Urut Mapel dan Kelompok Mapel Sudah di isi di Menu E Rapor. Jika belum diisi maka tidak muncul pada Pilih Mapel</b>          
							   </div>				
						<div class="box-body">
						<form action='?pg=normatif'  method='POST' class="form-horizontal" enctype='multipart/form-data'>
                          
							<div class="box-body box-pane">
							<label class="col-xs-12 control-label"></label>                  						
						     <div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Tingkat</label>
							<div class="col-sm-7">
							   <select id='level' name='level' class='form-control' required='true'>
                                      <option value=''>--Pilih Tingkat--</option>
                                       <?php $quem = mysqli_query($koneksi, "SELECT * FROM siswa GROUP BY level"); ?>
                                                <?php while ($m = mysqli_fetch_array($quem)) : ?>
                                                    <option value="<?= $m['level'] ?>"><?= $m['level'] ?></option>
                                                <?php endwhile ?>
                                                    </select>            
										   </div>
						            </div>
							<label class="col-xs-12 control-label"></label> 
							<div class="form-group-sm">
							<label class="col-sm-3 control-label">Kelas</label>
							<div class="col-sm-7">
							<select name='kelas' id="kelas" class='form-control'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							<label class="col-xs-12 control-label"></label> 	
			                   <div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Kelompok Mapel</label>
							<div class="col-sm-7">
							   <select id='kelompok' name='kelompok' class='form-control' required='true'>
                                      <option value=''>--Pilih Kelompok Mapel--</option>
                                       <?php $que = mysqli_query($koneksi, "SELECT * FROM mata_pelajaran WHERE kelompok<>'' GROUP BY kelompok"); ?>
                                                <?php while ($mT = mysqli_fetch_array($que)) : ?>
												 <?php
									              if($mT['kelompok']=='A'){
													$klp="A. Muatan Nasional";
												  }elseif($mT['kelompok']=='B'){
													$klp="B. Muatan Kewilayahan";
													}elseif($mT['kelompok']=='C1'){
													$klp="C1. Dasar Bidang Keahlian";
													}elseif($mT['kelompok']=='C2'){
													$klp="C2. Dasar Program Keahlian";
													}elseif($mT['kelompok']=='C3'){
													$klp="C3. Kompetensi Keahlian";
													}elseif($mT['kelompok']=='D'){
													$klp="D. Muatan Lokal";
												  }
									             ?>
                                                    <option value="<?= $mT['kelompok'] ?>"><?= $klp ?></option>
                                                <?php endwhile ?>
                                                    </select>            
										   </div>
						            </div>
							<label class="col-xs-12 control-label"></label>
							<div class="form-group-sm">
							<label class="col-sm-3 control-label">Pilih Mapel</label>
							<div class="col-sm-7">
							<select name='mapel' id="mapel" class='form-control'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							<label class="col-xs-12 control-label"></label> 	
								<div class="form-group-sm">
							<label class="col-sm-3 control-label">Semester</label>
							<div class="col-sm-9">
							<div class="input-group">
							  <select name='semester' class='form-control' required='true'>
                                                   <option value=''>--Pilih Semester--</option>
                                                    <option value='1'>1</option>
                                                     <option value='2'>2</option>
													  <option value='3'>3</option>
													   <option value='4'>4</option>
													    <option value='5'>5</option>
														 <option value='6'>6</option>
                                                    </select>
													 <span class="input-group-btn">
											   <button type='submit'  class='btn btn-sm  btn-primary'><i class='fa fa-eye' ></i><span> View Nilai</span></button>
											  </span>
                                            </div>						          	 							
						            </div>
									  
                                       </div>
						            </div>	
								
									           </form>
								            
											</div>
										</div>
									</div>
								</div> 
                          		 <script>
				  $("#level").change(function() {
					var level = $(this).val();
					console.log(level);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=ambil_kelas", 
						data: "level=" + level, 
						success: function(response) { 
							$("#kelas").html(response);
						}
					});
				});			
        			   $("#kelompok").change(function() {
					var kelompok = $(this).val();
					console.log(kelompok);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=ambil_mapel", 
						data: "kelompok=" + kelompok, 
						success: function(response) { 
							$("#mapel").html(response);
						}
					});
				});				
			</script>
					 
<?php } ?>	