<?php


$cekID = new cekID();

$crud = new crudData();
$cekID->cek('simakom_ref_kegiatan', 'id', $id_page);


$sql = $crud->editData('simakom_ref_kegiatan', 'id', $id_page);
$data = $sql->fetch(PDO::FETCH_OBJ);


?>
<style>
    .fontInput {
        font-size: 11px;
        font-family: arial;
    }
</style>
<!-- Content Wrapper. Contains page content -->
<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-square"></span> Edit Kegiatan</h4>
                        </div>
                        <div class="card-body mb-4 text-dark">
                            <form action="" method="post">
                                <?php $csrf->token(); ?>
                                <input type="text" name="kegiatan_old" value="<?php echo $data->kegiatan; ?>" hidden>
                                <input type="text" name="id" value="<?php echo $data->id; ?>" hidden>
                                <div class="row mx-3 mt-3" style="background-color: gainsboro;">
                                    <div class="col-md-7">
                                        <div class="card-body mt-4 px-2 mx-3">
                                            <div class="row">
                                                <label class="col-sm-3 col-form-label">Kode Kegiatan</label>
                                                <div class="col-sm-7">
                                                    <input type="text" name="kegiatan" class="form-control form-control-sm fontInput" value="<?php echo $data->kegiatan; ?>" placeholder="Kode Kegiatan [4 Digit]">
                                                    <p class="small">
                                                        <i class="d-block">Kode Kegiatan untuk Ketegori <b class="text-success">Pendapatan : 1000 - 1999</b></i>
                                                        <i class="d-block">Kode Kegiatan untuk Ketegori <b class="text-danger"> Belanja : 2000 - 2999</b></i>
                                                    </p>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <label class="col-sm-3 col-form-label">Kode Kegiatan Custome</label>
                                                <div class="col-sm-7">
                                                    <input type="text" name="kegiatan_custome" class="form-control form-control-sm fontInput" value="<?php echo $data->kegiatan_custome; ?>" placeholder="Kode Kegiatan Custome">
                                                    <p class="footnote small"><i>Kode Custome adalah Kode Kode sesuai Kebutuhan Sekolah/Lembaga. Jika tidak diperlukan kosongkan (sama dengan kode Kegiatan sistem)</i></p>
                                                </div>

                                            </div>
                                            <div class="row">
                                                <label class="col-sm-3 col-form-label">Uraian Kegiatan</label>
                                                <div class="col-sm-7">
                                                    <input type="text" name="uraian" value="<?php echo $data->uraian; ?>" minlength="3" class="form-control form-control-sm fontInput" placeholder="Uraian Kegiatan">

                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                <div class="my-2 pl-3 py-2 mx-3" style="background-color: gainsboro;">
                                    <div class="row">
                                        <div class="col-auto">
                                            <a <?php echo $link->page('seting/kegiatan/kegiatan_read'); ?> class="btn btn-primary btn-xs float-right mx-2"><i class="bi-arrow-left-circle"></i> Cancel</a>
                                            <button type="submit" class="btn btn-primary btn-xs float-right" name="submit"><i class="bi-save"></i> Simpan</button>
                                        </div>
                                    </div>
                                </div>
                            </form>


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

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

<?php
if (isset($_POST['submit'])) {
    $csrf = $csrf->cekToken();
    $class = new simakom_rkas();
    $save = $class->updateKegiatan();
} else {
    echo "";
};
