<style>
    .close:focus {
        outline: none;
    }

    .top-right {
        top: 20px;
        right: 20px;
    }

    .toast {
        border: 1px solid coral
    }
</style>
<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-clipboard-check"></span> Rekam Transaksi </b>
                        </div>

                        <!-- /.card-header -->
                        <div class="card-body my-0 mx-4">


                            <table id="example15" class="table table-bordered table-striped table-hover table-sm mb-4">
                                <thead>
                                    <tr>
                                        <th width="10">No</th>
                                        <th>NIS</th>
                                        <th>Nama User</th>
                                        <th>L/P</th>
                                        <th>Telpon</th>
                                        <th>Kelas</th>
                                        <th>Tanggungan</th>
                                        <th>Terbayar</th>
                                        <th>Kurang</th>
                                        <th>Pilih</th>

                                    </tr>
                                </thead>
                                <tbody>

                                    <?php

                                    $datatabel = new cekTabel;
                                    $cekTabel = $datatabel->cek($cekDB, $tb_siswa);

                                    if ($cekTabel > 0) {

                                        $crud = new crudData();
                                        $showSiswa = $crud->showTable($tb_siswa . " order by jenjang asc, paralel asc, nama asc");
                                        $no = 0;
                                        while ($data = $showSiswa->fetch(PDO::FETCH_OBJ)) {

                                            $classTanggungan = new listTanggungan();
                                            $val_tang = $classTanggungan->tanggunganSiswa($tb_siswa, 'id', $data->id);
                                            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->infoterbayartotal($tb_transaksi, $data->nis);
                                            $terbayar = @(number_format($Terbayar, 0, ".", "."));
                                            $kurang = $v_tanggungan - $Terbayar;
                                            $kurang = @(number_format(($kurang), 0, ".", "."));


                                            $link = new linkpage;
                                            $no++;
                                            echo "
                                                    <tr>
                                                     
                                                    <td>$no</td>
                                                        <td>$data->nis</td>
                                                        <td>$data->nama</td>
                                                        <td>$data->kelamin</td>
                                                        <td>$data->hp</td>
                                                        <td>$data->jenjang - $data->paralel</td>
                                                        <td align=left>$tanggungan</td>
                                                        <td align=left>$terbayar</td>
                                                        <td align=left>$kurang</td>
                                                        <td width='50px' align='center'>
                                                        <a " . $link->pageID($data->id, 'transaksi/transaksi_create') . " class='badge badge-primary  px-1 py-1 d-inline'> <i class='bi bi-pencil-square'></i> PILIH</a>
                                                        </td>
                                                    </tr>";
                                        }
                                    } else {
                                        echo "<tr>
                                                <td width='5px' colspan='7'>
                                                    TIDAK ADA TABEL / DATA TAHUN $tahun
                                                </td>
                                            </tr>";
                                    }


                                    ?>

                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--/. container-fluid -->
        </section>
        <!-- /.content -->
    </div>
</div>