

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


 <div class='row'>
 <div class="col-lg-12">
     <div id="kandidat">      
							
			         
		</div>
		</div>
		</div>
		<script type="text/javascript">
		$(document).ready(function(){
			setInterval(function(){
				$("#kandidat").load('sandik_vote/hasil.php')
			}, 1000);  
		});
	</script>
   <div class='row'>
    <div class="col-md-8" >
        <div class="card">
      <div class="card-header">	
			
                <h5 class='card-title'>
                    Informasi Data Pemilih
                </h5>
               
            </div>
            <div class='card-body' >
             <div id="pemilih"> 
			 </div>
        </div>
		</div>
		</div>
		<script type="text/javascript">
		$(document).ready(function(){
			setInterval(function(){
				$("#pemilih").load('sandik_vote/pemilih.php')
			}, 1000);  
		});
	</script>
            <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('?');
}
?>
     
				