<div class="content-wrapper">

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

    <div class="container col-12 mb-4 pb-5">
        <div class="row">
            <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-person-badge"></span> Data Pembayaran</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body my-4 mx-4">
                            <form action="" method="post">
                                <table id="example3" class="table table-bordered table-striped table-hover table-sm mb-4">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" class="small check_all"></th>
                                            <th>Tanggal</th>
                                            <th>Nama</th>
                                            <th>NIS</th>
                                            <th>Kelas</th>
                                            <th>Kode : Jenis Pembayaran</th>
                                            <th>Periode</th>
                                            <th>Jumlah</th>

                                            <th>Catatan</th>
                                            <th>Info</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php
                                        $class = new crudData();
                                        $showList = $class->showTable($tb_transaksi);
                                        while ($data = $showList->fetch(PDO::FETCH_OBJ)) {
                                            $format = new format();
                                            if ($data->setor == "Ya") {
                                                $setor = "Disetor";
                                            } else {
                                                $setor = "--";
                                            };
                                            $nis = $data->nis;
                                            $tahap = $data->tahap;
                                            //nama Bayar
                                            $classNB = new namaBayar();
                                            $ceknamaBayar = $classNB->ceknamaBayar($tahun, $data->jenis, $data->jenjang);

                                            //startAt
                                            $classTr = new transaksi();
                                            $startAt = $classTr->startAt($tb_siswa, $nis);
                                            $cekbulan = $classTr->cekPeriode($startAt, $tahap, $tahun1, $tahun2);

                                            //nama Bayar
                                            $classNB = new namaBayar();
                                            $ceknamaBayar = $classNB->ceknamaBayar($tahun, $data->jenis, $data->jenjang);

                                            $showJenis = $classNB->shownamaBayar($tahun, $data->jenis, $data->jenjang);
                                            $datajenis = $showJenis->fetch(PDO::FETCH_OBJ);
                                            $field_tang = 'tang_' . $datajenis->kode;
                                            $setbulanan = $datajenis->bulanan; //Cek Apakah Bulanan

                                            if ($setbulanan == "Tidak") {
                                                $periode = "Tahap " . $tahap;
                                            } else {
                                                $periode = $cekbulan;
                                            };

                                            //Proses Setor
                                            $clsSetor = new setor;
                                            $statusSetor = $clsSetor->statusSetor($data->setor);

                                            $link = new linkpage;

                                            echo "
                                                    <tr>
                                                        <td width='5px'>
                                                            <input type='checkbox' class='d-inline small chk_boxes1' name='id_trans[]' value='" . $data->no . "'> 
                                                        </td>
                                                        <td align=center>" . $format->dateToIndo($data->tanggal) . "</td>
                                                        <td align=left>$data->nama</td>
                                                        <td align=center>$nis</td>
                                                        <td align=center>$data->jenjang - $data->paralel</td>
                                                        <td align=left>$data->jenis : $ceknamaBayar</td>
                                                        <td align=left>$periode</td>
                                                        <td align=right>" . $format->ribuan($data->jumlah) . "</td>
                                                        <td align=left><i style='font-size:8px'>$data->catatan</i></td>
                                                        <td width='50px' align='center'>
                                                        " . $modal->modalTabunganTr('./view/transaksi/transaksi_view', 'viewTr', $data->id . $tahun, 'xl', 'default', 'DETAIL TRANSAKSI', "<strong class='bi bi-search text-secondary'> DETAIL TRANSAKSI</strong>", 'text-light', '<b class=text-light>DETAIL</b>', 'primary', 'DETAIL') . "
                                                         </td>
                                                    </tr>";
                                        }

                                        ?>

                                    </tbody>
                                </table>
                                <div class="div d-inline">
                                    <a <?php echo $link->page('seting/userAdmin/user_create'); ?> class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-printer"></i> CETAK ULANG</a>
                                    <button type="submit" name="submit" class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-trash"></i> HAPUS</button>

                                </div>

                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--/. container-fluid -->
        </section>
        <!-- /.content -->
    </div>
</div>
<!-- /.content-wrapper -->
<script type="text/javascript">
    $(function() {
        $('.check_all').click(function() {
            $('.chk_boxes1').prop('checked', this.checked);
        });
    });
</script>

<?php
if (isset($_POST['submit'])) {
    foreach ($_POST['id_trans'] as $id) {
        $class = new crudData();
        $delete = $class->deleteData($tb_transaksi, 'no', $id);
    };

    $direct = new toast();
    echo  $direct->redirect('toast', 'delete', 'transaksi/transaksi_read');
} else {
    echo '';
}



?>