<?php include "../koneksi.php"; ?>
<table class="table table-bordered" style="width:100%;">
		<tr>
			<th width="15%" rowspan="2">
				Date Plan
			</th>
			<th width="30%" rowspan="2">
				Product
			</th>
			<th width="20%" colspan="2">
				Plan
			</th>
			<th width="20%" colspan="2">
				Actual
			</th>
			<th width="15%" rowspan="2">
				Packaging
			</th>
		</tr>
		<tr>
			<th>Pack</th>
			<th>Qty</th>
			<th>Pack</th>
			<th>Qty</th>
		</tr>
		<?php 
		$data = mysqli_query ($koneksi, "SELECT plan.DatePlan,
												product.ItemDescription,
												product.SLoc,
												plan.QtyPlan,
												SUM(stpj.Qty) AS Qty,
												product.QtyUnit
										FROM plan
										INNER JOIN product
										ON plan.ProductID=product.ProductID
										INNER JOIN stpj
										ON stpj.PlanID=plan.PlanID
										WHERE MONTH(DatePlan)='$_POST[bln]' && YEAR(DatePlan)='$_POST[thn]' && plan.ProductID='$_POST[prod]'
										GROUP BY product.ProductID, plan.DatePlan
										ORDER BY plan.DatePlan ASC");
						
		while($row = mysqli_fetch_array ($data)):
		?>
		<tr>
			<td><?php echo date ("d-m-Y", strtotime($row['DatePlan'])); ?></td>
			<td><?php echo $row['ItemDescription'] ?></td>
			<td><?php echo $row['QtyPlan'] ?></td>
			<td><?php echo number_format($row['QtyPlan']*$row['QtyUnit'],0,".","."); ?></td>
			<td><?php echo $row['Qty'] ?></td>
			<td><?php echo number_format($row['Qty']*$row['QtyUnit'],0,".","."); ?></td>
			<td><?php echo $row['SLoc'] ?></td>

		</tr>
		<?php endwhile; ?>
</table>

