<?php
include "../include/config.php";
include "../function/inc_function.php";
$kv_id = isset($_REQUEST['kv_id']) ? $_REQUEST['kv_id'] : '';
$hd   = mysql_fetch_object(mysql_query("SELECT a.* ,c.prod_code, c.prod_name, c.prod_sat FROM konversi_barangjadi a 
	    INNER JOIN product c ON c.id=a.kv_prodid WHERE a.id='$kv_id'"));
$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">KONVERSI BARANG JADI</h1>
			<h5>Nomor:<?= $hd->kv_no; ?> Tanggal:<?= DateToIndo($hd->kv_date); ?> </h5>
			<hr size="3">
			</hr>
			<p id="text1">
				Dari :<br>
				<?= $hd->kv_pic; ?><br>
				Bersama dengan ini kami sampaikan telah proses konversi barang jadi sejumlah barang sebagai berikut:<br>
				Barang : <?= $hd->prod_code; ?>-<?= $hd->prod_name; ?> Sejumlah : <?= number_format($hd->kv_qty, 2, '.', ','); ?> <?= $hd->prod_sat; ?>
			</p>
			<table width="100%">
				<tr>
				</tr>
				<tr>
					<th>No.</th>
					<th>Kode Barang</th>
					<th>Nama Barang</th>
					<th>Jumlah</th>
					<th>Satuan</th>
				</tr>
				<?php
				$no = 0;
				$query = mysql_query("SELECT a.*, b.prod_code,b.prod_name,b.prod_sat
						  FROM konversi_barangjadi_detail a
						  INNER JOIN product b ON b.id=a.kvd_prodid
						  WHERE a.kvd_hid='$kv_id' ");
				while ($data = mysql_fetch_object($query)) {
					$no++;
				?>
					<tr>
						<td align="center"><?= $no; ?>.</td>
						<td><?= $data->prod_code; ?></td>
						<td><?= $data->prod_name; ?></td>
						<td align="right"><?= number_format($data->kvd_qty, 2, '.', ','); ?></td>
						<td align="center"><?= $data->prod_sat; ?></td>
					</tr>
				<?php } ?>
			</table>
			<p id="text1">
				Atas perhatian dan kerjasamanya disampaikan terima kasih.<br>
				<?= $comp->prof_city; ?>, <?= DateToIndo($hd->kv_date); ?><br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hormat kami <br><br><br><br><br><br>
				(............................................)

			</p>
	</div>
</body>

</html>