<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)) {
        if ($row['id_jenis'] == "11" or $row['id_jenis'] == "12" or $row['id_jenis'] == "18") {
            //rumahtahfidz
            $keri = mysqli_query($conn, "SELECT * FROM santri_rt WHERE id_santri='$row[id_santri]'");
            $r = mysqli_fetch_array($keri);

            $kelas1 = mysqli_query($conn, "SELECT nama_jenis FROM jenis_rt WHERE id='$r[jenis_rt]'");
            $kls = mysqli_fetch_array($kelas1);
        } else {
            $keri = mysqli_query($conn, "SELECT * FROM santri WHERE id_santri='$row[id_santri]'");
            $r = mysqli_fetch_array($keri);
        }

        $b1 = mysqli_query($conn, "SELECT * FROM bulan WHERE id_bulan='$row[spp_bulan]'");
        $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>
                ID Santri : <?php echo $row['id_santri']; ?></br>
                Nama : <?php echo $r['nama'];

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

                <?php if ($row['id_jenis'] == "5") {
                    echo "Jenis Pembayaran : $jns[nama_jenis]<br>";
                    echo "Bulan/Tahun : $b[nama_bulan] $row[spp_tahun] ";
                } elseif ($row['id_jenis'] == "14") {
                    echo "Jenis Pembayaran : Daftar awal masuk<br>";
                } elseif ($row['id_jenis'] == "17") {
                    echo "Jenis Pembayaran : Daftar Ulang<br>";
                    echo "Tahun : $row[dut_tahun] ";
                } elseif ($row['id_jenis'] == "18") {
                    echo "Jenis Pembayaran : Dana awal masuk Rumah Tahfidz Pagi<br>";
                } elseif ($row['id_jenis'] == "11" or $row['id_jenis'] == "12") {
                    echo "Jenis Pembayaran : $jns[nama_jenis] | $kls[nama_jenis]<br>";
                    echo "Bulan/Tahun : $b[nama_bulan] $row[spp_tahun] ";
                } ?><br>
                -------------------------------------------------------------- <br>
                <?php $rp = rupiah($row['debit']); ?>
                <b> Jumlah Bayar : Rp.<?php echo $rp; ?></b> <br>
                Keterangan : <?php echo $row['keterangan']; ?> <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>