<?php 
    include 'header.php'; 
    $noperk=$_GET['noperk'];
    $nawal = mysqli_query($koneksi,"select * from nawal where noperk='$noperk'");
    $k = mysqli_fetch_assoc($nawal);
?>

<div class="container">

 <div class="my-4 border-bottom">
   <h2 class="fw-semibold fs-3"></h2>
 </div>

  <div class="row justify-content-center">
    <div class="col-lg-12">
       <?php 
        if(isset($_GET['alert'])){
          if($_GET['alert'] == "berhasil"){
            ?>
            <div class="alert alert-success">
              Akunt laporan, telah diupdate!
            </div>
            <?php
          }
        }
        ?>
       <div class="card">
    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">Edit Akunt : <?php echo $k['perk'] ?></span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <i class="bi bi-subtract"></i> Ganti/Edit
      </button>
      <a href="kode_akunt.php?kd2=11&kd3=2" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
    </div>
    <div class="card-body">


      <!-- Modal -->
      <form action="kode_akunt_edit_act.php" method="post">
        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h1 class="modal-title fs-5" id="exampleModalLabel">Ganti / Edit</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
              </div>
              <div class="modal-body">
                            <div class="form-group" style="width:100%">
                              
                              <input type="hidden" name="tnoperk" readonly="readonly" class="form-control" value="<?php echo $k['noperk']; ?>">
                              <input type="hidden" name="toleh" readonly="readonly" class="form-control" value="<?php echo $oleh; ?>" style="width:100%">
                              <input type="hidden" name="tkdc" readonly="readonly" class="form-control" value="<?php echo $kdc; ?>" style="width:100%">
                            </div>
                          <div class="form-group mb-2">
                            <label class="form-label"><font color="#000fff">Nama Akunt</font></label>
                            <input type="text" name="tperk" class="form-control" value="<?php echo $k['perk']; ?>">
                          </div>    
        	</div>  
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
                <button type="submit" class="btn btn-primary">Simpan</button>
              </div>
            </div>
          </div>
        </div>
      </form>

      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable">
          <thead>
            <tr>
              <th width="1%" class="text-center">Kd</th>    
              <th width="20%" class="text-center">Nama Akunt</th>
              <th width="10%" class="text-center">Klp</th>
              <th width="10%" class="text-center">Sub</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM nawal where noperk='$noperk'");
            while($d = mysqli_fetch_array($data)){
                $sub = mysqli_query($koneksi,"select * from n_kode_2 where kd='$d[klp]'");
                    $s = mysqli_fetch_assoc($sub);
                $subx = mysqli_query($koneksi,"select * from n_kode_3 where kd='$d[nosub]'");
                    $x = mysqli_fetch_assoc($subx);                    
              ?>
              <tr>
                <td><?php echo $d['noperk']; ?></td>
                <td><?php echo $d['perk']; ?></td>
                <td><?php echo $s['nama']; ?></td>
                <td><?php echo $x['nama']; ?></td>
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>
    
  </div>
    </div>
  </div>
</div>
<?php include 'footer.php'; ?>