 <?php 
$jumbank = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM banksoal"));
$jumsoal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM soal"));
$jumnilai = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai"));
$jumjadwal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM ujian"));
$jumsiswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa"));
$totaldata = $jumbank + $jumsoal + $jumnilai + $jumjadwal;
$memo = memory_get_usage(true) . "\n"; 
$use = memory_get_usage(false) . "\n";
$ttl = $use+$memo;
$pakai = ($memo/$ttl)*100;
?>

<?php
$df = disk_free_space("C:");
$dt = disk_total_space("C:");
$du = $dt - $df;
$dp = sprintf('%.2f',($du / $dt) * 100);
$df = formatSize($df);
$du = formatSize($du);
$dt = formatSize($dt);

function formatSize( $bytes )
{
        $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
        for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
                return( round( $bytes, 2 ) . " " . $types[$i] );
}

?>

                       <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">storage</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">Free Disk</span>
                                                <span class="widget-stats-amount"><?= ($dt-$du); ?> GB</span>
                                                <span class="widget-stats-info" style="color:red;"><?= ($du); ?> GB Used Disk</span>
                                            </div>
                                           
                                        </div>
										 <div class="progress">
                                            <div class="progress-bar bg-danger"  role="progressbar" style="width: <?= ($du/$dt)*100; ?>%;" aria-valuenow="<?= ($du/$dt)*100; ?>" aria-valuemin="0" aria-valuemax="100"></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-warning">
                                                <i class="material-icons-outlined">memory</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">Free RAM</span>
                                                <span class="widget-stats-amount"><?= round($use/1024000,2); ?> GB</span>
                                                <span class="widget-stats-info" style="color:blue;"><?= round(($use+$memo+512000)/1024000,2); ?> GB Used</span>
                                            </div>
                                            
                                        </div>
										 <div class="progress">
                                            <div class="progress-bar"  role="progressbar" style="width: <?= $pakai; ?>%;" aria-valuenow="<?= ($du/$dt)*100; ?>" aria-valuemin="0" aria-valuemax="100"></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">DATA ASESMEN</span>
                                                <span class="widget-stats-amount"><?= number_format($totaldata); ?></span><p>
                                                <span class="widget-stats-info"><?= $setting['sekolah'] ?></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-positive align-self-start">
                                                <i class="material-icons">keyboard_arrow_up</i>
                                            </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">PERMINTAAN RESET</h5>
                                    </div>
                                    <div class="card-body">
                                        <div id='logreset' ></div> 
                                            
                                            
                                           
                                        </div>
                                    </div>
                                </div>
                          
                            <div class="col-xl-5">
                                <div class="card widget widget-list">
                                    <div class="card-header">
									
                                        <h5 class="card-title">STATUS PESERTA</h5>
										
                                    </div>
                                    <div class="card-body">
									  <div id='loglive' ></div> 
										
                                </div>
                               </div>
                             	<?php
							
							$jwb = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jawaban"));
							$jwdup = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jawaban_dup"));
							$jnilai = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai"));

							?> 
													
                                <div class="card widget widget-list">
                                    <div class="card-header">
                                        <h5 class="card-title">HAPUS DATA TABEL ASESMEN</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</b></span>
								</div>
								 <?php if ($user['level']=='admin'): ?>
									<form id='formhapusdata' action='' method='post'>
                                        <ul class="widget-list-content list-unstyled">
                                            <li class="widget-list-item widget-list-item-green">
                                                <span class="widget-list-item-check">
                                                    <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="jawaban" name="data[]">
                                                    </div>
                                                </span>
                                                <span class="widget-list-item-description">
                                                    <a href="#" class="widget-list-item-description-title">
                                                        Data Jawaban
                                                    </a>
                                                    <span class="widget-list-item-description-subtitle">
                                                       <?= $jwb ?> data
                                                    </span>
                                                </span>
                                            </li>
                                            <li class="widget-list-item widget-list-item-blue">
                                                <span class="widget-list-item-check">
                                                    <div class="form-check form-check-inline">
                                                        <input class="form-check-input" type="checkbox" value="jawaban_dup" name="data[]">
                                                    </div>
                                                </span>
                                                <span class="widget-list-item-description">
                                                    <a href="#" class="widget-list-item-description-title">
                                                        Data Jawaban Duplikat
                                                    </a>
                                                    <span class="widget-list-item-description-subtitle">
                                                       <?= $jwdup ?> data
                                                    </span>
                                                </span>
                                            </li>
                                            <li class="widget-list-item widget-list-item-purple">
                                                <span class="widget-list-item-check">
                                                    <div class="form-check form-check-inline">
                                                       <input class="form-check-input" type="checkbox" value="nilai" name="data[]">
                                                    </div>
                                                </span>
                                                <span class="widget-list-item-description">
                                                    <a href="#" class="widget-list-item-description-title">
                                                        Data Nilai
                                                    </a>
                                                    <span class="widget-list-item-description-subtitle">
                                                       <?= $jnilai ?> data
                                                    </span>
                                                </span>
                                            </li>
                                            <div class="widget-payment-request-actions m-t-lg d-flex">
                                              
                                                <button type="submit" id="blockui-2" class="btn btn-primary flex-grow-1 m-l-xxs">Reset Data</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() {
									
									$('#logreset').load('asesmen/logreset.php');
									$('#loglive').load('asesmen/loglive.php');
									$('#hadir').load('logandro.php');
								}, 1000
							);
						</script>
