<?php
session_start();
ob_start();
error_reporting(1);
include '../../config/conn.php';
include '../../lib/function.php'; ?>

<style>
    table,
    td,
    th {
        border: 0.1px solid black;
    }

    #table1 {
        border-collapse: separate;
        border-spacing: 0px;
    }

    #title {
        font-size: xx-large;
    }
</style>

<img src="../../build/images/bglap_ts.jpg" height="90" alt="Caption 1" />

<?php $query = mysqli_query($conn, "SELECT * FROM tarik_serentak WHERE id_tarik='$_GET[id]'");
$r = mysqli_fetch_array($query);

?>


<span>ID Tarik : <?php echo $_GET['id']; ?></span><br>
<span>Jumlah tarik : <?php echo rupiah($r['jumlah']); ?></span><br>
<span>Tanggal : <?php echo tgl($r['tanggal']); ?></span><br>
<span>Penarik(Id) : <?php echo namauser($r['user']); ?>(<?php echo $r['user']; ?>)</span><br>
<span>Keterangan : <?php echo $r['keterangan']; ?></span>
<table id="table1" border="0.3px" cellspacing="0">
    <thead>
        <tr align="center">
            <th>No</th>
            <th style="width: 130px;">ID Santri</th>
            <th style="width: 250px;">Nama</th>
            <th style="width: 100px;">Jumlah</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $no = 0;

        $hariini = date('Y-m-d');
        $data = $_GET['id'];
        $query = mysqli_query($conn, "SELECT * FROM transaksi_ewallet WHERE keterangan like '%$data%' ORDER BY id_transaksi");

        while ($row = mysqli_fetch_array($query)) {
            $no++;
        ?>
            <tr>
                <td><?php echo $no; ?></td>
                <td><?php echo $row['rekening']; ?></td>

                <td><?php echo nama($row['rekening']); ?></td>
                <td align="right"><?php echo rupiah($row['kredit']); ?></td>

            </tr>

        <?php } ?>
    <tfoot>
        <tr>
            <th colspan="3" style="font-weight: bolder; text-align:center">TOTAL</th>
            <th align="right"><?php
                                echo rupiah(jumlahsantri($_GET['id']) * $r['jumlah']); ?></th>
        </tr>
    </tfoot>
    </tbody>
</table>



<?php
$filename = "data TS-" . $_GET['id'] . ".pdf"; //ubah untuk menentukan nama file pdf yang dihasilkan nantinya
//==========================================================================================================
//Copy dan paste langsung script dibawah ini,untuk mengetahui lebih jelas tentang fungsinya silahkan baca-baca tutorial tentang HTML2PDF
//==========================================================================================================
$content = ob_get_clean();
$content = '<page style="font-family: freeserif">' . nl2br($content) . '</page>';
require_once('../../build/html2pdf/html2pdf.class.php');
try {
    $html2pdf = new HTML2PDF('P', 'A4', 'en', false, 'ISO-8859-15', array(30, 0, 20, 0));
    $html2pdf->setDefaultFont('Arial');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output($filename);
} catch (HTML2PDF_exception $e) {
    echo $e;
}
?>