<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
if($menu['rapor']=='0'){{$rapor="Non Aktif";}}elseif($menu['rapor']=='1'){{$rapor="Aktif";}}

?>
<?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-tools"></i> Pengaturan Rapor</h5></div>    
			    
						<div class="card-body">
                    <form id='menu'  method='post'>
					 <div class="row mb-1">
					   <label  class="col-md-3 col-form-label bold">Menu Guru</label>
							  <div class="col-sm-5">
						    <select name='guru'  class='form-select' required='true'>
                               <option value="<?= $menu['rapor'] ?>"><?= $rapor ?></option>
                                   <option value=''>Pilih Menu</option>
								   <option value='0'>Non Aktif</option>
								   <option value='1'>Aktif</option>
                                          </select>   
						          	</div>
									</div>
					 <div class="row mb-1">
					   <label  class="col-md-3 col-form-label bold">Tingkat</label>
							  <div class="col-sm-5">
						    <select name='level' id="level" class='form-select' required='true'>
                               <option value=''>Pilih Tingkat</option>
                                  <?php $qt = mysqli_query($koneksi, "SELECT * FROM kelas GROUP BY level"); ?>
                                     <?php while ($mt = mysqli_fetch_array($qt)) : ?>
                                         <option value="<?= $mt['level'] ?>"><?= $mt['level'] ?></option>
                                                <?php endwhile ?>
                                          </select>   
						          	</div>
									</div>
							<div class="row mb-1">
					   <label  class="col-md-3 col-form-label bold">Kurikulum</label>
							  <div class="col-sm-9">
						   <select name="kuri" id="kuri" class="form-select" style="width: 100%;" >
                               
                                  </select>
							</div>
							</div>
							<div class="row mb-1">
					      <label  class="col-md-3 col-form-label bold">Mode Rapor</label>
							  <div class="col-sm-9">
						   <select name="rapor" id="rapor" class="form-select" style="width: 100%;" >
                               
                                  </select>
							</div>
		                   </div>
                          
							<div class="row mb-1" id="kkm" style='display: none;'>
					      <label  class="col-md-3 col-form-label bold">Mode KKM</label>
							  <div class="col-sm-9">
						   <select name="kkm"  class="form-select" style="width: 100%;" >
                               <option value=''>--Pilih KKM--</option> 
							   <option value='singgle'>SINGGLE</option> 
							   <option value='multi'>MULTI</option> 
                                  </select>
							</div>
		                    </div>
							<div class="row mb-1">
					      <label  class="col-md-3 col-form-label bold">Semester</label>
							  <div class="col-sm-9">
						   <select name="smt" id="smt" class="form-select" style="width: 100%;" >
                               <option value="<?= $setting['semester']  ?>">Semester <?= $setting['semester']  ?></option>
							    <option value='1'>Semester 1</option>
                                 <option value='2'>Semester 2</option>								
                                  </select>
							</div>
		                   		</div>			      
							<div class="row mb-1">
					      <label  class="col-md-3 col-form-label bold">Ta Pel</label>
							  <div class="col-sm-9">
						   <input type="text" name="tp" value="<?= $setting['tp']  ?>" class="form-control" >
							</div>
		                    </div>
							<div class="row mb-1">
					      <label  class="col-md-3 col-form-label bold">Tgl Rapor</label>
							  <div class="col-sm-9">
						   <input type="text" name="tanggal_rapor" value="<?= $setting['tanggal_rapor']  ?>" class="form-control" placeholder="Contoh: 27 Desember 2022" required="true">
							</div>
							</div>
		                 <p>
						 <div class="right">
					   <button type='submit' name='submit' class='btn btn-success'><i class='fa fa-check-circle' ></i><span> Simpan</span></button>     
					 </div>
					  </form>
                        </div>
					 </div>
					   </div>
					   
					 <div class='col-md-5'>
						   <div class="card">
							 <div class="card-header">	
								  <h5 class='card-title'>
								  <i class="fas fa-trash"></i> Reset Data Rapor</h5></div>   
                                       <div class="card-body">         
												<div class='checkbox'>
												 <form id='formhapusdata' action='' method='post'>
                                                      <b>Kurikulum K-13</b><br />
                                                    <label><input type='checkbox' name='data[]' value='nilai_rapor' /> Nilai Rapor K-13</label><br />
													<label><input type='checkbox' name='data[]' value='deskripsi' /> Deskripsi Rapor K-13</label><br />
													<label><input type='checkbox' name='data[]' value='sosial' /> Nilai Sikap Sosial</label><br />
													<label><input type='checkbox' name='data[]' value='spiritual' /> Nilai Sikap Spiritual</label><br />
													<label><input type='checkbox' name='data[]' value='m_eskul' /> Master Ekstrakurikuler</label><br />
													<label><input type='checkbox' name='data[]' value='siswa_eskul' /> Data Siswa Ekstrakurikuler</label><br />
													<label><input type='checkbox' name='data[]' value='siswa_eskul' /> Nilai Sikap Rapor K-13 Versi 2022</label><br />
													 <b>Kurikulum Merdeka</b><br />
													<label><input type='checkbox' name='data[]' value='lingkup' /> Lingkup Materi</label><br />
													<label><input type='checkbox' name='data[]' value='tujuan' /> Tujuaan Pembelajaran</label><br />
													<label><input type='checkbox' name='data[]' value='nilai_formatif' /> Nilai Formatif</label><br />
													 <label><input type='checkbox' name='data[]' value='nilai_sumatif' /> Nilai Sumatif</label><br />
													  <b>Kurikulum Merdeka - Rapor Proyek</b><br />
													  <label><input type='checkbox' name='data[]' value='m_proyek' /> Master Proyek</label><br />
													  <label><input type='checkbox' name='data[]' value='proyek' /> Data Proyek</label><br />
													 <label><input type='checkbox' name='data[]' value='nilai_proses' /> Nilai Proses</label><br />
													 <label><input type='checkbox' name='data[]' value='nilai_proyek' /> Nilai Proyek</label><br />
                                                </div>
                                            </div>
											<div class="card-body">  
                                            <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Password Admin</label>
													<div class="col-sm-8">
													<div class="input-group">
                                                    <input type='password' name='password' class='form-control' required='true' />
                                                <span class="input-group-btn">
												 <button type='submit' name='submit3' class='btn btn-outline-danger'><i class='fa fa-trash'></i> Reset</button>
												</span>
												</div>
                                               </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        
                    </div>
                </div>
            </div>
        
   
					<script>
 
    $('#formhapusdata').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'pengaturan/crud_setting.php?pg=setting_clear',
            data: $(this).serialize(),
            success: function(data) {
                console.log(data);
                if (data == "ok") {
                     iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil dihapus',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
					setTimeout(function() {
                        window.location.reload();
                    }, 2000);
                } else {
                    iziToast.error({
                        title: 'Maaf!',
                        message: data,
                        position: 'topRight'
                    });
                }

            }
        });
        return false;
    });
	
