
<?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>
                      <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 ;
                        
                        $sql1 = mysqli_query($koneksi, "SELECT count(kd) AS nkd1 FROM n_kode_3 WHERE kd1=$kd");
                            list($nkd1) = mysqli_fetch_array($sql1);                           
                      ?>
                      <tr>
                        <td><?php echo $k['kd']; ?></td>
                        <td><?php echo $k['nama']; ?></td>
                        <td><?php echo $nkd1; ?></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>
                            
                        <?php if ($nkd1<1) { ;?>     
                          <a onclick="return confirm('Yakin ingin hapus <?php echo $k['nama']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_utama_hapus.php?id=$k['kd']">
                            <i class="bi bi-trash"></i>
                          </a>
                        <?php } else { 
                                } ;?>                                  
                  <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 style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">                              
                            <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>
</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">KD2</th>
                      <th width="60%" class="text-center">Nama2</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'];
                $kd =$k3['kd'];
                
                $kdg=$kd1.$kd2.$kd3 ;
                
                $sql1 = mysqli_query($koneksi, "SELECT count(noperk) AS xnoperk FROM nawal WHERE nosub=$kd");
                    list($xnoperk) = mysqli_fetch_array($sql1);                   
              ?>
              <tr>
                <td><?php echo $k3['kd']; ?></td>
                <td><?php echo $k3['nama']; ?></td>
                <td><?php echo $xnoperk; ?></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>
                    
                    <?php if ($xnoperk<1) { ;?> 
                          <a onclick="return confirm('Yakin ingin hapus kelompok <?php echo $k3['kd']; ?> - <?php echo $k3['nama']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_n3_hapus.php?kd=<?php echo $k3['kd']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>
                    <?php } else { 
                    } ;?>                          
                  <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 style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">                              
                            <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>
</div>                    
                  </form>                          
                </td>                
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>    






<?php 
    $kd2=$_GET[kd2] ;
    $kd3=$_GET[kd3] ;
    $kdg3=$kd2.$kd3 ;
    
    $sql12 = mysqli_query($koneksi, "SELECT noperk FROM nawal ORDER BY noperk DESC LIMIT 1");
                list($noperk) = mysqli_fetch_array($sql12);
    $kd_ke =$noperk+1 ;    
?>       
    
      <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="#exampleModal2">
                <a data-toggle='tooltip' data-placement='top' title='Tambah Akunt Baru <?php echo $kd_ke; ?>' style='margin-right:3px' class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#akunt_baru<?php echo $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">Kode3</th>
                      <th width="72%" class="text-center">Nama3</th>
                      <th width="1%" class="text-center">i</th>
                      <th width="26%" class="text-center">Opsi</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)){
                $tnoperk=$n['noperk'];
                $sql4 = mysqli_query($koneksi, "SELECT count(noperk) AS nnoperk FROM jor WHERE noperk=$tnoperk");
                    list($nnoperk) = mysqli_fetch_array($sql4);              
              ?>
              <tr>
                <td><?php echo $n['noperk']; ?></td>
                <td><?php echo $n['perk']; ?></td>
                <td><?php echo $nnoperk; ?></td>
                <td>
                    <a data-toggle='tooltip' data-placement='top' title='Edit Nama Akunt : <?php echo $n['perk'] ?>' class="btn btn-warning btn-sm" href="kode_akunt_edit.php?noperk=<?php echo $n['noperk'] ?>"><i class="bi bi-gear"></i></a>
                    <?php if ($nnoperk<1) { ;?> 
                          <a data-toggle='tooltip' data-placement='top' title='Hapus Akunt : <?php echo $n['perk'] ?>' onclick="return confirm('Yakin ingin hapus akunt <?php echo $n['noperk']; ?> - <?php echo $n['perk']; ?>.....?')" class="btn btn-danger btn-sm" href="kode_akunt_nawal_hapus.php?noperk=<?php echo $n['noperk']; ?>">
                            <i class="bi bi-trash"></i>
                          </a>
                    <?php } ?>
                    
                  <form action="kode_akunt_baru_act.php" method="post">
                    <div class="modal fade" id="akunt_baru<?php echo $noperk ; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel2" aria-hidden="true">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="exampleModalLabel2">Tambah Akunt Baru </h1>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                          </div>
                          <div class="modal-body">
<div style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">                              
                            <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%">
                              <input type="hidden" name="t2digit" readonly="readonly" class="form-control" value="<?php echo $kd2 ?>" 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>
</div>                    
                  </form>                          
                </td>                
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>    









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

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

