<?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="card">
             <div class="card-header">
					<h5 class='card-title'><i class="fas fa-print"></i> Cetak Rapor Proyek</h5>
					</div>    
			
						<div class="card-body">
						<form id="formpengaturan" action='?pg=cetakraporproyek&ac=siswa'  method='post' class="form-horizontal" enctype='multipart/form-data'>
                          <div class="row mb-2">
							<label  class="col-md-3 col-form-label bold">Pilih Tingkat</label>
							<div class="col-sm-7">
							   <select id='level' name='level' class='form-select' required='true'>
                                      <option value=''>Pilih Tingkat</option>
                                       <?php $quem = mysqli_query($koneksi, "SELECT * FROM kelas WHERE kurikulum='Merdeka' GROUP BY level"); ?>
                                                <?php while ($m = mysqli_fetch_array($quem)) : ?>
                                                    <option value="<?= $m['level'] ?>"><?= $m['level'] ?></option>
                                                <?php endwhile ?>
                                                    </select>            
										   </div>
						            </div>
							 <div class="row mb-2">
							<label  class="col-md-3 col-form-label bold">Kelas</label>
							<div class="col-sm-9">
							<select name='kelas' id="kelas" class='form-select'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							
							<div class="right">
							 <button type='submit'  class='btn btn-sm  btn-outline-success'><i class='fa fa-print' ></i><span> Print</span></button>
											
                                   </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);
						}
					});
				});		
						
			</script>
			
                    </div>
                </div>
			</div>			
						
	<?php } elseif ($ac == 'siswa') { ?>
<?php $kelas = $_POST['kelas']; ?>
<?php
$kur = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM kelas  WHERE id_kelas='$kelas'"));
?>
<div class='row'>

        <div class='col-md-12'>
            <div class="card">
             <div class="card-header">
					<h5 class='card-title'><i class="fas fa-print"></i> Cetak Rapor Proyek</h5>
					</div>    
			 
                <div class='card-body'>
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table  table-hover" id="example1">
                        <thead>
                            <tr>
                                 <th class="text-center" width="3%" >
                                    #
                                </th>
                              <th width="10%" >Kelas</th>
                                <th >N I S</th>
								 <th >N I S N</th>
								 <th >Nama Siswa</th>
								<th width="5%" style="text-align:center">Cover</th>
							<th width="5%" style="text-align:center">Biodata</th>
							<th width="5%" style="text-align:center">Rapor</th>
							</tr>
                        </thead>
                        <tbody>
                            <?php
                            $query = mysqli_query($koneksi, "select * from siswa WHERE id_kelas='$kelas' ");
                            $no = 0;
                            while ($siswa = mysqli_fetch_array($query)) {								
                                $no++;
                            ?>
                                <tr>
                                    <td><?= $no; ?></td>
                                   <td><?= $siswa['id_kelas'] ?></td>
								   <td><?= $siswa['nis'] ?></td>
								   <td><?= $siswa['nisn'] ?></td>
                                    <td><?= $siswa['nama'] ?></td>
									<td>
									<a href="sandik_rapor/print_cover.php?ids=<?= $siswa['id_siswa'] ?>" target="_blank" class="btn btn-sm btn-outline-primary"><i class="fas fa-graduation-cap"></i></a>
									</td>
									<td>
									<a href="sandik_rapor/print_biodata.php?ids=<?= $siswa['id_siswa'] ?>" target="_blank" class="btn btn-sm btn-outline-warning"><i class="fas fa-user-cog"></i></a>
									</td>
                                  <td>
								  
								  <a href="sandik_proyek/print_raport.php?ids=<?= $siswa['id_siswa'] ?>" 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>

					 
<?php } ?>	