<?php include "../koneksi.php"; ?>
<table class="table table-bordered" style="width:100%">
		<tr>
			<th width="30%">
				No Lot
			</th>
			<th width="30%" colspan="2">
				Quantity
			</th>
			<th width="40%" colspan="2">
				Description
			</th>
		</tr>
		<?php
		$data2 = mysqli_query ($koneksi, " SELECT 
				stpj.STPJ_ID,
				product.SLoc,
				product.QtyUnit,
				stpj.NoLot,
				sum(stpj.Qty) AS qty
		FROM stpj 
		INNER JOIN plan
		ON stpj.PlanID=plan.PlanID
		INNER JOIN product
		ON plan.ProductID=product.ProductID
		where stpj.Del_ID=$_POST[id]
		GROUP BY stpj.NoLot");

		while($row2 = mysqli_fetch_array ($data2)): ?>
		<tr>
			<td width="30%">
				<?php echo $row2['NoLot']; ?>
			</td>
			<td width="15%">
				<?php echo $row2['qty']; ?>
			</td>
			<td width="15%">
        		<?php echo substr($row2['SLoc'], 0, 3); ?>
			</td>
			<td width="20%">
				<?php echo number_format($row2['qty']*$row2['QtyUnit'],0,".","."); ?>
			</td>
			<td width="20%">
				PCS
			</td>
		</tr>
		<?php endwhile; ?>
		</table>
		<table class="table table-bordered" style="width:100%">
		<?php
		$data1 = mysqli_query ($koneksi, " SELECT 
				stpj.STPJ_ID,
				product.SLoc,
				product.QtyUnit,
				stpj.NoLot,
				sum(stpj.Qty) AS qty
		FROM stpj 
		INNER JOIN plan
		ON stpj.PlanID=plan.PlanID
		INNER JOIN product
		ON plan.ProductID=product.ProductID
		where stpj.Del_ID=$_POST[id]");

		$row1 = mysqli_fetch_array ($data1); ?>
		<tr>
			<th width="30%">
				TOTAL
			</th>
			<th width="30%" colspan="2">
				<?php echo $row1['qty']; ?>
				<?php echo substr($row1['SLoc'], 0, 3); ?>
			</th>
			<th width="40%" colspan="2">
				<?php echo $row1['qty']*$row1['QtyUnit']; ?>
				PCS
			</th>
		</tr>
	</table>