
<?php 
    include 'header.php';
    
    $kd2=$_GET[kd2] ;
    $kd3=$_GET[kd3] ;
    $kdg=$kd2.$kd3 ;
    
    $potong_kd  = substr($tnohp,1,12);
    
    $sql12 = mysqli_query($koneksi, "SELECT noperk FROM nawal ORDER BY noperk DESC LIMIT 1");
                list($noperk) = mysqli_fetch_array($sql12);
    $kd_ke =$noperk+1 ;
    
//    kode_akunt.php?kd2=11&kd3=1
?>              


<div class="container">
  <div class="my-2 border-bottom">
    <span class="card-title fw-semibold">KODE AKUNT BUKU BESAR</span>  
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <a href="index.php" class="btn btn-primary btn-sm pull-right"><i class="bi bi-reply"></i> &nbsp; Kembali</a> 
      </button>    
  </div>
  <section class="content">
    <div class="row justify-content-center">
      <div class="col-lg-4">    
        <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Kelompok Utama</span>
              <button type="button" class="btn btn-warning btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
                <a data-toggle='tooltip' data-placement='top' title='Tambah KELOMPOK UTAMA' style='margin-right:3px' class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#kelompok_utama<?php echo $d['noperk'] ?>"><i class="bi bi-plus-lg"></i></a>
              </button>
          </div>
          <div class="card-body">
              
              <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="60%" class="text-center">Nama</th>
                      <th width="39" class="text-center"></th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php 
                    $no=1;
                    $tgl_skr= date('Y-m-d');
                    $data = mysqli_query($koneksi,"SELECT * FROM n_kode_2 ORDER BY kd1 ASC");
                    while($k = mysqli_fetch_array($data)){
                        $kd1=$k['kd1'];
                        $kd2=$k['kd2'];
                        $kd=$k['kd'];
                        $kdg=$kd1.$kd2
                      ?>
                      <tr>
                        <td><?php echo $k['kd']; ?></td>
                        <td><?php echo $k['nama']; ?></td>
                        <td>
                            <a class="btn btn-warning btn-sm" href="kode_akunt.php?kd2=<?php echo $k['kd']; ?>&kd3=1"><i class="bi bi-chat-left-text"></i></a>
                          <a onclick="return confirm('Yakin ingin hapus <?php echo $k['nama']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_utama_hapus.php?id=<?php echo $k['kd']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>
                          
                  <form action="kode_akunt_utama_act.php" method="post">
                    <div class="modal fade" id="kelompok_utama<?php echo $d['noperk'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Kelompok Utama</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="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" style="width:100%">
                                <label class="form-label">Kelompok Sub Akunt</label>
                                <select class="form-control" name="tsub" required="required">
                                  <option value="">- Pilih Sub Akunt -</option>
                                  <?php 
                                  $kec = mysqli_query($koneksi,"select * from n_kode_1");
                                  while($x = mysqli_fetch_array($kec)){
                                    ?>
                                    <option value="<?php echo $x['kd1'] ?>"><?php echo $x['kd1'] ?> - <?php echo $x['nama'] ?></option>
                                    <?php } ?>
                                </select>
                        	</div>                
                            <div class="form-group" style="width:100%">
                              <label>Nama Kelompok</label>
                              <input type="text" class="form-control" name="tnama" value="<?php echo ""; ?>" required="required" placeholder="Masukkan nama kelompok ..">
                            </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>
                  
                        </td>
                      </tr>
                      <?php 
                    }
                    ?>
                  </tbody>
                </table>
              </div>
          </div>
        </div>
      </div>
              
               
              
<?php 
    $kd2=$_GET[kd2] ;
    $kd3=$_GET[kd3] ;
    $kdg=$kd2.$kd3 ;
