<?php 
include "../../include/config.php"; 
include "../../function/inc_function.php"; 
$po_no = isset($_REQUEST['po_no']) ? $_REQUEST['po_no'] :'';
$hd = mysql_fetch_object(mysql_query("SELECT a.*,b.sup_name, b.sup_address, b.sup_city, c.cust_name, c.cust_address, c.cust_city 
	 FROM purchase_order a LEFT JOIN supplier b ON b.id=a.po_idsupp 
	 LEFT JOIN customer c ON c.id=a.po_idcust WHERE a.po_no='$po_no'"));
	 if($hd->po_type=="Purchasiing"){
		 $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_object(mysql_query("SELECT prof_city FROM profil"));	
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href="../../include/css/print_styles.css" />	
</head>
<body>
<div id="popup">
<h3 align="center">PURCHASE ORDER SALES</h1>
<h5>Nomor:<?=$hd->po_no;?>  Tanggal:<?=DateToIndo($hd->po_date);?> </h5>
<hr size="3"></hr>
<p id="text1">
	Kepada Yth.<br>
	<?=$nama;?>	<br>
	<?=$alamat;?>	<br>
	<?=$kota;?> <br><br>
	Bersama dengan ini kami sampaikan purchase order dengan sejumlah barang sebagai berikut:	
</p>
<table width="100%">
	<tr>
	</tr>
	<tr>
		<th>No.</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Jumlah</th>
		<th>Harga</th>
		<th>Total</th>
		<th>Satuan</th>
	</tr>
    <?php
	$no=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
						  FROM purchase_order_detail a
						  INNER JOIN product b ON b.id=a.pod_prodid
						  WHERE a.po_no='$hd->po_no' ");
	while($data=mysql_fetch_object($query)){
		$no++;
		$tamount = $tamount+$data->pod_amount;
	?>
	 <tr>
		<td align="center"><?=$no;?>.</td>
		<td><?=$data->prod_code;?></td>
		<td><?=$data->prod_name;?></td>
		<td align="right"><?=$data->pod_qty;?></td>
		<td align="right"><?=number_format($data->pod_price,2,',','.');?></td>
		<td align="right"><?=number_format($data->pod_amount,2,',','.');?></td>
		<td align="center"><?=$data->prod_sat;?></td>
	</tr>
	<?php } ?>
    <tr>
    	<td colspan="5" align="right"><strong>Total</strong></td>
        <td align="right"><strong><?=number_format($tamount,2,',','.');?></strong></td>
        <td>&nbsp;</td>
    </tr>
</table>
<p id="text1">
	Atas perhatian dan kerjasamanya disampaikan terima kasih.<br>
	<?php echo "$comp->prof_city, ".DateToIndo($hd->po_date)."";  ?><br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hormat kami <br><br><br><br><br><br>
	(............................................)
	
</p>
</div>
</body>
</html>
