<script type="text/javascript">
		$(document).ready(function(){
			setInterval(function(){
				$("#norfid").load('sandik_ptm/nokartu.php')
			}, 1000);  
		});
	</script>
<div class='row'>
        <div class='col-md-6'>
            <div class="card">
             <div class="card-header">	
			    <div class='right '>
				<h5 class="sandik" style="color:blue"><b>Tempelkan Kartu RRFID</b> </h5>
				   </div>
                  <h5 class='card-title'><i class="fas fa-tools"></i> Register RFID</h5></div>    
			  
			 
						<div class="card-body">
						<?php $id=$_GET['id']; ?>
						<?php
						$siswa=fetch($koneksi,'siswa',['id_siswa'=>$_GET['id']]);
						?>
                    <form id='formkartu'  action="">
						<div class="box-body">
					         <div class="form-group">
							<label class="col-sm-3 control-label bold">ID</label>
							<div class="col-sm-5">
						    <select name="id" id="id" class="form-control" style="width: 100%;">
                             <option value="<?= $id  ?>"><?= $id  ?></option>
								
                                  </select>
							</div>
		                    </div>
							
					      <div class="form-group">
							<label class="col-sm-3 control-label bold">Nama Siswa</label>
							<div class="col-sm-9">
						   <input type="text" name="nama" class="form-control" value="<?= $siswa['nama'] ?>" >
							</div>
		                    </div>
							
					      <div class="form-group">
							<label class="col-sm-3 control-label bold">Kelas</label>
							<div class="col-sm-9">
						   <input type="text" name="kelas" class="form-control" value="<?= $siswa['id_kelas'] ?>" >
							</div>
		                    </div>
							
					      <div class="form-group">
							<label class="bold">No Kartu</label>
							<div class="col-sm-12">
						 <div id="norfid"></div>
							</div>
		                    </div>
					
							<p>
					 <div class="right">
					 <button type='submit' name='submit' class='btn btn-outline-success'><i class='fa fa-check-circle' ></i> Simpan</button>
					 </div>
					  </form>
                        </div>
					 </div>
                        </div>
						  </div>
                       <script>
  $('#formkartu').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'sandik_ptm/crud_kartu.php?pg=tambah_siswa',
            data: $(this).serialize(),
            beforeSend: function() {
                $('form button').on("click", function(e) {
                    e.preventDefault();
                });
            },
            success: function(data) {
                console.log(data);
                if (data == 'OK') {
                      iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
				  });
                    setTimeout(function() {
                        window.location.replace('?pg=rfidsiswa');
                    }, 500);
                } else {
                   iziToast.info(
            {
                title: 'Gagal!',
                message: 'Data Gagal disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
					setTimeout(function() {
                        window.location.reload();
                    }, 1000);
                }

            }
        });
        return false;
    });
   
</script>
 <div class='col-md-6'>
            <div class="card">
             <div class="card-header">	
                  <h5 class='card-title'><i class="fas fa-tools"></i> Register RFID</h5></div>    
			  
			 
						<div class="card-body" style="text-align:center;">
						<img src="<?= $homeurl ?>/<?= $setting['logo'] ?>" style="max-width:70px">
						<hr>
						<h5  style="color:blue"><b>Tempelkan Kartu RRFID</b> </h5>
						<img src="<?= $homeurl ?>/dist/img/animasi2.gif" >
						</div>
                        </div>
						  </div>
						   </div>