 <?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php if ($ac == '') { ?>
 <div class='row'>
        <div class='col-md-12'>
            <div class="card">
             <div class="card-header">	
                    <h5 class='card-title'><i class="fas fa-graduation-cap fa-fw"></i> Keterangan Perkembangan Peserta Didik</h5>
		   </div>
			
			 
						<div class="card-body">
                    <div class='table-responsive'>
                        <table id='datatable1' class='table  table-hover'>
                            <thead>
                            <tr>
                              
                                    <th width='3px' rowspan="2"></th>
                                    <th rowspan="2">NIS</th>									                                 
                                    <th rowspan="2">Nama</th>
                                    <th colspan="2" class="text-center">Meninggalkan Sekolah</th>
                                   <th colspan="2" class="text-center">Akhir Pendidikan</th>	
										 <th rowspan="2">Lanjut Ke</th>
									 <th width='5%' rowspan="2">Action</th>
									 </tr><tr>
									  <th>Tanggal</th>	
									  <th>Alasan</th>	
									  <th>Tanggal</th>	
									  <th>No Ijasah</th>	
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $query = mysqli_query($koneksi, "select * from binduk_siswa");
                            $no = 0;
                            while ($siswa = mysqli_fetch_array($query)) {
							
                                $no++;
                              
                            ?>
                                <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $siswa['nis'] ?></td>									
                                    <td><?= $siswa['nama'] ?></td>
                                    <td><?= $siswa['tglpindah'] ?></td>
									<td><?= $siswa['alasan_pindah'] ?></td>
									<td><?= $siswa['tgl_lulus'] ?></td>
									<td><?= $siswa['nomorijazah'] ?></td>
									 <td><?= $siswa['lanjutke'] ?></td>
								   <td class="text-center">
								   <a href="?pg=perkembangan&ac=edit&nis=<?= $siswa['nis'] ?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i></a>
									</td>
									</tr>
									<?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php } elseif ($ac == 'edit') { ?>	
<?php $siswa=fetch($koneksi,'binduk_siswa',['nis'=>$_GET['nis']]); ?>		
<div class='row'>
        <div class='col-md-12'>
            <div class="card">
             <div class="card-header">	
                    <h5 class='card-title'><i class="fas fa-graduation-cap fa-fw"></i> Keterangan Pekembangan</h5>
                   
					</div>
								
						              <div class="card-body">
												  <form id="formedit" method="post" action="" enctype="multipart/form-data">
                                                    <div class="modal-body">
                                                        <input type="hidden" value="<?= $siswa['nis'] ?>" name='nis'>
                                                        
                                                        <div class='form-group-sm'>
														<div class='row'>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;G. Keterangan Pekembangan Peserta Didik</h5>
															<div class='col-md-6'>
														 <label class="bold">Nama Lengkap</label>
                                                            <input type="text" class="form-control" value="<?= $siswa['nama'] ?>" readonly>
                                                        </div>
														</div>
														<p>
														<div class='row'>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Beasiswa <small>(Jika ada)</small></h5>
														<div class='col-md-4'>
														 <label class="bold">Tahun</label>
                                                             <input type="text" name="tahun1" class="form-control" value="<?= $siswa['tahun1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Tingkat</label>
                                                             <input type="text" name="tk1" class="form-control" value="<?= $siswa['tk1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Dari</label>
                                                             <input type="text" name="dari1" class="form-control" value="<?= $siswa['dari1'] ?>" placeholder="jika ada" >
                                                        </div>
														<div class='col-md-4'>
														 <label class="bold">Tahun</label>
                                                             <input type="text" name="tahun2" class="form-control" value="<?= $siswa['tahun1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Tingkat</label>
                                                             <input type="text" name="tk2" class="form-control" value="<?= $siswa['tk1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Dari</label>
                                                             <input type="text" name="dari2" class="form-control" value="<?= $siswa['dari1'] ?>" placeholder="jika ada" >
                                                        </div>
														<div class='col-md-4'>
														 <label class="bold">Tahun</label>
                                                             <input type="text" name="tahun3" class="form-control" value="<?= $siswa['tahun1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Tingkat</label>
                                                             <input type="text" name="tk3" class="form-control" value="<?= $siswa['tk1'] ?>" placeholder="jika ada" >
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Dari</label>
                                                             <input type="text" name="dari3" class="form-control" value="<?= $siswa['dari1'] ?>" placeholder="jika ada" >
                                                        </div>
														</div>
														<p>
														<div class='row'>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Meninggalkan Sekolah </h5>
														<div class='col-md-6'>
														 <label class="bold">Tanggal</label>
                                                             <input type="text" name="tanggal" class="form-control" value="<?= $siswa['tglpindah'] ?>"  >
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">Alasan</label>
                                                          <select name="alasan"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $siswa['alasan_pindah'] ?>"><?= $siswa['alasan_pindah'] ?></option>    													
															<option value="Pindah Sekolah">Pindah Sekolah</option>
															<option value="Lulus">Lulus</option>
															 </select>    
                                                        </div>
														</div>
														<p>
														<div class='row'>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Akhir Pendidikan </h5>
														<div class='col-md-6'>
														 <label class="bold">Tanggal</label>
                                                             <input type="text" name="tgl_lulus" class="form-control" value="<?= $siswa['tgl_lulus'] ?>"  >
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">No Ijazah</label>
                                                          <input type="text" name="nomorijazah" class="form-control" value="<?= $siswa['nomorijazah'] ?>"  > 
                                                        </div>
														 <div class='col-md-12'>
														 <label class="bold">Melanjutkan ke</label>
                                                          <input type="text" name="lanjutke" class="form-control" value="<?= $siswa['lanjutke'] ?>"  > 
                                                        </div>
														</div>
														 <p>
														 <div class="right">
														 <button type='submit' name='submit' class='btn btn-success' ><i class='fa fa-check-circle' ></i> Simpan</button>
														</div>
														</form>
														</div>
													</div>
												</div>
											</div>
<script>
   $('#formedit').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_binduk/crud_edit.php?pg=edit_perkembangan',
            enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
               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=perkembangan');
                }, 2000);

            }
        });
        return false;
    });
   
</script>
<?php } ?>