<?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);

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


$classNeraca = new simakom_neraca();

?>
<!--/ 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-3 pr-3">
            <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-hr"></span> Neraca </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="PERIODE" 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 Bulan</label>
                                                                <div class="col-md-9">
                                                                    <select name="bulan" class="form-control form-control-sm fontInput small">
                                                                        <option value="<?php echo $bulan; ?>"><?php echo $v_bulan; ?></option>
                                                                        <?php
                                                                        $oplist = $lembaga->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" 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>

                                                            <div class="row mt-3">
                                                                <label class="col-sm-3 col-form-label"></label>
                                                                <div class="col-md-9">
                                                                    <button type="submit" class="btn btn-primary btn-xs float-left px-2 mx-1" name="save"><i class="bi-funnel"></i> <b> SUBMIT</b></button>
                                                        </form>

                                                        <form name="cetak" action="<?php echo $link->pageAction('laporan/neraca/print_preview'); ?>" method="post">
                                                            <input name="tahun" value="<?php echo $tahun; ?>" hidden>
                                                            <input name="bulan" value="<?php echo $bulan; ?>" 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"><i class="bi bi-printer"></i><b> CETAK</b></button>
                                                        </form>
                                                    </div>
                                                </div>

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



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


        <div class="card-body mx-1">
            <label>
                <h6><b class="text-primary">NERACA</b></h6>
            </label>
            <?php
            $class = new simakom_search();
            $showList = $class->search_input();
            ?>
            <table class="table table-bordered table-hover table-sm mb-0 mt-2">
                <thead>
                    <tr>
                        <th>Uraian</th>
                        <th width="200">Jumlah</th>
                    </tr>
                </thead>
            </table>

            <table id="searchtable" class="table table-bordered table-sm mb-4 mt-0">

                <tbody>
                    <?php echo $classNeraca->viewJurnal($tb_siswa, $tb_transaksi,  $tb_transaksi_aks, $tb_jurnal, $periode, $tahun); ?>
                </tbody>
            </table>
        </div>
    </div>
</div>