 <?php 
$jaktif = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absen_daring WHERE tanggal='$tanggal'"));
$jmateri = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM materi WHERE tgl='$tanggal'"));
$jtugas = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM tugas"));


?>



                       <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">SISWA AKTIF HARI INI</span>
                                                <span class="widget-stats-amount"><?= $jaktif ?></span><p>
                                               
                                            </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">MATERI HARI INI</span>
                                                <span class="widget-stats-amount"><?= $jmateri ?></span><p>
                                                
                                            </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 TUGAS</span>
                                                <span class="widget-stats-amount"><?= $jtugas ?></span><p>
                                               
                                            </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 E LEARN HARI INI</h5>
										
                                    </div>
                                    <div class="card-body">
									  <div id='loglive' ></div> 
										
                                </div>
                               </div>
                             	<?php
							
							$jwb = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absen_daring"));
							
							?> 
													
                                <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="absen_daring" 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_learn/logabsen.php');
									$('#loglive').load('cbtserver_learn/logstatus.php');
									
								}, 1000
							);
						</script>
