<?php



$komponen_id = $id_page;
$classsimakomRKAS = new simakom_rkas;
$form = new form;
$db = database::getInstance();
$show = $db->runQuery("SELECT * FROM   {$tb_komponen}  WHERE id = '{$komponen_id}'");
$akun = $show->fetch(PDO::FETCH_OBJ);
$kategori_kode = $akun->kategori;
$kegiatan_kode = $akun->kegiatan;
$komponen_kode = $akun->komponen;
$komponen_uraian = $akun->uraian;

$class = new simakom_rkas();
$uraian_kategori = $class->uraianRKAS('simakom_ref_kategori', 'kategori', $kategori_kode, 'uraian');
$uraian_kegiatan = $class->uraianRKAS('simakom_ref_kegiatan', 'kegiatan', $kegiatan_kode, 'uraian');


$show_komp = $db->runQuery("SELECT * FROM   {$tb_komponen}  WHERE komponen = '{$komponen_kode}' and kegiatan='$kegiatan_kode'");
$komp = $show_komp->fetch(PDO::FETCH_OBJ);
$uraian_komponen = $komp->uraian; ?>
<div class="content-wrapper">
    <?php require('./layout/headerpage.php'); ?>
    <div class="container col-12 mb-4 pb-5">
        <div class="row">
            <div class="col-12">
                <div class="col-12">
                    <div class="card  mx-3">
                        <div class="timeline-header bg-primary py-2 pl-2">
                            <b class="text-light judul"><span class="bi bi-trash"></span> Hapus Komponen</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body my-4 mx-4">
                            <form action="" method="post">
                                <?php //$csrf->token();
                                ?>

                                <input type="text" name="kategori" value="<?php echo $kategori_kode;
                                                                            ?>" hidden>
                                <input type="text" name="kegiatan" value="<?php echo $kegiatan_kode;
                                                                            ?>" hidden>
                                <input type="text" name="komponen" value="<?php echo $komponen_kode;
                                                                            ?>" hidden>


                                <div class="info-box-content">
                                    <dl class="row">
                                        <dt class="col-sm-3 pt-0">KATEGORI</dt>
                                        <dd class="col-sm-9  pt-0"><b>: <?php echo $kategori_kode . ' - ' . $uraian_kategori; ?></b></dd>
                                        <dt class="col-sm-3">KEGIATAN</dt>
                                        <dd class="col-sm-9"><b>: <?php echo $kegiatan_kode . ' - ' . $uraian_kegiatan; ?></b></dd>
                                        <dt class="col-sm-3">KOMPONEN</dt>
                                        <dd class="col-sm-9"><b>: <?php echo $komponen_kode . ' - ' . $uraian_komponen; ?></b></dd>


                                    </dl>
                                </div>

                                <div class="col-md-12 mt-3">
                                    <p class="text-danger"><strong>Menghapus Komponen akan menghapus Seluruh Akun dan Rincian/Detail pada Komponen ini. Yakin akan menghapus?</strong></p>
                                </div>
                                <div class="div d-inline">
                                    <button type="submit" name="deleteKomponen" class="btn btn-danger btn-xs mb-2 btn-rounded small px-2 ml-1"> <i class="bi bi-trash"></i> YA, HAPUS KOMPONEN <?php echo $komponen_kode; ?></button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
if (isset($_POST['deleteKomponen'])) {
    $kategori = htmlspecialchars($_POST['kategori']);
    $kegiatan = htmlspecialchars($_POST['kegiatan']);
    $komponen = htmlspecialchars($_POST['komponen']);
    //$akun = htmlspecialchars(trim($_POST['old_akun']));
    $class = new simakom_rkas();
    $save = $class->deleteRKASKomponen($tb_komponen, $tb_akun, $tb_detail, $tb_revisi);
} else {
    echo "";
};
