 <?php 
$kls13 = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM kelas WHERE kurikulum='K-2013'"));
$kls23 = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM kelas WHERE kurikulum='K-Merdeka'"));
$jumsiswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa"));
$deskrip = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM deskrip"));
$jadwal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jadwal_rapor"));
$mapel = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM mapel_rapor"));
$nilai = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai_rapor"));
$lingkup = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM lingkup"));
$tujuan = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM tujuan"));
$formatif = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai_formatif"));
$sumatif = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai_sumatif"));
$tujuan = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM tujuan"));
$eskul = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa_eskul"));
?>




                       <div class="row">
                            <div class="col-xl-4">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-primary">
                                                <i class="material-icons-outlined">school</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">KURIKULUM 2013</span>
                                                <h2 class="bold"><span class="badge badge-primary"><?= $kls13 ?></span> <small class="badge badge-secondary">KELAS</small></h2>
                                               
                                            </div>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
							
                            <div class="col-xl-4">
                                 <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-success">
                                                <i class="material-icons-outlined">school</i>
                                            </div>
                                           <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">KURIKULUM MERDEKA</span>
                                                <h2 class="bold"><span class="badge badge-success"><?= $kls23 ?></span> <small class="badge badge-secondary">KELAS</small></h2>
                                               
                                            </div>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                          
                            <div class="col-xl-4">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-danger">
                                                <i class="material-icons-outlined">school</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">TOTAL PESERTA DIDIK</span>
                                                <h2 class="bold"><span class="badge badge-secondary"><?= $jumsiswa ?></span> <small class="badge badge-secondary">PD</small></h2>
                                               
                                            </div>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                           <div class="col-xl-7">
                                <div class="card widget widget-payment-request">
                                    <div class="card-header">
                                        <h5 class="card-title">PROGRES INPUT NILAI</h5>
                                    </div>
                                    <div class="card-body">
                                        <div id='logabsen' ></div> 
                                            
                                            
                                           
                                        </div>
                                    </div>
                                </div>
                          
                            <div class="col-xl-5">
                                <div class="card widget widget-list">
                                    <div class="card-header">
									
                                    </div>
                                    <div class="card-body">
									 <form id="formtujuan" action=''>
									 <div class="col-md-12">
									 <label class="bold">Tanggal Rapor</label>
									<input type="text" name="tanggal" class="form-control" value="<?= $setting['tanggal_rapor'] ?>" >
									</div>	  
									  <p>
									<div class="d-grid gap-2">
                                       <button type="submit" id="blockui-3" class="btn btn-primary">SIMPAN</button>
                         
                                            </div>
									     </form>
										 <p>
										  <h5 class="card-title">PROGRES NILAI</h5>
									  <div id='loglive' ></div> 
										
                                </div>
                               </div>
                             	<?php
							
							$jwb = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi"));
							
							?> 
													
                                <div class="card widget widget-list">
                                    <div class="card-header">
                                        <h5 class="card-title">HAPUS DATA TABEL E-RAPOR</h5>
                                    </div>
                                    <div class="card-body">
                                    <div class="alert alert-custom" role="alert">
									<span>Jika Server Terasa Lamban Silahkan Hapus Data dibawah ini, Namun sebelumnya Anda <b>Telah mecetak Data Nilai Atau Backup Data</b></span>
								</div>
								 <?php if ($user['level']=='admin'): ?>
									<form id='formhapusdata' action='' method='post'>
                                        
                                                    <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="mapel_rapor" name="data[]">
                                                     <span class="widget-list-item-description"> Mata Pelajaran Rapor  <?= $mapel ?> data </span>
													</div>
                                              <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="jadwal_rapor" name="data[]">
                                                     <span class="widget-list-item-description"> Jadwal Mata Pelajaran  <?= $jadwal ?> data </span>
													</div>
                                              <h5><span class="badge badge-secondary">KURIKULUM 2013</span></h5>
                                             <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="deskrip" name="data[]">
                                                     <span class="widget-list-item-description"> Deskripsi <?= $deskrip ?> data </span>
													</div>
													 <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="nilai_rapor" name="data[]">
                                                     <span class="widget-list-item-description"> Nilai Rapor <?= $nilai ?> data </span>
													</div>
													<h5><span class="badge badge-secondary">KURIKULUM MERDEKA</span></h5>
													 <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="lingkup" name="data[]">
                                                     <span class="widget-list-item-description"> Lingkup Materi <?= $lingkup ?> data </span>
													</div>
													 <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="tujuan" name="data[]">
                                                     <span class="widget-list-item-description"> Tujuan Pembelajaran <?= $tujuan ?> data </span>
													</div>
													 <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="nilai_formatif" name="data[]">
                                                     <span class="widget-list-item-description"> Nilai Formatif <?= $formatif ?> data </span>
													</div>
													 <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="nilai_sumatif" name="data[]">
                                                     <span class="widget-list-item-description"> Nilai Sumatif <?= $sumatif ?> data </span>
													</div>
													  <h5><span class="badge badge-secondary">EKSTRAKURIKULER</span></h5>
													<div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="siswa_eskul" name="data[]">
                                                     <span class="widget-list-item-description"> Peserta & Nilai Eskul <?= $eskul ?> data </span>
													</div>
													
													
													
                                            <div class="widget-payment-request-actions m-t-lg d-flex">
                                              
                                                <button type="submit" id="blockui-2" class="btn btn-danger flex-grow-1 m-l-xxs">Reset Data E-Rapor</button>
                                            </div>
                                        </ul>
										</form>
										<?php endif; ?>
                                    </div>
                                </div>
                            </div>
						</div>
                       </div>
					  
	
	<script>						
$('#formhapusdata').submit(function(e) {
        e.preventDefault();

        $.ajax({
            type: 'POST',
            url: 'asesmen/tsetting.php?pg=clear',
            data: $(this).serialize(),
            success: function(data) {
                console.log(data);
                if (data == "ok") {
                   setTimeout(function()
				{
				window.location.reload();
						}, 2000);
                } else {
                    iziToast.warning(
            {
                title: 'Gagal!',
                message: 'Belum ada yang dipilih',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: '#8b0000',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
                }

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

							var autoRefresh = setInterval(
								function() {
									
									$('#logabsen').load('cbtserver_rapor/loginput.php');
									$('#loglive').load('cbtserver_rapor/logstatus.php');
									
								}, 1000
							);
						</script>
<script>
	 $('#formtujuan').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
        $.ajax({
            type: 'POST',
            url: 'cbtserver_rapor/tkuri.php?pg=rapor',
            enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
           
                setTimeout(function() {
                    window.location.reload();
                }, 2000);

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