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

<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';

	$kode 	= $_GET['kode'];
	$kodesp	= $_GET['kodesp'];
	$namasp	= $_GET['namasp'];	
	$tanggal= $_GET['tgl'];
	$kodecab= $_GET['kodecab'];
	
	$sql= mysql_query("SELECT * FROM supplier WHERE kode_sp='$kodesp'");
	$r	= mysql_fetch_assoc($sql);
	$alamat	= $r['alamat'];
	
	$sql= mysql_query("SELECT * FROM cabang WHERE kode_cab='$kodecab'");
	$r	= mysql_fetch_assoc($sql);
	$kop1    =$r['nama_cab'];
	$kop2    =$r['alamat'];
	$kota    =$r['kota'];
	$apoteker=$r['apoteker'];
	$nosipa  =$r['nosipa'];
	$noijin  =$r['noijin'];
	
	$query 	= mysql_query("SELECT * FROM sopb WHERE kode_opb='$kode' ORDER BY no_urut");
	$hal   	= 1;
	
	echo "<table width='100%'><b>
		<tr>
			<td align='center' style='font:14px arial'><b>$kop1</b></td>
		</tr>
		<tr>
			<td align='center' style='font:13px arial'><b>SIA $noijin</b></td>
		</tr>
		<tr>
			<td align='center' style='font:13px arial;border-bottom:double 1px'>$kop2</td>
		</tr>
	</table>
	
	<table width='100%'>
		<tr>
		    <td align='center' style='font:15px arial;border-bottom:double 1px'>SURAT PESANAN</td>
	    </tr>
    </table>
    
	<table width='100%'>
		<tr>
			<td width='12%' style='font:13px arial;line-height:100%'>Kepada Yth.</td>
			<td width='45%' style='font:13px arial;line-height:100%'>: PBF $namasp</td>
			<td width='10%' style='font:13px arial;line-height:100%'></td>
			<td width='10%' style='font:13px arial;line-height:100%'>Nomor SP</td>
			<td width='20%' style='font:13px arial;line-height:100%'>: $kode</td>
		</tr>
		<tr>
			<td></td>
			<td style='font:13px arial;line-height:100%'>$alamat</td>
			<td></td>
			<td style='font:13px arial;line-height:100%'></td>
			<td style='font:13px arial;line-height:100%'></td>
			<td></td>
		</tr>
	</table>
	<table width='100%'>
		<tr>
		    <td style='font:13px arial'>Mohon dikirim obat-obatan untuk keperluan Apotek sebagai berikut :</td>
	    </tr>
    </table>
	<table width='100%'>
		<tr>
			<th width='5%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='35%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='10%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='10%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='35%' style='border-bottom:double 1px;font:13px arial'></th>
		</tr>
		<tr>
			<th style='font:13px arial'>No.</th>
			<th style='font:13px arial'>Nama Obat</th>
			<th style='font:13px arial'>Jumlah</th>
			<th style='font:13px arial'>Satuan</th>
			<th style='font:13px arial'>Keterangan</th>
		</tr>
		<tr>
			<th style='border-top:double 1px;font:13px arial'></th>
			<th style='border-top:double 1px;font:13px arial'></th>
			<th style='border-top:double 1px;font:13px arial'></th>
			<th style='border-top:double 1px;font:13px arial'></th>
			<th style='border-top:double 1px;font:13px arial'></th>
		</tr>
	</table>
	<table width='100%'>";
		$no=1;				
		
		while($r=mysql_fetch_array($query)){
			echo "<tr>
				<td width='5%' align='center' style='font:13px arial;line-height:100%'>$no</td>
				<td width='35%' style='font:13px arial;line-height:100%'>$r[nama_st]</td>
				<td width='10%' align='right' style='font:13px arial;line-height:100%'>$r[jml_unit]</td>
				<td width='10%' style='font:13px arial;line-height:100%'>$r[satuan]</td>
				<td width='35%' style='font:13px arial;line-height:100%'>$r[keterangan]</td>
			</tr>";
			$no++;
		}
	echo "</table>";
	if($no<11){
		while($no<11){
			echo "<br>";
			$no++;
		}
	}
	echo "<table width='100%'>
		<tr>
			<td width='5%' style='border-top:double 1px;font:13px arial'></td>
			<td width='35%' style='border-top:double 1px;font:13px arial'></td>
			<td width='10%' style='border-top:double 1px;font:13px arial'></td>			
			<td width='10%' style='border-top:double 1px;font:13px arial'></td>
			<td width='35%' style='border-top:double 1px;font:13px arial'></td>
		</tr>		
	</table>
	
	<table width='100%'>
		<tr>
			<td width='20%'></td>
			<td width='15%'></td>
			<td width='20%'></td>
			<td width='7%'></td>
			<td width='28%' align='center' style='font:13px arial;line-height:100%'>$kota, ".jin_date_str($tanggal)."</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align='center' style='font:13px arial;line-height:100%'>Apoteker Penanggung Jawab</td>
		</tr>
	</table>
	<br>
	<table width='100%'>
		<tr>
			<td width='20%'></td>
			<td width='15%'></td>
			<td width='20%'></td>
			<td width='7%' style='font:13px arial;line-height:100%'>Nama</td>
			<td width='28%' style='font:13px arial;line-height:100%'>: $apoteker</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td style='font:13px arial;line-height:100%'>No.SIPA</td>
			<td style='font:13px arial;line-height:100%'>: $nosipa</td>
		</tr>
	</table>";
?>
<script type="text/javascript">	
	history.back();
</script>