<?php
date_default_timezone_set('Asia/Jakarta');
$tanggal = mktime(date("m"), date("d"), date("Y"));
$tglsekarang = date("d-m-Y", $tanggal);


if (isset($_POST['buku'])) {
    $buku = $_POST['buku'];
    $classLap = new simakom_laporan();
    $v_buku = $classLap->jenisBuku($buku);
} else {
    $buku = 1;
    $classLap = new simakom_laporan();
    $v_buku = $classLap->jenisBuku($buku);
};

if (isset($_POST['tanggal'])) {
    $tanggal = $_POST['tanggal'];
} else {
    $classTime = new time();
    $tanggal =  $classTime->getDateInput();
};
$format = new format();
$tanggalBuku = $format->dateToEng($tanggal);

$optVal = new lembaga();
if (isset($_POST['bulan'])) {
    $bulan = $_POST['bulan'];
    $v_bulan = $optVal->ValPeriode($bulan, $tahun1, $tahun2);
    // if ($bulan > 6) {
    $periode = $bulan;
    $tahunLPJ = $tahun2;
    // } else {
    //    $periode = 1;
    //    $tahunLPJ = $tahun1;
    //};
} else {
    $bulan = 1;
    $v_bulan = $optVal->ValPeriode('1', $tahun1, $tahun2);
    $periode = 1;
    $tahunLPJ = $tahun1;
};


?>
<!--/ Hak Cipta dilindungi Undang-undang. Hak Cipta : Khamdi Rahmani, Reg. Kemenkum HAM No : 000121327. Dilarang merubah isi File tanpa ijin tertulis dari pemegang Hak Cipta.-->

<div class="content-wrapper">

    <?php require('./layout/headerpage.php'); ?>

    <div class="container col-12 mb-4 pb-5">
        <div class="row  mx-0 pr-3">
            <div class="col-12">
                <div class="col-12 ">
                    <div class="card  mx-0">
                        <div class="timeline-header bg-primary  py-2 pl-2">
                            <b class="text-light judul"><span class="bi bi-journal-text"></span> Buat Periode LPJ Bendahara </b>
                        </div>

                        <div class="row col-md-12">
                            <div class="col-md-6">
                                <div class="card-body mt-4 px-1 mx-2">

                                    <div class="row">
                                        <div class="col-12 col-sm-6 col-md-12">
                                            <div class="info-box mb-3">


                                                <div class="info-box-content">
                                                    <div class="relative mb-0 pb-4">
                                                        <input name="judul" value="PARAMETER" style="background-color: gainsboro;" class="form-control-sm col-sm-2 fontInput small bg-default mt-3 text-center" disabled>
                                                    </div>

                                                    <div class="col-sm-12 invoice-col pt-0">

                                                        <form action="" method="post">


                                                            <div class="row">
                                                                <label class="col-sm-3 col-form-label">Periode LPJ</label>
                                                                <div class="col-md-9">
                                                                    <select name="bulan" class="form-control form-control-sm fontInput small" onchange="this.form.submit()">

                                                                        <option value="<?php echo $bulan; ?>"><?php echo $v_bulan; ?></option>
                                                                        <?php

                                                                        $oplist = $optVal->listPeriode($tahun1, $tahun2);
                                                                        echo $oplist;
                                                                        ?>
                                                                    </select>
                                                                </div>

                                                            </div>
                                                            <div class="row">

                                                                <label class="col-sm-3 col-form-label">Tanggal Laporan</label>
                                                                <div class="col-md-3">
                                                                    <input class="form-control form-control-sm fontInput small d-inline" onchange="this.form.submit()" style="text-align:center" pattern="\d{2,2}-\d{2,2}-\d{4}" id="tanggal1" name="tanggal" value="<?php echo $tanggal;

                                                                                                                                                                                                                                                                        ?>" <?php
                                                                                                                                                                                                                                                                            $oldClass = new old();
                                                                                                                                                                                                                                                                            $bukti = $oldClass->showOld('tanggal'); ?> />
                                                                </div>

                                                            </div>

                                                        </form>


                                                        <form name="cetak" action="" method="post">
                                                            <input name="tahun" value="<?php echo $tahun; ?>" hidden>
                                                            <input name="periode" value="<?php echo $periode; ?>" hidden>
                                                            <input name="tanggal" value="<?php echo $tanggal; ?>" hidden>
                                                            <button type="submit" class="btn btn-primary btn-xs float-right px-2 mx-1 d-inline" name="submitLPJ"><i class="bi bi-save"></i><b> BUAT PERIODE LPJ</b></button>
                                                        </form>
                                                    </div>
                                                </div>

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



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



    </div>
</div>


<?php
if (isset($_POST['submitLPJ'])) {
    // $csrf = $csrf->cekToken();
    $class = new simakom_laporan();
    $save = $class->insertLPJ($tb_lpj);
} else {
    echo "";
};
