 <?php 
$jumguru = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM users WHERE level='guru'"));
$jumstaff = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM users WHERE level='staff'"));
$jumsiswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa"));


?>



                       <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">TOTAL GURU</span>
                                                <span class="widget-stats-amount"><?= $jumguru ?></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 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">TOTAL STAFF</span>
                                                <span class="widget-stats-amount"><?= $jumstaff ?></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 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 SISWA</span>
                                                <span class="widget-stats-amount"><?= $jumsiswa ?></span><p>
                                                <span class="widget-stats-info"><?= $setting['sekolah'] ?></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-negative 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">LOG ABSENSI</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">
									
                                        <h5 class="card-title">PROGRES ABSENSI HARI INI</h5>
										
                                    </div>
                                    <div class="card-body">
									  <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 ABSENSI</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 Absensi</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="absensi" name="data[]">
                                                    </div>
                                                </span>
                                                <span class="widget-list-item-description">
                                                    <a href="#" class="widget-list-item-description-title">
                                                        Absensi
                                                    </a>
                                                    <span class="widget-list-item-description-subtitle">
                                                       <?= $jwb ?> 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() {
									
									$('#logabsen').load('cbtserver_absen/logabsen.php');
									$('#loglive').load('cbtserver_absen/logstatus.php');
									
								}, 1000
							);
						</script>
