<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php if ($ac == '') { ?>
 
 <div class='row'>
 <div class='col-md-7'>
 <div class="card">
             <div class="card-header">	
                  <h5 class='card-title'><i class="fas fa-graduation-cap"></i> Nilai Harian</h5>
                </div>
						 
            <div class='card-body'>
                 <div class="table-responsive">
                     <table style="font-size: 11px" id='mapel' class='table table-hover'>
                        <thead>						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Kode</th>
								<th>Kelas</th>
								<th>Kurikulum</th>
								<th></th>
                                
                            </tr>						
                        </thead>
                        <tbody>
						
                            <?php
							$hari=date('D');
							$tg=date('Y-m-d');
							$no = 0;
                              $query = mysqli_query($koneksi, "select * from jadwal_mapel WHERE guru='$_SESSION[id_user]' AND hari='$hari'");                            
                                while ($jadwal = mysqli_fetch_array($query)) {
							      $kurikulum = fetch($koneksi,'kelas',['id_kelas'=>$jadwal['kelas']]);			
                                      $no++;                         
                                        ?>
                                <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $jadwal['kode'] ?></td>
									 <td><?= $jadwal['kelas'] ?></td>
									  <td><b style="color:blue"><?= $kurikulum['kurikulum'] ?></b></td>
									  <td>
                                      <a href="?pg=nilaiharian&ac=t&idjadwal=<?= $jadwal['id_jadwal'] ?>&kode=T" class="btn btn-sm btn-outline-primary" data-bs-placement="top" data-bs-toggle="tooltip" title="Nilai Tugas"><i class="fa fa-plus-circle"></i> PR</a>									  
									  <a href="?pg=nilaiharian&ac=t&idjadwal=<?= $jadwal['id_jadwal'] ?>&kode=U" class="btn btn-sm btn-outline-info" data-bs-placement="top" data-bs-toggle="tooltip" title="Nilai Ulangan"><i class="fa fa-plus-circle"></i> UH</a>									  
									    <a href="sandik_ptm/m_nilai/rekapharian.php?idj=<?= $jadwal['id_jadwal'] ?>&k=<?= $jadwal['kelas'] ?>" target="_blank" class="btn btn-sm btn-outline-danger"><i class="fa fa-print"></i></a>									  
									  
									   </td>									    
											</tr>
								            <?php } ?>
												</tbody>
												</table>
											</div>
										</div>
						              </div>
						          </div>
						      
			<div class='col-md-5'>
           <div class="card">
             <div class="card-header">	
                  <h5 class='card-title'><i class="fas fa-graduation-cap"></i> Nilai Harian</h5>
                </div>
            <div class='card-body'>
			 <div class="table-responsive">
                     <table style="font-size: 11px" id='example' class='table table-hover'>
                        <thead>						
                            <tr style="height:50px">
                   
                                <th>KD / TP</th>						
								<th >Kurikulum</th>
								<th width="20%">Excel</th>
                                
                            </tr>						
                        </thead>
                        <tbody>
						 <?php
							$no = 0;
                              $queryQ = mysqli_query($koneksi, "select * from nilai_harian JOIN jadwal_mapel ON jadwal_mapel.id_jadwal=nilai_harian.idjadwal WHERE jadwal_mapel.guru='$user[id_user]' GROUP BY kd");                            
                                while ($n = mysqli_fetch_array($queryQ)) {
							     
                                      $no++;                         
                                        ?>
                                <tr>
                                  
                                    <td><?= $n['kd'] ?></td>
									 <td><?= $n['kurikulum'] ?> - Kelas <?= $n['kelas'] ?></td>
									
									  <td>
                                     
										   <a href="sandik_ptm/m_nilai/prosesharian.php?&idj=<?= $n['id_jadwal'] ?>&kd=<?= $n['kd'] ?>" class="btn btn-sm btn-outline-success" data-bs-placement="top" data-bs-toggle="tooltip" title="Download Excel"><i class="fa fa-download"></i></a>								
									   </td>									    
											</tr>
								            <?php } ?>
						</tbody>
					</table>
	           </div>
			</div>
		</div>
     </div>

<?php } elseif ($ac == 't') { ?>
<?php $jadwal = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM jadwal_mapel JOIN kelas ON kelas.id_kelas=jadwal_mapel.kelas  WHERE id_jadwal='$_GET[idjadwal]'")); ?>
 <div class='row'>
 <div class='col-md-8'>
  <div class="card">
             <div class="card-header">	
					<h5 class='card-title'><i class="fas fa-graduation-cap"></i>
					Nilai Tugas / PR <?= $jadwal['kode'] ?> <?= $jadwal['kelas'] ?></h5>
                </div>
            <div class='card-body'>
		  <div class="table-responsive">
							
                     <table style="font-size: 12px" id='example' class='table'>
                        <thead>
                            <tr height="50px">
                                <th width='5px'>
                                    #
                                </th>
                              <th>
							  <?php if($jadwal['kurikulum']=='K-13'){ ?>
							  Kompetensi Dasar
							  <?php }else{ ?>
							  Tujuan Pembelajaran
							  <?php } ?>
							  </th>
                                 <th>Nilai</th>
                            </tr>
						
                        </thead>
                        <tbody>
			          <?php
							
							$no = 0;
							 if($jadwal['kurikulum']=='Merdeka'):
                              $query = mysqli_query($koneksi, "select * from tujuan JOIN jadwal_mapel ON jadwal_mapel.id_jadwal=tujuan.idjadwal
							  JOIN kelas ON kelas.id_kelas=jadwal_mapel.kelas WHERE jadwal_mapel.guru='$user[id_user]' and kelas.kurikulum='Merdeka'");                            
                              elseif($jadwal['kurikulum']=='K-13'):
							    $query = mysqli_query($koneksi, "select * from kodekd");     
							  endif;
							  while ($j = mysqli_fetch_array($query)) {
							     
                                      $no++;                         
                                        ?>
                                <tr>
                                    <td><?= $no ?></td>
                                    
                                  <?php if($jadwal['kurikulum']=='Merdeka'){ ?>									 
                                    <td> (<?= $j['tp'] ?>) <?= $j['tujuan'] ?></td>
								  <?php }else{ ?>
									 <td> <?= $j['ki3'] ?></td>									
								  <?php } ?>
                                    <td>
									 <?php if($jadwal['kurikulum']=='Merdeka'){ ?>	
                                    <a href="?pg=nilaiharian&ac=input3&kd=<?= $j['tp'] ?>&idj=<?= $jadwal['id_jadwal'] ?>&kode=<?= $_GET['kode'] ?>"  class='btn btn-sm btn-outline-success'><i class='fa fa-check-circle'></i> Input</button>
									<?php }else{ ?>
									<a href="?pg=nilaiharian&ac=input3&kd=<?= $j['ki3'] ?>&idj=<?= $jadwal['id_jadwal'] ?>&kode=<?= $_GET['kode'] ?>"  class='btn btn-sm btn-outline-success'><i class='fa fa-check-circle'></i> Input</button>
									   <?php } ?>
									  </td>
											 </tr>
											  <?php } ?>
										</tbody>
											</table>
												
												</div>
												</div>
											</div>
											
									        </div>
											 <div class="col-xl-4">
                                <div class="card widget widget-info">
                                    <div class="card-body">
                                        <div class="widget-info-container">
                                            <div class="widget-info-image" style="background: url('../dist/img/logo65.png')"></div>
                                            <h6 class="widget-info-title">NEW SANDIK</h6>
                                            <p class="widget-info-text"><b>SISTEM APLIKASI PENDIDIK</b><br>Multi Jenjang REGULER & PKBM <small> Created By STBC</small></p>
                                           
                                        </div>
                                    </div>
                                </div>
											
<?php } elseif ($ac == 'input3') { ?>
<?php $jadwal = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM jadwal_mapel JOIN kelas ON kelas.id_kelas=jadwal_mapel.kelas  WHERE id_jadwal='$_GET[idj]'")); ?>
 <div class='row'>
 <div class='col-md-12'>
    <div class="card">
             <div class="card-header">	
					
                    <div class='right '>
					 <h5 class="card-title"><?= date("d-m-Y") ?></h5>
                    </div>
					<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Nilai Tugas/<?= $jadwal['kode'] ?> <?= $jadwal['kelas'] ?>/<?= $_POST['kd'] ?></h5>
                </div>
				
            <div class='card-body'>
			<form id="formnilai" action="" >
		  <div class="table-responsive">							
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>						
                           <tr height="50px">
                                <th width='5px'>
                                    #
                                </th>
                                <th>Nama</th>
								<th width="10%">Kelas</th>
                                 <th width="30%">Nilai</th>
                            </tr>
						
                        </thead>
                        <tbody>									
						<?php
					$query = mysqli_query($koneksi, "select * from siswa WHERE id_kelas='$jadwal[kelas]'");
                            $no = 0; ?>
                           <?php while ($siswa = mysqli_fetch_array($query)) {								
                                $no++;                              
                            ?>
                          <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $siswa['nama'] ?></td>
									 <td><?= $siswa['id_kelas'] ?>
									 <input type="hidden" name="ids[]" value="<?php echo $siswa['id_siswa'] ?>">
									<input type="hidden" name="idj[]" value="<?php echo $jadwal['id_jadwal'] ?>">
									<input type="hidden" name="tanggal[]" value="<?php echo date('Y-m-d') ?>">
									<input type="hidden" name="kd[]" value="<?php echo $_GET['kd'] ?>">
									<input type="hidden" name="kuri[]" value="<?= $jadwal['kurikulum'] ?>">
									<input type="hidden" name="kode[]" value="<?= $_GET['kode'] ?>">
									 </td>
									 <td><input type="number" name="nilai[]" class="form-control" value="0" ></td>
									</tr>
																<?php } ?>
																
															</tbody>
														</table>
														
											<div class='right '>
													<button type='submit'  class='btn  btn-success'><i class='fa fa-check-circle'></i> Simpan</button>
																</div>
															 </form>
													</div>
												</div>
						
						</div>
						
		<script>
       $('#formnilai').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
        $.ajax({
            type: 'POST',
            url: 'sandik_ptm/m_nilai/crud_nilai.php?pg=tambah',
           enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
               iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
                setTimeout(function() {
                    window.location.replace('?pg=nilaiharian');
                }, 2000);

            }
        });
        return false;
    });
   </script>
		
  <?php } elseif ($ac == 'u') { ?>
<?php $jadwal = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM jadwal_mapel JOIN kelas ON kelas.id_kelas=jadwal_mapel.kelas  WHERE id_jadwal='$_GET[idjadwal]'")); ?>
 <div class='row'>
 <div class='col-md-12'>
  <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                    <div class='box-tools pull-right '>
					 
                    </div>
					<h4 class='box-title'><i class="fas fa-graduation-cap"></i> Nilai Tugas / PR <?= $jadwal['kode'] ?></h4>
                </div>
				
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Menu PTM</a></li>
                    </ul>
					<div class="tab-content">
                    <div class="tab-pane active" id="tab_1" >
					<br>
				<div class="panel panel-default">
				<div class='row'>
            <div class='col-md-12'>
            <div class="panel panel-default">
               
                    </div>
           
            <div class='box-body'>
			<form id="formtujuan" action="?pg=nilaiharian&ac=input3" method="POST">
			
          
		  <div class="table-responsive">
							
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Nama</th>
								<th width="10%">Kelas</th>
                              <th width="15%">Pilih KD</th>
                                 <th>Nilai</th>
                            </tr>
						
                        </thead>
                        <tbody>
			
                                <tr>
                                    <td>1</td>
                                    <td><?= $jadwal['mapel'] ?>
									<input type="hidden" name="idjadwal" value="<?= $jadwal['id_jadwal'] ?>" >
									</td>									
									 <td><?= $jadwal['kelas'] ?>
									 <input type="hidden" name="kur" value="<?= $adwal['kurikulum'] ?>" >
									 </td>
                                    <td>
									<?php if($jadwal['kurikulum']=='K-13'){ ?>
									<select  name="kd"  class="form-control"  style="width:100px;" required="true">     
									 <?php 
									   $sql=mysqli_query($koneksi,"SELECT * FROM kodekd");
									   while ($data=mysqli_fetch_array($sql)) {
										echo '<option value="'.$data['ki3'].'">'.$data['ki3'].'</option> ';
									   }
									  ?>
									</select>
                                    <?php } ?>									
									</td>
                                    <td>
                                    <button type='submit'  class='btn btn-sm btn-success'><i class='fa fa-check'></i> Input</button>
									   </td>
											 </tr>
										</tbody>
											</table>
												</form>	
												</div>
												</div>
											</div>
											
									        </div>	
<?php } elseif ($ac == 'input4') { ?>

 <div class='row'>
 <div class='col-md-12'>
  <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                    <div class='box-tools pull-right '>
					 
                    </div>
					<h4 class='box-title'><i class="fas fa-graduation-cap"></i> Nilai Harian Pengetahuan (KI-4) - <?= $_GET['mapel'] ?></h4>
                </div>
				<div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Menu PTM</a></li>
                    </ul>
					<div class="tab-content">
                    <div class="tab-pane active" id="tab_1" >
				<div class="panel panel-default">
				<div class='row'>
 <div class='col-md-12'>
            <div class="panel panel-default">
               
                    </div>
           
            <div class='box-body'>
			<form id="formtujuan" action="?pg=nilaiharian&ac=inputki4" method="POST">
			
          
		  <div class="table-responsive">
							
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Nama</th>
								<th width="5%">Kelas</th>
                              <th width="15%">Pilih KD</th>
                                 <th>Nilai</th>
                            </tr>
						
                        </thead>
                        <tbody>
						 
                          
							
                                <tr>
                                    <td>1</td>
                                    <td><?= $_GET['mapel'] ?>
									<input type="hidden" name="mapel" value="<?= $_GET['mapel'] ?>" >
									</td>									
									 <td><?= $_GET['kelas'] ?>
									 <input type="hidden" name="kelas" value="<?= $_GET['kelas'] ?>" >
									 </td>
                                    <td>
									<select id="idpeg" name="kd"  class="form-control"  style="width:100px;" required="true">     
									 <?php 
									   $sql=mysqli_query($koneksi,"SELECT * FROM kodekd");
									   while ($data=mysqli_fetch_array($sql)) {
										echo '<option value="'.$data['ki4'].'">'.$data['ki4'].'</option> ';
									   }
									  ?>
									</select>	
									</td>
                                    <td>
                                    <button type='submit'  class='btn btn-sm btn-success'><i class='fa fa-check'></i> Input</button>
									   </td>
											 
																</tr>
																
																
															</tbody>
															
														</table>
												
															 </form>	

													</div>
												</div>
											</div>
											
									</div>
<?php } elseif ($ac == 'inputki4') { ?>

 <div class='row'>
 <div class='col-md-12'>
  <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                    <div class='box-tools pull-right '>
					 <h4><?= date("d-m-Y") ?></h4>
                    </div>
					<h4 class='box-title'><i class="fas fa-graduation-cap"></i> Nilai Harian Pengetahuan (KI-3) - <?= $_POST['mapel'] ?>/<?= $_POST['kelas'] ?>/<?= $_POST['kd'] ?></h4>
                </div>
				<div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Menu PTM</a></li>
                    </ul>
					<div class="tab-content">
                    <div class="tab-pane active" id="tab_1" >
				<div class="panel panel-default">
				<div class='row'>
 <div class='col-md-12'>
            <div class="panel panel-default">
               
                    </div>
           
            <div class='box-body'>
			<form id="formnilai" action="" >
			
		  <div class="table-responsive">							
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Nama</th>
								<th width="5%">Kelas</th>
                                 <th>Nilai</th>
                            </tr>
						
                        </thead>
                        <tbody>									
						<?php
					$query = mysqli_query($koneksi, "select * from siswa_ptm WHERE id_kelas='$_POST[kelas]'");
                            $no = 0; ?>
                           <?php while ($siswa = mysqli_fetch_array($query)) {								
                                $no++;                              
                            ?>
                          <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $siswa['nama'] ?></td>
									 <td><?= $siswa['id_kelas'] ?>
									 <input type="hidden" name="ids[]" value="<?php echo $siswa['id_siswa'] ?>">
									<input type="hidden" name="guru[]" value="<?php echo $_SESSION['id_pengawas'] ?>">
									<input type="hidden" name="kelas[]" value="<?php echo $_POST['kelas'] ?>">
									<input type="hidden" name="mapel[]" value="<?php echo $_POST['mapel'] ?>">
									<input type="hidden" name="kd[]" value="<?php echo $_POST['kd'] ?>">
									<input type="hidden" name="ket[]" value="KI4">
									 </td>
									 <td><input type="number" name="nilai[]" class="form-control" value="0" ></td>
									</tr>
																<?php } ?>
																
															</tbody>
														</table>
														
											<div class='box-tools pull-right '>
													<button type='submit'  class='btn btn-sm btn-success'><i class='fa fa-check'></i> Simpan</button>
																</div>
															 </form>
													</div>
												</div>
						
						</div>
						
		<script>
       $('#formnilai').submit(function(e) {
         e.preventDefault();
        var data = new FormData(this);
        $.ajax({
            type: 'POST',
            url: 'ptm/m_nilai/crud_nilai.php?pg=tambah',
             enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                Swal.fire({	
				title: '<a href="#" class="sandik">Nilai berhasil disimpan</a>',				
				showConfirmButton: false,
				 animation: false,
				  customClass: 'animated tada',				  
				  imageUrl: '../dist/img/sandik_kecil.gif',
                 footer: '<a href="#"><b style="color:red">Sistem Administrasi Pendidik (SANDIK)</b></a>'				  
                });
                setTimeout(function() {
                    window.location.replace('?pg=nilaiharian');
                }, 2000);

            }
        });
        return false;
    });
    </script>										
			
