<!-- Printing -->
<link rel="stylesheet" href="css/printing.css">

<?php
include("sess_check.php");
include("dist/function/format_tanggal.php");
include("dist/function/format_rupiah.php");
if ($_GET) {
	$kode = $_GET['code'];
	$sql = "SELECT siswa.*, kelas.*, tingkatan.*, jenis_pembayaran.*, pos.* FROM siswa, kelas, tingkatan, jenis_pembayaran, pos
			WHERE siswa.id_kelas=kelas.id_kelas AND kelas.id_tingkatan=tingkatan.id_tingkatan AND jenis_pembayaran.id_tingkatan=tingkatan.id_tingkatan
			AND jenis_pembayaran.id_pos=pos.id_pos AND siswa.nis='" . $_GET['code'] . "'";
	$query = mysqli_query($conn, $sql);
	$result = mysqli_fetch_array($query);
} else {
	echo "Nomor Transaksi Tidak Terbaca";
	exit;
}
?>
<html>

<head>
</head>

<body>
	<div id="section-to-print">
		<section id="header-kop">
			<div class="container-fluid">
				<table class="table table-borderless">
					<tbody>
						<tr>
							<td class="text-left" width="20%">
								<img src="foto/MAN1PASURUAN.png" alt="logo-dkm" width="70" />
							</td>
							<td class="text-center" width="60%">
								<b>MADRASAH ALIYAH NEGERI 1 PASURUAN</b> <br>
								Jl. Balai Desa Gelanggang 3A<br>
								Telp: (0343) 742690<br>
							<td class="text-right" width="20%">
							</td>
						</tr>
					</tbody>
				</table>
				<hr class="line-top" />
			</div>
		</section>

		<section id="body-of-report">
			<div class="container-fluid">
				<h4 class="text-center">Detail Pembayaran</h4>
				<br />
				<table width="100%">
					<tr>
						<td width="20%"><b>Nis</b></td>
						<td width="2%"><b>:</b></td>
						<td width="78%"><?php echo $result['nis']; ?></td>
					</tr>

					<tr>
						<td width="20%"><b>Nama Lengkap</b></td>
						<td width="2%"><b>:</b></td>
						<td width="78%"><?php echo $result['nama_lengkap']; ?></td>
					</tr>
					<tr>
						<td width="20%"><b>Kelas</b></td>
						<td width="2%"><b>:</b></td>
						<td width="78%"><?php echo $result['tingkatan']; ?></td>
					</tr>
				</table>
				</br>
				<table class="table table-bordered table-keuangan">
					<thead>
						<tr>
							<th width="1%">No</th>
							<th width="10%">Jenis Pembayaran</th>
							<th width="5%">Jumlah</th>
							<th width="10%">Harga Satuan</th>
							<th width="10%">Total</th>
						</tr>
					</thead>
					<tbody>
						<?php
						$i = 1;
						$grand = 0;
						$sqltmp = "SELECT jenis_pembayaran.*, pos.* FROM jenis_pembayaran, pos WHERE jenis_pembayaran.id_pos=pos.id_pos
								AND jenis_pembayaran.id_jenis='$kode' ORDER BY pos.nama_pos ASC";
						$querytmp = mysqli_query($conn, $sqltmp);

						while ($data = mysqli_fetch_array($querytmp)) {
							$ttl = $data['jml'] * $data['harga'];
							echo '<tr>';
							echo '<td class="text-center">' . $i . '</td>';
							echo '<td>' . $data['jenis_pembayaran'] . '</td>';
							echo '<td>' . $data['jml'] . '</td>';
							echo '<td>' . format_rupiah($data['tagihan']) . '</td>';
							echo '<td>' . format_rupiah($ttl) . '</td>';
							echo '</tr>';
							$i++;
							$grand += $ttl;
						}
						?>
					</tbody>
					<tfoot>
						<tr>
							<th colspan="4" class="text-center">Total </th>
							<th class="text-right"><?php echo format_rupiah($grand); ?></th>
						</tr>
					</tfoot>
				</table>
				<br />
			</div><!-- /.container -->
		</section>
		<div class="modal-footer">
			<a href="trx_cetak.php?id=<?php echo $kode; ?>" target="_blank" class="btn btn-warning">Cetak</a>
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
		</div>
	</div>

</body>

</html>