<?php

$time = new time;
$sekolah = new sekolah();
$grafik = new aks_grafik();
$crud = new crudData();
$format = new format();
$clslistTanggungan = new listTanggungan();
$classTrans = new transaksi();
$cekVersi = new update();
$cekInt = new cekint();

$hariini = $time->tanggalIni();

if ((int)substr($time->getDate(), 5, 2) > 6) {
    $blnNow = (int)substr($time->getDate(), 5, 2) - 6;
} else {
    $blnNow = (int)substr($time->getDate(), 5, 2) + 6;
}

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

//HAPUS SEMUA FILE DALAM FOLER QRCODE
$filesQR = glob('../../qrcode/*.png');
foreach ($filesQR as $fileQR) {
    if (is_file($fileQR))
        unlink($fileQR);
}
$filesPdf = glob('view/transaksi/*.pdf');
foreach ($filesPdf as $filePdf) {
    if (is_file($filePdf))
        unlink($filePdf);
}

//$crud = new crudData;


$today = $time->tanggalIni();; ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <?php require('./layout/headerpage.php'); ?>
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">

                </div><!-- /.col -->
                <div class="col-sm-6">

                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- Info boxes -->

            <!-- /.row -->
            <div class="row">
                <div class="col-md-12">
                    <div class="card  my-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 ml-3 "><span class="bi bi-card-list"></span> Profil Lembaga</b>
                        </div>

                        <!-- /.card-header -->

                        <div class="row">
                            <div class="col-md-8">
                                <div class="card-body">
                                    <span class='text-danger ml-2'><b>PROFIL LEMBAGA </b></span>
                                    <?php include "beranda/profil.php";  ?>
                                    <div class="row float-left ml-2">
                                        <i class="text-success float-right" style="font-size:13px">Versi : <?php //require "../../versi.php";
                                                                                                            $cekVersi = new versi;
                                                                                                            echo $cekVersi->aplikasi(); ?></i>
                                    </div>

                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="card-body">
                                    <iframe src="../../asset/bootstrap/plugins/jam/jam4.html" height="230" width="230" frameborder="0"></iframe>
                                </div>
                            </div>
                            <!--
                            <div class="col-md-5">
                                <div class="card-body">
                                    <span class='text-danger'><b>PENERIMAAN HARI INI</b></span>
                                    <?php //include "beranda/realisasi.php";
                                    ?>


                                </div>
                            </div>

