<!DOCTYPE html>
<html lang="en">

<head>

    <link rel="stylesheet" href="../../../../../asset/bootstrap/css/adminlte.min.css">

    <script src="../../../../../asset/bootstrap/plugins/jquery/jquery.min.js"></script>
    <script src="../../../../../asset/bootstrap/asset/rupiah/rupiah.js"></script>
    <style>
        .font {
            font-family: arial;
            font-size: 11px;
        }

        .fontlamp {
            font-family: arial;
            font-size: 8px;
        }

        .fontJudullamp {
            font-size: 12px;
            font-family: arial;

        }

        .fontInput {
            font-size: 11px;
            font-family: arial;
        }

        .fontJudul {
            font-size: 12px;
            font-family: arial;
            color: dodgerblue;
            background: #000;
        }
    </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed small">

    <div class="wrapper">
        <?php
        error_reporting(0);
        require('../../../../../asset/mod/autoLoad.php');

        require('../../../../../asset/bootstrap/asset/phpqrcode/qrlib.php');

        $link = new linkpage;
        date_default_timezone_set('Asia/Jakarta');
        $tanggal = mktime(date("m"), date("d"), date("Y"));
        $tglsekarang = date("d-m-Y", $tanggal);
        $tahunnow = date("Y", $tanggal);

        if (isset($_GET['tahun'])) {
            $tahun = $_GET['tahun'];
        } else {
            $tahun = $tahunnow;
        };
        $tahun1 = substr($tahun, 0, 4);
        $tahun2 = substr($tahun, 5, 4);

        $tahun_tabel = substr($tahun, 2, 2) . substr($tahun, 7, 2);

        $tb_siswa = "tb_siswa" . $tahun_tabel;
        $tb_transaksi = "db_transaksi" . $tahun_tabel;
        $tb_detailakun = "detail_akun" . $tahun_tabel;



        if (isset($_GET['tanggal1'])) {
            $tgl_1 = $_GET['tanggal1'];
        } else {
            $tgl_1 = $tglsekarang;
        };
        if (isset($_GET['tanggal2'])) {
            $tgl_2 = $_GET['tanggal2'];
        } else {
            $tgl_2 = $tglsekarang;
        };
        if (isset($_GET['penerima'])) {
            $penerima_lap = $_GET['penerima'];
        } else {
            $penerima_lap = "Semua";
        };
        if (isset($_GET['jenjang'])) {
            $jenjang_lap = $_GET['jenjang'];
        } else {
            $jenjang_lap = "Semua";
        };
        if (isset($_GET['paralel'])) {
            $paralel_lap = $_GET['paralel'];
        } else {
            $paralel_lap = "Semua";
        };
        if (isset($_GET['metode'])) {
            $metode_lap = $_GET['metode'];
        } else {
            $metode_lap = "Semua";
        };


        //Indo to Egg
        function ubahformatTgl($tanggal)
        {
            $pisah = explode('-', $tanggal);
            $urutan = array($pisah[2], $pisah[1], $pisah[0]);
            $satukan = implode('-', $urutan);
            return $satukan;
        }
        // Cara penggunaan function ubahTgl
        $tanggal1 = ubahformatTgl($tgl_1);
        $tanggal2 = ubahformatTgl($tgl_2);; ?>


        <div class="container col-12 mb-4">
            <div class="row">
                <div class="col-12">
                    <div class="row">
                        <div class="card-body col-12 mx-4">
                            <h5 class="page-header">
                                <?php
                                $view = new lembaga;
                                $clssekolah = new sekolah;
                                echo $view->viewImage('../../../../../asset/dokumen/foto/', 'logo', 'mr-2 position-absolute', '60', '60');
                                echo "<b class='d-block ml-5 pl-3 pt-1'>" . $clssekolah->dataSekolah('sekolah') . "</b>";
                                echo "<i class='footer font ml-5 pl-3 mb-2 pb-3'>" . $clssekolah->dataSekolah('alamat')  . "</i>"; ?>
                                <small class="float-right position-relative"><b class="text-danger">REKAPITULASI PEMBAYARAN<br>TP. <?php echo $tahun; ?></b> </small><br>
                            </h5>
                        </div>

                        <div class="card-body mx-4">
                            <label>
                                <h6><b class="text-primary">REKAPITULASI PEMBAYARAN</b></h6>
                            </label>
                            <table class="table table-bordered table-sm">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Kode : Jenis Pembayaran</th>
                                        <th>Jenjang</th>
                                        <th>Bulanan</th>
                                        <th>Record</th>
                                        <th>Tanggungan</th>
                                        <th>Terbayar</th>
                                        <th>Kurang</th>
                                        <th>Persen</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $classForm = new form();
                                    $sekolah = new sekolah();
                                    $grafik = new aks_grafik();
                                    $crud = new crudData();
                                    $format = new format();
                                    $clslistTanggungan = new listTanggungan();
                                    $classTrans = new transaksi();

                                    $sekolah = $crud->editData('sekolah', 'no', 1);
                                    $dataSekolah = $sekolah->fetch(PDO::FETCH_OBJ);
                                    $jenjang = strtolower($dataSekolah->jenjang);
                                    // $jenjang = "smp";
                                    $tingkat = $classForm->optSelect('tb_tingkat', "where {$jenjang}<>'' order by no asc");
                                    while ($datatingkat = $tingkat->fetch(PDO::FETCH_OBJ)) {
                                        $jenjang_opt = $datatingkat->{$jenjang};
                                        echo "
                                        <tr>
                                            <td width='5px'>#</td>
                                            <td align=left colspan='4'><b>Jenjang $jenjang Kelas $jenjang_opt</b></td>
                                        </tr>";
                                        $classLaporan = new laporan();
                                        $jenisBayar = $classLaporan->ShowjenisBayar($tahun, $jenjang_opt);
                                        while ($datajenis = $jenisBayar->fetch(PDO::FETCH_OBJ)) {
                                            $jenis = $datajenis->kode;
                                            $field = "tang_" . $jenis;


                                            $tanggungan_jenis = @($crud->sum($tb_siswa, 'tang_' . $jenis, "where jenjang='$jenjang_opt'"));
                                            $terbayar_jenis = @($crud->sum($tb_transaksi, 'jumlah', "where jenjang='$jenjang_opt' and jenis='$jenis'"));
                                            $kurang_jenis = @($tanggungan_jenis) - @($terbayar_jenis);
                                            $persen_jenis = $format->persen($terbayar_jenis, $tanggungan_jenis);
                                            $progresBar_jenis = $grafik->progresBar($persen_jenis);

                                            //SSub Total
                                            $tanggungan = $clslistTanggungan->tanggunganSiswaIf($tb_siswa, " jenjang='$jenjang_opt' and paralel!=''");
                                            $terbayar = @($crud->sum($tb_transaksi, 'jumlah', "where jenjang='$jenjang_opt'"));
                                            $kurang = @($tanggungan) - @($terbayar);
                                            $persen = $format->persen($terbayar, $tanggungan);

                                            //Total
                                            $tanggungan_total = $clslistTanggungan->tanggunganSiswaIf($tb_siswa, " jenjang!=''");
                                            $terbayar_total = @($crud->sum($tb_transaksi, 'jumlah', ""));
                                            $kurang_total = @($tanggungan_total) - @($terbayar_total);
                                            $persen_total = $format->persen($terbayar_total, $tanggungan_total);



                                            $progresBar = $grafik->progresBar($persen);
                                            $progresBar_total = $grafik->progresBar($persen_total);


                                            echo "
                        <tr>
                            <td width='5px'></td>
                            <td align=left>$datajenis->kode : $datajenis->nama</td>
                            <td align=left>$datajenis->kelas</td>
                            <td align=left>$datajenis->bulanan</td>
                            <td align=center>" . $crud->countData($tb_transaksi, "where jenjang='$datajenis->kelas' && jenis='$jenis'") . "</td>
                            <td align=right>" . $format->ribuan($tanggungan_jenis) . "</td>
                            <td align=right>" . $format->ribuan($terbayar_jenis) . "</td>
                            <td align=right>" . $format->ribuan($kurang_jenis) . "</td>
                          
                            <td align=right>" . $format->ribuan($persen_jenis) . "</td>
                            </tr>";
                                        };
                                        echo "
                        <tr bg-color='grey'>
                            <td width='5px'></td>
                            <td align=left colspan='3'><i>Jumlah Kelas $jenjang_opt </i></td>
                            <td align=center>" . $crud->countData($tb_transaksi, "where jenjang='$jenjang_opt'") .  "</td>
                            <td align=right>" . $format->ribuan($tanggungan) . "</td>
                            <td align=right>" . $format->ribuan($terbayar) . "</td>
                            <td align=right>" . $format->ribuan($kurang) . "</td>
                          
                            <td align=right>" . $format->ribuan($persen) . "</td>
                        </tr>";
                                    };
                                    echo "
                                        <tr>
                                            <td width='5px'></td>
                                            <td align=left colspan='3'><b>TOTAL</b></td>
                                            <td align=center>" . $crud->countData($tb_transaksi, "") .  "</td>
                                            <td align=right>" . $format->ribuan($tanggungan_total) . "</td>
                                            <td align=right>" . $format->ribuan($terbayar_total) . "</td>
                                            <td align=right>" . $format->ribuan($kurang_total) . "</td>
                                          
                                            <td align=right>" . $format->ribuan($persen_total) . "</td>
                                            </tr>";
                                    ?>

                                </tbody>
                            </table>



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

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

            </section>

        </div>


        <script src="../../../../../asset/bootstrap/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/sweetalert2/sweetalert2.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/toastr/toastr.min.js"></script>
        <script src="../../../../../asset/bootstrap/js/adminlte.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jquery-ui/jquery-ui.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/chart.js/Chart.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/sparklines/sparkline.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jqvmap/jquery.vmap.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jquery-knob/jquery.knob.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/moment/moment.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/daterangepicker/daterangepicker.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/summernote/summernote-bs4.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
        <script src="../../../../../asset/bootstrap/js/pages/dashboard.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/select2/js/select2.full.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/inputmask/jquery.inputmask.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/bs-stepper/js/bs-stepper.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/dropzone/min/dropzone.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables/jquery.dataTables.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jszip/jszip.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/pdfmake/pdfmake.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/pdfmake/vfs_fonts.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-buttons/js/buttons.print.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jquery-mousewheel/jquery.mousewheel.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jquery-mapael/jquery.mapael.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/jquery-mapael/maps/usa_states.min.js"></script>
        <script src="../../../../../asset/bootstrap/plugins/raphael/raphael.min.js"></script>
        <script src="../../../../../asset/bootstrap/js/pages/dashboard2.js"></script>

</body>


</html>