<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
$skl = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM skl  WHERE id_skl='1'"));
?>
<div class='row'>
    <div class='col-md-12'>
        <div class="card">
             <div class="card-header">	
                    <h5 class='card-title'><i class="fas fa-users-cog"></i> Update Data Siswa</h5>
					</div>   
                 		
            <div class='card-body'>

                                <form id='formsiswa' enctype='multipart/form-data'>
                                    <div class='col-md-4'>
                                        <label>Pilih File</label>
                                        <input type='file' name='file' class='form-control' required='true' />
                                    </div>
                                    <div class='col-md-4'>
                                        <label>&nbsp;</label><br>
                                        <button type='submit' name='submit' class='btn-sm btn-success'><i class='fa fa-upload'></i> Import</button>
                                    </div>
                                </form>
                           
                       
						<br>
						
						 <a href="sandik_skl/ekspor.php?level=<?= $skl['tingkat'] ?>" class="btn-link"><i class='fa fa-download'></i> <b>Download Format</b></a>
						
                        <div id='progressbox'></div>
                        <div id='hasilimport'></div>
                    </div>
                </div>
            </div>
           
        </div>
    </div>
</div>
<script>
    $('#formsiswa').on('submit', function(e) {
        e.preventDefault();
        $.ajax({
            type: 'post',
            url: 'sandik_skl/import_siswa.php',
            data: new FormData(this),
            processData: false,
            contentType: false,
            cache: false,
            beforeSend: function() {
                $('#progressbox').html('<div><img src="<?= $homeurl ?>/dist/img/animasi1.gif" style="margin-left:100px"></div>');
                $('.progress-bar').animate({
                    width: "30%"
                }, 100);
            },
            success: function(response) {
                setTimeout(function() {
                    $('.progress-bar').css({
                        width: "100%"
                    });
                    setTimeout(function() {
                        $('#hasilimport').html(response);
						});
						setTimeout(function() {
                    window.location.replace('?pg=siswa');
                    }, 2000);
                }, 2000);
            }
        });
    });
</script>
