<?php
/* contoh text */  
// $text = 'Eh, ini adalah pesan text yang akan tercetak di printer...!';     
/* tulis dan buka koneksi ke printer */    
// $printer = printer_open("EPSON L120 Series");  
/* write the text to the print job */  
// printer_write($printer, $text);   
/* close the connection */ 
// printer_close($printer);

// $user_name = "root";
// $password = "";
// $database = "komitedb";
// $host_name = "localhost";
// $connect_db=mysql_connect($host_name, $user_name, $password);
// $find_db=mysql_select_db($database);
// if ($find_db) {
?>

<?php
	// $nama_dokumen='Bukti Transaksi'; 
	// define('_MPDF_PATH','mpdf/');
	// require (_MPDF_PATH."mpdf.php");
	// $mpdf=new mPDF('utf-8', array(190,500),'',5,3,0,0,0,0,''); 
	// ob_start(); 
?>

<?php
session_start ();
include_once "library/inc.connection.php";
include_once "library/inc.library.php";

	# Baca variabel URL
$kodeTransaksi = $_GET['noNota'];
	# Perintah untuk mendapatkan data dari tabel transaksi
$trSql = "SELECT transaksi.*, user.*, transaksi_item.*, siswa.nama_siswa  FROM transaksi, user, siswa, transaksi_item 
WHERE transaksi.no_transaksi='$kodeTransaksi' AND transaksi.userid=user.userid AND transaksi_item.no_transaksi='$kodeTransaksi' 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'];

?>

<html>
<table border="0">
	<tr>
		<td colspan="3" align="center" style="font-size:14px; color:red;"><b>KOMITE MADRASAH ALIYAH NEGERI 4 BOGOR</td>
		</tr>
		
		<tr>
			<td colspan="3" align="center" style="padding-bottom:0px; font-size:12px;">Jl. Stasiun Cigombong Kp. Cijambu Desa Cisalada Telp.0251-8222509</td>
		</tr>
		<tr>
			<td colspan="3" align="center" style="padding-bottom:2px; font-size:15px;"><hr></td>
		</tr>
		<tr>
			<td colspan="3" align="center" style="padding-bottom:2px; font-size:12px;">BUKTI TRANSAKSI</td>
		</tr>	

		<tr>
			<td width="250" style="font-size:12px;">Nomor</td>
			<td width="30" style="font-size:12px;">:</td>
			<td width="550" style="font-size:12px;"><?php echo ($A); ?></td>
		</tr>
		<tr>
			<td style="font-size:12px;">Tanggal</td>
			<td style="font-size:12px;">:</td>
			<td style="font-size:12px;"><?php echo IndonesiaTgl($tgl); ?></td>
		</tr>
		<tr>
			<td style="font-size:12px;">NIS</td>
			<td style="font-size:12px;">:</td>
			<td style="font-size:12px;"><?php echo ($C); ?></td>
		</tr>
		<tr>
			<td style="font-size:12px;">Nama</td>
			<td style="font-size:12px;">:</td>
			<td style="font-size:12px;"><?php echo ($B); ?></td>
		</tr>
		<tr>
			<td colspan="3" style="font-size:12px;padding-top:5px;">Pembayaran </td>
		</tr>
		<tr>
			<td colspan="3" >
				<table border="0" valign="top">
					<?php

					# Menampilkan List untuk Nomor Transaksi Terpilih
					$listSql = "SELECT bulan.keterangan, transaksi_item.*	FROM transaksi_item, bulan 
					WHERE transaksi_item.no_transaksi='$kodeTransaksi' 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 align="center" style="font-size:12px;"><?php echo $nomor; ?>.</td>
							<td align="left" width="600" style="font-size:12px;"> <?php echo $listRow['keterangan']; ?></td>
							<td align="right" width="200" style="font-size:12px;"><?php echo format_angka ($listRow['banyak']); ?></td>	
						</tr>

						<?php } ?>

						<tr>
							<td colspan="2" align="right" style="font-size:12px;">Jumlah :</td>
							<td align="right" style="font-size:12px;"> <?php echo format_angka($totalBayar); ?></td>
						</tr>
					</table>
				</td>
			</tr>

			<tr>
				<td colspan="3" align="center" style="padding-bottom:20px; font-size:12px;">Penerima</td>
			</tr>
			<tr>
				<td colspan="3" align="center" style="font-size:12px;"><?php echo($D); ?></td>
			</tr>
			<tr>
				<td colspan="3" align="center" style="font-size:12px;">--------- terima kasih ---------</td>
			</tr>
				<!-- <tr>
					<td style="padding-bottom:35px;">...</td>
				</tr> -->

			</table>
			</html>



			<?php
				// $html = ob_get_contents(); 
				// ob_end_clean();
				// $mpdf->WriteHTML(utf8_encode($html));
				// $mpdf->Output($nama_dokumen."-".$A."-".$C."-".$B.".pdf" ,'I');
				// exit;
			?>
			<?php
				// mysql_close($connect_db);
			// }else {
				// echo "Database Tidak Ada";
				// mysql_close($connect_db);
			// }
			?>
			<script>
				window.print();
			</script>