<?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:1px solid black;
      }
      .table-print tr th{
            border:1px solid black;
      }
    }
     </style>
<body style="font-size: 11px">

<?php
	$data0 = 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,
                                            material.NoMat,
                                            plan.POOR,
                                            plan.NoPBB_ID,
                                            no_pbb.No_PBB
                                    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
                                    INNER JOIN no_pbb
                                    ON plan.NoPBB_ID=no_pbb.NoPBB_ID
                                    WHERE PlanID ='$_GET[id]'");
    $row0 = mysqli_fetch_array ($data0);
    
    $data1 = mysqli_query ($koneksi, "SELECT sum(material.Qty) as Qty
                                      FROM pbb
                                      INNER JOIN incoming
                                      ON pbb.IncomingID=incoming.IncomingID
                                      INNER JOIN material
                                      ON incoming.MaterialID=material.MaterialID
                                      WHERE pbb.NoPBB_ID='$row0[NoPBB_ID]'
                                      ORDER BY pbb.Lot, pbb.Bag ASC");
    $row1 = mysqli_fetch_array ($data1);
?>
<table class="table-print" style="width:100%; text-align: center;">
  <tr>
  <td width="20%" rowspan="4">
    <img src="../image/logo.png" alt="" width="45" height="40"><br>
    <text style='font-size: 9px; font-weight: bold; letter-spacing: -0.5px;'>PT. INDO TIRTA ABADI</text><br>
    <text style='font-size: 8px; font-weight: bold; letter-spacing: -0.5px;'>DEPARTEMENT WAREHOUSE</text>
  </td>
  <td width="80%" colspan="2" style="text-align: center;">
    <text style="font-size: 16px;">PENYERAHAN BAHAN BAKU</text>
  </td>
  </tr>
   	<tr>
      <td width="40%" style="text-align: left; font-size: 11px;  padding-left: 5px;">NO :  <?php echo $row0['No_PBB']; ?></td>
   		<td width="40%" style="text-align: left; font-size: 11px;  padding-left: 5px;">TANGGAL :  <?php echo date ("d-m-Y", strtotime( $row0['DatePlan'])); ?></td>
   	</tr>
  <tr>
    <td  style="text-align: left; font-size: 11px;  padding-left: 5px;">Type Mesin  :  <?php echo $row0['Mesin']; ?></td>
    <td style="text-align: left; font-size: 11px;  padding-left: 5px;">Jumlah  :  <?php echo number_format($row1['Qty'],0,"","."); ?></td>
  </tr>
  <tr>
    <td style="text-align: left; font-size: 11px;  padding-left: 5px;">Jenis Bahan Baku  :  <?php echo $row0['RawMat']; ?></td>
    <td style="text-align: left; font-size: 11px;  padding-left: 5px;">Kode Barang  :  <?php echo $row0['NoMat']; ?></td>
  </tr>
</table>
<table class="table-print" style="width:100%; text-align: center; font-size: 11px;">
		<tr>
      <th>No</th>
      <th>No. Bag Bahan Baku</th>
      <th>Qty/ Bag</th>
      <th>Keterangan</th>
    </tr>
<?php 
	$no = 1;
	$data = mysqli_query ($koneksi, " SELECT pbb.PBB_ID,
												pbb.IncomingID,
												incoming.MaterialID,
												incoming.Date_Inc,
												material.Qty,
												pbb.Lot,
												pbb.Material,
												pbb.Bag
									FROM pbb
									INNER JOIN incoming
									ON pbb.IncomingID=incoming.IncomingID
									INNER JOIN material
									ON incoming.MaterialID=material.MaterialID
									WHERE pbb.NoPBB_ID='$row0[NoPBB_ID]'
									ORDER BY pbb.Lot, pbb.Bag ASC");

	while($row = mysqli_fetch_array ($data)): ?>
		<tr>
			<td width="10%">
				<?php echo $no++; ?>
			</td>
			<td width="40%" style="text-align: left; padding-left: 5px;">
				<?php echo $row['Lot']; ?>&emsp;-&emsp;
				<?php echo $row['Bag']; ?>
			</td>
			<td width="15%">
				<?php echo number_format($row['Qty'],0,"","."); ?>
			</td>
			<td width="25%" style="text-align: right">
				<?php echo $row['Material']; ?>&emsp;&emsp;
				<?php echo date ("d/m/Y", strtotime($row['Date_Inc'])); ?>&emsp;&emsp;
			</td>
		</tr>
			<?php endwhile; ?>
    <tr>
      <th colspan='2'>TOTAL</th>
      <th><?php echo number_format($row1['Qty'],0,"","."); ?></th>
      <th></th>
    </tr>
	</table>

  <table class="table-print" style="width:100%; margin-top: 15px; text-align: center;">
    <tr>
      <td width="20%">
        Diserahkan
      </td>
      <td width="20%">
        Diketahui
      </td>
      <td width="20%">
        Diterima
      </td>
      <td rowspan="3" width="40%" style="text-align: left;" valign="top">Catatan :</td>
    </tr>
    <tr>
      <td height="50px"></td>
      <td height="50px"></td>
      <td height="50px"></td>
    </tr>
    <tr>
      <td>Harun S.</td>
      <td>Harun S.</td>
      <td>Harun S.</td>
    </tr>
  </table>

  <span style="font-size: 13px; letter-spacing: 0.7px;">012/FORM-GPL/SOP1001/WH/REV.01</span>


</body>
</html>