 <?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> Data Orang Tua Siswa</h5>
         </div>
		
						<div class="card-body">
                    <div class='table-responsive'>
                        <table  id='datatable1' class='table  table-hover'>
                            <thead>
                            <tr>
                              
                                    <th width='3px'></th>
                                    <th>NIS</th>									                                 
                                    <th>Nama</th>
                                    <th>Nama Ayah</th>
                                    <th>Pekerjaan Ayah</th>
                                    <th>Nama Ibu</th>									 
									 <th>Pekejaan Ibu</th>									
									<th>Ket</th>			
									 <th width='5%'>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $query = mysqli_query($koneksi, "select * from binduk_ortu");
                            $no = 0;
                            while ($ortu = mysqli_fetch_array($query)) {
							$siswa=fetch($koneksi,'binduk_siswa',['nis'=>$ortu['nis']]);
                                $no++;
                              
                            ?>
                                <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $siswa['nis'] ?></td>									
                                    <td><?= $siswa['nama'] ?></td>
                                    <td><?= $ortu['ayah'] ?></td>
									<td><?= $ortu['pek_ayah'] ?></td>
									<td><?= $ortu['ibu'] ?></td>
									<td><?= $ortu['pek_ibu'] ?></td>
									
                                    <td>
									<?php if($ortu['warga_ayah']<>''){ ?>
									<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=ortu&ac=edit&nis=<?= $ortu['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 
$ortu=fetch($koneksi,'binduk_ortu',['nis'=>$_GET['nis']]); 
$siswa=fetch($koneksi,'binduk_siswa',['nis'=>$ortu['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 Orang Tua</h5>
                   
						</div>
													
						              <div class="card-body">
												  <form id="formedit" method="post" action="" enctype="multipart/form-data">
                                                    <div class="modal-body">
                                                        <input type="hidden" value="<?= $ortu['nis'] ?>" name='nis'>
                                                        
                                                        <div class='form-group-sm'>
														<div class='row'>
															<div class='col-md-12'>
														 <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;E. Keterangan Orang Tua Kandung</h5>
														<div class='col-md-4'>
														 <label class="bold">Nama Ayah Kandung</label>
                                                            <input type="text" name="ayah" class="form-control" value="<?= $ortu['ayah'] ?>">
                                                        </div>
														 <div class='col-md-4'>
														    <label class="bold">Agama</label>
                                                             <select name="agama_ayah"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $ortu['agama_ayah'] ?>"><?= $ortu['agama_ayah'] ?></option>    												
															<option value="Islam">Islam</option>
															<option value="Kristen">Kristen</option>
                                                            <option value="Katolik">Katolik</option>
															<option value="Hindu">Hindu</option>
															<option value="Budha">Budha</option>
															<option value="Konghucu">Konghucu</option>
															 </select>
														   </div>	
														    <div class='col-md-4'>
														 <label class="bold">Kewarganegaraan</label>
                                                              <select name="warga_ayah"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $ortu['warga_ayah'] ?>"><?= $ortu['warga_ayah'] ?></option>    															
															<option value="WNI">WNI</option>
															<option value="WNI Keturunan">WNI Keturunan</option>
															<option value="WNA">WNA</option>
															 </select>    
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Pendidikan Terakhir Ayah</label>
                                                           <select name="pend_ayah"  class="form-control" style="width: 100%;" required >
                                                             <option value="<?= $ortu['pend_ayah'] ?>"><?= $ortu['pend_ayah'] ?></option>    													
															<option value="Tidak Sekolah">Tidak Sekolah</option>
															<option value="SD Sederajat">SD Sederajat</option>
															<option value="SMP Sederajat">SMP Sederajat</option>
															<option value="SMA Sederajat">SMA Sederajat</option>
															<option value="D-1">D-1</option>
															<option value="D-2">D-2</option>
															<option value="D-3">D-3</option>
															<option value="S-1">S-1</option>
															<option value="S-2">S-2</option>
															<option value="S-3">S-3</option>
															 </select>   
                                                        </div>
                                                          <div class='col-md-4'>
														    <label class="bold">Pekerjaan Ayah</label>
                                                            <select name="pek_ayah"  class="form-control" style="width: 100%;" required >
                                                             <option value="<?= $ortu['pek_ayah'] ?>"><?= $ortu['pek_ayah'] ?></option>    													
															<option value="Tidak Bekerja">Tidak Bekerja</option>
															<option value="Nelayan">Nelayan</option>
															<option value="Petani">Petani</option>
															<option value="Peternak">Peternak</option>
															<option value="PNS/TNI/POLRI">PNS/TNI/POLRI</option>
															<option value="Karyawan Swasta">Karyawan Swasta</option>
															<option value="Pedagang">Pedagang</option>
															<option value="Wiraswasta">Wiraswasta</option>
															<option value="Buruh">Buruh</option>
															<option value="Pensiunan">Pensiunan</option>
															<option value="Lainnya">Lainnya</option>
								
															 </select>                             
														   </div>	
                                                          
														<div class='col-md-4'>
														 <label class="bold">Penghasilan per bulan</label>
                                                            <select name="hasil_ayah"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $ortu['hasil_ayah'] ?>"><?= $ortu['hasil_ayah'] ?></option>    													
															<option value="Kurang dari 500.000">Kurang dari 500.000</option>
															<option value="500.000-1.000.000">500.000-1.000.000</option>
															<option value="1.000.000-2.000.000">1.000.000-2.000.000</option>
															<option value="Di atas 2.000.000">Di atas 2.000.000</option>
															</select>   
                                                        </div>
															
                                                          
														<div class='col-md-4'>
														 <label class="bold">No Handphone</label>
                                                             <input type="number" name="hp_ayah" class="form-control" value="<?= $ortu['hp_ayah'] ?>" placeholder="jika ada" >
                                                        </div>
														<div class='col-md-4'>
														 <label class="bold">Keadaan</label>
                                                             <select name="keadaan_ayah"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $ortu['keadaan_ayah'] ?>"><?= $ortu['keadaan_ayah'] ?></option>    													
															<option value="Masih hidup">Masih hidup</option>
															<option value="Sudah meninggal">Sudah meninggal</option>
															</select> 
                                                        </div>
														</div>
														<p>
														<div class='row'>
															<h5 class='card-title'> &nbsp;&nbsp;&nbsp;Data Ibu Kandung</h5>
														<div class='col-md-4'>
														 <label class="bold">Nama Ibu Kandung</label>
                                                            <input type="text" name="ibu" class="form-control" value="<?= $ortu['ibu'] ?>">
                                                        </div>
														 <div class='col-md-4'>
														    <label class="bold">Agama</label>
                                                             <select name="agama_ibu"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $ortu['agama_ibu'] ?>"><?= $ortu['agama_ibu'] ?></option>    												
															<option value="Islam">Islam</option>
															<option value="Kristen">Kristen</option>
                                                            <option value="Katolik">Katolik</option>
															<option value="Hindu">Hindu</option>
															<option value="Budha">Budha</option>
															<option value="Konghucu">Konghucu</option>
															 </select>
														   </div>	
														    <div class='col-md-4'>
														 <label class="bold">Kewarganegaraan</label>
                                                              <select name="warga_ibu"  class="form-control" style="width: 100%;"  >
                                                             <option value="<?= $ortu['warga_ibu'] ?>"><?= $ortu['warga_ibu'] ?></option>    															
															<option value="WNI">WNI</option>
															<option value="WNI Keturunan">WNI Keturunan</option>
															<option value="WNA">WNA</option>
															 </select>    
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Pendidikan Terakhir Ibu</label>
                                                           <select name="pend_ibu"  class="form-control" style="width: 100%;"  >
                                                             <option value="<?= $ortu['pend_ibu'] ?>"><?= $ortu['pend_ibu'] ?></option>    													
															<option value="Tidak Sekolah">Tidak Sekolah</option>
															<option value="SD Sederajat">SD Sederajat</option>
															<option value="SMP Sederajat">SMP Sederajat</option>
															<option value="SMA Sederajat">SMA Sederajat</option>
															<option value="D-1">D-1</option>
															<option value="D-2">D-2</option>
															<option value="D-3">D-3</option>
															<option value="S-1">S-1</option>
															<option value="S-2">S-2</option>
															<option value="S-3">S-3</option>
															 </select>   
                                                        </div>
                                                          <div class='col-md-4'>
														    <label class="bold">Pekerjaan Ibu</label>
                                                            <select name="pek_ibu"  class="form-control" style="width: 100%;" required >
                                                             <option value="<?= $ortu['pek_ibu'] ?>"><?= $ortu['pek_ibu'] ?></option>    													
															<option value="Tidak Bekerja">Tidak Bekerja</option>
															<option value="Nelayan">Nelayan</option>
															<option value="Petani">Petani</option>
															<option value="Peternak">Peternak</option>
															<option value="PNS/TNI/POLRI">PNS/TNI/POLRI</option>
															<option value="Karyawan Swasta">Karyawan Swasta</option>
															<option value="Pedagang">Pedagang</option>
															<option value="Wiraswasta">Wiraswasta</option>
															<option value="Buruh">Buruh</option>
															<option value="Pensiunan">Pensiunan</option>
															<option value="Lainnya">Lainnya</option>
								
															 </select>                             
														   </div>	
                                                          
														<div class='col-md-4'>
														 <label class="bold">Penghasilan per bulan</label>
                                                            <select name="hasil_ibu"  class="form-control" style="width: 100%;" required >
                                                             <option value="<?= $ortu['hasil_ibu'] ?>"><?= $ortu['hasil_ibu'] ?></option>    													
															<option value="Kurang dari 500.000">Kurang dari 500.000</option>
															<option value="500.000-1.000.000">500.000-1.000.000</option>
															<option value="1.000.000-2.000.000">1.000.000-2.000.000</option>
															<option value="Di atas 2.000.000">Di atas 2.000.000</option>
															</select>   
                                                        </div>
															
                                                          
														<div class='col-md-4'>
														 <label class="bold">No Handphone</label>
                                                             <input type="number" name="hp_ibu" class="form-control" value="<?= $ortu['hp_ibu'] ?>" placeholder="jika ada" >
                                                        </div>
														<div class='col-md-4'>
														 <label class="bold">Keadaan</label>
                                                             <select name="keadaan_ibu"  class="form-select" style="width: 100%;" required >
                                                             <option value="<?= $ortu['keadaan_ibu'] ?>"><?= $ortu['keadaan_ibu'] ?></option>    													
															<option value="Masih hidup">Masih hidup</option>
															<option value="Sudah meninggal">Sudah meninggal</option>
															</select> 
                                                        </div>
														 </div>
														<p>
														<div class='row'>
															<h5 class='card-title'> &nbsp;&nbsp;&nbsp;F. Keterangan Tentang Wali <small>( Jika ada )</small></h5>
														<div class='col-md-4'>
														 <label class="bold">Nama </label>
                                                            <input type="text" name="wali" class="form-control" value="<?= $ortu['wali'] ?>">
                                                        </div>
														 <div class='col-md-4'>
														    <label class="bold">Agama</label>
                                                             <select name="agama_wali"  class="form-select" style="width: 100%;" >
                                                             <option value="<?= $ortu['agama_wali'] ?>"><?= $ortu['agama_wali'] ?></option>    												
															<option value="Islam">Islam</option>
															<option value="Kristen">Kristen</option>
                                                            <option value="Katolik">Katolik</option>
															<option value="Hindu">Hindu</option>
															<option value="Budha">Budha</option>
															<option value="Konghucu">Konghucu</option>
															 </select>
														   </div>	
														    <div class='col-md-4'>
														 <label class="bold">Kewarganegaraan</label>
                                                              <select name="warga_wali"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $ortu['warga_wali'] ?>"><?= $ortu['warga_wali'] ?></option>    															
															<option value="WNI">WNI</option>
															<option value="WNI Keturunan">WNI Keturunan</option>
															<option value="WNA">WNA</option>
															 </select>    
                                                        </div>
														 <div class='col-md-4'>
														 <label class="bold">Pendidikan Terakhir</label>
                                                           <select name="pend_wali"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $ortu['pend_wali'] ?>"><?= $ortu['pend_wali'] ?></option>    													
															<option value="Tidak Sekolah">Tidak Sekolah</option>
															<option value="SD Sederajat">SD Sederajat</option>
															<option value="SMP Sederajat">SMP Sederajat</option>
															<option value="SMA Sederajat">SMA Sederajat</option>
															<option value="D-1">D-1</option>
															<option value="D-2">D-2</option>
															<option value="D-3">D-3</option>
															<option value="S-1">S-1</option>
															<option value="S-2">S-2</option>
															<option value="S-3">S-3</option>
															 </select>   
                                                        </div>
                                                          <div class='col-md-4'>
														    <label class="bold">Pekerjaan</label>
                                                            <select name="pek_wali"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $ortu['pek_wali'] ?>"><?= $ortu['pek_wali'] ?></option>    													
															<option value="Tidak Bekerja">Tidak Bekerja</option>
															<option value="Nelayan">Nelayan</option>
															<option value="Petani">Petani</option>
															<option value="Peternak">Peternak</option>
															<option value="PNS/TNI/POLRI">PNS/TNI/POLRI</option>
															<option value="Karyawan Swasta">Karyawan Swasta</option>
															<option value="Pedagang">Pedagang</option>
															<option value="Wiraswasta">Wiraswasta</option>
															<option value="Buruh">Buruh</option>
															<option value="Pensiunan">Pensiunan</option>
															<option value="Lainnya">Lainnya</option>
								
															 </select>                             
														   </div>	
                                                          
														<div class='col-md-4'>
														 <label class="bold">Penghasilan per bulan</label>
                                                            <select name="hasil_wali"  class="form-select" style="width: 100%;"  >
                                                             <option value="<?= $ortu['hasil_wali'] ?>"><?= $ortu['hasil_wali'] ?></option>    													
															<option value="Kurang dari 500.000">Kurang dari 500.000</option>
															<option value="500.000-1.000.000">500.000-1.000.000</option>
															<option value="1.000.000-2.000.000">1.000.000-2.000.000</option>
															<option value="Di atas 2.000.000">Di atas 2.000.000</option>
															</select>   
                                                        </div>
														<div class='col-md-4'>
														    <label class="bold">Alamat</label>
                                                             <input type="text" name="alamat" class="form-control" value="<?= $ortu['alamat_wali'] ?>"  >                                               
														   </div>	
                                                           <div class='col-md-2'>
														 <label class="bold">RT</label>
                                                             <input type="text" name="rt" class="form-control" value="<?= $ortu['rt_wali'] ?>"  >
                                                        </div>
														<div class='col-md-2'>
														 <label class="bold">RW</label>
                                                             <input type="text" name="rw" class="form-control" value="<?= $ortu['rw_wali'] ?>"  >
                                                        </div>
                                                        <div class='col-md-4'>
														    <label class="bold">Desa/Kelurahan</label>
                                                             <input type="text" name="desa" class="form-control" value="<?= $ortu['desa_wali'] ?>"  >                                               
														   </div>	
                                                           
														   <div class='col-md-4'>
														 <label class="bold">Kecamatan</label>
                                                             <input type="text" name="kecamatan" class="form-control" value="<?= $ortu['kec_wali'] ?>"  >
                                                        </div>
														<div class='col-md-4'>
														 <label class="bold">Kabupaten/Kota</label>
                                                             <input type="text" name="kabupaten" class="form-control" value="<?= $ortu['kab_wali'] ?>"  >
                                                        </div>
                                                         <div class='col-md-4'>
														 <label class="bold">Provinsi</label>
                                                             <input type="text" name="propinsi" class="form-control" value="<?= $ortu['prop_wali'] ?>" >
                                                        </div>
														   <div class='col-md-4'>
														 <label class="bold">Kode Pos</label>
                                                             <input type="text" name="pos" class="form-control" value="<?= $ortu['pos_wali'] ?>" >
                                                        </div>	
                                                          
														<div class='col-md-4'>
														 <label class="bold">No Handphone</label>
                                                             <input type="number" name="hp_wali" class="form-control" value="<?= $ortu['hp_wali'] ?>"  >
                                                        </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>
														<br>
														</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_ortu',
            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=ortu');
                }, 2000);

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