<?php



$komponen_id = $id_page;

$cekID = new cekID();
$cekID->cek($tb_komponen, 'id', $komponen_id);
$classsimakomRKAS = new simakom_rkas;
$class = new crudData();
$form = new form();
$edit = $class->editData($tb_komponen, 'id', $komponen_id);
$data = $edit->fetch(PDO::FETCH_OBJ);
$kategori = $data->kategori;
$kegiatan = $data->kegiatan;
$komponen_uraian = $data->uraian;
$komponen_kode = $data->komponen;
$uraian_kategori = $classsimakomRKAS->uraianRKAS('simakom_ref_kategori', 'kategori', $kategori, 'uraian');
$rkas = new simakom_rkas();
$kegiatan_custome = $rkas->kodeCustome('simakom_ref_kegiatan', 'kegiatan', $kegiatan, 'kegiatan_custome');
$kegiatan_uraian = $rkas->kodeCustome('simakom_ref_kegiatan', 'kegiatan', $kegiatan, '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-pencil"></span> Edit Komponen</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body my-4 mx-4">
                            <form action="" method="post">
                                <input type="text" name="kategori" value="<?php echo $data->kategori;
                                                                            ?>" hidden>
                                <input type="text" name="kegiatan" value="<?php echo $data->kegiatan;
                                                                            ?>" hidden>
                                <input type="text" name="kegiatan_old" value="<?php echo $kegiatan;
                                                                                ?>" hidden>
                                <input type="text" name="komponen_id" value="<?php echo $komponen_id;
                                                                                ?>" hidden>
                                <input type="text" name="submitUpdate" value="<?php echo $komponen_id;
                                                                                ?>" 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 . ' - ' . $uraian_kategori; ?></b></dd>
                                        <dt class="col-sm-3">KEGIATAN</dt>
                                        <dd class="col-sm-9"><b><?php echo $kegiatan . ' - ' . $kegiatan_uraian; ?></b></dd>
                                        <dt class="col-sm-3 mt-2">KODE KOMPONEN</dt>
                                        <dd class="col-sm-9"><b><input type="text" name="komponen" class="form-control form-control-sm fontInput" value="<?php echo $komponen_kode;
                                                                                                                                                            ?>"></b></dd>
                                        <dt class="col-sm-3">URAIAN KOMPONEN</dt>
                                        <dd class="col-sm-9"><b><input type="text" name="uraian" class="form-control form-control-sm fontInput" value="<?php echo $komponen_uraian;
                                                                                                                                                        ?>">

                                            </b></dd>


                                    </dl>
                                </div>
                                <div class="div d-inline">
                                    <button type="submit" name="submitUpdateKomponen" class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-save"></i> SIMPAN </button>
                                </div>


                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php

if (isset($_POST['submitUpdateKomponen'])) {
    $komponen_new = htmlspecialchars($_POST['komponen']);
    $class = new simakom_rkas();
    //$update = $class->updateRKASKegiatan($tb_komponen, $tb_komponen, $tb_akun, $tb_detail, $kegiatan_old, $tb_revisi);
    $update = $class->updateRKASKomponen($tb_kegiatan, $tb_komponen, $tb_akun, $tb_detail, $komponen_kode, $tb_revisi, $komponen_id, $kategori, $kegiatan,  $komponen_kode, $komponen_new);
} else {
    echo "";
};
