<?php 
    include 'header.php'; 

    //////////////////////////////////////////////////////////////////////////// 
    $oleh   = $_SESSION['id_kar']; 
    $kdc    = $_SESSION['kdc']; 
    $tabel_tujuan   = "cmob_trans_".$oleh."_".$kdc; 
    $tabel_asal     = "cmob_trans"; 
    //////////////////////////////////////////////////////////////////////////// 
    $query_hapus = "DROP TABLE IF EXISTS $tabel_tujuan "; 
    mysqli_query($koneksi, $query_hapus); 
    $querycc = "CREATE TABLE $tabel_tujuan LIKE $tabel_asal"; 
    mysqli_query($koneksi, $querycc); 
    echo $tabel_tujuan ; 
    //////////////////////////////////////////////////////////////////////////// 
            $cbrg = mysqli_query($koneksi,"SELECT * FROM cmob_brg ");
            while($d = mysqli_fetch_array($cbrg)){
                $xkd     =$d['kd'];
                $xkode   =$d['kode'];
                $xnama   =$d['nama'];

                $query = mysqli_query($koneksi, "INSERT INTO $tabel_tujuan (kd,nama,kode) 
                                        VALUES('$xkd','$xnama','$xkode') ")
                                        or die('Ada kesalahan pada query insert : '.mysqli_error($koneksi)); 
            }     
    
?>

<div class="container">

  <div class="my-2 border-bottom">
    <h5 class="fw-semibold fs-5">TRANSAKSI PENYUSUTAN ASET TETAP</h5>
  </div>

  <section class="content">
    <div class="row">
      <section class="col-lg-12">
        <div class="box box-info">
          <div class="box-header">
          <div class="box-body">
              
            <form method="GET" action="at_penyusutan_2.php">
                <!-- Isi form seperti sebelumnya -->
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-group" style="width:100%">
                                <label class="form-label">Pilih Bulan : </label>
                                <select class="form-control" name="xbulan" required="required">
                                    <option value="">- Pilih Bulan -</option>
                                    <?php $kbln = mysqli_query($koneksi,"select * from aa_bulan ORDER BY id ASC"); while($x = mysqli_fetch_array($kbln)){ ?>
                                    <option value="<?php echo $x['ke'] ?>"><?php echo $x['bulan'] ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-group" style="width:100%">
                                <label class="form-label">Pilih Tahun : </label>
                                <select class="form-control" name="xtahun" required="required">
                                    <option value="">- Pilih Tahun -</option>
                                    <?php $thn = mysqli_query($koneksi,"select * from aa_tahun WHERE yt<>'X' ORDER BY id ASC"); while($y = mysqli_fetch_array($thn)){ ?>
                                    <option value="<?php echo $y['ke'] ?>"><?php echo $y['tahun'] ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-group" style="width:100%">
                                <label class="form-label">Pilih Jenis Asset : </label>
                                <select class="form-control" name="xkas" required="required">
                                    <option value="">- Pilih -</option>
                                    <?php $kas = mysqli_query($koneksi,"select * from kdjenis_at WHERE kd<>'11' ORDER BY id ASC"); while($k = mysqli_fetch_array($kas)){ ?>
                                    <option value="<?php echo $k['kd'] ?>"> - <?php echo $k['nama'] ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <br/>
                            <input type="submit" value="TAMPILKAN DATA" class="btn btn-sm btn-primary">
                        </div>
                    </div>
                </div>
            </form>
          </div>
        </div>


<?php if(isset($_GET['xbulan']) && isset($_GET['xtahun']) && isset($_GET['xkas'])){ 
    $bulane = $_GET['xbulan']; 
    $tahune = $_GET['xtahun']; 
    $kase = $_GET['xkas']; 


?>
       </div> 
    </div>    

              <?php 
            }else{
              ?>

              <div class="alert alert-info text-center">
                Silahkan Filter Laporan Terlebih Dulu.
              </div>

              <?php
            }
            ?>

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

</div>
<?php include 'footer.php'; ?>