<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> Monitoring Data Transfer </b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body my-4 mx-4">
                            <a <?php echo $link->page('transaksi/kuitansi_read'); ?> class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-printer"></i> CETAK ULANG KUITANSI</a>

                            <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>Record</th>
                                            <th>Jumlah</th>
                                            <th>Bukti</th>
                                            <th>ID</th>
                                            <th>Proses Terima</th>
                                            <th>Tolak Konfirmasi</th>

                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php
                                        //Filter by Level Operator

                                        $crud = new crudData();
                                        $showList = $crud->showTable($payment_list . " where order by status asc, created_at desc");
                                        while ($data = $showList->fetch(PDO::FETCH_OBJ)) {
                                            $format = new format();
                                            $modal = new modal();

                                            $nis = $data->nis;


                                            $link = new linkpage;

                                            //cek data siswa
                                            $count_siswa = $crud->countData($tb_siswa, " where nis='$nis'");
                                            if ($count_siswa > 0) {
                                                $bg_tr = "";
                                            } else {
                                                $bg_tr = "bg-danger text-light text-bold";
                                            };

                                            $bukti = $modal->modalkonfirmTransfer('./view/transfer/bukti', 'verifikasi', $data->payment_id, $tahun, 'lg', 'grey', 'BUKTI TRANSFER', "<strong class='text-secondary'>BUKTI TRANSFER</strong>", 'receipt-cutoff text-light', '<b class=text-light>BUKTI TRANSFER</b>', 'secondary', 'BUKTI TRANSFER');
                                            $terima = $modal->modalkonfirmTransfer('./view/transfer/terima', 'terima', $data->payment_id, $tahun, 'md', 'grey', 'TERIMA', "<strong class='text-secondary'>PROSES TERIMA</strong>", 'check2-circle text-light', '<b class=text-light>TERIMA KONFIRMASI</b>', 'success', 'TERIMA KONFIRMASI');
                                            $tolak = $modal->modalkonfirmTransfer('./view/transfer/tolak', 'tolak', $data->payment_id, $tahun, 'md', 'grey', 'TOLAK', "<strong class='text-secondary'>TOLAK KONFIRMASI</strong>", 'check2-circle text-light', '<b class=text-light>TOLAK KONFIRMASI</b>', 'danger', 'TOLAK KONFIRMASI');

                                            $count1 = $crud->countData($tb_transaksi, " where id_tr='$data->payment_id'");
                                            $count2 = $crud->countData('payment_list_detail', " where id_tr='$data->payment_id'");
                                            $count = $count1 + $count2;

                                            echo "
                                                    <tr class='$bg_tr'>
                                                        <td width='5px'></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>$count</td>
                                                     
                                                        <td align=right>" . $format->ribuan($data->jumlah) . "</td>
                                                        <td align=left><i style='font-size:8px'></i>$bukti</td>                                                       
                                                        <td align=left>$data->payment_id</td>
                                                        <td align=left>$terima</td>
                                                        <td align=left>$tolak</td>
                                                       
                                                    </tr>";
                                        }

                                        ?>

                                    </tbody>
                                </table>


                        </div>
                    </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

$direct = new toast();
$clsTime = new time;
$clsIP = new ip;
$clsCrud = new crudData;

$waktu = $clsTime->getTime();
$ip = $clsIP->getIP();
$browser = $clsIP->getBrowser();
$user = $clsCrud->getValue('user', " where username='$username'", 'id');

if (isset($_POST['submit']) && isset($_POST['transaksi_delete'])) {
    foreach ($_POST['transaksi_delete'] as $id) {
        //Insert ke DB Transaksi

        $tanggal = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'tanggal');
        $nis = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'nis');
        $nama = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'nama');
        $kelamin = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'kelamin');
        $jenjang = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'jenjang');
        $paralel = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'paralel');
        $jenis = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'jenis');
        $tahap = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'tahap');
        $jumlah = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'jumlah');
        $random = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'random');
        $penerima = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'penerima');
        $setor = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'setor');
        $id_setor = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'id_setor');
        $metode = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'metode');
        $catatan = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'catatan');
        $time = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'time');
        $ip = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'ip');
        $browser = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'browser');
        $id_tr = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'id_tr');
        $id = $clsCrud->getValue($tb_transaksi, "where id='$id'", 'id');

        $alasan = $_POST['alasan'];

        $dataarray = [
            'tanggal' => $tanggal,
            'nis' => $nis,
            'nama' => $nama,
            'kelamin' => $kelamin,
            'jenjang' => $jenjang,
            'paralel' => $paralel,
            'jenis' => $jenis,
            'tahap' => $tahap,
            'jumlah' => $jumlah,
            'random' => $random,
            'penerima' => $penerima,
            'setor' => $setor,
            'id_setor' => $id_setor,
            'metode' => $metode,
            'catatan' => $catatan,
            'time' => $time,
            'ip' => $ip,
            'browser' => $browser,
            'id_tr' => $id_tr,
            'id' => $id,
            'deleted_at' => $waktu,
            'deleted_by' => $user,
            'alasan' => $alasan,

        ];
        $clsCrud->insertData('deleted_transaksi', $dataarray);
        $delete = $clsCrud->deleteData($tb_transaksi,  'id',  $id);
    }
    echo  $direct->redirect('toast', 'delete', 'transaksi/transaksi_read');
} else {
    echo "";
};