-->

                        </div>

                    </div>

                </div>

            </div>
            <div class="row">
                <div class="col-12 col-sm-6 col-md-6">
                    <div class="info-box">
                        <span class="info-box-icon bg-primary elevation-1"><i class="bi bi-hdd"></i></span>

                        <div class="info-box-content pb-2">
                            <span class="info-box-text text-primary"><strong>Backup Database</strong></span>
                            <span class="info-box-number">
                                <?php include "beranda/backup.php"; ?>

                            </span>
                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>
                <div class="col-12 col-sm-6 col-md-3">
                    <div class="info-box">
                        <span class="info-box-icon bg-<?php if ($count_konfirm > 0) {
                                                            echo "danger";
                                                        } else {
                                                            echo "purple";
                                                        }; ?>  elevation-1"><i class="bi bi-megaphone"></i></span>

                        <div class="info-box-content pb-4">
                            <span class="info-box-text text-<?php if ($count_konfirm > 0) {
                                                                echo "danger";
                                                            } else {
                                                                echo "purple ";
                                                            }; ?>"><strong>Konfirmasi Transfer</strong></span>
                            <span class="info-box-number pb-1">
                                <?php if ($count_konfirm > 0) {
                                    echo "<a " . $link->page('transfer/konfirmasi') . " class='btn btn-danger btn-xs btn-rounded small'> <i class='bi bi-megaphone'></i>  Ada " . $format->ribuan($count_konfirm) . " Konfirmasi. Cek Sekarang</a>";
                                    //echo $format->ribuan($count_konfirm) . " Konfirmasi. Verifikasi";
                                } else {
                                    echo "<i class='small text-secondary' font-size:'10pt'>--Tidak Ada--</i>";
                                }; ?>

                            </span>
                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>



                <!-- fix for small devices only -->
                <div class="clearfix hidden-md-up"></div>

                <div class="col-12 col-sm-6 col-md-3">
                    <div class="info-box">
                        <span class="info-box-icon bg-success elevation-1"><i class="bi bi-smartwatch"></i></span>

                        <div class="info-box-content pb-3 mb-1">
                            <div class="col-sm-12 invoice-col pt-0 pb-1">
                                <span><strong class="text-success">Penerimaan Hari ini <?php echo $format->dateToIndoLong($today); ?></strong></span>
                                <?php include "beranda/realisasi.php"; ?>

                            </div>
                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>

            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="card  my-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 ml-3 "><span class="bi bi-reception-4"></span> Progres Pembayaran Siswa</b>
                        </div>

                        <!-- /.card-header -->

                        <div class="row">
                            <div class="col-md-10">
                                <div class="card-body">
                                    <span class='text-danger ml-2'><b>PROGRES PEMBAYARAN</b></span>
                                    <?php include "beranda/progres.php";
                                    ?>

                                </div>
                            </div>

                            <div class="col-md-2">
                                <div class="card-body text-center ">

                                    <div class="box-body mt-5">
                                        <input type="text" class="knob" value="<?php echo  $format->persen(@($crud->sum($tb_transaksi, 'jumlah', '')), $clslistTanggungan->tanggunganSiswaIf($tb_siswa,  " jenjang!=''")); ?>" data-skin="tron" data-thickness="0.2" data-width="120" data-height="120" data-fgColor="#f56954">
                                    </div>
                                </div>
                            </div>

                        </div>

                    </div>

                </div>

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

                <div class="col-12 col-sm-6 col-md-6">
                    <div class="card  my-2 mt-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-bar-chart-line"></span> Grafik Penerimaan Bulanan</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row ">
                                <div class="col-md-12">
                                    <p class="text-center">
                                        <strong>Grafik Penerimaan Bulanan TP. <?php echo $tahun; ?></strong>
                                    </p>

                                    <iframe src="chart/chart_bulanan.php" width="100%" height="430px" frameborder="0" scrolling="no"></iframe>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>
                <!-- /.col -->
                <div class="col-12 col-sm-6 col-md-6">
                    <div class="card  my-2 mt-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-bar-chart-line"></span> Grafik Penerimaan Harian</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">

                                    <div class="card-body">
                                        <iframe src="chart/chart_harian.php" width="100%" height="425px" frameborder="0" scrolling="no"></iframe>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>

                <!-- fix for small devices only -->
                <div class="clearfix hidden-md-up"></div>


            </div>

            <div class="row">
                <div class="col-md-12">
                    <div class="card  my-2">

                        <div class="timeline-header bg-success pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-calculator"></span> Laporan Realisasi</b>
                        </div>

                        <!-- /.card-header -->

                        <div class="row">
                            <div class="col-md-12">
                                <div class="card-body">
                                    <?php include "beranda/laporan_transaksi.php";
                                    ?>
                                </div>
                            </div>


                        </div>

                    </div>

                </div>


            </div>


            <div class="row">

                <div class="col-12 col-sm-6 col-md-4">
                    <div class="card  my-2 mt-0">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-people"></span> Penerimaan Hari Ini Per Penerima</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">

                                    <div class="card-body">
                                        <?php include "beranda/penerimaan_penerima.php";
                                        ?>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>
                <!-- /.col -->
                <div class="col-12 col-sm-6 col-md-4">
                    <div class="card  my-2 mt-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-card-list"></span> Penerimaan Hari Ini Per Jenis</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">

                                    <div class="card-body">
                                        <?php include "beranda/penerimaan_jenis.php";
                                        ?>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>

                <!-- fix for small devices only -->
                <div class="clearfix hidden-md-up"></div>

                <div class="col-12 col-sm-6 col-md-4">
                    <div class="card  my-2 mt-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-card-list"></span> Penerimaan Hari Ini Per Kelas</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">


                                    <div class="card-body">
                                        <?php include "beranda/penerimaan_kelas.php";
                                        ?>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>

            </div>
            <div class="row">
                <div class="col-lg-6 col-sm-12">

                    <div class="card  my-2 mt-2">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-card-list"></span> Monitoring Setor</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <p class="text-center">
                                        <strong>Monitoring Setor Teller</strong>
                                    </p>

                                    <div class="card-body">
                                        <?php include "beranda/setor.php";
                                        ?>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                </div>
                <div class="col-lg-6">

                    <div class="card  my-2 mt-0">

                        <div class="timeline-header bg-primary pt-2 pb-2">
                            <b class="text-light judul my-3 mx-2"><span class="bi bi-card-list"></span> Daftar Transaksi Hari Ini</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">

                                    <div class="card-body">
                                        <?php include "beranda/transaksi.php";
                                        ?>
                                    </div>
                                    <!-- /.chart-responsive -->
                                </div>
                                <!-- /.col -->

                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- ./card-body -->

                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>



        </div>
        <!--/. container-fluid -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php

$clsbackup = new backup();
$clsbupdate = new update();
if (isset($_POST['backupBeranda'])) {
    $clsbackup->backup_proses($tahun, 'D');
} elseif (isset($_POST['submitUpdate'])) {
    $clsbupdate->proses();
} else {
    echo '';
}
