<?php include "../koneksi.php";
$data1 = mysqli_query ($koneksi, " SELECT NoPBB_ID2,
										POOR
										 from plan where PlanID='$_GET[id]'");
$row1 = mysqli_fetch_array($data1);
if($row1['NoPBB_ID2']>0) { ?>
<table class="table table-bordered">
		<tr>
			<th width="5%" >
				#
			</th>
			<th width="30%">
				LOT
			</th>
			<th width="20%">
				BAG
			</th>
			<th width="20%">
				Date
			</th>
		
		</tr>
			<?php 
			$data2 = mysqli_query ($koneksi, " select product.Pewarna
												from 
												plan
												INNER JOIN product
												ON plan.ProductID=product.ProductID
												WHERE PlanID ='$_GET[id]'");
				$row2 = mysqli_fetch_array ($data2);
				$data = mysqli_query ($koneksi, " SELECT pbb.PBB_ID,
															pbb.PlanID,
															pbb.Lot,
															pbb.Bag,
															incoming.MaterialID,
															incoming.Date_Inc
												FROM pbb
												INNER JOIN incoming
												ON pbb.IncomingID=incoming.IncomingID
												INNER JOIN material
												ON incoming.MaterialID=material.MaterialID
												WHERE material.MaterialID='13' AND pbb.NoPBB_ID IS NULL
                                				Order by incoming.Date_Inc, pbb.Bag, pbb.Lot ASC");
	

				while($row = mysqli_fetch_array ($data)): ?>
		<tr>
			<td width="5%" >
				<a href="out.php?id=<?php echo $row['PBB_ID']; ?>&plan_id=<?php echo $_GET['id']; ?>&nopbbid=<?php echo $row1['NoPBB_ID2']; ?>&poor=<?php echo $row1['POOR']; ?>" style="color: black;" ><i class="bi bi-arrow-left-square-fill"></i></a>
			</td>
			<td width="30%">
				<?php echo $row['Lot']; ?>
			</td>
			<td width="20%">
				<?php echo $row['Bag']; ?>
			</td>
			<td width="20%">
				<?php echo date ("d-m-Y", strtotime($row['Date_Inc'])); ?>
			</td>

		</tr>
			<?php endwhile; ?>
	</table>
<?php } else {} ?>