<?php 
$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

// Melakukan Pengaturan dan Pemanggilan Script PDF dari Script mPDF
$nama_dokumen='PDF With MPDF'; 
define('_MPDF_PATH','mpdf/');
require (_MPDF_PATH."mpdf.php");
$mpdf=new mPDF('utf-8', 'A4'); 

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
	$jualSql = "SELECT transaksi.*, user.*, transaksi_item.*, siswa.nama_siswa  FROM transaksi, user, siswa, transaksi_item 
				WHERE transaksi.userid=user.userid AND transaksi_item.no_transaksi='$kodeTransaksi' AND transaksi_item.nis=siswa.nis ";
	$jualQry = mysql_query($jualSql, $koneksidb)  or die ("Query penjualan salah : ".mysql_error());
	$jualRow = mysql_fetch_array($jualQry);	
	$A	=	$jualRow['no_transaksi'];
	$B	=	$jualRow['nama_siswa'];
	$C	=	$jualRow['nis'];
	$D	=	$jualRow['nama'];
	$tgl	=	date("Y-m-d");
	
?>


<html>
<head>
<title> :: Nota Pembayaran SPMP dan DSP</title>
<link href="styles/style.css" rel="stylesheet" type="text/css">
</head>
<body>

<a href="index.php?page=Transaksi-Pembayaran" style="border:2px;">_</a>

<table style="border:1px solid grey;">
<tr>
<td>
<table width="700" border="0" >
<tr >
	<td width="210"  align="center" style="font-size:20px; color:red; "><b>KOMITE MAN 4 BOGOR</b></td>
	<td colspan="2" align="center" width="480" style="padding-top:20px; padding-bottom:0px; font-size:23px;"><b>K W I T A N S I</b></td>
</tr>
<tr>
	<td align="center" valign="top" style=" font-size:10px;"> Jl. Stasiun Cigombong Kp. Cijambu <br>Desa Cisalada Telp.0251-8222509</td>
	<td colspan="2" align="center" style="padding-bottom:25px; font-size:15px; text-decoration:underline; color:blue;"><strong>No.  <?php echo ($A); ?></strong></td>
	
</tr>
</table>

<table border="0" width="700" >
<?php

$query="SELECT SUM(banyak) as jml FROM transaksi_item WHERE no_transaksi='TR000019'" ;
$jualQry = mysql_query($query, $koneksidb)  or die ("Query penjualan salah : ".mysql_error());
	$data = mysql_fetch_array($jualQry);
?>


<tr>

	<td width="210" >Sudah terima dari</td>
	<td width="20">:</td>
	<td width="420" style="border-bottom:1px Solid grey;"><?php echo ($B); ?>&nbsp;&nbsp;(<?php echo ($C); ?>)</td>
	
</tr>

<tr>
	<td style="padding-top:10x;" >Uang sebesar</td>
	<td style="padding-top:10x;">:</td>
	<td style="border-bottom:1px Solid grey;  padding-top:10px;"><?php echo Terbilang ($data['jml']); ?></i></td>
	
</tr>

<tr>
	<td style="padding-top:10px;">Untuk pembayaran</td>
	<td style="padding-top:10px;">:</td>
	<td style="padding-top:7px;" rowspan="4"  valign="top">
	<table border="0" valign="top">
	<?php
	
		# Menampilkan List untuk Nomor Transaksi Terpilih
		$listBarangSql = "SELECT bulan.keterangan, transaksi_item.*	FROM transaksi_item, bulan 
		WHERE transaksi_item.no_transaksi='TR000019' AND transaksi_item.kode_bayar=bulan.kode ";
		$listBarangQry = mysql_query($listBarangSql, $koneksidb)  or die ("Query list barang salah : ".mysql_error());
		$nomor  = 0; $totalBayar = 0;
		while ($listBarangRow = mysql_fetch_array($listBarangQry)) 
		{
		
			$totalBayar = $totalBayar + intval($listBarangRow['banyak']);
			
			$nomor++;
				
	?>
	<tr>
		<td align="center" ><?php echo $nomor; ?>.</td>
		<td align="left" width="200"> <?php echo $listBarangRow['keterangan']; ?></td>
		<td align="right" width="80" name="X"><?php echo format_angka ($listBarangRow['banyak']); ?></td>	
	</tr>
	
	<?php } ?>
	
	</table></td>
</tr>
<tr >
	<td style=color:white;>,</td>
</tr>
<tr>
	<td style=color:white;>,</td>
</tr>
<tr>
	<td style=color:white;>,</td>
</tr>


</table>
<table  width="700" border="0" cellspacing="1" cellpadding="2">
	<TR>
		<td width="300" colspan="3"></td>
		<td style="border-bottom:1px Solid grey;"><?php echo TglIndonesia($tgl); ?></td>
	</tr>
	<tr>
		<td> </td>
		<td > </td>
		<td width="265"> </td>
		<td  align="left">Hormat kami, </td>
	</tr>
	<tr>
		<td width="100" align="right" height="40" style="border-bottom:1px Solid grey; border-top:1px solid grey;"> <i>Jumlah Rp.</td>
		<td width="120" align="center" style="border-bottom:1px Solid grey; border-top:1px solid grey;" > <i> <?php echo format_angka($totalBayar); ?>  </td>
		<td width="220"> </td>
		<td> </td>
	</tr>
<tr>
	<td> </td>
	<td> </td>
	<td style=color:white;>,</td>
	<td  align="left">( <?php echo $D; ?> ) </td>
</tr>
</table>
</td>
</tr>

</table>


<?php
$html = ob_get_contents(); //Proses untuk mengambil hasil dari OB..
ob_end_clean();
//Here convert the encode for UTF-8, if you prefer the ISO-8859-1 just change for $mpdf->WriteHTML($html);
$mpdf->WriteHTML(utf8_encode($html));
$mpdf->Output($nama_dokumen.".pdf" ,'I');
exit;
?>
<?php

mysql_close($connect_db);
 
}else {
 
  echo "Database Tidak Ada";
 
  mysql_close($connect_db);
 
}
	?>