<script type="text/javascript">
	window.print();
</script>
<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
	
	$kode 		= $_GET[kode];
	$kodeplg	= $_GET[kodeplg];
	$tanggal	= $_GET[tgl];
	$nomorfk	= $_GET[nomorfk];
	$tglfk		= $_GET[tglfk];
	
	$sql1		= "SELECT * FROM customer WHERE kode_pl='$kodeplg' ORDER BY kode_pl";
	$query1 	= mysql_query($sql1);
		
	while($r1=mysql_fetch_array($query1)){
		$namaplg = $r1[nama];
		$alamat  = $r1[alamat];
	}
	
	$sql2		= "SELECT * FROM company";		
	$query2 	= mysql_query($sql2);
		
	while($r2=mysql_fetch_array($query2)){
		$kop1 = $r2[nama1];
		$kop2 = $r2[alamat];
	}
	
	$sql = mysql_query("SELECT * FROM retur_pj WHERE kode_rj='$kode' ORDER BY kode_rj");
	$row = mysql_num_rows($sql);
	$hal = 1;
	
	echo "<table width='790'>
		<tr>
			<td style='font:15px Century Gothic'><b>$kop1</b></td>
		</tr>
		<tr>
			<td align='center' style='font:18px Century Gothic'><b>MEMO KREDIT</b></td>
		</tr>
		</table>
		
		<table width='790'>
		<tr>
			<td width='12%' style='font:14px Century Gothic'>Kepada Yth :</td>
			<td width='30%' style='font:14px Century Gothic'>$namaplg</td>
			<td width='15%' style='font:14px Century Gothic'></td>
			<td width='12%' style='font:14px Century Gothic'>No.Bukti</td>
			<td width='13%' style='font:14px Century Gothic'>: $kode</td>
		</tr>
		
		<tr>
			<td></td>
			<td style='font:14px Century Gothic'>$alamat</td>
			<td></td>
			<td style='font:14px Century Gothic'>Tanggal</td>";
			if($row>12)
				echo "<td style='font:14px Century Gothic'>: ".jin_date_str($tanggal)." ------ Halaman : $hal</td>";
			else
				echo "<td style='font:14px Century Gothic'>: ".jin_date_str($tanggal)."</td>";
		echo "</tr>
		
		<tr>
			<td style='font:14px Century Gothic'>No. Faktur :</td>
			<td style='font:14px Century Gothic'>$nomorfk</td>
			<td></td>			
			<td style='font:14px Century Gothic'>Tgl. Faktur</td>
			<td style='font:14px Century Gothic'>: ".jin_date_str($tglfk)."</td>
		</tr>
		</table>
		
		<table width='790'>
		<tr>
			<th width='4%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>No.</th>
			<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Kode</th>
			<th width='38%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Nama Barang</th>			
			<th width='9%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Jumlah Unit</th>
			<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Satuan</th>
			<th width='10%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Harga Jual</th>
			<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Total Harga</th>
		</tr>
		</table>
		<table width='790'>";
		
		$no=1;				
		$tjumlah=0;
		$brs=1;
		while($r_data=mysql_fetch_array($sql)){
			
			if($brs<12){
				if(!($no==$row)){
					echo "<tr>
						<td width='4%' align='center' style='font:14px Century Gothic'>$no</td>
						<td width='8%' align='center' style='font:14px Century Gothic'>$r_data[kode_st]</td>
						<td width='38%' style='font:14px Century Gothic'>$r_data[nama_st]</td>						
						<td width='9%' align='right' style='font:14px Century Gothic'>$r_data[jml_retur]</td>
						<td width='8%' style='font:14px Century Gothic'>$r_data[satuan]</td>
						<td width='10%' align='right' style='font:14px Century Gothic'>".number_format($r_data[hg_jual],0)."</td>
						<td width='12%' align='right' style='font:14px Century Gothic'>".number_format($r_data[jumlah],0)."</td>
					</tr>";
				}else{
					echo "<tr>
						<td width='4%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>$no</td>
						<td width='8%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[kode_st]</td>
						<td width='38%' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[nama_st]</td>						
						<td width='9%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[jml_retur]</td>
						<td width='8%' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[satuan]</td>
						<td width='10%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>".number_format($r_data[hg_jual],0)."</td>
						<td width='12%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>".number_format($r_data[jumlah],0)."</td>
					</tr>";
				}
			}
				
			if($brs==12){
				echo "<tr>
					<td width='4%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>$no</td>
					<td width='8%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[kode_st]</td>
					<td width='38%' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[nama_st]</td>					
					<td width='9%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>$r_data[jml_retur]</td>
					<td width='8%' style='border-bottom:double 1px;font:14px Century Gothic'> $r_data[satuan]</td>
					<td width='10%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>".number_format($r_data[hg_jual],0)."</td>
					<td width='12%' align='right' style='border-bottom:double 1px;font:14px Century Gothic'>".number_format($r_data[jumlah],0)."</td>
				</tr>";
				
				If(!($no==$row)){
					$brs=0;
					$hal++;
					echo "</table>
					<br>
					<br>
					<br>
					<br>
					
					<table width='790'>
					<tr>
						<td style='font:14px Century Gothic'><b>$kop1</b></td>
					</tr>
					<tr>
						<td align='center' style='font:12px Century Gothic'><b>MEMO KREDIT</b></td>
					</tr>
					</table>
		
					<table width='790'>
					<tr>
						<td width='12%' style='font:14px Century Gothic'>Kepada Yth :</td>
						<td width='30%' style='font:14px Century Gothic'>$namaplg</td>
						<td width='20%' style='font:14px Century Gothic'></td>
						<td width='10%' style='font:14px Century Gothic'>No.Bukti</td>
						<td width='20%' style='font:14px Century Gothic'>: $kode</td>
					</tr>
		
					<tr>
						<td></td>
						<td style='font:14px Century Gothic'>$alamat</td>
						<td></td>
						<td style='font:14px Century Gothic'>Tanggal</td>";
						if($row>10)
							echo "<td style='font:14px Century Gothic'>: ".jin_date_str($tanggal)." ------ Halaman : $hal</td>";
						else
							echo "<td style='font:14px Century Gothic'>: ".jin_date_str($tanggal)."</td>";
					echo "</tr>
		
					<tr>
						<td width='10%' style='font:14px Century Gothic'>No. Faktur</td>
						<td style='font:14px Century Gothic'>: $nomorfk</td>
						<td></td>			
						<td style='font:14px Century Gothic'>Tgl. Faktur</td>
						<td style='font:14px Century Gothic'>: ".jin_date_str($tglfk)."</td>
					</tr>
					</table>
					<br>
	
					<table width='790'>
					<tr>
						<th width='4%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>No.</th>
						<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Kode</th>
						<th width='38%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Nama Barang</th>						
						<th width='9%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Jumlah Unit</th>
						<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Satuan</th>
						<th width='10%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Harga Jual</th>
						<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:14px Century Gothic'>Total Harga</th>
					</tr>
					</table>";
				}
			}
			$tjumlah=$tjumlah+$r_data[jumlah];
			$no++;
			$brs++;
		}
		echo "</table>
		
		<table width='790'>
		<tr>
			<td width='15%' align='center' style='font:14px Century Gothic'>Pelanggan</td>
			<td width='5%'></td>
			<td width='15%' align='center' style='font:14px Century Gothic'>Bagian Gudang</td>
			<td width='5%'></td>
			<td width='15%' align='center' style='font:14px Century Gothic'>Penjualan</td>
			<td width='5%'></td>
			<td width='10%' align='left' style='font:14px Century Gothic'>Jumlah</td>
			<td width='10%' align='right' style='font:14px Century Gothic'>".number_format($tjumlah,0)."</td>
		</tr>
		</table>
		<br><br>
		
		<table width='790'>
		<tr>
			<td width='15%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>_</td>
			<td width='5%'></td>
			<td width='15%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>_</td>
			<td width='5%'></td>
			<td width='15%' align='center' style='border-bottom:double 1px;font:14px Century Gothic'>_</td>
			<td width='5%'></td>
			<td width='10%'></td>
			<td width='10%'></td>
		</tr>
	</table>";
?>