</script>   
					   
					   
					   
					   
					   
					   
					   <div class='col-md-7' style="margin-top:-90px">
					 <div class="card">
                    <div class="card-header"></div>
						<div class="card-body">
						<div class='table-responsive'>
                    <table id='example' style="font-size: 12px" class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>#</th>
                               
                                <th>Tingkat</th>
                                <th>Rombel</th>
                                <th>Kurikulum</th>
								<th>Model Rapor</th>
								<th>Model KKM</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $lev = mysqli_query($koneksi, "SELECT * FROM kelas ORDER BY level ASC"); ?>
                            <?php while ($k = mysqli_fetch_array($lev)) : ?>
                             <?php $rapor=fetch($koneksi,'m_kurikulum',['id'=>$k['model_rapor']]); ?>   
								<?php $no++; ?>
                                <tr>
                                    <td><?= $no ?></td>
                                    <td><?= $k['level'] ?></td>
                                    <td><?= $k['id_kelas'] ?></td>
                                    <td><?= $k['kurikulum'] ?></td>  
                                    <td><?= $rapor['rapor'] ?></td> 
									<td><?= strtoupper($k['model_kkm']) ?></td>
                                </tr>
                            <?php endwhile ?>
                        </tbody>
                    </table>
					   </div>
					 </div>
				</div>
			</div>
		</div>
		</div> 
		<script>
        $("#level").change(function() {
        var level = $(this).val();
        console.log(level);
        $.ajax({
            type: "POST",
            url: "sandik_rapor/crud_setting.php?pg=ambilkuri", 
            data: "level=" + level, 
            success: function(response) { 
                $("#kuri").html(response);
            }
        });
    });
	$("#kuri").change(function() {
        var kuri = $(this).val();
        console.log(kuri);
        $.ajax({
            type: "POST",
            url: "sandik_rapor/crud_setting.php?pg=model", 
            data: "kuri=" + kuri, 
            success: function(response) { 
                $("#rapor").html(response);
            }
        });
    });
</script>
	<script type="text/javascript">
    $(function () {
        $("#kuri").change(function () {
            if ($(this).val() == "K-13") {
                $("#kkm").show();
           
            }else{
                $("#kkm").hide();
              }
        });
    }); 
		 </script>
		  <script>
		$('#menu').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_rapor/crud_setting.php?pg=setting_rapor',
            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.reload();
                }, 2000);

            }
        });
        return false;
    });
</script>
						
                       
<?php } ?>