<?php include "../koneksi.php"; ?>
<!DOCTYPE html>
<!-- Designined by CodingLab | www.youtube.com/codinglabyt -->
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="bootstrap.css">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
   </head>
   <style type="text/css">
    @media all{
      .table-print tr td{
            border-bottom: 1px solid #ddd;
      }
      .table-print tr th{
            border-bottom: 1px solid black;
      }
      .table-borderprint tr td{
            border:1px solid black;
      }
      .table-borderprint tr th{
            border:1px solid black;
      }
    }
	</style>
<body style="font-size: 14px">
		<h4 style="text-align: center">CEK LIST BAHAN BAKU</H4>
<?php 
$data1 = mysqli_query ($koneksi, " SELECT incoming.IncomingID,
                                          incoming.Date_Inc,
                                          incoming.MaterialID,
                                          material.RawMat,
                                          material.Qty,
                                          incoming.Supplier,
                                          incoming.No_SJ,
                                          incoming.Qty_Inc,
                                          incoming.`Desc`
                                      FROM incoming
                                      INNER JOIN material
                                      ON incoming.MaterialID=material.MaterialID
                                      WHERE IncomingID ='$_GET[id]'");

$row1 = mysqli_fetch_array ($data1)
?>

<table style="width:100%; font-size: 13px">
<tr>
	<td width="15%">
				Tanggal
	</td>
	<td width="40%">
		<?php echo date ("d-m-Y", strtotime( $row1['Date_Inc'])); ?>
	</td>
</tr>
<tr>
	<td width="15%">
				No Surat Jalan
	</td>
	<td width="40%">
		<?php echo $row1['No_SJ']; ?>
	</td>
</tr>
<tr>
	<td width="15%">
				No BPB
	</td>
	<td width="40%">
		<?php echo $row1['No_SJ']; ?>
	</td>
</tr>
<tr>
	<td width="15%">
				Jenis Bahan Baku
	</td>
	<td width="40%">
		<?php echo $row1['RawMat']; ?>
	</td>
</tr>
<tr>
	<td width="15%">
				Supplier
	</td>
	<td width="40%">
		<?php echo $row1['Supplier']; ?>
	</td>
</tr>
<tr>
	<td width="15%">
				Jumlah Bag
	</td>
	<td width="40%">
		<?php echo $row1['Qty_Inc']/$row1['Qty']; ?>
		JB
	</td>
</tr>
<tr>
	<td width="15%">
				Total
	</td>
	<td width="40%">
		<?php echo $row1['Qty_Inc']; ?>
	</td>
</tr>
</table>
<?php if($row1['MaterialID']==='1' || $row1['MaterialID']==='2' ) { ?>
<table class="table-print" style="width:100%; text-align: left; font-size: 12px">
	<thead>
		<tr>
			<th width="10%">
				No.
			</th>
			<th width="30%">
				No Bag/No Lot
			</th>
			<th width="40%">
				Tanggal Pemakaian
			</th>
			<th width="20%">
				Keterangan
			</th>
		</thead>
		</tr>
			<?php
				$no = 1;
				$data = mysqli_query ($koneksi, " SELECT pbb.PBB_ID,
															pbb.IncomingID,
															incoming.MaterialID,
															pbb.NoPBB_ID,
															pbb.Lot,
															pbb.Bag,
															pbb.Batch,
															pbb.Material
												FROM pbb
												INNER JOIN incoming
												ON pbb.IncomingID=incoming.IncomingID
												WHERE pbb.IncomingID='$_GET[id]'
												ORDER BY pbb.Lot, pbb.Bag ASC");

				while($row = mysqli_fetch_array ($data)): ?>
		<tr>
			<td width="10%">
				<?php echo $no++; ?>
			</td>
			<td width="30%">
				<?php echo $row['Bag']; ?>&emsp;
				<?php echo $row['Batch']; ?>&emsp;
				<?php echo $row['Lot']; ?>
			</td>
			<td width="40%">
				<?php $data1 = mysqli_query ($koneksi, " SELECT DatePlan
												FROM plan WHERE NoPBB_ID='$row[NoPBB_ID]'");
				$row1 = mysqli_fetch_array ($data1);
				echo $row1['DatePlan']; ?>
			</td>
			<td width="20%">
				<?php echo $row['Material']; ?>
			</td>
		</tr>
			<?php endwhile; ?>
	</table>
	<?php } else { ?>
	<table class="table-print" style="width:100%; text-align: left; font-size: 12px">
	<thead>
		<tr>
			<th width="10%">
				No.
			</th>
			<th width="30%">
				No Bag/No Lot
			</th>
			<th width="30%">
				Tanggal Pemakaian
			</th>
			<th width="30%">
				Keterangan
			</th>
		</thead>
		</tr>
			<?php
				$no = 1;
				$data = mysqli_query ($koneksi, " SELECT pbb.PBB_ID,
															pbb.IncomingID,
															incoming.Date_Inc,
															incoming.MaterialID,
															pbb.NoPBB_ID,
															pbb.Lot,
															pbb.Bag,
															pbb.Material
												FROM pbb
												INNER JOIN incoming
												ON pbb.IncomingID=incoming.IncomingID
												WHERE pbb.IncomingID='$_GET[id]'
												ORDER BY pbb.Lot, pbb.Bag ASC");

				while($row = mysqli_fetch_array ($data)): ?>
		<tr>
			<td width="10%">
				<?php echo $no++; ?>
			</td>
			<td width="30%">
				<?php echo $row['Lot']; ?>-<?php echo $row['Bag']; ?>&emsp;<?php echo substr(preg_replace('/[^A-Za-z0-9]/', '', $row['Date_Inc']), 2, 4); ?>
			</td>
			<td width="40%">
				<?php $data1 = mysqli_query ($koneksi, " SELECT DatePlan
												FROM plan WHERE NoPBB_ID='$row[NoPBB_ID]'");
				$row1 = mysqli_fetch_array ($data1);
				echo $row1['DatePlan']; ?>
			</td>
			<td width="35%">
			</td>
		</tr>
			<?php endwhile; ?>
	</table>
	<?php } ?>
	<table class="table-print" style="width:100%">
	<thead><tr><th></th></thead>
	</table>
	<table  style="width:100%">
		<td width="25%">
		<table class="table-borderprint" style="width:15%; margin-top: 15px;">
		<tr>
			<td width="100%" height="50px">
			</td>
		</tr>
	</table>
	<span style="font-size: 10px; font-style: italic;" >004/FORM-GPL/SOP 1001/WH/REV.01</span>
	</td>
				</td>
</body>
</html>