 <?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 Pendidikan</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">Nama</th>
                                    <th rowspan="2">Sekolah Asal</th>
                                    <th rowspan="2">Tgl Ijazah</th>									 
									 <th rowspan="2">No Ijazah</th>
									<th colspan="2" class="text-center">Pindahan</th>
									<th colspan="2" class="text-center">Diterima</th>
									 <th rowspan="2">Ket</th>
									 <th width='5%' rowspan="2">Action</th>
                                    </tr><tr>									
									 <th>Dari Sekolah</th>									 
									 <th>Alasan Pindah</th>
									 <th>Di Kelas</th>									 
									 <th>Tanggal</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['nama'] ?></td>									
                                    <td><?= $siswa['asal'] ?></td>
									<td><?= $siswa['tglijazah'] ?></td>
									<td><?= $siswa['noijazah'] ?></td>
									<td><?= $siswa['dari'] ?></td>
									 <td><?= $siswa['alasanpindah'] ?></td>
									 <td><?= $siswa['dikelas'] ?></td>
									 <td><?= $siswa['tglterima'] ?></td>
                                    <td>
									<?php if($siswa['noijazah']<>''){ ?>
									<b style="color:blue">Lengkap</b>
									<?php }else{ ?>
									<b style="color:red" class="siskolah">Belum Lengkap</b>
									<?php } ?>
									</td>
								   <td class="text-center">
								   <a href="?pg=pendidikan&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 Pendidikan</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;D. Keterangan Pendidikan</h5>
															<div class='col-md-6'>
														 <label class="bold">Nama Lengkap</label>
                                                            <input type="text" class="form-control" value="<?= $siswa['nama'] ?>" readonly>
                                                        </div>
														</div>
														<div class='row'>
														<div class='col-md-6'>
														 <label class="bold">Pendidikan Sebelumnya</label>
                                                             <select name="sebelumnya"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $siswa['sebelumnya'] ?>"><?= $siswa['sebelumnya'] ?></option>    												
															<?php if($setting['jenjang']=='SD'): ?>
															<option value="PAUD">PAUD</option>
															<option value="TK">TK</option>
															<?php elseif($setting['jenjang']=='SMP'): ?>
                                                            <option value="SD">SD</option>
															<?php elseif($setting['jenjang']=='SMA'): ?>
															<option value="SMP">SMP</option>
															<?php elseif($setting['jenjang']=='SMK'): ?>
															<option value="SMP">SMP</option>
															<?php endif; ?>
															 </select>
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">Sekolah Asal</label>
                                                             <input type="text" name="asal" class="form-control" value="<?= $siswa['asal'] ?>" required >
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">Tanggal Ijazah</label>
                                                             <input type="text" name="tglijazah" class="form-control" value="<?= $siswa['tglijazah'] ?>" required >
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">Nomor Ijazah</label>
                                                             <input type="text" name="noijazah" class="form-control" value="<?= $siswa['noijazah'] ?>" required >
                                                        </div>
														 </div>
														 </div>
														<hr>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Jika siswa pindahan</h5>
														<div class='form-group-sm'>
														 <div class="row">
														 <div class='col-md-6'>
														 <label class="bold">Dari Sekolah</label>
                                                             <input type="text" name="dari" class="form-control" value="<?= $siswa['dari'] ?>" placeholder="jika siswa pindahan" >
                                                        </div>
														 <div class='col-md-6'>
														 <label class="bold">Alasan Pindah</label>
                                                             <input type="text" name="alasanpindah" class="form-control" value="<?= $siswa['alasanpindah'] ?>" placeholder="jika siswa pindahan" >
                                                        </div>
														</div>
														</div>
														<hr>
														<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Diterima di sekolah ini <small>(siswa lama maupun pindahan)</small></h5>
														<div class='form-group-sm'>
														<div class="row">
														 <div class='col-md-6'>
														 <label class="bold">Dikelas</label>
                                                         <select name="dikelas" class='form-select' required='true'>
                                                    <option value="<?= $siswa['dikelas'] ?>"><?= $siswa['dikelas'] ?></option>
                                                      <?php $qt = mysqli_query($koneksi, "SELECT * FROM siswa  GROUP BY id_kelas"); ?>
                                                <?php while ($mt = mysqli_fetch_array($qt)) : ?>
                                                    <option value="<?= $mt['id_kelas'] ?>"><?= $mt['id_kelas'] ?></option>
                                                <?php endwhile ?>
                                                    </select>   
                                                        </div>
														<div class='col-md-6'>
														 <label class="bold">Kelompok/Level</label>
                                                           <select name="kelompok" class='form-control' required='true'>
                                                    <option value="<?= $siswa['kelompok'] ?>"><?= $siswa['kelompok'] ?></option>
                                                      <?php $que = mysqli_query($koneksi, "SELECT * FROM siswa  GROUP BY level"); ?>
                                                <?php while ($k = mysqli_fetch_array($que)) : ?>
                                                    <option value="<?= $k['level'] ?>"><?= $k['level'] ?></option>
                                                <?php endwhile ?>
                                                    </select>   
                                                        </div>
														<?php if($setting['jenjang']=='SMA' OR $setting['jenjang']=='SMK' OR $setting['jenjang']=='PAKET-C'): ?>
														 <div class='col-md-6'>
														 <label class="bold">Jurusan</label>
                                                           <select name="jurusan" class='form-control' >
                                                    <option value="<?= $siswa['jurusan'] ?>"><?= $siswa['jurusan'] ?></option>
                                                      <?php $query = mysqli_query($koneksi, "SELECT * FROM siswa  GROUP BY idpk"); ?>
                                                <?php while ($j = mysqli_fetch_array($query)) : ?>
                                                    <option value="<?= $j['idpk'] ?>"><?= $j['idpk'] ?></option>
                                                <?php endwhile ?>
                                                    </select>   
                                                        </div>
														<?php endif; ?>
														 <div class='col-md-6'>
														 <label class="bold">Tanggal diterima</label>
                                                             <input type="text" name="tglterima" class="form-control" value="<?= $siswa['tglterima'] ?>" required >
                                                        </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_pendidikan',
            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=pendidikan');
                }, 2000);

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