<div class="x_content">

    <table id="datatable" class="table table-bordered">
        <thead>
            <tr>
                <!--<th>Tanggal</th>-->
                <!--<th>id transaksi</th> -->
                <th width="15px">NO.</th>
                <th width="15px">Kode</th>
                <th>keterangan</th>
                <th>Debit</th>
                <th>Kredit</th>
                <th width="110">TOTAL<br>(debit-kredit)</th>
                <th width="100">Cetak laporan<br>per bulan</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $no = 0;
            $count = 1;
            $total_rekap = 0;
            $query = mysqli_query($conn, "SELECT * FROM jenis_transaksi WHERE id_jenis NOT IN (1) order by id_jenis ASC ");


            $ro = 0;



            while ($row = mysqli_fetch_array($query)) {

                $query_rekap = mysqli_query($conn, "SELECT SUM(debit) as jumlah_debit, SUM(kredit) as jumlah_kredit FROM transaksi WHERE id_jenis ='$row[id_jenis]'
                                AND MONTH(tanggal)='$bln' 
                                AND YEAR(tanggal)='$thn'");

                $rekap = mysqli_fetch_array($query_rekap);
                $no++;
            ?>

                <tr style="background: <?php if ($no % 2 == 1) { ?>
                          #defff1;
                          <?php } else { ?>
                            white;
                            <?php } ?>">

                    <!--<td><?php //echo $row['id_transaksi'];
                            ?></td>-->
                    <td><?php echo $no; ?></td>
                    <td><?php echo $row['id_jenis']; ?></td>
                    <td><?php echo $row['nama_jenis']; ?></td>

                    <td><?php echo "Rp." . rupiah($rekap['jumlah_debit']); ?></td>
                    <td><?php echo "Rp." . rupiah($rekap['jumlah_kredit']); ?></td>
                    <td>
                        <?php
                        $total = $rekap['jumlah_debit'] - $rekap['jumlah_kredit'];
                        echo "Rp." . rupiah($total);
                        $total_rekap = $total_rekap + $total;
                        ?>
                    </td>
                    <td><a href="component/com_transaksi/export_pembukuan.php?periode=bln&type=<?php echo $row['id_jenis'] ?>&bln=<?php echo $bln; ?>&thn=<?php echo $thn; ?>" class="btn btn-primary btn-sm"><i class="fa fa-print"></i></a>
                    </td>


                    <?php
                    $count++
                    ?>

                </tr>

            <?php } ?>

            <!-- tambahan kas-->
            <?php

            $count = 1;

            $query = mysqli_query($conn, "SELECT * FROM transaksi WHERE id_jenis='1'
                            AND MONTH(tanggal)='$bln' 
                            AND YEAR(tanggal)='$thn'");



            $ro = 0;



            while ($row = mysqli_fetch_array($query)) {
                $keri = mysqli_query($conn, "SELECT * FROM santri WHERE id_santri='$row[id_santri]'");
                $r = mysqli_fetch_array($keri);

                $no++;
            ?>



            <?php } ?>
            <tr bgcolor="#f6eee0">
                <td colspan="5" align="center"><b>TOTAL</b></td>
                <td><?php echo "Rp." . rupiah($total_rekap); ?></td>
            </tr>



        </tbody>
    </table>
    <a href="component/com_transaksi/export.php?bln=<?php echo $bln; ?>&thn=<?php echo $thn; ?>" class="btn btn-primary btn-sm"><i class="fa fa-print"></i> Cetak</a>
</div>