<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php
$skl = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM skl  WHERE id_skl='1'"));
?>
<?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 KARTU PELAJAR</h5></div>    
			 
						<div class="card-body">
						<form action='?pg=cetakkarpel&ac=kelas'  method='POST'  class="form-horizontal" enctype='multipart/form-data'>
                          <div class="row mb-1">
							<label  class="col-md-3 col-form-label bold">Tingkat</label>
							  <div class="col-sm-9">
							   <select id='level' name='level' class='form-select' 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>
							
							<div class="row mb-1">
							<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>
							
						       <p>
							<div class="right">
							
											   <button type='submit'  class='btn btn-outline-primary'><i class='fa fa-print'></i>Print</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>
			
       <?php } elseif ($ac == 'kelas') { ?>
<?php $kelas = $_POST['kelas']; ?>
<?php $level = $_POST['level']; ?>
<div class='row'>
<form  action='sandik_karpel/cetakkartu.php' method="post" target="_blank" enctype='multipart/form-data'>
        <div class='col-md-12'>
             <div class="card">
             <div class="card-header">
			    <div class='right'>
				 <button type="submit" class="btn btn-flat btn-outline-danger"><i class="fa fa-print"></i> Semua </button>
				<input type="hidden" name="kelas" value="<?= $kelas ?>" >
				<input type="hidden" name="level" value="<?= $level ?>" >
				</div>
                  <h5 class='box-title'><i class="fas fa-print"></i> CETAK KARPEL</h5></div>    
			 
                <div class='card-body'>
				<div class="alert alert-primary" role="alert">
                   <div class="custom-alert-icon icon-dark"></div>
                        <div class="alert-content">
                          <span class="alert-text" style="text-align:justify">Untuk mempercepat Load Backgroud Pada Cetak Semua silahkan Pilih 4 siswa pada checkbox  setiap Cetak per Lembar ukuran HVS A4 atau PVC ID CARD</span>
                                                    </div>
                                                </div>
                <div class="table-responsive">
                    <table 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 ></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><input type="checkbox" name="edis[]<?= $siswa['id_siswa'] ?>" value="<?= $siswa['id_siswa'] ?>"></td>
                                   <td><?= $siswa['id_kelas'] ?></td>
								   <td><?= $siswa['nis'] ?></td>
								   <td><?= $siswa['nisn'] ?></td>
                                    <td><?= $siswa['nama'] ?></td>
                                  <td>
								  <a href="sandik_karpel/cetakkartu2.php?nis=<?= $siswa['nis'] ?>" 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>             
	</form>	 
					 
<?php } ?>	