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

<head>

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

    <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
        require('../../../../../asset/mod/autoLoad.php');


        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;
        $tb_setor = "setor_kjks" .  $tahun_tabel;
        $tb_transaksisim = "sim_transaksi" . $tahun_tabel;


        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['jenis'])) {
            $jenis_lap = $_GET['jenis'];
        } else {
            $jenis_lap = "Semua";
        };

        $clsLaporan = new laporan;
        $walikelas = $clsLaporan->walikelas($jenjang_lap, $paralel_lap);

        $dt_jenis = new namaBayar();
        $showJenis = $dt_jenis->shownamaBayar($tahun, $jenis_lap, $jenjang_lap);
        $count_nb = $showJenis->rowCount();
        $datajenis = $showJenis->fetch(PDO::FETCH_OBJ);

        if ($count_nb > 0) {
            $namaBayar = $datajenis->nama;
            $bulanan = $datajenis->bulanan;
            $filterJenis = "and jenis='$datajenis->kode'";
        } else {
            $namaBayar = "Semua";
            $bulanan = "Tidak";
            $filterJenis = "";
        };

        if ($bulanan == "Ya" or $bulanan == "ya") {
            $tahap1 = "Juli";
            $tahap2 = "Agt";
            $tahap3 = "Sept";
            $tahap4 = "Okt";
            $tahap5 = "Nop";
            $tahap6 = "Des";
            $tahap7 = "Jan";
            $tahap8 = "Feb";
            $tahap9 = "Mar";
            $tahap10 = "Apr";
            $tahap11 = "Mei";
            $tahap12 = "Jun";
        } else {
            $tahap1 = "Thp-1";
            $tahap2 = "Thp-2";
            $tahap3 = "Thp-3";
            $tahap4 = "Thp-4";
            $tahap5 = "Thp-5";
            $tahap6 = "Thp-6";
            $tahap7 = "Thp-7";
            $tahap8 = "Thp-8";
            $tahap9 = "Thp-9";
            $tahap10 = "Thp-10";
            $tahap11 = "Thp-11";
            $tahap12 = ">=12";
        };

        //Query Tanggungan
        $classTanggungan = new listTanggungan();
        $val_sumtang = $classTanggungan->sumTanggunganByFilter($tb_siswa, $jenjang_lap, $paralel_lap, $jenis_lap);

        if ($val_sumtang == "" || $val_sumtang  == 0) {
            $sumtanggungan = number_format(0, 0, ",", ".");
            $v_sumtanggungan = 0;
        } else {
            $sumtanggungan = number_format($val_sumtang, 0, ",", ".");
            $v_sumtanggungan = $val_sumtang;
        };
        //Terbayar & Kurang
        $classTrans = new transaksi();
        $Terbayar = $classTrans->sumTerbayar($tb_transaksi, $jenjang_lap, $paralel_lap, $jenis_lap);
        $sumterbayar = @(number_format($Terbayar, 0, ".", "."));
        $kurang = $v_sumtanggungan - $Terbayar;
        $sumkurang = @(number_format(($kurang), 0, ".", "."));


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


        <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">LAPORAN REKAPITULASI [MODEL-3]<br>TP. <?php echo $tahun; ?></b> </small><br>
                            </h5>
                        </div>
                        <div class="card-body col-12 mx-4">
                            <div class="row invoice-info">
                                <div class="col-sm-6 invoice-col">

                                    <dl class="row">
                                        <dt class="col-sm-4 pt-3">KELAS</dt>
                                        <dd class="col-sm-8 pt-3"><b>: <?php echo $jenjang_lap . "-" . $paralel_lap; ?></b></dd>
                                        <dt class="col-sm-4">JENIS PEMBAYARAN</dt>
                                        <dd class="col-sm-8 "><b>: <?php echo $jenis_lap . " - " . $namaBayar; ?> </b></dd>
                                        <dt class="col-sm-4">WALI KELAS</dt>
                                        <dd class="col-sm-8"><b>: <?php echo $walikelas; ?></b></dd>


                                    </dl>
                                </div>

                                <div class="col-sm-6 invoice-col">
                                    <dl class="row">
                                        <dt class="col-sm-4 pt-3">JML TANGGUNGAN</dt>
                                        <dd class="col-sm-8 pt-3"><b>: <?php echo $sumtanggungan; ?></b></dd>
                                        <dt class="col-sm-4">JML TERBAYAR</dt>
                                        <dd class="col-sm-8 "><b>: <?php echo $sumterbayar; ?> </b></dd>
                                        <dt class="col-sm-4">JML KURANG</dt>
                                        <dd class="col-sm-8"><b>: <?php echo $sumkurang; ?></b>
                                        </dd>
                                    </dl>
                                </div>
                            </div>
                        </div>
                        <div class="card-body mx-4">
                            <label>
                                <h6><b class="text-primary">DETAIL RINCIAN </b></h6>
                            </label>
                            <table class="table table-bordered table-striped table-sm">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th>Nama</th>
                                        <th>NIS</th>
                                        <th>Kelas</th>
                                        <th>Tanggungan</th>
                                        <th><?php echo $tahap1; ?></th>
                                        <th><?php echo $tahap2; ?></th>
                                        <th><?php echo $tahap3; ?></th>
                                        <th><?php echo $tahap4; ?></th>
                                        <th><?php echo $tahap5; ?></th>
                                        <th><?php echo $tahap6; ?></th>
                                        <th><?php echo $tahap7; ?></th>
                                        <th><?php echo $tahap8; ?></th>
                                        <th><?php echo $tahap9; ?></th>
                                        <th><?php echo $tahap10; ?></th>
                                        <th><?php echo $tahap11; ?></th>
                                        <th><?php echo $tahap12; ?></th>
                                        <th>Jumlah</th>
                                        <th>Kurang</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $classLaporan = new laporan();
                                    $showList = $classLaporan->showRekap($tb_siswa, $jenjang_lap, $paralel_lap, 'jenjang asc, paralel asc, nama asc');
                                    $no = 0;
                                    while ($data = $showList->fetch(PDO::FETCH_OBJ)) {

                                        $nis = $data->nis;
                                        $id = $data->id;
                                        $nama = $data->nama;
                                        $jenjang = $data->jenjang;
                                        $paralel = $data->paralel;
                                        $kelas = $jenjang . '-' . $paralel;

                                        //Query Tanggungan
                                        $classTanggungan = new listTanggungan();
                                        $val_tang = $classTanggungan->tanggunganByKode($tb_siswa, 'id', $id, $jenis_lap);
                                        if ($val_tang == "" || $val_tang  == 0) {
                                            $tanggungan = number_format(0, 0, ",", ".");
                                            $v_tanggungan = 0;
                                        } else {
                                            $tanggungan = number_format($val_tang, 0, ",", ".");
                                            $v_tanggungan = $val_tang;
                                        };
                                        //Terbayar & Kurang
                                        $classTrans = new transaksi();
                                        $Terbayar = $classTrans->infoterbayarIf($tb_transaksi, $nis, $jenis_lap);
                                        $terbayar = @(number_format($Terbayar, 0, ".", "."));
                                        $kurang = $v_tanggungan - $Terbayar;
                                        $kurang = @(number_format(($kurang), 0, ".", "."));

                                        $no++;

                                        echo "
                                    <tr>
                                        <td width='5px'>$no</td>
                                        <td align=left>$nama</td>
                                        <td align=left>$nis</td>
                                        <td align=left>$kelas</td>
                                        <td align=right>$tanggungan</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '1', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '2', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '3', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '4', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '5', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '6', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '7', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '8', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '9', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '10', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '11', $nis,  $filterJenis) . "</td>
                                        <td align=right>" . $classLaporan->sumTahap($tb_transaksi, '>=12', $nis,  $filterJenis) . "</td>
                                        <td align=right>$terbayar</td>
                                        <td align=right>$kurang</td>
                                    </tr>";
                                    };
                                    echo "
                                      <tr>
                                          <td colspan='4'>JUMLAH</td>
                                          <td align=right>$sumtanggungan</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '1', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '2', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '3', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '4', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '5', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '6', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '7', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '8', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '9', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '10', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '11',  $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>" . $classLaporan->totalTahap($tb_transaksi, '>=12', $jenjang_lap, $paralel_lap, $filterJenis) . "</td>
                                          <td align=right>$sumterbayar</td>
                                          <td align=right>$sumkurang</td>
                                      </tr>";
                                    ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            </section>
        </div>


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

