<?php
$nilai = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM nilai"));
$soal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM soal_quiz"));
$siswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa"));
$materi = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM materi"));
$tugas = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM tugas"));
$mapel = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM mata_pelajaran"));
$online = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jawaban"));
$ujian = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM ujian where status='1'"));
$jawaban = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jawaban_quiz"));
?>

<?php if ($user['level'] == 'admin') : ?>


 <div class='row'>
 <div class="col-lg-8">
            <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-content flex-fill">
                                                <span class="widget-stats-title">Data Siswa</span>
                                                <span class="widget-stats-amount"><?= $siswa ?></span>
                                               
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-users-cog"></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-content flex-fill">
                                                <span class="widget-stats-title">DATA MAPEL</span>
                                                <span class="widget-stats-amount"><?= $mapel ?></span>
                                               
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-book"></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-content flex-fill">
                                                <span class="widget-stats-title">DATA MATERI</span>
                                                <span class="widget-stats-amount"><?= $materi ?></span>
                                               
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-chevron-down"></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-content flex-fill">
                                                <span class="widget-stats-title">DATA TUGAS</span>
                                                <span class="widget-stats-amount"><?= $tugas ?></span>
                                                
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-laptop"></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-content flex-fill">
                                                <span class="widget-stats-title">DATA QUIZ</span>
                                                <span class="widget-stats-amount"><?= $soal ?></span>
                                               
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-envelope"></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-content flex-fill">
                                                <span class="widget-stats-title">JAWABAN QUIZ</span>
                                                <span class="widget-stats-amount"><?= $jawaban ?></span>
                                              
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-edit"></i> 
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
							
							 </div>
							  </div>
				
            
			
		
		 <div class="col-md-4" >
           <div class="card">
      <div class="card-header">	
				<h5 class='card-title'>Posko Sekolah</h5>
                        </div>  
						
                    <ul class="list-group">
                        <li class="list-group-item"><img src="../dist/img/guru.png" width="45" class="success" alt="">
                             &nbsp;&nbsp;Kepala Sekolah</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="?pg=teknis" class="btn btn-sm btn-link"><b><?php echo $setting['kepsek']; ?></b></a>
                    
                            </li>
                        <li class="list-group-item"><img src="../dist/img/support-custom.png" width="45" alt="">
                            
                              &nbsp;&nbsp;Proktor</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="?pg=teknis" class="btn btn-sm btn-link"><b><?php echo $setting['proktor']; ?></b></a>
                            </li>
                       
							</ul>
							
						</div>
						  </div>
						    </div>
						       </div>
   <div class='row'>
    <div class="col-md-8" >
        <div class="card">
      <div class="card-header">	
			
                <h5 class='card-title'>
                    Informasi
                </h5>
               
            </div>
            <div class='card-body' >
               <div class='table-responsive'>
                        <table style="font-size: 11px" id='example1' class='table'>
                            <thead>
                                <tr>
                                    <th width='3px' style="text-align: center">No</th>
									 <th>Tanggal</th> 
                                    <th>Nama</th>  
                                     <th width="15%">Kelas</th> 										
										<th style="text-align: center">Ket</th>
											
                                </tr>
                            </thead>
							
							<tbody>
							
                                <?php
								$no = 0;
								$tanggal=date('Y-m-d');
							$query = mysqli_query($koneksi,"select * from absen_daring WHERE tanggal='$tanggal'");
                             $no = 0;
                                while ($dft = mysqli_fetch_array($query)) {
								$siswa = fetch($koneksi,'siswa',['id_siswa'=>$dft['idsiswa']]);
                                $no++;
                            ?>
							 <tr>
                                    <td style="text-align: center"><?= $no; ?></td>
									  <td><?= $dft['tanggal'] ?></td>
							        <td><?= $siswa['nama'] ?></td>
									  <td><?= $siswa['id_kelas'] ?></td>
									  
									    <td style="text-align: center">
										<?php if($dft['ket']=="H"){ ?>
										<b style="color:blue" class="siskolah">Hadir</b>
										<?php } ?>
										<?php if($dft['ket']=="A"){ ?>
										<b style="color : red;">Alpha</b>
										<?php } ?>
										<?php if($dft['ket']=="S"){ ?>
										<b style="color : blue;">Sakit</b>
										<?php } ?>
										<?php if($dft['ket']=="I"){ ?>
										<b style="color : blue;">Izin</b>
										<?php } ?>
										</td>
										
							       </tr>
                            <?php } ?>
                        </tbody>
                        </table>
            </div>
        </div>
		</div>
		</div>
            <div class='animated flipInX col-md-4' >
            <div class='box box-solid direct-chat direct-chat-warning'>
                <div class='card'>
				 <div class="card-header">	
                    <h5 class='card-title'><i class='fa fa-history'></i> Log Aktifitas</h5>
                    <div class='right'>
                        <a href='?pg=<?= $pg ?>&ac=clearlog' class='btn btn-default' title='Bersihkan Log'><i class='fa fa-trash'></i></a>
                    </div>
                </div>
                <div class='box-body'>
                    <div id='log-list'>
                        <p class='text-center'>
                            <br /><i class='fa fa-spin fa-circle-o-notch'></i> Loading....
                        </p>
                    </div>
                </div>
            </div>
        </div>
    

           	
                    	
