<html>
<?php
include "../../config/conn.php";
include "../../config/rupiah.php";
$hp1 = mysqli_query($conn, "SELECT * FROM pengaturan WHERE id_pengaturan=1");
$hp = mysqli_fetch_array($hp1); ?>

<head>
    <title>Faktur Pembayaran</title>
    <style>
        #tabel {
            font-size: 15px;
            border-collapse: collapse;
        }

        #tabel td {
            padding-left: 5px;
            border: 1px solid black;
        }
    </style>
</head>

<body style="margin-left: 20px ;" style='font-family:tahoma;' onload="javascript:">
    <center>
        <table style='width:550px; font-family:calibri; border-collapse: collapse;' border='0'>
            <td width='100%' align='left' style='font-size:large padding-right:80px; vertical-align:top'>
                <H2 style="font-size:21pt;">PONDOK TAHFIDZ MODERN AL-IMAM</H2>
                <div style="margin-top: -22px; font-size:14pt;">Desa Tiru Kidul, Kec. Gurah, Kab. Kediri <br>
                    HP : <?php echo $hp['telephone']; ?></div>
            </td>

        </table><br>


    </center>

    <?php


    $query = mysqli_query($conn, "SELECT * FROM transaksi WHERE id_transaksi='$_GET[id_tran]' order by tanggal ASC ");



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

        $b1 = mysqli_query($conn, "SELECT * FROM jenis_donatur WHERE id='$row[jenis_donatur]'");
        $b = mysqli_fetch_array($b1);

        //nama admin
        $adm1 = mysqli_query($conn, "SELECT * FROM pegawai WHERE id_pegawai='$row[id_pegawai]'");
        $adm = mysqli_fetch_array($adm1); ?>

        <table style='width:550px; font-size:18pt; font-family:calibri; border-collapse: collapse;' border='0'>
            <td width='100%' align='left' style='padding-right:80px; vertical-align:top'>
                <?php echo  date('d-M-Y', strtotime($row['tanggal'])); ?> <br>
                ID TRAN. : <?php echo $row['id_transaksi']; ?> <br>
                -------------------------------------------------------------- <br>
                <?php
                if ($row['id_donatur'] == "") { ?>
                    ID Donatur : -</br>
                    Nama Donatur: <?php echo $row['nama_donatur_tidak_tetap'];
                                } else {
                                    ?>
                    ID Donatur : <?php echo $row['id_donatur']; ?></br>
                    Nama Donatur: <?php echo $r['nama_donatur'];
                                }

                                $jns1 = mysqli_query($conn, "SELECT * FROM jenis_transaksi WHERE id_jenis='$row[id_jenis]'");
                                $jns = mysqli_fetch_array($jns1);

                                /* bagian footer */
                                $jns1 = mysqli_query($conn, "SELECT * FROM jenis_transaksi WHERE id_jenis='$row[id_jenis]'");
                                $jns = mysqli_fetch_array($jns1);

                                $jendon1 = mysqli_query($conn, "SELECT * FROM jenis_donatur WHERE id='$row[jenis_donatur]'");
                                $jendon = mysqli_fetch_array($jendon1); ?> <br>


                <?php
                echo "Jenis Pembayaran : $jns[nama_jenis]<br>";
                echo "$jendon[nama_jenis] "; ?><br>
                -------------------------------------------------------------- <br>


                <?php

                $rp = rupiah($row['debit']);
                echo "<b>JUMLAH BAYAR : Rp.$rp </b><br>";
                if (!isset($row['spp_bulan'])) {
                    $ket = "";
                } else {
                    $ket = "Bulan $row[spp_bulan] , Tahun $row[spp_tahun]";
                }
                ?>

                Keterangan : <?php echo $row['keterangan']; ?> <br>
                <?php echo $ket; ?> <br>
                -------------------------------------------------------------- <br>
                <div style="font-size: 13pt;"> User : <?php echo $adm['nama']; ?> <br>
                    Tgl Cetak <?php echo date('d/m/y H:i'); ?></div>
            </td>

        </table>
    <?php
        $id_san = $row['id_santri'];
    }
    ?>


</body>


<script type="text/javascript">
    window.print();
    window.onafterprint = window.close;
</script>

</html>