</body>


<script>
    $(function() {
        $("#example1").DataTable({
            "responsive": true,
            "lengthChange": true,
            "lengthMenu": [
                [10, 50, 100, 500, 1000, -1],
                [10, 50, 100, 500, 1000, "All"]
            ],
            "autoWidth": true,
            "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
        }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        $("#example2").DataTable({
            "responsive": true,
            "lengthChange": true,
            "lengthMenu": [
                [10, 50, 100, 500, 1000, -1],
                [10, 50, 100, 500, 1000, "All"]
            ],
            "autoWidth": true,
            "buttons": ["excel", "pdf", "print"]
        }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)');
        $("#example3").DataTable({
            "responsive": true,
            "lengthChange": true,
            "lengthMenu": [
                [10, 50, 100, 500, 1000, -1],
                [10, 50, 100, 500, 1000, "All"]
            ],
            "autoWidth": true
        });
        $("#example14").DataTable({
            "responsive": true,
            "lengthChange": true,
            "autoWidth": true
        });
        $("#example15").DataTable({
            "responsive": true,
            "lengthChange": true,
            "lengthMenu": [
                [15, 50, 100, 500, 1000, -1],
                [15, 50, 100, 500, 1000, "All"]
            ],
            "autoWidth": true
        });

    });
</script>





</html>