<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
$jsiswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa"));
?>           
	
                   <div class="row">
                          <div class="col-md-8">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">SINKRON DATA SISWA</h5>
										
                                    </div>
                                    <div class="card-body">
									<div id='progressbox'></div>
									<p>
									 <div class="col-xl-12">
                                <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">PESERTA DIDIK</span>
                                                <span class="widget-stats-amount"><?= $jsiswa ?> PD</span><p>
                                                
                                            </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>
										
									</div>
									<?php if ($ac == '') : ?>
					       <div class="col-md-4">
                     
                                <div class="card widget widget-payment-request">
                                    <div class="card-header">
                                  
                                    </div>
                                    <div class="card-body">
                                        <div class="widget-payment-request-container">
                                            <div class="widget-payment-request-author">
                                                <div class="avatar m-r-sm">
                                                    <img src="../images/user.png" alt="">
                                                </div>
                                                <div class="widget-payment-request-author-info">
                                                    <span class="widget-payment-request-author-name"><?= strtoupper($user['nama']) ?></span>
                                                    <span class="widget-payment-request-author-about"><?= $setting['sekolah'] ?></span>
                                               
											   </div>
                                            </div>
											
									<div class="widget-payment-request-info m-t-md">
									 <div class="d-grid gap-1">
									<button class="btn btn-secondary" type="button" disabled>
										<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
										 SINKRON DATA SISWA
									</button>
											</div>
										
									<form id='formsinkron' class="row g-1"> 
									<p>
									 <div class="col-md-12">
									 <input type="text" class="form-control" value="<?= $setting['sekolah'] ?>" readonly>
									 </div>
									
									  <div class="col-md-12">
									 <input type="text" class="form-control" value="<?= $setting['url_host'] ?>" readonly>
									 </div>
                                     <p>
									  
								           <div class="d-grid gap-3">
                                       
                                         <button type="submit" class="btn btn-primary flex-grow-1 m-l-xxs">SINKRON</button>
                                          
                                            </div>
										</form>
										
										</div>
									 </div>
					            </div>
								</div>
							</div>
						</div>
					</div>
				</div>
			
<script>
    $('#formsinkron').submit(function(e){
    e.preventDefault();
    var data = new FormData(this);
    $.ajax(
    {
        type: 'POST',
        url: 'sinkron/sinkrondata.php',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
       beforeSend: function() {
                $('#progressbox').html('<div><label class="cbtserver" style="color:blue;margin-left:10px;">Data sedang di proses</label>&nbsp;&nbsp;&nbsp;<img src="../images/animasi1.gif" ></div>');
                $('.progress-bar').animate({
                    width: "30%"
                }, 1000);
            },
			success: function(data){ 
            setTimeout(function()
            {
                window.location.reload();
            }, 2000);
		  
        }
    });
    return false;
});
</script>				   
					  <?php endif ?>
					  
					  
					  
					  	  
					  
					  
					