<?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>
<?php
	include "../koneksi.php";
	$data0 = mysqli_query ($koneksi, " SELECT coa.PlanID,
											 coa.Date_COA,
											 coa.Lot_COA,
											 coa.Shift,
											 coa.Material as MaterialCOA,
							 				 product.ProductID,
											 product.ItemDescription,
											 product.Material,
											 product.Pewarna,
											 plan.MaterialID
										from coa
										INNER JOIN plan
										ON coa.PlanID=plan.PlanID
										INNER JOIN product
										ON plan.ProductID=product.ProductID
										WHERE COA_ID=$_GET[coa_id]");
	$row0 = mysqli_fetch_array($data0);

	$data = mysqli_query ($koneksi, " SELECT standard.StdID,
		SUBSTRING_INDEX(REPLACE(REPLACE(REPLACE(spec.Spec,',',' '),')',' '),'(',' '),' ',-1) AS 'diameter',
											standard.SpecID,
											standard.ProductID,
											standard.CL,
											standard.Allowance,
											spec.Kode,
											spec.Spec,
											product.ItemDescription
									FROM standard
									INNER JOIN spec
									ON standard.SpecID=spec.SpecID
									INNER JOIN product
									ON standard.ProductID=product.ProductID
									where standard.ProductID = $row0[ProductID]");

	$data1 = mysqli_query ($koneksi, " SELECT * from add_coa
										WHERE COA_ID=$_GET[coa_id]");

	$data2 = mysqli_query ($koneksi, " SELECT spec.Spec,
										add_std.AddStdID,
										add_std.Type_Cek,
										add_std.CL,
										add_std.Allowance
										FROM add_std
										INNER JOIN spec
										ON add_std.SpecID=spec.SpecID
										WHERE add_std.ProductID=$row0[ProductID]");
?>
<body style="font-size: 12px">
<h4 style="font-family: Britannic; font-size: 21px; font-weight: bold; text-align: center; margin-top: 60px;"><u>CERTIFICATE OF ANALYIS</u></h4>
<?php if ($row0['ProductID']=='8'){ ?>
<h5 style="font-family: Britannic; font-size: 17px; font-weight: bold; text-align: center; margin-top: -2px;">PET BOTOL HOTFILL 350 ML</h5>
<?php } else { ?>
<h5 style="font-family: Britannic; font-size: 17px; font-weight: bold; text-align: center; margin-top: -2px;">PET BOTOL HOTFILL 500 ML</h5>
<?php } ?>
<h5 style="font-family: Britannic; font-weight: bold; text-align: center; margin-top: -2px;">CoA No : <?php echo substr($row0['Date_COA'], 0, 4); ?> - <?php echo $row0['Material']; ?> - <?php echo $row0['Lot_COA']; ?></h5>
<table style="width: 90%; font-size: 12px; margin-top: 35px; margin-right: 5%; margin-left: 5%;">
	<tr>
		<td width="19%" style="text-align: left;">Production Date</td>
		<td width="1%">:</td>
		<td width="40%" style="letter-spacing: 2px; font-size: 13px;"><?php echo substr($row0['Date_COA'], 5, 2); ?><?php echo substr($row0['Date_COA'], 8, 2); ?><?php echo substr($row0['Date_COA'], 2, 2); ?></td>
		<td width="19%" style="text-align: left;">Lot Number</td>
		<td width="1%">:</td>
		<td width="20%"><?php echo $row0['Lot_COA']; ?></td>
	</tr>
	<tr>
		<td width="19%" style="text-align: left;" valign="top">Colour</td>
		<td width="1%" valign="top">:</td>
		<td width="40%" valign="top">CLEAR</td>
	</tr>
	<tr>
		<td width="19%" style="text-align: left;" valign="top">Resin Material</td>
		<td width="1%" valign="top">:</td>
		<td width="40%" valign="top"><?php echo $row0['MaterialCOA']; ?></td>
	</tr>
</table>
<table class="table-print" style="width:100%; font-size: 9px; border-collapse: collapse; text-align: center;">
	<tr>
		<th rowspan="2" width="35%" style="padding-top: 5px;">PROPERTIES</th>
		<th rowspan="2" width="10%" style="padding-top: 5px;">UNIT</th>
		<th rowspan="2" width="19%"style="padding-top: 5px;">SPECIFICATION</th>
		<th colspan="3" width="21%">RESULT</th>
		<th rowspan="2" style="padding-top: 5px;" width="15%">TEST METHOD</th>
	</tr>

	<tr>
		<th width="7%">MAX</th>
		<th width="7%">AVG</th>
		<th width="7%">MIN</th>
	</tr>
	<?php $j = 1;
	while( $row = mysqli_fetch_array ($data) ) : ?>
	<?php $data3 = mysqli_query ($koneksi, " SELECT MAX(bot_dimensi.Nilai) AS MAX,
												AVG(bot_dimensi.Nilai) AS AVG,
												MIN(bot_dimensi.Nilai) AS MIN
												FROM bot_dimensi
												WHERE bot_dimensi.COA_ID=$_GET[coa_id] AND bot_dimensi.StdID=$row[StdID] AND Fill='1'");
		$row3 = mysqli_fetch_array($data3);
		?>
	<tr>
		<?php if ($j==1) {
			echo '<td style="text-align: left;">WEIGHT</td>';
			echo '<td>grams</td>';
			echo '<td>'.number_format($row['CL'],2).'&ensp; &#177; &ensp;'.number_format($row['Allowance'],2).'</td>';
			echo '<td style="text-align: center;">'.number_format($row3['MAX'], 2).'</td>';
			echo '<td style="text-align: center;">'.number_format($row3['AVG'], 2).'</td>';
			echo '<td style="text-align: center;">'.number_format($row3['MIN'], 2).'</td>';
			echo '<td style="text-align: center;">ITA Method</td>';
		} else if ($j>1 && $j<14) { ?>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;"><?php echo $row['diameter']=='DIAMETER' ? '<text style="font-size: 11px;">⌀</text>' : ''; ?><?php echo $row['Kode']; ?></td>
					<td width="79%" style="border: hidden;"><?php echo $row['Spec']; ?></td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td style="text-align: center;">
			<?php echo number_format($row['CL'],2); ?>&ensp; &#177; &ensp;<?php echo number_format($row['Allowance'],2); ?>
		</td>
		<td style="text-align: center;">
			<?php echo number_format($row3['MAX'], 2); ?>
		</td>
        <td style="text-align: center;">
        	<?php echo number_format($row3['AVG'], 2); ?>
		</td>
        <td style="text-align: center;">
        	<?php echo number_format($row3['MIN'], 2); ?>
		</td>
		<td>ITA Method</td>
		<?php } ?>
	<tr>
	<?php if ($j==1) { 
	echo '<tr><td colspan="7" style="text-align: left;">DIMENSION</td></tr>';
	} ?>
	<?php $j++;
	 endwhile; ?>
	 <?php 
	 $dimshrink = array(31,32,33,34);
	 for ($i=0; $i < count($dimshrink); $i++) { 
	 	$data4 = mysqli_query ($koneksi, " SELECT standard.StdID,
		SUBSTRING_INDEX(REPLACE(REPLACE(REPLACE(spec.Spec,',',' '),')',' '),'(',' '),' ',-1) AS 'diameter',
											standard.SpecID,
											standard.ProductID,
											standard.CL,
											standard.Allowance,
											spec.Kode,
											spec.Spec,
											product.ItemDescription
									FROM standard
									INNER JOIN spec
									ON standard.SpecID=spec.SpecID
									INNER JOIN product
									ON standard.ProductID=product.ProductID
									where standard.ProductID = $row0[ProductID] and spec.SpecID=$dimshrink[$i]");
	 	$row4 = mysqli_fetch_array($data4);	
	  ?>
	  <tr>
	  	<td style="text-align: left;">
	  		<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;"><?php echo $row4['diameter']=='DIAMETER' ? '<text style="font-size: 11px;">⌀</text>' : ''; ?><?php echo $row4['Kode']; ?></td>
					<td width="79%" style="border: hidden;">SHRINKED</td>
				</tr>
			</table>
	  	</td>
	  	<td style="text-align: center; font-weight: bold">%</td>
	  	<td style="text-align: center;">MAX - 2</td>
	  	<?php  $shringked = array();
			$valfresh = array();
            $data5 = mysqli_query ($koneksi, " select Nilai FROM bot_dimensi
                                    where COA_ID = $_GET[coa_id] AND StdID=$row4[StdID] AND Fill=1");
			while ($row5 = mysqli_fetch_array($data5)) {
			 	array_push($valfresh, $row5['Nilai']);
			}
			$valafter = array();
    		$data6 = mysqli_query ($koneksi, " select Nilai FROM bot_dimensi
                                    where COA_ID = $_GET[coa_id] AND StdID=$row4[StdID] AND Fill=2");
			while($row6 = mysqli_fetch_array($data6)) {
				array_push($valafter, $row6['Nilai']);
			}
			for ($y=0; $y < count($valfresh); $y++) { 
				$hasilshrink = (($valafter[$y]-$valfresh[$y])*100)/$valfresh[$y];
				array_push($shringked, number_format($hasilshrink, 2));
			} ?>
			<td style="text-align: center;">
				<?php echo max($shringked); ?>
			</td>
            <td style="text-align: center;">
				<?php echo number_format(array_sum($shringked)/count($shringked), 2) ?>
			</td>
            <td style="text-align: center;">
				<?php echo min($shringked); ?>
			</td>
			<td style="text-align: center;">ITA Method</td>
	  </tr>
	<?php } ?>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;">V1</td>
					<td width="79%" style="border: hidden;">FILL POINT FRESH</td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td>361.00&ensp; &#177; &ensp;5.00</td>
		<?php $data7 = mysqli_query ($koneksi, "SELECT MAX(bot_dimensi.Nilai) AS MAX,
												AVG(bot_dimensi.Nilai) AS AVG,
												MIN(bot_dimensi.Nilai) AS MIN
					FROM bot_dimensi
					inner join standard
					ON bot_dimensi.StdID=standard.StdID
					inner join spec
					ON standard.SpecID=spec.SpecID
                    where COA_ID = $_GET[coa_id] AND spec.SpecID='41' AND Fill='1'");
              $row7 = mysqli_fetch_array($data7); ?>
        <td><?php echo number_format($row7['MAX'],2); ?></td>
        <td><?php echo number_format($row7['AVG'],2); ?></td>
        <td><?php echo number_format($row7['MIN'],2); ?></td>
        <td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;">V2</td>
					<td width="79%" style="border: hidden;">FILL POINT VOLUME ( 89⁰ C )</td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td>350.00&ensp; &#177; &ensp;5.00</td>
		<?php $data8 = mysqli_query ($koneksi, "SELECT MAX(bot_dimensi.Nilai) AS MAX,
												AVG(bot_dimensi.Nilai) AS AVG,
												MIN(bot_dimensi.Nilai) AS MIN
					FROM bot_dimensi
					inner join standard
					ON bot_dimensi.StdID=standard.StdID
					inner join spec
					ON standard.SpecID=spec.SpecID
                    where COA_ID = $_GET[coa_id] AND spec.SpecID='41' AND Fill='2'");
              $row8 = mysqli_fetch_array($data8); ?>
        <td><?php echo number_format($row8['MAX'],2); ?></td>
        <td><?php echo number_format($row8['AVG'],2); ?></td>
        <td><?php echo number_format($row8['MIN'],2); ?></td>
        <td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;">t1</td>
					<td width="79%" style="border: hidden;">SHOULDER WALLTHICKNESS</td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td>min 0.200</td>
		<?php $data9 = mysqli_query ($koneksi, " SELECT MAX(bot_wall.t1) AS MAXt1,
												AVG(bot_wall.t1) AS AVGt1,
												MIN(bot_wall.t1) AS MINt1
												FROM bot_wall
												WHERE bot_wall.COA_ID=$_GET[coa_id]");
		$row9 = mysqli_fetch_array($data9); ?>
		<td style="text-align: center;">
			<?php echo number_format($row9['MAXt1'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['AVGt1'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['MINt1'], 3); ?>
		</td>
		<td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;">t2</td>
					<td width="79%" style="border: hidden;">BODY WALLTHICKNESS</td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td>min 0.200</td>
		<?php $data9 = mysqli_query ($koneksi, " SELECT MAX(bot_wall.t2) AS MAXt2,
												AVG(bot_wall.t2) AS AVGt2,
												MIN(bot_wall.t2) AS MINt2
												FROM bot_wall
												WHERE bot_wall.COA_ID=$_GET[coa_id]");
		$row9 = mysqli_fetch_array($data9); ?>
		<td style="text-align: center;">
			<?php echo number_format($row9['MAXt2'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['AVGt2'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['MINt2'], 3); ?>
		</td>
		<td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;">t3</td>
					<td width="79%" style="border: hidden;">BOTTOM WALLTHICKNESS</td>
				</tr>
			</table>
		</td>
		<td>mm</td>
		<td>min 0.200</td>
		<?php $data9 = mysqli_query ($koneksi, " SELECT MAX(bot_wall.t3) AS MAXt3,
												AVG(bot_wall.t3) AS AVGt3,
												MIN(bot_wall.t3) AS MINt3
												FROM bot_wall
												WHERE bot_wall.COA_ID=$_GET[coa_id]");
		$row9 = mysqli_fetch_array($data9); ?>
		<td style="text-align: center;">
			<?php echo number_format($row9['MAXt3'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['AVGt3'], 3); ?>
		</td>
        <td style="text-align: center;">
			<?php echo number_format($row9['MINt3'], 3); ?>
		</td>
		<td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;"></td>
					<td width="79%" style="border: hidden;">HEAT RESSISTANCE</td>
				</tr>
			</table>
		</td>
		<td>⁰C</td>
		<td>92⁰C</td>
		<td colspan="3">OK</td>
		<td>ITA Method</td>
	</tr>
	<tr>
		<td style="text-align: left;">
			<table style="width: 100%; border: hidden; font-size: 9px;">
				<tr style="border: hidden;">
					<td width="6%" style="text-align: center; border: hidden;">-</td>
					<td width="15%" style="text-align: center; border: hidden;"></td>
					<td width="79%" style="border: hidden;">DROP TEST</td>
				</tr>
			</table>
		</td>
		<td>m</td>
		<td style="font-size: 8px;">Bottle dropred from<br> 1.5 m height</td>
		<td colspan="3">PASS</td>
		<td>ITA Method</td>
	</tr>
</table>
<table style="width: 100%">
	<tr>
		<td width="60%">
			<br><br><br><br>
			<u>EDI PURNOMO</u><br>
			QUALITY EXECUTIVE<br><br>
			Note :<br>
			<text style="font-size: 9px;">Packaging Wrapping tidak boleh sobek atau rusak dalam masa penyimpanan.<br>
			* Dalam proses develop menambahan volume fresh botol permintaan customer</text>
			<br><br>
			011/FORM-CORP/SOP0504/QAC/REV.02
		</td>
		<td width="40%"><img src="../image/FT-350.jpg" alt="" width="200" height="300"></td>
	</tr>
</table>
</body>
</html>