<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
$jumbank = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM banksoal"));
$jumsoal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM soal"));
?>           
	
                   <div class="row">
                          <div class="col-md-8">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">SINKRON DATA SOAL</h5>
										
                                    </div>
                                    <div class="card-body">
									<div id='progressbox'></div>
									<p>
									<div class="row">
									 <div class="col-xl-6">
                                <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">inbox</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">BANK SOAL</span>
                                                <span class="widget-stats-amount"><?= number_format($jumbank); ?></span><p>
                                               
                                            </div>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
							<div class="col-xl-6">
                                <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">mark_chat_read</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">JUMLAH SOAL</span>
                                                <span class="widget-stats-amount"><?= number_format($jumsoal); ?></span><p>
                                               
                                            </div>
                                            
                                        </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-2">
									<button class="btn btn-secondary" type="button" disabled>
										<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
										 SINKRON DATA SOAL
									</button>
											</div>
										<p>
									<form id='formsinkron' class="row g-1"> 
									 <input type="hidden" class="form-control" name="tokenapi" id="tokenapi" value="<?= $setting['token_api'] ?>" readonly>
									<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-2">
                                       
                                         <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/sinkronsoal.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 ?>
					  
					  
					  
					  	  
					  
					  
					