<script type="text/javascript">	
	window.print();
</script>

<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
			
	$kode 	= $_GET['kode'];
	$tanggal= $_GET['tgl'];
	$jenisby= $_GET['jenisby'];
	$jeniskt= $_GET['jeniskt'];
	$nokartu= $_GET['nokartu'];

	$query2 = mysql_query("SELECT * FROM company");
	$r2		= mysql_fetch_assoc($query2);
	$kop1 	= $r2['nama1'];
	$kop2 	= $r2['nama2'];
	$kop3 	= $r2['alamat'];
	
	$query2 = mysql_query("SELECT * FROM standard");
	$r2		= mysql_fetch_assoc($query2);
	$ucapan	= $r2['ucapan'];
	
	$query1	= mysql_query("SELECT kode_cab,nama_pl,user,jam FROM faktur_pj WHERE kode_pj='$kode' GROUP BY kode_pj");
	$r		= mysql_fetch_assoc($query1);
	$namadt	= $r['nama_dt'];
	$pasien	= $r['pasien'];
	$namapl	= $r['nama_pl'];
	$user	= $r['user'];
	$kodecab= $r['kode_cab'];
	$jam	= $r['jam'];
	
	$query2 = mysql_query("SELECT * FROM cabang WHERE kode_cab='$kodecab'");
	$r2		= mysql_fetch_assoc($query2);
	$kop1	= $r2['nama_cab'];
	$kop2   = $r2['alamat'];
	
	echo "<table width='100%'>
		<tr>
			<td style='font:14px Verdana;line-height:100%' align='center'><b>$kop1</b></td>
		</tr>
		<tr>
			<td style='font:10px Verdana;line-height:100%' align='center'>$kop2</td>
		</tr>
	</table>
	<hr>";

	echo "<table width='100%'>
		<tr>
			<td style='font:10px Verdana;line-height:100%'>$kode</td>
			<td></td>
			<td width='20%' style='font:10px Verdana;line-height:100%'>".jin_date_str($tanggal)."</td>
		</tr>
	</table>
	<table width='100%'>
		<tr>
			<td style='font:10px Verdana;line-height:100%'>Kasir</td>
			<td style='font:10px Verdana;line-height:100%'>: $user</td>
			<td style='font:10px Verdana;line-height:100%'>$jam</td>
		</tr>";
		if(!$namadt==''){
			echo "<tr>
				<td style='font:10px Verdana;line-height:100%'>Dokter</td>
				<td style='font:10px Verdana;line-height:100%'>: $namadt</td>
				<td style='font:10px Verdana;line-height:100%'>Pas : $pasien</td>
			</tr>";
		}
		if(!$namapl==''){
			echo "<tr>
				<td style='font:10px Verdana;line-height:100%'>Paramedis</td>
				<td style='font:10px Verdana;line-height:100%'>: $namapl</td>
				<td style='font:10px Verdana;line-height:100%'></td>
			</tr>";
		}
	echo "</table>
	<hr>";
		
		$query= mysql_query("SELECT * FROM faktur_pj WHERE kode_pj='$kode' ORDER BY no_urut");
		
		$tjumlah=0;
		$tpotong=0;
		$tcharge=0;
		$tbayar=0;
		
		while($r=mysql_fetch_array($query)){
			$jumlah	=$r['jumlah']+$diskon;
			$tjumlah=$tjumlah+$jumlah;
			$tpotong=$tpotong+$r['potongan'];
			$tcharge=$tcharge+$r['charge_edc'];
			$tbayar	=$tbayar+$r['bayar'];
			
			echo "<table width='100%'>
				<tr>
					<td width='100%' style='font:11px Verdana;line-height:100%'>$r[nama_st]</td>
				</tr>
			</table>
			<table width='100%'>
				<tr>
					<td width='24%' style='font:11px Verdana;line-height:100%'>".number_format($r['jml_unit'],2)." $r[satuan]</td>
					<td width='4%' style='font:11px Verdana;line-height:100%'> x </td>
					<td width='16%' align='right' style='font:11px Verdana;line-height:100%'>".number_format($r['hg_jual'],0)."</td>
					<td width='4%' style='font:11px Verdana;line-height:100%'> = </td>
					<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($jumlah,0)."</td>
				</tr>
			</table>";
		}
	echo "<hr>";
	$netto	=$tjumlah-$tpotong;
	$gtotal	=$netto+$tcharge;
	$sisa	=$tbayar-$gtotal;

	echo "<table width='100%'>
		<tr>
			<td width='56' style='font:11px Verdana;line-height:100%'></td>			
			<td width='20%' style='font:11px Verdana;line-height:100%'>Jumlah</td>
			<td width='4%' style='font:11px Verdana;line-height:100%'> = </td>
			<td width='20%' align='right' style='font:11px Verdana;line-height:100%'>".number_format($tjumlah,0)."</td>
		</tr>
		<tr>
			<td style='font:11px Verdana;line-height:100%'></td>
			<td style='font:11px Verdana;line-height:100%'>Potongan</td>
			<td style='font:11px Verdana;line-height:100%'> = </td>
			<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($tpotong,0)."</td>
		</tr>
		<tr>
			<td style='font:11px Verdana;line-height:100%'></td>
			<td style='font:11px Verdana;line-height:100%'>Netto</td>
			<td style='font:11px Verdana;line-height:100%'> = </td>
			<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($netto,0)."</td>
		</tr>
		<tr>
			<td style='font:11px Verdana;line-height:100%'></td>
			<td style='font:11px Verdana;line-height:100%'>Pembayaran</td>
			<td style='font:11px Verdana;line-height:100%'> : </td>
			<td style='font:11px Verdana;line-height:100%'>$jenisby</td>
		</tr>";
		
		if($jenisby=='EDC'){
			echo "<tr>				
				<td style='font:11px Verdana;line-height:100%'></td>
				<td style='font:11px Verdana;line-height:100%'>Jenis Kartu</td>
				<td style='font:11px Verdana;line-height:100%'> : </td>
				<td style='font:11px Verdana;line-height:100%'>$jeniskt</td>
			</tr>
			<tr>				
				<td style='font:11px Verdana;line-height:100%'></td>
				<td style='font:11px Verdana;line-height:100%'>Nomor Kartu</td>
				<td style='font:11px Verdana;line-height:100%'> : </td>
				<td style='font:11px Verdana;line-height:100%'>$nokartu</td>
			</tr>
			<tr>				
				<td style='font:11px Verdana;line-height:100%'></td>
				<td style='font:11px Verdana;line-height:100%'>Charge EDC</td>
				<td style='font:11px Verdana;line-height:100%'> = </td>
				<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($tcharge,0)."</td>
			</tr>
			<tr>
				<td style='font:11px Verdana;line-height:100%'></td>
				<td style='font:11px Verdana;line-height:100%'>Total</td>
				<td style='font:11px Verdana;line-height:100%'> = </td>
				<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($gtotal,0)."</td>
			</tr>";
		}
		
		echo "<tr>			
			<td style='font:11px Verdana;line-height:100%'></td>
			<td style='font:11px Verdana;line-height:100%'>Dibayar</td>
			<td style='font:11px Verdana;line-height:100%'> = </td>
			<td align='right' style='font:11px Verdana;line-height:100%'>".number_format($tbayar,0)."</td>
		</tr>
		<tr>			
			<td style='font:11px Verdana;line-height:100%'></td>
			<td style='font:11px Verdana;border-bottom:double 1px;line-height:100%'>Kembali</td>
			<td style='font:11px Verdana;border-bottom:double 1px;line-height:100%'>=</td>
			<td style='font:11px Verdana;border-bottom:double 1px;line-height:100%' align='right'>".number_format($sisa,0)."</td>
		</tr>			
	</table>
	<br>
		
	<table width='100%'>
	    <tr>
			<td align='center' style='font:11px Verdana;line-height:100%'>BARANG YANG DIBELI TIDAK BISA DITUKAR ATAU DIKEMBALIKAN.</td>
		</tr>
		<tr>
			<td align='center' style='font:11px Verdana;line-height:100%'>Terima kasih, selamat datang kembali.</td>
		</tr>
		<tr>
			<td align='center' style='font:11px Verdana;line-height:100%'>$ucapan</td>
		</tr>
	</table>
	<br>
	<br>
	<br>
	<br>";
?>
<script type="text/javascript">	
	history.back();
</script>