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

<?php
	include '../../inc/inc.koneksi.php';
	include '../../inc/fungsi_tanggal.php';
			
	$kode 		= $_GET[kode];
	$tanggal	= $_GET[tanggal];
	$namasp 	= $_GET[namasp];
	$nopol  	= $_GET[nopol];
	$namadv 	= $_GET[namadv];
	
	$query1	= mysql_query("SELECT * FROM company");
	$r1			= mysql_fetch_assoc($query1);
	$kop1 		= $r1[nama1];
	$kop2 		= $r1[nama2];
	$kop3 		= $r1[nama3];
	
	$query	= mysql_query("SELECT * FROM surat_jln WHERE kode_sj='$kode' ORDER BY no_urut");
	$row   	= mysql_num_rows($query);
	$hal   	= 1;
	
	echo "<table width='700'>
		<tr>
			<td style='font:arial 11px'><b>$kop1</b></td>
		</tr>
		<tr>
			<td style='font:arial 11px'>$kop2</td>
		</tr>
		<tr>
			<td style='font:arial 11px'>$kop3</td>
		</tr>
	</table>
	<br>
	
	<table width='700'>
		<tr>
			<td align='center' style='font:15px verdana;line-height:100%'><b>SURAT JALAN</b></td>
		</tr>
		</table>
		<br>";

	echo "<table width='700'>
		<tr>
			<td width='10%' style='font:13px verdana;line-height:100%'>SPBE</td>
			<td width='50%' style='font:13px verdana;line-height:100%'>: $namasp</td>
			<td width='10%' style='font:13px verdana;line-height:100%'>Nomor</td>
			<td width='18%' style='font:13px verdana;line-height:100%'>: $kode</td>
		</tr>
	</table>

	<table width='700'>
		<tr>
			<td width='10%' style='font:13px verdana;line-height:100%'>Pengemudi</td>
			<td width='20%' style='font:13px verdana;line-height:100%'>: $namadv</td>
			<td width='10%' style='font:13px verdana;line-height:100%'>No. Polisi</td>
			<td width='20%' style='font:13px verdana;line-height:100%'>: $nopol</td>
			<td width='10%' style='font:13px verdana;line-height:100%'>Tanggal</td>";
			if($row>12)
				echo "<td style='font:13px verdana;line-height:100%'>: ".jin_date_str($tanggal)." ------ Halaman : $hal</td>";
			else
				echo "<td style='font:13px verdana;line-height:100%'>: ".jin_date_str($tanggal)."</td>";
		echo "</tr>
		</table>
		
		<table width='700'>
		<tr>
			<th width='4%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>No.</th>
			<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Kode</th>
			<th width='35%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Nama Pangkalan</th>			
			<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Jumlah</th>
			<th width='16%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Pembayaran</th>
			<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Harga Jual</th>
			<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Total Harga</th>
		</tr>
		</table>";
		
	echo "<table width='700'>";
		$no=1;				
		$tjumlah=0;
		$tunit=0;
		$brs=1;
		
		while($r_data=mysql_fetch_array($query)){
			$user	= $r_data[user];
			
			if($brs<12){
				if(!($no==$row)){
					echo "<tr>
						<td width='4%' align='center' style='font:13px verdana;line-height:100%'>$no</td>
						<td width='8%' align='center' style='font:13px verdana;line-height:100%'>$r_data[kode_pl]</td>
						<td width='35%' style='font:13px verdana;line-height:100%'>$r_data[nama_pl]</td>
						<td width='8%' align='right' style='font:13px verdana;line-height:100%'>$r_data[jml_unit]</td>
						<td width='16%' style='font:13px verdana;line-height:100%'>$r_data[namakas]</td>
						<td width='12%' align='right' style='font:13px verdana;line-height:100%'>".number_format($r_data[hg_jual],0)."</td>
						<td width='12%' align='right' style='font:13px verdana;line-height:100%'>".number_format($r_data[jumlah],0)."</td>
					</tr>";
				}else{
					echo "<tr>
						<td width='4%' align='center' style='font:13px verdana;line-height:100%'>$no</td>
						<td width='8%' align='center' style='font:13px verdana;line-height:100%'>$r_data[kode_pl]</td>
						<td width='35%' style='font:13px verdana;line-height:100%'>$r_data[nama_pl]</td>
						<td width='8%' align='right' style='font:13px verdana;line-height:100%'>$r_data[jml_unit]</td>
						<td width='16%' style='font:13px verdana;line-height:100%'>$r_data[namakas]</td>
						<td width='12%' align='right' style='font:13px verdana;line-height:100%'>".number_format($r_data[hg_jual],0)."</td>
						<td width='12%' align='right' style='font:13px verdana;line-height:100%'>".number_format($r_data[jumlah],0)."</td>
					</tr>
					</table>";
					
					while($brs<12){
						echo "<br>";
						$brs++;
					}
				}
			}
				
			if($brs==12){
				echo "<tr>
					<td width='4%' align='center' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='8%' align='center' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='35%' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='8%' align='right' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='16%' align='center' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='12%' align='right' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
					<td width='12%' align='right' style='border-bottom:double 1px;font:13px verdana;line-height:100%'></td>
				</tr>";
				
				If(!($no==$row)){
					$brs=0;
					$hal++;
					echo "</table>
					<br>
					<br>
					<br>
					<br>
					
					<table width='700'>
						<tr>
							<td style='font:arial 11px'><b>$kop1</b></td>
						</tr>
						<tr>
							<td style='font:arial 11px'>$kop2</td>
						</tr>
						<tr>
							<td style='font:arial 11px'>$kop3</td>
						</tr>
					</table>
					<br>
	
					<table width='700'>
						<tr>
							<td align='center' style='font:15px verdana;line-height:100%'><b>SURAT JALAN</b></td>
						</tr>
					</table>
					<br>";

					echo "<table width='700'>
						<tr>
							<td width='10%' style='font:13px verdana;line-height:100%'>SPBE</td>
							<td width='50%' style='font:13px verdana;line-height:100%'>: $namasp</td>
							<td width='10%' style='font:13px verdana;line-height:100%'>Nomor</td>
							<td width='18%' style='font:13px verdana;line-height:100%'>: $kode</td>
						</tr>
					</table>

					<table width='700'>
						<tr>
							<td width='10%' style='font:13px verdana;line-height:100%'>Pengemudi</td>
							<td width='20%' style='font:13px verdana;line-height:100%'>: $namadv</td>
							<td width='10%' style='font:13px verdana;line-height:100%'>No. Polisi</td>
							<td width='20%' style='font:13px verdana;line-height:100%'>: $nopol</td>
							<td width='10%' style='font:13px verdana;line-height:100%'>Tanggal</td>
							<td style='font:13px verdana;line-height:100%'>: ".jin_date_str($tanggal)." ------ Halaman : $hal</td>
						</tr>
					</table>
		
					<table width='700'>
						<tr>
							<th width='4%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>No.</th>
							<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Kode</th>
							<th width='35%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Nama Pangkalan</th>			
							<th width='8%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Jumlah</th>
							<th width='16%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Pembayaran</th>
							<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Harga Jual</th>
							<th width='12%' style='border-top:double 1px;border-bottom:double 1px;font:13px verdana;line-height:100%'>Total Harga</th>
						</tr>
					</table>";
				}
			}
			$tunit	= $tunit+$r_data[jml_unit];
			$tjumlah= $tjumlah+$r_data[jumlah];
			$no++;
			$brs++;
		}
			
	echo "<table width='700'>
		<tr>
			<td width='4%' align='center' style='font:13px verdana;line-height:100%'></td>
			<td width='8%' align='center' style='font:13px verdana;line-height:100%'></td>
			<td width='35%' align='right' style='font:13px verdana;line-height:100%'>Total :</td>
			<td width='8%' align='right' style='font:13px verdana;border-bottom:double 1px;line-height:100%'>$tunit</td>
			<td width='16%' style='font:13px verdana;border-bottom:double 1px;line-height:100%'></td>
			<td width='12%' align='right' style='font:13px verdana;border-bottom:double 1px;line-height:100%'></td>
			<td width='12%' align='right' style='font:13px verdana;border-bottom:double 1px;line-height:100%'>".number_format($tjumlah,0)."</td>
		</tr>
	</table>
	
	<table width='700'>
		<tr>
			<td width='70%' style='font:12px verdana;line-height:100%'></td>
			<td width='30%' align='center' style='font:13px verdana;line-height:100%'>Administrasi</td>
		</tr>
	</table>
	<br><br><br>
	<table width='700'>
		<tr>
			<td width='70%' style='font:12px verdana;line-height:100%'></td>
			<td width='30%' align='center' style='border-bottom:double 1px;font:13px verdana'>$user</td>
		</tr>
	</table>";
?>