<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'];
	$almapt  =$r['alamat_apt'];
	$nosipa  =$r['nosipa'];
	$noijin  =$r['noijin'];
	
	$query 	= mysql_query("SELECT * FROM sopb WHERE kode_opb='$kode' ORDER BY no_urut");
	$row   	= mysql_num_rows($query);
	$hal   	= 1;
	
	echo "<table width='100%'>
		<tr>
		    <td align='center' style='font:14px arial'><b>SURAT PESANAN OBAT PSIKOTROPIKA</b></td>
	    </tr>
	    <tr>
		    <td align='center' style='font:14px arial'>Nomor SP : $kode</td>
	    </tr>
    </table>
    
	<table width='100%'>
	    <tr>
	        <td style='font:13px arial;line-height:100%'>Yang bertanda tangan di bawah ini :</td>
	    </tr>
	</table>
	<table width='100%'>
		<tr>
			<td width='10%' style='font:13px arial;line-height:100%'>Nama</td>
			<td style='font:13px arial;line-height:100%'>: $apoteker</td>
	    </tr>
	    <tr>
			<td style='font:13px arial;line-height:100%'>Alamat</td>
			<td style='font:13px arial;line-height:100%'>: $almapt</td>
		</tr>
		<tr>
			<td style='font:13px arial;line-height:100%'>Jabatan</td>
			<td style='font:13px arial;line-height:100%'>: Apoteker Penanggungjawab</td>
		</tr>
		<tr>
			<td style='font:13px arial;line-height:100%'>No. SIPA</td>
			<td style='font:13px arial;line-height:100%'>: $nosipa</td>
		</tr>
	</table>
	<table width='100%'>
	    <tr>
	        <td style='font:13px arial;line-height:100%'>Mengajukan pesanan Obat Psikotropika kepada :</td>
	    </tr>
	</table>
	<table width='100%'>
	    <tr>
			<td width='10%' style='font:13px arial;line-height:100%'>Nama</td>
			<td style='font:13px arial;line-height:100%'>: $namasp</td>
	    </tr>
	    <tr>
			<td style='font:13px arial;line-height:100%'>Alamat</td>
			<td style='font:13px arial;line-height:100%'>: $alamat</td>
		</tr>
	</table>
	
	<table width='100%'>
	    <tr>
	        <td style='font:13px arial;line-height:100%'>Jenis pesanan Obat Psikotropika sebagai berikut :</td>
	    </tr>
	</table>
		
	<table width='100%'>
		<tr>
			<th width='5%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='23%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='22%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='15%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='7%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='7%' style='border-bottom:double 1px;font:13px arial'></th>
			<th width='21%' 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'>Zat Aktif</th>
			<th style='font:13px arial'>Bentuk Sediaan</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>
			<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='23%' style='font:13px arial;line-height:100%'>$r[nama_st]</td>
				<td width='22%' style='font:13px arial;line-height:100%'>$r[zat_aktif]</td>
				<td width='15%' style='font:13px arial;line-height:100%'>$r[bentuk]</td>
				<td width='7%' align='right' style='font:13px arial;line-height:100%'>$r[jml_unit]</td>
				<td width='7%' style='font:13px arial;line-height:100%'>$r[satuan]</td>
				<td width='21%' style='font:13px arial;line-height:100%'>$r[keterangan]</td>
			</tr>";
			$no++;
		}
	echo "</table>";
	if($no<5){
		while($no<5){
			echo "<br>";
			$no++;
		}
	}
	echo "<table width='100%'>
		<tr>
			<td width='5%' style='border-top:double 1px;font:13px arial'></td>
			<td width='23%' style='border-top:double 1px;font:13px arial'></td>
			<td width='22%' style='border-top:double 1px;font:13px arial'></td>
			<td width='15%' 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='15%' style='border-top:double 1px;font:13px arial'></td>
		</tr>		
	</table>
	
	<table width='100%'>
	    <tr>
	        <td width='65%' style='font:13px arial;line-height:100%'>Obat Psikotropika tersebut digunakan untuk memenuhi kebutuhan :</td>
	        <td width='35%' align='center' style='font:13px arial;line-height:100%'>$kota, ".jin_date_str($tanggal)."</td>
	    </tr>
	</table>
	
	<table width='100%'>
		<tr>
		    <td width='15%' style='font:13px arial;line-height:100%'>Nama Apotek</td>
			<td width='50%' style='font:13px arial;line-height:100%'>: $kop1</td>
			<td width='35%' align='center' style='font:13px arial;line-height:100%'>Apoteker Penanggung Jawab</td>
	    </tr>
    </table>
    <table width='100%'>
	    <tr>
			<td width='15%' style='font:13px arial;line-height:100%'>Alamat</td>
			<td width='50%' style='font:13px arial;line-height:100%'>: $kop2</td>
			<td width='10%' style='border-bottom:double 1px;font:13px arial;line-height:100%'></td>
			<td width='25%' style='border-bottom:double 1px;font:13px arial;line-height:100%'></td>
		</tr>
		<tr>
			<td style='font:13px arial;line-height:100%'>No. Ijin Apotek</td>
			<td style='font:13px arial;line-height:100%'>: $noijin</td>
			<td style='border-bottom:double 1px;font:13px arial;line-height:100%'>Nama</td>
			<td style='border-bottom:double 1px;font:13px arial;line-height:100%'>: $apoteker</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td style='border-bottom:double 1px;font:13px arial;line-height:100%'>Nomor SIPA</td>
			<td style='border-bottom:double 1px;font:13px arial;line-height:100%'>: $nosipa</td>
		</tr>
	</table>";
?>