<?php 
include "../../include/config.php"; 
include "../../function/inc_function.php"; 
$po_no = isset($_REQUEST['po_no']) ? $_REQUEST['po_no'] :'';
$hd = mysql_fetch_array(mysql_query("SELECT a.*, b.sup_name, b.sup_address, b.sup_city, c.cust_name, c.cust_address, c.cust_city, d.bbt_tipe 
	 FROM purchase_order a 
	 LEFT JOIN supplier b ON b.id=a.po_idsupp 
	 LEFT JOIN customer c ON c.id=a.po_idcust 
	 LEFT JOIN buku_besar_tipe d ON d.id=a.po_ptype 
	 WHERE a.po_no='$po_no'"));
	 if($hd['po_type']=="Purchasing"){
		 $nama   = $hd['sup_name'];
		 $alamat = $hd['sup_address'];
		 $kota   = $hd['sup_city'];
	 }else{
		 $nama   = $hd['cust_name'];
		 $alamat = $hd['cust_address'];
		 $kota   = $hd['cust_city'];
	 }
$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 class="dyppop_signtop1">Sec. Chief</div><div class="dyppop_signbottom1">&nbsp;</div>
<div class="dyppop_signtop2">Manager</div><div class="dyppop_signbottom2">&nbsp;</div>
<div class="dyppop_signtop3">Director</div><div class="dyppop_signbottom3">&nbsp;</div>
<div class="dyppop_signtop4">V. President</div><div class="dyppop_signbottom4">&nbsp;</div>
<div class="dyppop_signtop5">President</div><div class="dyppop_signbottom5">&nbsp;</div>
<br><br><br>
<center><h2><u><b>PURCHASE ORDER</b></u></h2></center>
&nbsp;PO# : <?=$hd['po_no'];?> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Date : <?=DateToIndo($hd['po_date']);?>
<br><br>
<div id="popup">
<table width="144%">
	<tr>
		<td colspan="2">
			&nbsp;&nbsp;SUPPLIER &nbsp;: <?=$nama;?><br>
			&nbsp;&nbsp;ADDRES &nbsp;&nbsp;&nbsp;: <?=$alamat;?>
		</td>
		<td colspan="4">
			&nbsp;&nbsp;P.REQN.NO &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?=$hd['po_no'];?><br>
			&nbsp;&nbsp;DELIVERY DATE : <br>
			&nbsp;&nbsp;PAYMENT TERM : <?=$hd['bbt_tipe'];?>
		</td>
	</tr>
	<tr>
		<td colspan="6" align="center">
		<br>
		&nbsp;&nbsp;Please deliver the following items subject to the terms and condition started below :
		<br>&nbsp;<br>
		</td>
	</tr>
	<tr height="40px;">
		<th width="5%">ITEM No.</th>
		<th width="50%">DESCRIPTION OF MATERIALS</th>
		<th width="10%">UNIT</th>
		<th width="10%">QTY</th>
		<th width="10%">UNIT PRICE</th>
		<th width="15%">AMOUNT</th>
	</tr>
    <?php
	$no=0; $tqty=0; $tamount=0;
	$query = mysql_query("SELECT a.id,a.pod_qty,a.pod_price,a.pod_amount,b.prod_code,b.prod_name,b.prod_sat, a.pod_desc
						  FROM purchase_order_detail a
						  INNER JOIN product b ON b.id=a.pod_prodid
						  WHERE a.po_no='$hd[po_no]' AND a.pod_status=10 ORDER BY a.id ASC ");
	while($data=mysql_fetch_array($query)){
		$no++;
		$tqty    = $tqty+$data['pod_qty'];
		$tamount = $tamount+$data['pod_amount'];
	?>
	 <tr>
		<td align="center"><?=$no;?>.</td>
		<td><?=$data['prod_code'];?> : <?=$data['prod_name'];?></td>
		<td align="center"><?=$data['prod_sat'];?></td>
		<td align="right"><?=number_format($data['pod_qty'],2,',','.');?></td>
		<td align="right"><?=number_format($data['pod_price'],2,',','.');?></td>
		<td align="right"><?=number_format($data['pod_amount'],2,',','.');?></td>
	</tr>
	<?php } ?>
	<tr>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
	</tr>
	<tr>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
	</tr>
	<tr>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
	</tr>
	<tr>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
	</tr>
	<tr>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
		<td align="right">&nbsp;</td>
	</tr>
    <tr>
    	<td colspan="3" align="center"><strong>TOTAL</strong></td>
		<td align="right"><strong><?=number_format($tqty,2,',','.');?></strong></td>
		<td>&nbsp;</td>
        <td align="right"><strong><?=number_format($tamount,2,',','.');?></strong></td>
    </tr>
</table>
</div>
<div class="dyppop_note">
	Goods are subject to out inspction upon delivery. Thos delivered not in<br>
	accordance with specification will be returned and not be replaced<br>
	without our intructions. No account shall be paid unless the original copies of<br>
	the invoice and the purchase order are presented.
</div>
<div class="dyppop_salam">
	<b><?=$comp['prof_name'];?></b>
</div>
<br><br><br><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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