<?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-print"></i> Cetak PTS - <?= $setting['semester'] ?></h5></div>    
			  
						
						<div class="card-body">
						<form id="formpengaturan" action='?pg=cetakpts&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 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-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>
							<p>
							<div class="right">
					 <button type='submit'  class='btn btn-sm  btn-default'><i class='fa fa-print' ></i><span> Print Rapor</span></button>
								</div>						          	 							
						           
									           </form>
								            
											</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 class="col-md-5">
			<div class="card">
             <div class="card-header">
					<h5 class='card-title'>CETAK LEGER</h5>
						</div>
						<div class="card-body">
						<form id="formpengaturan" action="?pg=cetakrapor&ac=leger"  method='post' class="form-horizontal" enctype='multipart/form-data'>
                           <div class="row mb-2">
							<label  class="col-md-3 col-form-label bold">Tingkat</label>
							<div class="col-sm-7">
							   <select id='tingkat' name='tingkat' 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-2">
							<label  class="col-md-3 col-form-label bold">Kelas</label>
							<div class="col-sm-9">
							<select name='kls' id="kls" class='form-select'  required='true'>
                            
                                                </select>
                                            </div>
                                        </div>
							<p>
							<div class="right">
							<button type='submit'  class='btn btn-sm  btn-default'><i class='fa fa-print' ></i><span> Print Leger</span></button>
							</div> 				
									           </form>
								            
											</div>
										</div>
									</div>
								
                          
					  <script>
			 $("#tingkat").change(function() {
					var tingkat = $(this).val();
					console.log(tingkat);
					$.ajax({
						type: "POST", 
						url: "sandik_pk/crud_pk.php?pg=kelas", 
						data: "tingkat=" + tingkat, 
						success: function(response) { 
							$("#kls").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 PTS <?= $kur['kurikulum'] ?></h5>
					</div>    
			  
			 
                <div class='card-body'>
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-hover" id="datatable1">
                        <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>
								  <?php if($kur['kurikulum']=='K-13' AND $kur['model_rapor']=='1'): ?>
								  <a href="sandik_rapor/print_rapor1.php?nis=<?= $siswa['nis'] ?>" target="_blank" class="btn btn-sm btn-outline-danger"><i class="fa fa-print"></i></a>
								 <?php elseif($kur['kurikulum']=='K-13' AND $kur['model_rapor']=='2'): ?>
                                     <a href="sandik_rapor/print_rapor2.php?nis=<?= $siswa['nis'] ?>" target="_blank" class="btn btn-sm btn-outline-danger"><i class="fa fa-print"></i></a>
								  <?php elseif($kur['kurikulum']=='Merdeka' AND $kur['model_rapor']=='3'): ?>
                                     <a href="sandik_rapor/print_rapor3.php?ids=<?= $siswa['id_siswa'] ?>" target="_blank" class="btn btn-sm btn-outline-danger"><i class="fa fa-print"></i></a>
								  
								  <?php endif; ?>
								 </td>
                                </tr>

                            <?php }
                            ?>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

 <?php } elseif ($ac == 'leger') { ?>
<?php $kelas = $_POST['kls']; ?>
<?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='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-print"></i> Cetak Leger - <?= $kelas ?></h4></div>    
			  
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Rapor <?= $kur['kurikulum'] ?></a></li>
					</ul>					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>					
						<div class="panel panel-default">
                 <div class="col-md-3"></div>	
                 <div class="col-md-6">				 
                <div class='box-body'>
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-bordered table-hover" >
                        <thead>
                            <tr>
                                 <th class="text-center" width="3%" >
                                    #
                                </th>
                                <th >Leger</th>
								 <th >Print</th>
								
							</tr>
                        </thead>
                        <tbody>
                           
                                
									
                               	<?php if($kur['kurikulum']=='K-13'){ ?>
									<tr>
									  <td>1</td>
									<td>Pengetahuan (KI-3)</td>
									<td style="text-align:center">
                                        <a href="sandik_rapor/legerP.php?kelas=<?= $kelas ?>" target="_blank" class='btn btn-xs btn-flat btn-warning' ><i class='fa fa-print'></i> </a>                                        		
										   </td>
									 </tr><tr>
									  <td>2</td>
									<td>Keterampilan (KI-4)</td>
									<td style="text-align:center">
                                       <a href="sandik_rapor/legerK.php?kelas=<?= $kelas ?>" target="_blank" class='btn btn-xs btn-flat btn-success' ><i class='fa fa-print'></i> </a>                                        
										 
									</td>
									
									 </tr>
								    <?php } ?>
	                       <?php if($kur['kurikulum']=='Merdeka'){ ?>
									<tr>
                                    <td>1</td>
                                    <td>Leger Nilai</td>
									<td style="text-align:center">
                                       <a href="sandik_ikm/dna.php?kelas=<?= $kelas ?>" target="_blank" class='btn btn-xs btn-flat btn-success' ><i class='fa fa-print'></i> </a>                                        
										 
									</td>
									
								    <?php } ?>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php } ?>	