<script>
$('#forminfowa').submit(function(e){
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_admin/crud_admin.php?pg=ubahinfo',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Infomasi 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>
<div class="modal fade" id="modalwa" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="formtugas">
                <div class="modal-body">
                    <iframe width="100%" height="415" src="<?= $setting['url_api'] ?>/scan" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                    <div class='modal-footer'>
                        <div class='box-tools pull-right btn-group'>
                            
                            <button type='button' class='btn btn-default btn-sm pull-left' data-dismiss='modal'>Close</button>
                        </div>
                    </div>
            </form>
        </div>
    </div>
</div>
<script>
$('#formwa').submit(function(e){
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_admin/crud_admin.php?pg=ubahwa',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Nomor WA Gateway 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>


<script>
$('#example').on('click', '.hapus', function() {
        var id = $(this).data('id');
        console.log(id);
        Swal.fire({
				  title: 'Are you sure?',
				  text: "Hapus Akun WA Gateway!",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#3085d6',
				  cancelButtonColor: '#d33',
				  confirmButtonText: 'Yes, delete it!'	
        }).then((result) => {
            if (result.value) {
                $.ajax({
                   url: 'sandik_admin/crud_admin.php?pg=hapusakun',
                    method: "POST",
                    data: 'id=' + id,
                    success: function(data) {
						  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);
                    }
                });
            }
            return false;
        })

    });

</script>



<?php endif ?>
<?php if ($user['level'] == 'pengawas') : ?>

<div class="row">
<div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading" style="height:45px">
                <h4 class='box-title'>
                    Informasi
                </h4>
                <div class='box-tools pull-right' id="hapus">
               			
                </div>
            </div>
            <div class='box-body'>
                <div id='pengumuman'>
                    <p class='text-center'>
                        <br /><i class='fa fa-spin fa-circle-o-notch'></i> Loading....
                    </p>
                </div>
            </div>
        </div>
    </div>
		
			
           
<div class='animated flipInX col-md-4'>
            <div class='box box-solid direct-chat direct-chat-warning'>
                <div class='box-header with-border'>
                    <h3 class='box-title'><i class='fa fa-history'></i> Log Aktifitas</h3>
                    <div class='box-tools pull-right'>
                      
                    </div>
                </div>
                <div class='box-body'>
                    <div id='log-list'>
                        <p class='text-center'>
                            <br /><i class='fa fa-spin fa-circle-o-notch'></i> Loading....
                        </p>
                    </div>
                </div>
            </div>
        </div>

    </div>
        <?php endif ?>
        <?php
if ($ac == 'clearlog') {
    mysqli_query($koneksi, "TRUNCATE log");
    jump('?');
}

if ($ac == 'clearpengumuman') {
    mysqli_query($koneksi, "TRUNCATE pengumuman");
    jump('?');
}
?>
     
				