<?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>
<body style="font-size: 11px">

<?php
	$data = mysqli_query ($koneksi, " select 
                                            plan.PlanID,
                                            plan.DatePlan,
                                            plan.MesinID,
                                            mesin.Mesin,
                                            plan.ProductID,
                                            product.ItemDescription,
                                            product.SLoc,
                                            product.QtyUnit,
                                            plan.QtyPlan,
                                            plan.Prioritas,
                                            plan.MaterialID,
                                            material.RawMat,
                                            plan.POOR
                                    from 
                                    plan
                                    INNER JOIN mesin
                                    ON plan.MesinID=mesin.MesinID
                                    INNER JOIN product
                                    ON plan.ProductID=product.ProductID
                                    INNER JOIN material
                                    ON plan.MaterialID=material.MaterialID
                                    WHERE PlanID ='$_GET[id]'");
    $row = mysqli_fetch_array ($data);
?>
<table class="table table-bordered">
   	<tr >
   		<td width="30%" colspan="2"><text style="font-size: 13px; font-weight: bold;">SERAH TERIMA PRODUK JADI</text></td>
   	</tr>
  	<tr>
  		<th colspan="2">
<table class="table">
   	<tr>
     <td width="50%" style="text-align: left; padding-left: 120px">POOR:  <?php echo $row['POOR']; ?></td>
      <td width="50%" style="text-align: left; padding-left: 120px">KEMASAN :  <?php echo $row['SLoc']; ?>&ensp;<?php echo $row['QtyUnit']; ?></td>
   	</tr>
   	<tr>
      <td width="50%" style="text-align: left; padding-left: 120px">PRODUCT NAME:  <?php echo $row['ItemDescription']; ?></td>
      <td width="50%" style="text-align: left; padding-left: 120px">MATERIAL :  <?php echo $row['RawMat']; ?></td>
   	</tr>
</table>
		</th>
</tr>
</table>
<table class="table">
<td>
<table class="table table-bordered">
  <tr>
    <th colspan='5'>SHIFT I</th>
  </tr>
  <tr>
    <th>NO</th>
    <th>MATERIAL</th>
    <th>NO. PRODUKSI</th>
    <th>JUMLAH</th>
    <th><?php echo substr($row['SLoc'], 0, 3); ?></th>
  </tr>
  <tr>
  <?php
  $no1 = 1;
	$data1 = mysqli_query ($koneksi, " select 
														stpj.STPJ_ID,
														plan.PlanID,
														plan.DatePlan,
														plan.POOR,
														product.QtyUnit,
														product.SLoc,
														stpj.Material,
														stpj.Shift,
														stpj.Kode,
														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 ='$_GET[id]' AND stpj.Shift ='1'
												order by stpj.NoLot ,stpj.Kode ASC
												");

				while($row2 = mysqli_fetch_array ($data1)): 
			
			?>
		<tr>
			<td width="10%">
				<?php echo $no1++; ?>
			</td>
			<td width="20%">
				<?php echo $row2['Material']; ?>
			</td>
			<td width="30%">
				<?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); ?>-<?php echo $row2['NoLot']; ?>
			</td>
			<td width="15%">
				<?php echo $row2['QtyUnit']; ?>
			</td>
			<td width="15%">
				<?php
				if($row['SLoc']=='NTN2') {
					echo $row2['Nick'];
				 } else {
				 echo $row2['Qty'];
				} 
				?> 
			</td>
		</tr>
			<?php endwhile; ?>
</table>
</td>
<td>
<table class="table table-bordered">
  <tr>
    <th colspan='5'>SHIFT II</th>
  </tr>
  <tr>
    <th>NO</th>
    <th>MATERIAL</th>
    <th>NO. PRODUKSI</th>
    <th>JUMLAH</th>
    <th><?php echo substr($row['SLoc'], 0, 3); ?></th>
  </tr>
  <tr>
  <?php
  $no2 = 1;
	$data2 = mysqli_query ($koneksi, " select 
														stpj.STPJ_ID,
														plan.PlanID,
														plan.DatePlan,
														plan.POOR,
														product.QtyUnit,
														product.SLoc,
														stpj.Material,
														stpj.Shift,
														stpj.Kode,
														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 ='$_GET[id]' AND stpj.Shift ='2'
												order by stpj.NoLot ,stpj.Kode ASC
												");

				while($row2 = mysqli_fetch_array ($data2)): 
			
			?>
		<tr>
			<td width="10%">
				<?php echo $no2++; ?>
			</td>
			<td width="20%">
				<?php echo $row2['Material']; ?>
			</td>
			<td width="30%">
				<?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); ?>-<?php echo $row2['NoLot']; ?>
			</td>
			<td width="15%">
				<?php echo $row2['QtyUnit']; ?>
			</td>
			<td width="15%">
				<?php
				if($row['SLoc']=='NTN2') {
					echo $row2['Nick'];
				 } else {
				 echo $row2['Qty'];
				} 
				?> 
			</td>
		</tr>
			<?php endwhile; ?>
</table>
</td>
<td>
<table class="table table-bordered">
  <tr>
    <th colspan='5'>SHIFT III</th>
  </tr>
  <tr>
    <th>NO</th>
    <th>MATERIAL</th>
    <th>NO. PRODUKSI</th>
    <th>JUMLAH</th>
    <th><?php echo substr($row['SLoc'], 0, 3); ?></th>
  </tr>
  <tr>
  <?php
  $no3 = 1;
	$data3 = mysqli_query ($koneksi, " select 
														stpj.STPJ_ID,
														plan.PlanID,
														plan.DatePlan,
														plan.POOR,
														product.QtyUnit,
														product.SLoc,
														stpj.Material,
														stpj.Shift,
														stpj.Kode,
														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 ='$_GET[id]' AND stpj.Shift ='3'
												order by stpj.NoLot ,stpj.Kode ASC
												");

				while($row3 = mysqli_fetch_array ($data3)): 
			
			?>
		<tr>
			<td width="10%">
				<?php echo $no3++; ?>
			</td>
			<td width="20%">
				<?php echo $row3['Material']; ?>
			</td>
			<td width="30%">
				<?php if ($row3['Kode']<10) {
					echo '00'.$row3['Kode'];
				} else if ($row3['Kode']<100) {
				    echo '0'.$row3['Kode'];
				} else {
					echo $row3['Kode'];
				} 
				?>-<?php echo substr(preg_replace('/[^A-Za-z0-9]/', '', $row3['DatePlan']), 2, 4); ?>-<?php echo $row3['NoLot']; ?>
			</td>
			<td width="15%">
				<?php echo $row3['QtyUnit']; ?>
			</td>
			<td width="15%">
				<?php
				if($row['SLoc']=='NTN2') {
					echo $row3['Nick'];
				 } else {
				 echo $row3['Qty'];
				} 
				?> 
			</td>
		</tr>
			<?php endwhile; ?>
</table>
</td>
</table>
</body>
</html>