?>       
    
      <div class="col-lg-4">    
       <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Sub Kelompok <?php echo $kd2; ?></span>
              <button type="button" class="btn btn-success btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
                <a data-toggle='tooltip' data-placement='top' title='Tambah SUB KELOMPOK' style='margin-right:3px' class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#kelompok_sub<?php echo $d['noperk'] ?>"><i class="bi bi-plus-lg"></i></a>
              </button>
          </div>
              
      <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="60%" class="text-center">Nama</th>
                      <th width="39" class="text-center"></th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM n_kode_3 WHERE kd1=$kd2 ORDER BY kd ASC");
            while($k3 = mysqli_fetch_array($data)){
                $kd1=$k3['kd1'];
                $kd2=$k3['kd2'];
                
                $kdg=$kd1.$kd2.$kd3
              ?>
              <tr>
                <td><?php echo $k3['kd']; ?></td>
                <td><?php echo $k3['nama']; ?></td>
                <td>
                    <a class="btn btn-success btn-sm" href="kode_akunt.php?kd2=<?php echo $k3['kd1']; ?>&kd3=<?php echo $k3['kd2']; ?>"><i class="bi bi-chat-left-text"></i></a>
                          <a onclick="return confirm('Yakin ingin hapus <?php echo $k['nama']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_utama_hapus.php?kd=<?php echo $k['kd']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>
                          
                  <form action="kode_akunt_sub_act.php" method="post">
                    <div class="modal fade" id="kelompok_sub<?php echo $d['noperk'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Tambah SUB Kelompok</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="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" style="width:100%">
                                <label class="form-label">Kelompok Sub Akunt</label>
                                <select class="form-control" name="tsub" required="required">
                                  <option value="">- Pilih Sub Akunt -</option>
                                  <?php 
                                  $n_kode_2 = mysqli_query($koneksi,"select * from n_kode_2 WHERE kd='$kd1' ");
                                  while($y = mysqli_fetch_array($n_kode_2)){
                                    ?>
                                    <option value="<?php echo $y['kd'] ?>"><?php echo $y['kd'] ?> - <?php echo $y['nama'] ?></option>
                                    <?php } ?>
                                </select>
                        	</div>                
                            <div class="form-group" style="width:100%">
                              <label>Nama Kelompok SUB </label>
                              <input type="text" class="form-control" name="tnama" value="<?php echo ""; ?>" required="required" placeholder="Masukkan nama kelompok ..">
                            </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>                          
                </td>                
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>    






<?php 
    $kd2=$_GET[kd2] ;
    $kd3=$_GET[kd3] ;
    $kdg3=$kd2.$kd3 ;
?>       
    
      <div class="col-lg-4">    
       <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Daftar Akunt Kelompok : <?php echo $kdg3 ; ?></span>
              <button type="button" class="btn btn-danger btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
                <a data-toggle='tooltip' data-placement='top' title='Tambah Akunt Baru' style='margin-right:3px' class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#akunt_baru<?php echo $kd_ke ; ?>"><i class="bi bi-plus-lg"></i></a>
              </button>
          </div>
              
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable">
          <thead>
            <tr>
                      <th width="1%" class="text-center">Kode3</th>
                      <th width="60%" class="text-center">Nama3</th>
                      <th width="39" class="text-center"></th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            
            $nawal = mysqli_query($koneksi,"SELECT * FROM nawal WHERE left(noperk,3)='$kdg3' ORDER BY noperk ASC");
            while($n = mysqli_fetch_array($nawal)){
              
              ?>
              <tr>
                <td><?php echo $n['noperk']; ?></td>
                <td><?php echo $n['perk']; ?></td>
                    
                <td>
                    <a class="btn btn-success btn-sm" href="kode_akunt_baru.php?kd2=<?php echo $k3['kd1']; ?>&kd3=<?php echo $k3['kd2']; ?>"><i class="bi bi-chat-left-text"></i></a>
                          <a onclick="return confirm('Yakin ingin hapus <?php echo $k['nama']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_utama_hapus.php?kd=<?php echo $k['kd']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>
                          
                  <form action="kode_akunt_baru_act.php" method="post">
                    <div class="modal fade" id="akunt_baru<?php echo $kd_ke ; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Akunt Baru</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="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" style="width:100%">
                              <label>Kode kelompok </label>
                              <input type="text" class="form-control" name="t2digit" value="<?php echo $kd2 ?>" readonly="readonly">
                            </div>
                            <div class="form-group" style="width:100%">
                              <label>Kode sub kelompok Akunt </label>
                              <input type="text" class="form-control" name="t3digit" value="<?php echo $kdg3 ?>" readonly="readonly">
                            </div>                        	
                            <div class="form-group" style="width:100%">
                              <label>Nama Akunt Baru </label>
                              <input type="text" class="form-control" name="tnama_akunt" value="<?php echo ""; ?>" required="required" placeholder="Masukkan nama akunt yg dikehendaki ..">
                            </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>                          
                </td>                
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>    









      
<?php 
    $kd2x=$_GET[kd2] ;
    $kd3x=$_GET[kd3] ;
    $kdgx=$kd2x.$kd3x ;
?>       
    
      <div class="col-lg-4">    
       <div class="card card-info">
          <div class="card-header justify-content-between d-flex">
            <span class="card-title fw-semibold">Akunt Kelompok : <?php echo $kdg ; ?></span>
              <button type="button" class="btn btn-info btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
                <a data-toggle='tooltip' data-placement='top' title='Tambah Akunt Baru' style='margin-right:3px' class="btn btn-info btn-sm" data-bs-toggle="modal" data-bs-target="#akunt<?php echo $d['noperk'] ?>"><i class="bi bi-plus-lg"></i></a>
              </button>
          </div>
              
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable">
          <thead>
            <tr>
              <th width="1%" class="text-center">Akunt</th>
              <th width="75%" class="text-center">Nama</th>
              <th width="24%" class="text-center"></th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $nawal = mysqli_query($koneksi,"SELECT * FROM nawal WHERE left(noperk,3)='$kdgx' ORDER BY noperk ASC");
            while($n = mysqli_fetch_array($nawal)){

              ?>
              <tr>
                <td><?php echo $n['noperk']; ?></td>
                <td><?php echo $n['perk']; ?></td>
                <td>
                    <a data-toggle='tooltip' data-placement='top' title='Edit Akunt' style='margin-right:3px' class="btn btn-info btn-sm" data-bs-toggle="modal" data-bs-target="#edit_akunt<?php echo $n['noperk'] ?>"><i class="bi bi-gear"></i></a>
                          <a onclick="return confirm('Yakin ingin hapus <?php echo $n['perk']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_hapus.php?noperk=<?php echo $n['noperk']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>                

                  <form action="kode_akunt_act.php" method="post">
                    <div class="modal fade" id="akunt<?php echo $n['noperk'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Akunt Bu Bes</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="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" style="width:100%">
                                <label class="form-label">Kelompok Sub Akunt2</label>
                                <select class="form-control" name="tsub" required="required">
                                  <option value="">- Pilih Sub Akunt -</option>
                                  <?php 
                                  $n_kode_3 = mysqli_query($koneksi,"select * from n_kode_3 WHERE kd='$kdgx' ");
                                  while($q = mysqli_fetch_array($n_kode_3)){
                                    ?>
                                    <option value="<?php echo $q['kd'] ?>"><?php echo $q['kd'] ?> - <?php echo $q['nama'] ?></option>
                                    <?php } ?>
                                </select>
                        	</div>                
                            <div class="form-group" style="width:100%">
                              <label>Nama Akunt Bu Bes </label>
                              <input type="text" class="form-control" name="tnama" value="<?php echo ""; ?>" required="required" placeholder="Masukkan nama kelompok ..">
                            </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>                      
                  
                  
                  <form action="kode_akunt_edit_act.php" method="post">
                    <div class="modal fade" id="edit_akunt<?php echo $n['noperk'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel">Edit Akunt <?php echo $n['noperk'] ?> </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 $n['noperk'] ?>" style="width:100%">
                              <input type="hidden" name="tnosub" readonly="readonly" class="form-control" value="<?php echo $n['nosub'] ?>" style="width:100%">
                            </div>
                            <div class="form-group" style="width:100%">
                              <label>Nama Akunt Bu Bes Lama </label>
                              <input type="text" class="form-control" name="tnama_l" value="<?php echo $n['perk'] ?>" required="required" >
                            </div>                 
                            <div class="form-group" style="width:100%">
                              <label>Nama Akunt Bu Bes Baru </label>
                              <input type="text" class="form-control" name="tnama" value="<?php echo $n['perk'] ?>" required="required" >
                            </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>                     
                  
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>

      </div>
    </div>
  </section>
</div>

<?php include 'foot_ku.php'; ?>

