<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");

?>  
<?php
				$query = mysqli_query($koneksi, "SELECT * FROM reset ORDER BY id DESC LIMIT 10"); 
				$cek = mysqli_num_rows($query);
				if ($cek >= 1) {
				while ($data = mysqli_fetch_array($query)) :
				 $nilai = fetch($koneksi,'nilai',['id_nilai'=>$data['idnilai']]);
				 $bank = fetch($koneksi,'banksoal',['id_bank'=>$nilai['id_bank']]);
				
				 $siswa = fetch($koneksi,'siswa',['id_siswa'=>$nilai['id_siswa']]);
				$no++;
                ?>

							   <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"><b><?= $siswa['nama'] ?> <p class="kanan">KELAS <?= $siswa['kelas'] ?> - <?= $bank['nama'] ?></p></b></span>
                                                    <span class="widget-payment-request-author-about">JAM <?= date('H:i:s',strtotime($nilai['ujian_selesai'])); ?><br><?= $nilai['jenis_browser'] ?> </span>
                                                <div class="spinner-grow text-danger kanan" role="status">
														<span class="visually-hidden">Loading...</span>
													</div>
												</div>
											
                                            </div>
                                        
											 <div class="widget-payment-request-actions m-t-lg d-flex" id="datatable1">
                                               <button data-id="<?= $data['idnilai'] ?>" class="selesai btn btn-secondary flex-grow-1 m-l-xxs">Reject</a>
                                                <button data-id="<?= $data['idnilai'] ?>" class="hapus btn btn-primary flex-grow-1 m-l-xxs">Approve</button>
                                            </div>
												<?php endwhile; ?>
												
												
												 <?php } ?>
												 
												 
												 
												 
												 
						<script>
						$('#datatable1').on('click', '.hapus', function() {
							var id = $(this).data('id');
							console.log(id);
							swal({
							title: 'Yakin Reset Peserta Ujian?',
							text: "You won't be able to revert this!",
							type: 'warning',
							showCancelButton: true,
							confirmButtonColor: '#3085d6',
							cancelButtonColor: '#d33',
							confirmButtonText: 'Ya, Reset!',
							cancelButtonText: "Batal"				  
							}).then((result) => {
							if (result.value) {
							$.ajax({
								url: 'asesmen/tsiswa.php?pg=resetbrowser',
								method: "POST",
								data: 'id=' + id,
								success: function(data) {
								iziToast.info(
							{
							title: 'Sukses!',
							message: 'Data berhasil direset',
							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>
						$('#datatable1').on('click', '.selesai', function() {
							var id = $(this).data('id');
							console.log(id);
							swal({
							title: 'Yakin Selesaikan Peserta Ujian?',
							text: "You won't be able to revert this!",
							type: 'warning',
							showCancelButton: true,
							confirmButtonColor: '#3085d6',
							cancelButtonColor: '#d33',
							confirmButtonText: 'Ya, Reset!',
							cancelButtonText: "Batal"				  
							}).then((result) => {
							if (result.value) {
							$.ajax({
								url: 'asesmen/tsiswa.php?pg=selesai',
								method: "POST",
								data: 'id=' + id,
								success: function(data) {
								iziToast.info(
							{
							title: 'Sukses!',
							message: 'Data berhasil diselesaikan',
							titleColor: '#FFFF00',
							messageColor: '#fff',
							backgroundColor: 'rgba(0, 0, 0, 0.5)',
							progressBarColor: '#FFFF00',
							position: 'topRight'				  
							});
							setTimeout(function() {
							window.location.reload();
										}, 2000);
									}
								});
							}
							return false;
									})

								});

							</script>