<?php } elseif ($ac == 'lihat3') { ?>

 <div class='row'>
 <div class='col-md-12'>
  <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                    <div class='box-tools pull-right '>
					<button id="generate-excel" class="btn btn-sm btn-success"><i class="fas fa-graduation-cap"></i>
            Eksport Excel</button>
                    </div>
					<h4 class='box-title'><i class="fas fa-graduation-cap"></i> Nilai Harian Pengetahuan (KI-3) - <?= $_GET['mapel'] ?>/<?= $_GET['kelas'] ?></h4>
                </div>
				<div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Menu PTM</a></li>
                    </ul>
					<div class="tab-content">
                    <div class="tab-pane active" id="tab_1" >
				<div class="panel panel-default">
				<div class='row'>
 <div class='col-md-12'>
            <div class="panel panel-default">
               
                    </div>
   <div class="table-responsive">							
<table id="test_table" class="table table-bordered">
	 <thead>
      <tr>
	<th width='2%' style="text-align: center;">No</th>
	<th>Nama Siswa</th>
	<th width='15%'>Mapel</th>
	<th width='10%'>Kelas</th>
	 <?php
			$querys = mysqli_query($koneksi,"select * from nilai_harian WHERE ket='KI3' AND mapel='$_GET[mapel]' AND kelas='$_GET[kelas]' AND guru='$_GET[guru]'  GROUP BY kd");
			
              while ($kd = mysqli_fetch_array($querys)) {
			?>
			<th width='8%' style="text-align: center;"><?= $kd['kd'] ?></th>
			  <?php } ?>
			  
	</tr>
	 </thead>	
				<?php
	       $no=0;
			$query = mysqli_query($koneksi,"select * from siswa_ptm WHERE id_kelas='$_GET[kelas]'");
              while ($siswa = mysqli_fetch_array($query)) {
				 
				  $no++;
			?>
     <tbody>
	
	         <tr>
	        <td><?= $no ?></td>
			<td><?= ucwords(strtolower($siswa['nama'])) ?></td>
			<td><?= $_GET['mapel'] ?></td>
			<td><?= $_GET['kelas'] ?></td>
	       <?php
			$queryxx = mysqli_query($koneksi,"select AVG(nilai) AS nkd from nilai_harian 
			JOIN kodekd ON kodekd.ki3=nilai_harian.kd
			WHERE nilai_harian.idsiswa='$siswa[id_siswa]' AND nilai_harian.ket='KI3' AND nilai_harian.mapel='$_GET[mapel]'  AND nilai_harian.kelas='$_GET[kelas]' AND nilai_harian.guru='$_GET[guru]' GROUP  BY nilai_harian.kd ");
              while ($nilai = mysqli_fetch_array($queryxx)) {
		 
		 
			?>
	
     	<td style="text-align: center;"><?= round($nilai['nkd'],2) ?></td>
			 <?php } ?>
			 </tr>
			
			  <?php   } ?>
	
	  
	 </tbody>
	</table>	
					
			</div>
</div>
</div>
</div>			

<?php } elseif ($ac == 'lihat4') { ?>

 <div class='row'>
 <div class='col-md-12'>
  <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                    <div class='box-tools pull-right '>
					 <button id="generate-excel" class="btn btn-sm btn-success"><i class="fas fa-graduation-cap"></i>
            Eksport Excel</button>
                    </div>
					<h4 class='box-title'><i class="fas fa-graduation-cap"></i> Nilai Harian Pengetahuan (KI-4) - <?= $_GET['mapel'] ?>/<?= $_GET['kelas'] ?></h4>
                </div>
				<div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Menu PTM</a></li>
                    </ul>
					<div class="tab-content">
                    <div class="tab-pane active" id="tab_1" >
				<div class="panel panel-default">
				<div class='row'>
 <div class='col-md-12'>
            <div class="panel panel-default">
               
                    </div>
   <div class="table-responsive">							
      <table id="test_table" class="table table-bordered">
	 <thead>
      <tr>
	<th width='2%' style="text-align: center;">No</th>
	<th>Nama Siswa</th>
	<th width='15%'>Mapel</th>
	<th width='10%'>Kelas</th>
	 <?php
			$querys = mysqli_query($koneksi,"select * from nilai_harian WHERE ket='KI4' AND mapel='$_GET[mapel]' AND kelas='$_GET[kelas]' AND guru='$_GET[guru]'  GROUP BY kd");
              while ($kd = mysqli_fetch_array($querys)) {
			?>
			<th width='8%' style="text-align: center;"><?= $kd['kd'] ?></th>
			  <?php } ?>
			  
	</tr>
	 </thead>	
				<?php
	       $no=0;
			$query = mysqli_query($koneksi,"select * from siswa_ptm WHERE id_kelas='$_GET[kelas]'");
              while ($siswa = mysqli_fetch_array($query)) {
				 
				  $no++;
			?>
     <tbody>
	
	         <tr>
	        <td><?= $no ?></td>
			<td><?= ucwords(strtolower($siswa['nama'])) ?></td>
			<td><?= $_GET['mapel'] ?></td>
			<td><?= $_GET['kelas'] ?></td>
	       <?php
			$queryxx = mysqli_query($koneksi,"select AVG(nilai) AS nkd from nilai_harian 
			JOIN kodekd ON kodekd.ki4=nilai_harian.kd
			WHERE nilai_harian.idsiswa='$siswa[id_siswa]' AND nilai_harian.ket='KI4' AND nilai_harian.mapel='$_GET[mapel]'  AND nilai_harian.kelas='$_GET[kelas]' AND nilai_harian.guru='$_GET[guru]' GROUP  BY nilai_harian.kd ");
              while ($nilai = mysqli_fetch_array($queryxx)) {
		 
		 
			?>
	
     	<td style="text-align: center;"><?= round($nilai['nkd'],2) ?></td>
			 <?php } ?>
			 </tr>
			
			  <?php   } ?>
	
	  
	 </tbody>
	</table>	
					
			</div>
</div>
</div>
</div>			
						<?php } ?>
						
						
						
						
						
						
						
						
						
						
						