<?php 
include "../include/config.php"; 
include "../function/inc_function.php"; 
ob_start();
$dlv_id = isset($_REQUEST['dlv_id']) ? $_REQUEST['dlv_id'] :'';
$hd = mysql_fetch_array(mysql_query("SELECT a.*, b.cust_name
									  FROM delivery a 
									  LEFT JOIN customer b ON b.id=a.dlv_idcust
									  WHERE a.id='$dlv_id'"));
$dlv = mysql_fetch_array(mysql_query("SELECT a.*,b.prod_code,b.prod_name,b.prod_sat
						  FROM delivery_detail a
						  LEFT JOIN product b ON b.id=a.dlvd_prodid
						  WHERE a.dlvd_hid='$dlv_id' "));
$comp = mysql_fetch_array(mysql_query("SELECT * FROM profil"));									  
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href="../include/css/print_styles.css" />	
</head>
<body>
<div id="popup">
<table width="100%" border="0">
	<tr>
		<td width="170" border="0"></td>
		<td width="200" border="0"><img src="../images/Hab Dong Indo Logo.png" width="200" height="50"></td>
		<td width="350" border="0"><b><?=$comp['prof_name'];?><br><?=wordwrap($comp['prof_address'],50,"<br>\n",TRUE);?></b></td>
	</tr>
	<tr>
		<td colspan="3" border="0"><br><hr></hr></td>
	</tr>
	<tr>
		<td colspan="3" align="center" border="0"><b><u><font size="3">SURAT JALAN</font></u></b><br>NO. <?=$hd['dlv_nosj'];?></td>
	</tr>
</table>

<br>

<table>
	<tr>
		<td border="0" width="100">Tanggal</td>
		<td style="border-right:none; border-top:none;" width="250">: <?=date("d-M-Y",strtotime($hd['dlv_sjdate']));?></td>
		<td border="0" width="100">No. Inv</td>
		<td style="border-right:none; border-top:none;" width="250">: <?=$hd['dlv_invno'];?></td>
	</tr>
	
	<tr>
		<td border="0">Jenis Kendaraan</td>
		<td style="border-right:none;">: &nbsp;</td>
		<td border="0">No. BC</td>
		<td style="border-right:none;">: <?=$hd['dlv_bcno'];?></td>
	</tr>
	
	<tr>
		<td border="0">No. Polisi</td>
		<td style="border-right:none;">: <?=$hd['dlv_polisino'];?></td>
		<td border="0">Tujuan</td>
		<td style="border-right:none;">: <?=wordwrap($hd['cust_name'],38,"<br>\n",TRUE);?></td>
	</tr>
	
	<tr>
		<td border="0">Driver</td>
		<td style="border-right:none;">: <?=$hd['dlv_drivername'];?></td>
		<td border="0"></td>
		<td style="border-right:none;"></td>
	</tr>
	<tr>
		<td colspan="4" border="0"><br><b>Dikirim barang-barang sebagai berikut : </b></td>
	</tr>
</table>
<br>
<table>
	<tr align="center" >
		<td height="20" style="border-bottom:2;"><b>NO</b></td>
		<td style="border-bottom:2;" valign="middle"><b>PART NO</b></td>
		<td style="border-bottom:2;" valign="middle"><b>NAMA PART</b></td>
		<td style="border-bottom:2;" valign="middle"><b>MODEL</b></td>
		<td style="border-bottom:2;" valign="middle"><b>NO. WO</b></td>
		<td style="border-bottom:2;" valign="middle"><b>QTY</b></td>
		<td style="border-bottom:2;" valign="middle"><b>SATUAN</b></td>
		<td style="border-bottom:2;" valign="middle"><b>KETERANGAN</b></td>
	</tr>
	<?php
	$no=0;
	$query = mysql_query("SELECT a.*,b.prod_code,b.prod_name,b.prod_sat
						  FROM delivery_detail a
						  LEFT JOIN product b ON b.id=a.dlvd_prodid
						  WHERE a.dlvd_hid='$dlv_id' ORDER BY a.id ASC");
	while($data=mysql_fetch_array($query)){
		$no++;
	?>
	<tr height="1000px;">
		<td width="20" style="border-bottom:none;" align="center"><?=$no;?></td>
		<td width="100" style="border-bottom:none;"><?=wordwrap($data['prod_code'],20,"<br>\n",TRUE);?></td>
		<td width="120" style="border-bottom:none;"><?=wordwrap($data['prod_name'],18,"<br>\n",TRUE);?></td>
		<td width="100" style="border-bottom:none;"><?=wordwrap($data['dlvd_model'],12,"<br>\n",TRUE);?></td>
		<td width="100" style="border-bottom:none;"><?=wordwrap($data['dlvd_wono'],12,"<br>\n",TRUE);?></td>
		<td width="70" style="border-bottom:none;" align="right"><?=number_format($data['dlvd_qty'],2,'.',',');?></td>
		<td width="80" style="border-bottom:none;" align="center"><?=$data['prod_sat'];?></td>
		<td width="100" style="border-bottom:none;" align="center"><?=$data['dlvd_qtypackages'];?> <?=$data['dlvd_unitpackages'];?> <br></td>
	</tr>
	
	<tr >
	<td height="30" style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	<td style="border-bottom:none;"></td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="8"></td>
	</tr>
	<tr>
		<td colspan="5" align="center" height="25" valign="middle"><b>TOTAL</b></td>
		<?php
			$t_qty=mysql_fetch_array(mysql_query("SELECT SUM(dlvd_qty) AS qty FROM delivery_detail WHERE dlvd_hid='$dlv_id'"));
		?>
		<td border="1" valign="middle" align="right"><?=number_format($t_qty['qty'],2,'.',',');?></td>
		<td border="1" valign="middle" align="center">PCE</td>
		<td border="1" valign="middle"></td>
	</tr>
</table>

<br>

<table>
	<tr>
		<td colspan="3" align="center">Pengirim</td>
		<td align="center" border="0"></td>
		<td align="center" style="border-right:none; border-top:none;">Penerima</td>
	</tr>
	<tr>
		<td width="100" align="center">Di Siapkan</td>
		<td width="100" align="center">Di Check</td>
		<td width="100" align="center">Di Setujui</td>
		<td width="300" align="center" style="border-bottom:none;"></td>
		<td width="100" align="center"></td>
	</tr>
	<tr>
		<td height="40"></td>
		<td></td>
		<td></td>
		<td style="border-bottom:none;"></td>
		<td></td>
	</tr>
	<tr>
		<td height="10"></td>
		<td></td>
		<td></td>
		<td style="border-bottom:none;"></td>
		<td></td>
	</tr>
</table>
</div>
</body>
</html>


<?php   
	 #PDF
	 $filename="Invoice.pdf";   
	 $content = ob_get_clean();  
	 require_once('../function/html2pdf/html2pdf.class.php');  
	 try  
	 {  
	  $html2pdf = new HTML2PDF('P','A4','en', false, 'ISO-8859-15',array(5, 5, 5, 5));
	  $html2pdf->setDefaultFont('Arial');  
	  $html2pdf->writeHTML($content, isset($_GET['vuehtml']));  
	  $html2pdf->Output($filename);  
	 }  
	 catch(HTML2PDF_exception $e) { echo $e; }
?> 
