<table class="table-dtm table-bordered" style="width:100%; background-color: white; text-align: center">
	<tr>
		<th width="10%">No.</th>
		<th width="35%">Kode</th>
		<th width="20%">NoLot</th>
		<th width="20%">Material</th>
		<th width="15%">Pack</th>
	</tr>
	<?php include "../koneksi.php";
	$no=1;
	$data = mysqli_query ($koneksi, " select 
											stpj.STPJ_ID,
											plan.PlanID,
											plan.DatePlan,
											plan.POOR,
											product.QtyUnit,
											product.SLoc,
											stpj.Kode,
											stpj.Material,
											stpj.NoLot,
											stpj.Nick,
											stpj.Qty
									from 
									stpj 
									INNER JOIN plan
									ON stpj.PlanID=plan.PlanID
									INNER JOIN product
									ON plan.ProductID=product.ProductID
									WHERE stpj.PlanID ='$_POST[id]' AND stpj.Shift='1' AND plan.WH_Conf='0'
									group by stpj.STPJ_ID
									order by stpj.Shift, stpj.Kode, stpj.NoLot ASC");
	
	if(mysqli_num_rows($data)>0) { ?>
	<tr>
		<th colspan="5" style="text-align: center;">SHIFT I</th>
	</tr>

	<?php while($row = mysqli_fetch_array ($data)): ?>
	<td width="10%"><?php echo $no; ?>
			</td>
			<td width="30%" style="text-align: left;">
				<?php echo $row['POOR']; ?>-<?php if ($row['Kode']<10) {
					echo '00'.$row['Kode'];
				} else if ($row['Kode']<100) {
				    echo '0'.$row['Kode'];
				} else {
					echo $row['Kode'];
				} ?>-<?php echo substr(preg_replace('/[^A-Za-z0-9]/', '', $row['DatePlan']), 2, 4); ?>
			</td>
			<td width="20%" style="text-align: left;">
				<?php echo $row['NoLot']; ?>
			</td>
			<td width="15%" style="text-align: left;">
				<?php echo $row['Material']; ?>
			</td>
			<td width="10%" style="text-align: left;">
				<?php 
				if ($row['SLoc']=='NTN2') {
				echo $row['Nick'];
				} else {
				echo $row['Qty'].' ';
				echo substr($row['SLoc'], 0, 3); } ?>
			</td>
		</tr>
			<?php $no++;
			 endwhile;
			 } ?>


	<?php 
	$data1 = mysqli_query ($koneksi, " select 
											stpj.STPJ_ID,
											plan.PlanID,
											plan.DatePlan,
											plan.POOR,
											product.QtyUnit,
											product.SLoc,
											stpj.Kode,
											stpj.Material,
											stpj.NoLot,
											stpj.Nick,
											stpj.Qty
									from 
									stpj 
									INNER JOIN plan
									ON stpj.PlanID=plan.PlanID
									INNER JOIN product
									ON plan.ProductID=product.ProductID
									WHERE stpj.PlanID ='$_POST[id]' AND stpj.Shift='2' AND plan.WH_Conf='0'
									group by stpj.STPJ_ID
									order by stpj.Shift, stpj.Kode, stpj.NoLot ASC");
	

	if(mysqli_num_rows($data1)>0) { ?>
	<tr>
		<th colspan="5" style="text-align: center;">SHIFT II</th>
	</tr>
	<?php while($row1 = mysqli_fetch_array ($data1)): ?>
	<td width="10%"><?php echo $no; ?>
			</td>
			<td width="30%" style="text-align: left;">
				<?php echo $row1['POOR']; ?>-<?php if ($row1['Kode']<10) {
					echo '00'.$row1['Kode'];
				} else if ($row1['Kode']<100) {
				    echo '0'.$row1['Kode'];
				} else {
					echo $row1['Kode'];
				} ?>-<?php echo substr(preg_replace('/[^A-Za-z0-9]/', '', $row1['DatePlan']), 2, 4); ?>
			</td>
			<td width="20%" style="text-align: left;">
				<?php echo $row1['NoLot']; ?>
			</td>
			<td width="15%" style="text-align: left;">
				<?php echo $row1['Material']; ?>
			</td>
			<td width="10%" style="text-align: left;">
				<?php 
				if ($row1['SLoc']=='NTN2') {
				echo $row1['Nick'];
				} else {
				echo $row1['Qty'].' ';
				echo substr($row1['SLoc'], 0, 3); } ?>
			</td>
		</tr>
			<?php $no++;
			 endwhile;
	} ?>
	<?php 
	$data2 = mysqli_query ($koneksi, " select 
											stpj.STPJ_ID,
											plan.PlanID,
											plan.DatePlan,
											plan.POOR,
											product.QtyUnit,
											product.SLoc,
											stpj.Kode,
											stpj.Material,
											stpj.NoLot,
											stpj.Nick,
											stpj.Qty
									from 
									stpj 
									INNER JOIN plan
									ON stpj.PlanID=plan.PlanID
									INNER JOIN product
									ON plan.ProductID=product.ProductID
									WHERE stpj.PlanID ='$_POST[id]' AND stpj.Shift='3' AND plan.WH_Conf='0'
									group by stpj.STPJ_ID
									order by stpj.Shift, stpj.Kode, stpj.NoLot ASC");
	

	if(mysqli_num_rows($data2)>0) { ?>
	<tr>
		<th colspan="5" style="text-align: center;">SHIFT III</th>
	</tr>
	<?php while($row2 = mysqli_fetch_array ($data2)): ?>
	<td width="10%"><?php echo $no; ?>
			</td>
			<td width="30%" style="text-align: left;">
				<?php echo $row2['POOR']; ?>-<?php if ($row2['Kode']<10) {
					echo '00'.$row2['Kode'];
				} else if ($row2['Kode']<100) {
				    echo '0'.$row2['Kode'];
				} else {
					echo $row2['Kode'];
				} ?>-<?php echo substr(preg_replace('/[^A-Za-z0-9]/', '', $row2['DatePlan']), 2, 4); ?>
			</td>
			<td width="20%" style="text-align: left;">
				<?php echo $row2['NoLot']; ?>
			</td>
			<td width="15%" style="text-align: left;">
				<?php echo $row2['Material']; ?>
			</td>
			<td width="10%" style="text-align: left;">
				<?php 
				if ($row2['SLoc']=='NTN2') {
				echo $row2['Nick'];
				} else {
				echo $row2['Qty'].' ';
				echo substr($row2['SLoc'], 0, 3); } ?>
			</td>
		</tr>
			<?php $no++;
			 endwhile;
	} ?>
</table>