<?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: 12px">
<table class="table" style="width:100%">
	<td width="30%">
	</td>
	<td width="50%"></td>
	<td width="20%" height="50px">
		<span style="font-family: Roman17cpi; font-size: 16px; font-weight: bold;">Delivery Note</span>
	</td>
</table>
<table style="width:100%; font-family: Roman12cpi;">
<tr style="font-weight: bold" >
	<td width="70%"></td>
	<td width="30%">
		Jl. Raya Surabaya-Malang Km.40.5<br>
		Desa Ngerong Kec. Gempol<br>
		Pasuruan Jawa Timur 67155<br>
		Indonesia<br>
		Tel: +62 21 5930 6880<br>
		Fax: +62 21 5930 6882
	</td>
</tr>
</table>
<table class="table" style="width:100%; margin-top: 30px;">
	<thead><tr><th></th></thead>
</table>

<?php 
        $data1 = mysqli_query ($koneksi, " select 
                              deliverytbl.Del_ID,
                              deliverytbl.DateKirim,
                              deliverytbl.DetailPO_ID,
                              detail_po.PO_ID,
                              po_tbl.No_PO,
                              po_tbl.TanggalPO,
                              po_tbl.CustomerID,
                              customer.CustomerName,
                              customer.CustomerNo,
                              customer.Alamat,
                              customer.Sales,
                              customer.TOD,
                              customer.Kota,
                              customer.HO_ID,
                              ho_tbl.HO_Customer,
                              ho_tbl.No_HO,
                              ho_tbl.Alamat_HO,
                              detail_po.ProductID,
                              product.Material,
                              product.ItemDescription,
                              product.SLoc,
                              product.QtyUnit,
                              deliverytbl.DetailEkspedisi_ID,
                              detailekspedisi.EkspedisiID,
                              ekspedisi.Ekspedisi,
                              detailekspedisi.Sopir,
                              detailekspedisi.NoPolisi,
                              detailekspedisi.NoHP,
                              deliverytbl.NoDN,   
                              deliverytbl.QtyKirim,
                              deliverytbl.Expedisi,
                              deliverytbl.Cont,
                              deliverytbl.Seal    
                      from 
                      deliverytbl
                      INNER JOIN detail_po
                      ON deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
                      INNER JOIN po_tbl
                      ON detail_po.PO_ID=po_tbl.PO_ID
                      INNER JOIN customer
                      ON po_tbl.CustomerID=customer.CustomerID
                      INNER JOIN product
                      ON detail_po.ProductID=product.ProductID
                      INNER JOIN detailekspedisi
                      ON deliverytbl.DetailEkspedisi_ID=detailekspedisi.DetailEkspedisi_ID
                      INNER JOIN ho_tbl
                      ON customer.HO_ID=ho_tbl.HO_ID
                      INNER JOIN ekspedisi
                      ON detailekspedisi.EkspedisiID=ekspedisi.EkspedisiID
                      WHERE Del_ID ='$_GET[id]'");
        
    	$row1 = mysqli_fetch_array ($data1)
      ?>

<table style="width:100%; font-family: Roman17cpi; margin-top: 5px;">
	<tr style="font-weight: bold; font-size: 14px;">
			<td width="22%">
				Document No.
			</td>
			<td width="22%">
				Document Date
			</td>
			<td width="22%">
				Delivery Date
			</td>
			<td width="22%">
				Arrival Time
			</td>
			<td width="12%">
				SO Number
			</td>
	</tr>
	<tr style="font-size: 14px;">
			<td width="22%">
				<?php echo $row1['NoDN']; ?>
			</td>
			<td width="22%">
				<?php echo date ("d.m.Y", strtotime($row1['DateKirim'])); ?>
			</td>
			<td width="22%">
				<?php echo date ("d.m.Y", strtotime($row1['DateKirim'])); ?>
			</td>
			<td width="22%">
				10:00:00
			</td>
			<td width="20%">
				987654332
			</td>
	</tr>
</table>
<table class="table" style="width:100%; margin-top: 5px;">
	<thead><tr><th></th></thead>
</table>
<table style="width:100%; height: 150px">
	<tr><td valign="top">
<table style="width:100%; font-family: Roman12cpi; margin-top: 5px;">
	<tr style="font-weight: bold">
			<td width="10%">
				Customer:
			</td>
			<td width="20%">
				ITA FOC
			</td>
			<td width="17%"></td>
			<td width="9%">
				Ship to:
			</td>
			<td width="20%">
				<?php echo $row1['CustomerNo']; ?>
			</td>
			<td width="23%">
			</td>
	</tr>
	<tr style="font-weight: bold">
			<td width="10%">
				
			</td>
			<td width="20%" colspan="2" >
				PT. INDO TIRTA ABADI
			</td>
			<td width="9%"></td>
			<td width="20%" colspan="2">
				<?php echo $row1['CustomerName']; ?>
			</td>
			<td width="23%">
			</td>
	</tr>
	<tr style="font-weight: bold">
			<td width="10%">
				
			</td>
			<td width="25%" valign="top" colspan="2">
				Kawasan Industri Jatake<br>
				Banten 15710<br>
				Indonesia<br>
				Tel: +62 21 5930 6880
			</td>
			<td width="9%"></td>
			<td width="25%" valign="top" colspan="2">
				<?php echo $row1['Alamat']; ?>
			</td>
			<td width="20%">
			</td>
	</tr>
</table>
	</td></tr>
</table>
<table class="table" style="width:100%; margin-top: 5px;">
	<thead><tr><th></th></thead>
</table>
<table style="width:100%; font-family: Roman12cpi; margin-top: 5px;">
	<tr>
			<td width="15%">
				Sales Person
			</td>
			<td width="20%">
				: <?php echo $row1['Sales']; ?>
			</td>
			<td width="17%"></td>
			<td width="9%"></td>
			<td width="20%">
			</td>
			<td width="23%">
			</td>
	</tr>
	<tr>
			<td width="15%">
				Terms of delivery
			</td>
			<td width="20%">
				: <?php echo $row1['TOD']; ?>
			</td>
			<td width="17%"></td>
			<td width="9%"></td>
			<td width="20%">
			</td>
			<td width="23%">
			</td>
	</tr>
	<tr>
			<td width="13%">
			</td>
			<td width="20%">
				&ensp;<?php echo $row1['Kota']; ?>
			</td>
			<td width="17%"></td>
			<td width="9%"></td>
			<td width="20%">
			</td>
			<td width="23%">
			</td>
	</tr>
</table>

<table style="width:100%; font-family: Roman12cpi;">
<tr>
	<td width="50%">
				<?php echo $row1['Expedisi']; ?>
	</td>
	<td width="50%"></td>
</tr>
<tr>
	<td width="50%">
				<?php echo $row1['Cont']; ?>
	</td>
	<td width="50%"></td>
</tr>
<tr>
	<td width="50%">
				<?php echo $row1['Seal']; ?>
	</td>
	<td width="50%"></td>
</tr>
<tr>
	<td width="50%">
		007/FORM-CORP/SOP0901/PL/REV.01			
	</td>
	<td width="50%"></td>
</tr>
</table>
<table class="table" style="width:100%; margin-top: 5px;">
	<thead><tr><th></th></thead>
</table>
<table style="width:100%; font-family: Roman17cpi; margin-top: 5px;">
	<tr style="font-weight: bold; font-size: 14px;" >
			<td width="10%">
				Item
			</td>
			<td width="10%">
				DG
			</td>
			<td width="30%">
				Material No.
			</td>
			<td width="20%">
				PO No.
			</td>
			<td width="15%">
				Batch No.
			</td>
			<td width="15%">
				Quantity
			</td>
	</tr>
	<tr style="font-weight: bold; font-size: 14px;">
			<td width="10%"></td>
			<td width="10%">
				Trem
			</td>
			<td width="30%">
				Description
			</td>
			<td width="20%">
				PO Date
			</td>
			<td width="15%"></td>
			<td width="15%"></td>
	</tr>
</table>
<table class="table" style="width:100%; margin-top: 5px;">
	<thead><tr><th></th></thead>
</table>
<table style="width:100%; height: 150px">
	<tr><td valign="top">
<table style="width:100%; font-family: Roman12cpi; margin-top: 10px;">
	<tr>
			<td width="10%">
				000010
			</td>
			<td width="10%">
			</td>
			<td width="30%">
				<?php echo $row1['Material']; ?>
			</td>
			<td width="20%">
				<?php echo $row1['No_PO']; ?>
			</td>
			<td width="15%">
			</td>
			<td width="15%">
			</td>
	</tr>
	<tr>
			<td width="10%"></td>
			<td width="10%">
			</td>
			<td width="30%">
				<?php echo $row1['ItemDescription']; ?>
			</td>
			<td width="20%">
				<?php echo date ("d.m.Y", strtotime($row1['TanggalPO'])); ?>
			</td>
			<td width="15%"></td>
			<td width="15%"></td>
	</tr>
	<?php 
	$data4 = mysqli_query ($koneksi, " SELECT 
									COUNT(stpj.STPJ_ID) AS jumlah,
									product.SLoc,
									product.QtyUnit,
									sum(stpj.Qty) as jml,
									DATE_FORMAT(plan.DatePlan, '%y%m') AS dateplan
					FROM stpj 
					INNER JOIN plan
					ON stpj.PlanID=plan.PlanID
					INNER JOIN product
					ON plan.ProductID=product.ProductID
					where stpj.Del_ID='$_GET[id]'
					GROUP BY DATE_FORMAT(plan.DatePlan, '%y%m'), plan.ProductID
					Order BY product.ProductID ,plan.DatePlan ASC");
	
	while($row4 = mysqli_fetch_array ($data4)):
	?>
	<tr>
			<td width="10%">
			</td>
			<td width="10%">
			</td>
			<td width="30%">
			</td>
			<td width="20%">
			</td>
			<td width="15%">
				<?php echo $row4['dateplan']; ?>
			</td>
			<td width="15%">
				<?php echo number_format($row4['jml']*$row4['QtyUnit'], 0, "","."); ?>&emsp;
				PCE
			</td>
	</tr>
<?php endwhile; ?>
</table>
<?php if ($row1['CustomerID']==='3' || $row1['CustomerID']==='6' || $row1['CustomerID']==='9') { ?>
<table style="width:100%; font-family: Roman12cpi; margin-top: 30px;"> 
	<tr>
			<td width="10%">
				000020
			</td>
			<td width="10%">
			</td>
			<td width="30%">
				568076
			</td>
			<td width="20%">
				<?php echo $row1['No_PO']; ?>
			</td>
			<td width="15%">
				<?php if($row1['CustomerID']==='3') { ?>
				GPL-KLN
				<?php } else if($row1['CustomerID']==='6') { ?>
				GPL-SGN
				<?php } else { ?>
				GPL-PDN
				<?php } ?>
			</td>
			<td width="15%">
				<?php echo $row1['QtyKirim'] ?>&emsp;
				PC
			</td>
	</tr>
	<tr>
			<td width="10%"></td>
			<td width="10%">
			</td>
			<td width="30%">
				Nicktainer
			</td>
			<td width="20%">
				<?php echo date ("d.m.Y", strtotime($row1['TanggalPO'])); ?>
			</td>
			<td width="15%"></td>
			<td width="15%"></td>
	</tr>
</table>
<?php } ?>
</td></tr>
</table>
<table class="table" style="width:100%; margin-top: 30px; ">
	<thead><tr><th></th></thead>
</table>
	<table class="table" style="width:100%; margin-top: 10px; ">
		<td width="5%"></td>
		<td width="45%">
		<?php if ($row1['CustomerID']==='3' || $row1['CustomerID']==='9') { ?>
		<?php
		$data3 = mysqli_query ($koneksi, " SELECT 
				stpj.STPJ_ID,
				product.SLoc,
				product.QtyUnit,
				stpj.NoLot,
				sum(stpj.Qty) AS qty
		FROM stpj 
		INNER JOIN plan
		ON stpj.PlanID=plan.PlanID
		INNER JOIN product
		ON plan.ProductID=product.ProductID
		where stpj.Del_ID='$_GET[id]'");

		$row3 = mysqli_fetch_array ($data3) ?>
	<table class="table" style="width:100%; font-family: Roman17cpi;">
		<thead>
		<tr>
			<th width="30%">
				UNLOADING :
			</th>
			<th width="15%">
				<?php if($row1['CustomerID']==='3') { ?>
				SPS-3
				<?php } else { ?>
				SHINTA
				<?php } ?>
			</th>
			<th width="15%">
        		
			</th>
			<th width="20%">
				ETA JAM
			</th>
			<th width="20%">
				10:00:00
			</th>
		</tr>
	</thead>
	<thead>
		<tr>
			<th width="30%">
				No Lot
			</th>
			<th width="30%" colspan="2">
				Quantity
			</th>
			<th width="40%" colspan="2">
				Total
			</th>
		</tr>
	</thead>
		<?php
		$data2 = mysqli_query ($koneksi, " SELECT 
				stpj.STPJ_ID,
				product.SLoc,
				product.QtyUnit,
				stpj.NoLot,
				sum(stpj.Qty) AS qty
		FROM stpj 
		INNER JOIN plan
		ON stpj.PlanID=plan.PlanID
		INNER JOIN product
		ON plan.ProductID=product.ProductID
		where stpj.Del_ID='$_GET[id]'
		GROUP BY stpj.NoLot");

		while($row2 = mysqli_fetch_array ($data2)): ?>
		<tr>
			<td width="30%">
				<?php echo $row2['NoLot']; ?>
			</td>
			<td width="15%">
				<?php echo $row2['qty']; ?>
			</td>
			<td width="15%">
        		<?php echo substr($row2['SLoc'], 0, 3); ?>
			</td>
			<td width="20%">
				<?php echo number_format($row2['qty']*$row2['QtyUnit'], 0, "","."); ?>
			</td>
			<td width="20%">
				PCS
			</td>
		</tr>
		<?php endwhile; ?>
	</table>
	<?php } ?>
	</td>
		<td width="15%"></td>
		<td width="35%">
			<table class="table" style="width:100%; margin-top: 5px; font-family: Roman17cpi;">
		<tr>
			<td width="100%" colspan="3">
				RECEIVED BY
			</td>
		</tr>
		<tr>
			<td width="100%" colspan="3" >
				Please stamp, sign, print name  return copy
			</td>
		</tr>
		<tr>
			<td width="20%"></td>
			<td width="60%" height="30px" style="border-bottom: 1px solid black">
			</td>
			<td width="20%"></td>
		</tr>
	</table>
</td>
</body>
</html>