<?php
# Baca variabel URL
$kode = $_GET['Kode'];
$trSql = "SELECT transaksi.*, user.*, transaksi_item.*, siswa.nama_siswa  FROM transaksi, user, siswa, transaksi_item 
WHERE transaksi.no_transaksi='$kode' AND transaksi.userid=user.userid AND transaksi_item.no_transaksi='$kode' AND transaksi_item.nis=siswa.nis ";
$trQry = mysql_query($trSql, $koneksidb)  or die ("Query penjualan salah : ".mysql_error());
$trRow = mysql_fetch_array($trQry);	
$A	=	$trRow['no_transaksi'];
$B	=	$trRow['nama_siswa'];
$C	=	$trRow['nis'];
$D  =	$trRow['nama'];
$tgl=	$trRow['tgl_transaksi'];
?>

<div class="col-lg-12 mt-5">
	<div class="card">
		<div class="card-body">
			<div class="invoice-area">
				<div class="invoice-head">
					<div class="row">
						<div class="iv-center col-12 text-md-center">
							<span><h3 align="center">KOMITE <br> MAN 4 BOGOR</h3></span>
						</div>
						<div class="iv-center col-12 text-md-center">
							<span><p align="center">Jl. Stasiun Cigombong Kp. Cijambu Desa Cisalada Telp.0251-8222509</p></span>
						</div>
					</div>
				</div>
				<div class="invoice-head">
					<div class="row">
						<div class="iv-left col-6">
							<span>BUKTI TRANSAKSI</span>
						</div>
						<div class="iv-right col-6 text-md-right">
							<span><?php echo ($A); ?></span>
						</div>
					</div>
				</div>
				<div class="row align-items-center">
					<div class="col-md-6">
						<div class="invoice-address">
							<h3><?php echo ($B); ?></h3>
							<h5><?php echo ($C); ?></h5>
						</div>
					</div>
					<div class="col-md-6 text-md-right">
						<ul class="invoice-date">
							<li>Tanggal Transaksi</li>
							<li><?php echo IndonesiaTgl($tgl); ?></li>
						</ul>
					</div>
				</div>
				<br>
				<div class="invoice-table table-responsive mt-0">
					<table class="table table-bordered table-hover text-right">
						<thead>
							<tr class="text-capitalize">
								<th class="text-center" style="width: 5%;">No</th>
								<th class="text-left" style="width: 45%; min-width: 130px;">Pembayaran
									<th style="min-width: 100px">Jumlah</th>
								</tr>
							</thead>
							<tbody>
								<?php

					# Menampilkan List untuk Nomor Transaksi Terpilih
								$listSql = "SELECT bulan.keterangan, transaksi_item.*	FROM transaksi_item, bulan 
								WHERE transaksi_item.no_transaksi='$kode' AND transaksi_item.kode_bayar=bulan.kode ";
								$listQry = mysql_query($listSql, $koneksidb)  or die ("Query list barang salah : ".mysql_error());
								$nomor  = 0; $totalBayar = 0;
								while ($listRow = mysql_fetch_array($listQry)) 
								{

									$totalBayar = $totalBayar + intval($listRow['banyak']);

									$nomor++;
									?>
									<tr>
										<td class="text-center"><?php echo $nomor; ?></td>
										<td class="text-left"><?php echo $listRow['keterangan']; ?></td>
										<td><?php echo format_angka ($listRow['banyak']); ?></td>
									</tr>
									<?php } ?>
								</tbody>
								<tfoot>
									<tr>
										<td colspan="2">Total Pembayaran</td>
										<td><?php echo format_angka($totalBayar); ?></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
					<div class="invoice-head">
						<div class="row align-items-center">
							<div class="col-md-12 text-md-center">
								<ul class="invoice-date">
									<li align="center">Penerima</li>
									<br><br>
									<li  align="center"><?php echo($D); ?></li>
								</ul>
							</div>
						</div>
					</div>

					<div class="invoice-buttons text-right">
						<a href="../cetak.php?noNota=<?php echo $kode; ?>" target="_blank" class="invoice-btn col-12" style="text-align: center;">Cetak Bukti Transaksi</a>
					</div>
				</div>
			</div>
		</div>