<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-people"></span> Daftar Siswa </b>
                        </div>

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

                            <form action="" method="post">
                                <table id="example15" class="table table-bordered table-striped table-hover table-sm  mb-4">
                                    <thead>
                                        <tr>
                                            <th>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
                                        $cekTabel = new cekTabel;
                                        $cekTabel = $cekTabel->cek($cekDB,  $tb_siswa);

                                        if ($cekTabel > 0) {

                                            $crud = new crudData();
                                            $showSiswa = $crud->showTable($tb_siswa);
                                            $no = 0;
                                            while ($data = $showSiswa->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->tanggunganSiswa($tb_siswa, 'id', $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, $nis);
                                                $terbayar = @(number_format($Terbayar, 0, ".", "."));
                                                $kurang = $v_tanggungan - $Terbayar;
                                                $kurang = @(number_format(($kurang), 0, ".", "."));
                                                // $linkID = new linkpageID;
                                                $link = new linkpage;
                                                $linkpost = new linkpost;
                                                $no++;
                                                echo "<a " . $link->pageID($data->nis, 'transaksi/transaksi_create') . "><button class='btn btn-sm'>
                                                    <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'>
                                                        " . $linkpost->IDSiswa($data->id, 'laporan/siswa/print_preview', $id, $tahun, '', 'search', 'primary') . "
                                                       </td>
                                                    </tr></button></a>";
                                            }
                                        } else {
                                            echo "<tr>
                                                <td width='5px' colspan='7'>
                                                    TIDAK ADA TABEL / DATA TAHUN $tahun
                                                </td>
                                            </tr>";
                                        }


                                        ?>

                                    </tbody>
                                </table>


                            </form>


                            <?php
                            //  include "layout/toastr.php";
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--/. container-fluid -->
        </section>
        <!-- /.content -->
    </div>
</div>