<?php
date_default_timezone_set('Asia/Jakarta');
$tanggal = mktime(date("m"), date("d"), date("Y"));
$tglsekarang = date("d-m-Y", $tanggal);

if (isset($_GET['i4'])) {
    $id_setor = $_GET['i4'];
} else {
    $id_setor = "";
};


?>
<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="card mx-4 mt-3">

                    <div class="timeline-header bg-secondary  py-1 pl-1">
                        <b class="text-light judul"><span class="bi bi-box-arrow-in-up-right"></span> List Transaksi</b>
                    </div>

                    <div class="card-body mx-4">
                        <div class="row mt-3">

                            <div class="col-md-9">

                                <a <?php echo $link->pageID($id_setor, 'setor/setor_addTr'); ?> class="btn btn-primary btn-xs float-left mr-1"><i class="bi-file-earmark-plus"></i> <b>TAMBAH TRANSAKSI</b></a>

                            </div>
                        </div>
                    </div>
                    <div class="card-body mx-4">
                        <label>
                            <h6><b class="text-primary">DATA TRANSAKSI ID SETOR : <?php echo strtoupper($id_setor); ?></b></h6>
                        </label>
                        <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>Metode</th>
                                        <th>Penerima</th>
                                        <th>Catatan</th>
                                        <th>Info</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $class = new setor();
                                    $show = $class->list_TRsetor($tb_transaksi, $id_setor, $tahun, $tb_siswa, $tahun1, $tahun2)
                                    ?>
                                </tbody>
                            </table>
                            <div class="div d-inline">
                                <a <?php echo $link->page('setor/setor_read_create'); ?> class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-chevron-double-left"></i> KEMBALI</a>
                                <button type="submit" name="submitDel" 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>
</div>

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

<?php
if (isset($_POST['submitDel']) && isset($_POST['id_tr'])) {
    foreach ($_POST['id_tr'] as $id) {
        $class = new crudData();
        $dataarray = [
            'setor' => '',
            'id_setor' => ''
        ];
        $update = $class->updateData($tb_transaksi, $dataarray, ['no', ' = ', $id]);
        //Update
        // $delete = $user_admin->deleteData('tb_paralel', 'no', $id);
    };

    $direct = new toast();
    echo  $direct->redirectID('toast', 'delete', $id_setor, 'setor/setor_list');
};
