<?php 
ob_start();
session_start();
require_once("../conn/conn.php");
//include('../utility/chksession.php');
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>Sanko Quality- Admin</title>

		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="../assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="../assets/font-awesome/4.5.0/css/font-awesome.min.css" />

		<!-- page specific plugin styles -->

		<!-- text fonts -->
		<link rel="stylesheet" href="../assets/css/fonts.googleapis.com.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="../assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="assets/css/ace-part2.min.css" class="ace-main-stylesheet" />
		<![endif]-->
		<link rel="stylesheet" href="../assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="../assets/css/ace-rtl.min.css" />

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->
		<script src="../assets/js/ace-extra.min.js"></script>

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body class="no-skin">
		
		<div class="main-container ace-save-state" id="main-container">
			<script type="text/javascript">
				try{ace.settings.loadState('main-container')}catch(e){}
			</script>


			<div class="main-content">
				<div class="main-content-inner">
					<!-- /.ace-settings-container -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<div class="space-6"></div>

								<div class="row">
									<div class="col-sm-10 col-sm-offset-1">
										<div class="widget-box transparent">
											<div class="widget-header widget-header-large">
												<h3 class="widget-title grey lighter">
                                                แบบฟอร์มสรุป Snift Test</h3>

												<div class="widget-toolbar no-border invoice-info">
													<span>หมายเลขเอกสาร :</span>
													<span>FM-QA-SS-003</span>

													<br />
													<span>แก้ไขครั้งที่ : </span>
													<span>00/2017</span>

                                                    <br />
													<span>วันที่มีผลบังคับใช้ : </span>
													<span>01/08/2017</span>
												</div>

											
											</div>

											<div class="widget-body">
									
                                        <?php
										
											$Cli_date1 = $_POST['Cli_date1'];
											$Cli_date2 = $_POST['Cli_date2'];
											$Item_id = $_POST['Item_id'];
											$Cli_code = $_POST['Cli_code'];
		
											//echo $Cli_date1.$Cli_date2.$Item_id.$Cli_code;
											?></br><?	
										
											echo "วันที่  "."$Cli_date1"." - "."$Cli_date2";
											?></br><?		
											?></br><?								
										
											if($Cli_date1 != "" && $Cli_date2 !="" && $Item_id!="NULL" && $Cli_code!=""){
												//echo "1 วันที่1".$Cli_date1."วันที่2".$Cli_date2."item".$Item_id."code".$Cli_code;
												
												$strSQL = "SELECT * FROM qc_checklistitem2
												WHERE Cli_date BETWEEN '$Cli_date1' AND '$Cli_date2'
												AND Item_id='$Item_id'
												AND Cli_code='$Cli_code'";
												$objQuery = mysqli_query($con,$strSQL);  
										
										

											?>
                                        <table class="table table-striped table-bordered" width='100%'>
                                          <thead>
                                            <tr>
                                              <th rowspan="2%" class="center">วันที่</th>
                                              <th rowspan="2">ตัวอย่างที่ทดลอง </th>
                                              <th rowspan="2" class="hidden-xs">Code</th>
                                              <th rowspan="2" class="hidden-xs"><span class="hidden-480">Reference</span></th>
                                              <th colspan="6">Sensory</th>
                                              <th rowspan="2">ผล</th>
                                              <th colspan="2">สรุปผล</th>
                                              <th rowspan="2">จัดเตรียมโดย</th>
                                              <th rowspan="2">ผู้ตรวจสอบ</th>
                                              <th rowspan="2">หมายเหตุ</th>
                                            </tr>
                                            <tr>
                                              <th width="69" align="center">1</th>
                                              <th width="95" align="center">2</th>
                                              <th width="95" align="center">3</th>
                                              <th width="95" align="center">4</th>
                                              <th width="95" align="center">5</th>
                                              <th width="100" align="center">6</th>
                                              <th>ผ่าน&lt;2.5</th>
                                              <th>ไม่ผ่าน &gt;2.5</th>
                                            </tr>
                                          </thead>
                                          <tbody>
                                            <?php
													while($objResult = mysqli_fetch_array($objQuery)){

                                                        $strSQL1 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 0,1;";
														$objQuery1 = mysqli_query($con,$strSQL1);  
														$objResult1 = mysqli_fetch_array($objQuery1);

                                                        $strSQL2 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 1,1;";
														$objQuery2 = mysqli_query($con,$strSQL2);  
														$objResult2 = mysqli_fetch_array($objQuery2);

                                                        $strSQL3 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 2,1;";
														$objQuery3 = mysqli_query($con,$strSQL3);  
														$objResult3 = mysqli_fetch_array($objQuery3);

                                                        $strSQL4 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 3,1;";
														$objQuery4 = mysqli_query($con,$strSQL4);  
														$objResult4 = mysqli_fetch_array($objQuery4);

                                                        $strSQL5 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 4,1;";
														$objQuery5 = mysqli_query($con,$strSQL5);  
														$objResult5 = mysqli_fetch_array($objQuery5);

                                                        $strSQL6 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 5,1;";
														$objQuery6 = mysqli_query($con,$strSQL6);  
														$objResult6 = mysqli_fetch_array($objQuery6);


													?>
                                            <tr>
                                              <td width="150" class="center"><?=$objResult['Cli_date'];  ?></td>
                                              <td width="200"><?=$objResult['Item_id']." - ".$objResult['Item_name']; ?></td>
                                              <td width="100"><?=$objResult['Cli_code']; ?></td>
                                              <td width="100"><?=$objResult['Cli_ref']; ?></td>
                                              <td width="69"><?php //echo $objResult1['result'];
                                                                    
                                                                    if(isset($objResult1['result'])) 
																	{echo $objResult1['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult2['result'])) 
																	{echo $objResult2['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php
                                                                    if(isset($objResult3['result'])) 
																	{echo $objResult3['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult4['result'])) 
																	{echo $objResult4['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult5['result'])) 
																	{echo $objResult5['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult6['result'])) 
																	{echo $objResult6['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 

																	//คำนวน count
																	$strSQLa = "SELECT AVG(result) FROM qc_resultsnift,qc_resultsniftsub
                                                                    where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                                    and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                                    and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                                    and qc_resultsniftsub.Topic_id='T005'
																	and qc_resultsnift.Item_id='$objResult[Item_id]'
																	and qc_resultsnift.Cli_code='$objResult[Cli_code]'";
																	$objQuerya = mysqli_query($con,$strSQLa);  
																	$objResulta = mysqli_fetch_array($objQuerya);

																	$counttotal = $objResulta['AVG(result)'];
																	//$counttotala=$counttotal*3;
																	echo number_format( $counttotal, 2 );
																	
																	


																		?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	    echo "/";
																	     
																	}else if($counttotal>=2.5){
																	    
																	    
																	}
																	?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	   
																	     
																	}else if($counttotal>=2.5){
																	    
																	     echo "/";
																	}
																	?></td>
                                              <td width="70" align="center"><?php echo $objResult['Cli_record'] ?></td>
                                              <td width="100"><?php echo $objResult['Cli_checker'] ?></td>
                                              <td width="74"><?php echo $objResult['Cli_note']; 
                                                                    
																	?></td>
                                            </tr>
                                            <?php
                                                            }

                                                        ?>
                                          </tbody>
                                        </table>
                                        <?
												
											}else if($Cli_date1 != "" && $Cli_date2 !="" && $Item_id=="NULL" && $Cli_code!=""){
												//echo "2 วันที่1".$Cli_date1."วันที่2".$Cli_date2."item".$Item_id."code".$Cli_code;
												
												$strSQL = "SELECT * FROM qc_checklistitem2 
												WHERE Cli_date BETWEEN '$Cli_date1' AND '$Cli_date2'
												AND Cli_code='$Cli_code';";
												$objQuery = mysqli_query($con,$strSQL);  
										
										

											?>
                                        <table class="table table-striped table-bordered" width='100%'>
                                          <thead>
                                            <tr>
                                              <th rowspan="2%" class="center">วันที่</th>
                                              <th rowspan="2">ตัวอย่างที่ทดลอง </th>
                                              <th rowspan="2" class="hidden-xs">Code</th>
                                              <th rowspan="2" class="hidden-xs"><span class="hidden-480">Reference</span></th>
                                              <th colspan="6">Sensory</th>
                                              <th rowspan="2">ผล</th>
                                              <th colspan="2">สรุปผล</th>
                                              <th rowspan="2">จัดเตรียมโดย</th>
                                              <th rowspan="2">ผู้ตรวจสอบ</th>
                                              <th rowspan="2">หมายเหตุ</th>
                                            </tr>
                                            <tr>
                                              <th width="69" align="center">1</th>
                                              <th width="95" align="center">2</th>
                                              <th width="95" align="center">3</th>
                                              <th width="95" align="center">4</th>
                                              <th width="95" align="center">5</th>
                                              <th width="100" align="center">6</th>
                                              <th>ผ่าน&lt;2.5</th>
                                              <th>ไม่ผ่าน &gt;2.5</th>
                                            </tr>
                                          </thead>
                                          <tbody>
                                            <?php
													while($objResult = mysqli_fetch_array($objQuery)){

                                                        $strSQL1 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 0,1;";
														$objQuery1 = mysqli_query($con,$strSQL1);  
														$objResult1 = mysqli_fetch_array($objQuery1);

                                                        $strSQL2 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 1,1;";
														$objQuery2 = mysqli_query($con,$strSQL2);  
														$objResult2 = mysqli_fetch_array($objQuery2);

                                                        $strSQL3 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 2,1;";
														$objQuery3 = mysqli_query($con,$strSQL3);  
														$objResult3 = mysqli_fetch_array($objQuery3);

                                                        $strSQL4 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 3,1;";
														$objQuery4 = mysqli_query($con,$strSQL4);  
														$objResult4 = mysqli_fetch_array($objQuery4);

                                                        $strSQL5 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 4,1;";
														$objQuery5 = mysqli_query($con,$strSQL5);  
														$objResult5 = mysqli_fetch_array($objQuery5);

                                                        $strSQL6 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 5,1;";
														$objQuery6 = mysqli_query($con,$strSQL6);  
														$objResult6 = mysqli_fetch_array($objQuery6);


													?>
                                            <tr>
                                              <td width="150" class="center"><?=$objResult['Cli_date'];  ?></td>
                                              <td width="200"><?=$objResult['Item_id']." - ".$objResult['Item_name']; ?></td>
                                              <td width="100"><?=$objResult['Cli_code']; ?></td>
                                              <td width="100"><?=$objResult['Cli_ref']; ?></td>
                                              <td width="69"><?php //echo $objResult1['result'];
                                                                    
                                                                    if(isset($objResult1['result'])) 
																	{echo $objResult1['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult2['result'])) 
																	{echo $objResult2['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php
                                                                    if(isset($objResult3['result'])) 
																	{echo $objResult3['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult4['result'])) 
																	{echo $objResult4['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult5['result'])) 
																	{echo $objResult5['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult6['result'])) 
																	{echo $objResult6['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 

																	//คำนวน count
																	$strSQLa = "SELECT AVG(result) FROM qc_resultsnift,qc_resultsniftsub
                                                                    where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                                    and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                                    and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                                    and qc_resultsniftsub.Topic_id='T005'
																	and qc_resultsnift.Item_id='$objResult[Item_id]'
																	and qc_resultsnift.Cli_code='$objResult[Cli_code]'";
																	$objQuerya = mysqli_query($con,$strSQLa);  
																	$objResulta = mysqli_fetch_array($objQuerya);

																	$counttotal = $objResulta['AVG(result)'];
																	//$counttotala=$counttotal*3;
																	echo number_format( $counttotal, 2 );
																	
																	


																		?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	    echo "/";
																	     
																	}else if($counttotal>=2.5){
																	    
																	    
																	}
																	?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	   
																	     
																	}else if($counttotal>=2.5){
																	    
																	     echo "/";
																	}
																	?></td>
                                              <td width="70" align="center"><?php echo $objResult['Cli_record'] ?></td>
                                              <td width="100"><?php echo $objResult['Cli_checker'] ?></td>
                                              <td width="74"><?php echo $objResult['Cli_note']; 
                                                                    
																	?></td>
                                            </tr>
                                            <?php
                                                            }

                                                        ?>
                                          </tbody>
                                        </table>
                                        <?
												
												
											}else if($Cli_date1 != "" && $Cli_date2 !="" && $Item_id!="NULL" && $Cli_code==""){
													//echo "3 วันที่1".$Cli_date1."วันที่2".$Cli_date2."item".$Item_id."code".$Cli_code;
													$strSQL = "SELECT * FROM qc_checklistitem2 
												WHERE Cli_date BETWEEN '$Cli_date1' AND '$Cli_date2'
												AND Item_id='$Item_id'";
												$objQuery = mysqli_query($con,$strSQL);  
										
										

											?>
                                        <table class="table table-striped table-bordered" width='100%'>
                                          <thead>
                                            <tr>
                                              <th rowspan="2%" class="center">วันที่</th>
                                              <th rowspan="2">ตัวอย่างที่ทดลอง </th>
                                              <th rowspan="2" class="hidden-xs">Code</th>
                                              <th rowspan="2" class="hidden-xs"><span class="hidden-480">Reference</span></th>
                                              <th colspan="6">Sensory</th>
                                              <th rowspan="2">ผล</th>
                                              <th colspan="2">สรุปผล</th>
                                              <th rowspan="2">จัดเตรียมโดย</th>
                                              <th rowspan="2">ผู้ตรวจสอบ</th>
                                              <th rowspan="2">หมายเหตุ</th>
                                            </tr>
                                            <tr>
                                              <th width="69" align="center">1</th>
                                              <th width="95" align="center">2</th>
                                              <th width="95" align="center">3</th>
                                              <th width="95" align="center">4</th>
                                              <th width="95" align="center">5</th>
                                              <th width="100" align="center">6</th>
                                              <th>ผ่าน&lt;2.5</th>
                                              <th>ไม่ผ่าน &gt;2.5</th>
                                            </tr>
                                          </thead>
                                          <tbody>
                                            <?php
													while($objResult = mysqli_fetch_array($objQuery)){

                                                        $strSQL1 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 0,1;";
														$objQuery1 = mysqli_query($con,$strSQL1);  
														$objResult1 = mysqli_fetch_array($objQuery1);

                                                        $strSQL2 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 1,1;";
														$objQuery2 = mysqli_query($con,$strSQL2);  
														$objResult2 = mysqli_fetch_array($objQuery2);

                                                        $strSQL3 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 2,1;";
														$objQuery3 = mysqli_query($con,$strSQL3);  
														$objResult3 = mysqli_fetch_array($objQuery3);

                                                        $strSQL4 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 3,1;";
														$objQuery4 = mysqli_query($con,$strSQL4);  
														$objResult4 = mysqli_fetch_array($objQuery4);

                                                        $strSQL5 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 4,1;";
														$objQuery5 = mysqli_query($con,$strSQL5);  
														$objResult5 = mysqli_fetch_array($objQuery5);

                                                        $strSQL6 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 5,1;";
														$objQuery6 = mysqli_query($con,$strSQL6);  
														$objResult6 = mysqli_fetch_array($objQuery6);


													?>
                                            <tr>
                                              <td width="150" class="center"><?=$objResult['Cli_date'];  ?></td>
                                              <td width="200"><?=$objResult['Item_id']." - ".$objResult['Item_name']; ?></td>
                                              <td width="100"><?=$objResult['Cli_code']; ?></td>
                                              <td width="100"><?=$objResult['Cli_ref']; ?></td>
                                              <td width="69"><?php //echo $objResult1['result'];
                                                                    
                                                                    if(isset($objResult1['result'])) 
																	{echo $objResult1['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult2['result'])) 
																	{echo $objResult2['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php
                                                                    if(isset($objResult3['result'])) 
																	{echo $objResult3['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult4['result'])) 
																	{echo $objResult4['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult5['result'])) 
																	{echo $objResult5['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult6['result'])) 
																	{echo $objResult6['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 

																	//คำนวน count
																	$strSQLa = "SELECT AVG(result) FROM qc_resultsnift,qc_resultsniftsub
                                                                    where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                                    and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                                    and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                                    and qc_resultsniftsub.Topic_id='T005'
																	and qc_resultsnift.Item_id='$objResult[Item_id]'
																	and qc_resultsnift.Cli_code='$objResult[Cli_code]'";
																	$objQuerya = mysqli_query($con,$strSQLa);  
																	$objResulta = mysqli_fetch_array($objQuerya);

																	$counttotal = $objResulta['AVG(result)'];
																	//$counttotala=$counttotal*3;
																	echo number_format( $counttotal, 2 );
																	
																	


																		?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	    echo "/";
																	     
																	}else if($counttotal>=2.5){
																	    
																	    
																	}
																	?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	   
																	     
																	}else if($counttotal>=2.5){
																	    
																	     echo "/";
																	}
																	?></td>
                                              <td width="70" align="center"><?php echo $objResult['Cli_record'] ?></td>
                                              <td width="100"><?php echo $objResult['Cli_checker'] ?></td>
                                              <td width="74"><?php echo $objResult['Cli_note']; 
                                                                    
																	?></td>
                                            </tr>
                                            <?php
                                                            }

                                                        ?>
                                          </tbody>
                                        </table>
                                        <?
												
											}else if($Cli_date1 != "" && $Cli_date2 !="" && $Item_id=="NULL" && $Cli_code==""){
												//echo "4 วันที่1".$Cli_date1."วันที่2".$Cli_date2."item".$Item_id."code".$Cli_code;
												$strSQL = "SELECT * FROM qc_checklistitem2 
												WHERE Cli_date BETWEEN '$Cli_date1' AND '$Cli_date2'";
												$objQuery = mysqli_query($con,$strSQL);  
										
										

											?>
                                        <table class="table table-striped table-bordered" width='100%'>
                                          <thead>
                                            <tr>
                                              <th rowspan="2%" class="center">วันที่</th>
                                              <th rowspan="2">ตัวอย่างที่ทดลอง </th>
                                              <th rowspan="2" class="hidden-xs">Code</th>
                                              <th rowspan="2" class="hidden-xs"><span class="hidden-480">Reference</span></th>
                                              <th colspan="6">Sensory</th>
                                              <th rowspan="2">ผล</th>
                                              <th colspan="2">สรุปผล</th>
                                              <th rowspan="2">จัดเตรียมโดย</th>
                                              <th rowspan="2">ผู้ตรวจสอบ</th>
                                              <th rowspan="2">หมายเหตุ</th>
                                            </tr>
                                            <tr>
                                              <th width="69" align="center">1</th>
                                              <th width="95" align="center">2</th>
                                              <th width="95" align="center">3</th>
                                              <th width="95" align="center">4</th>
                                              <th width="95" align="center">5</th>
                                              <th width="100" align="center">6</th>
                                              <th>ผ่าน&lt;2.5</th>
                                              <th>ไม่ผ่าน &gt;2.5</th>
                                            </tr>
                                          </thead>
                                          <tbody>
                                            <?php
													while($objResult = mysqli_fetch_array($objQuery)){

                                                        $strSQL1 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 0,1;";
														$objQuery1 = mysqli_query($con,$strSQL1);  
														$objResult1 = mysqli_fetch_array($objQuery1);

                                                        $strSQL2 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 1,1;";
														$objQuery2 = mysqli_query($con,$strSQL2);  
														$objResult2 = mysqli_fetch_array($objQuery2);

                                                        $strSQL3 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 2,1;";
														$objQuery3 = mysqli_query($con,$strSQL3);  
														$objResult3 = mysqli_fetch_array($objQuery3);

                                                        $strSQL4 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 3,1;";
														$objQuery4 = mysqli_query($con,$strSQL4);  
														$objResult4 = mysqli_fetch_array($objQuery4);

                                                        $strSQL5 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 4,1;";
														$objQuery5 = mysqli_query($con,$strSQL5);  
														$objResult5 = mysqli_fetch_array($objQuery5);

                                                        $strSQL6 = "SELECT * FROM qc_resultsnift,qc_resultsniftsub
                                                        where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                        and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                         and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                        and qc_resultsniftsub.Topic_id='T005'
                                                        and qc_resultsnift.Item_id='$objResult[Item_id]'
                                                        and qc_resultsnift.Cli_code='$objResult[Cli_code]'
                                                        LIMIT 5,1;";
														$objQuery6 = mysqli_query($con,$strSQL6);  
														$objResult6 = mysqli_fetch_array($objQuery6);


													?>
                                            <tr>
                                              <td width="150" class="center"><?=$objResult['Cli_date'];  ?></td>
                                              <td width="200"><?=$objResult['Item_id']." - ".$objResult['Item_name']; ?></td>
                                              <td width="100"><?=$objResult['Cli_code']; ?></td>
                                              <td width="100"><?=$objResult['Cli_ref']; ?></td>
                                              <td width="69"><?php //echo $objResult1['result'];
                                                                    
                                                                    if(isset($objResult1['result'])) 
																	{echo $objResult1['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult2['result'])) 
																	{echo $objResult2['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php
                                                                    if(isset($objResult3['result'])) 
																	{echo $objResult3['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult4['result'])) 
																	{echo $objResult4['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult5['result'])) 
																	{echo $objResult5['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 
                                                                    if(isset($objResult6['result'])) 
																	{echo $objResult6['result']." ";}
                                                                    else{echo "";}
                                                                    ?></td>
                                              <td><?php 

																	//คำนวน count
																	$strSQLa = "SELECT AVG(result) FROM qc_resultsnift,qc_resultsniftsub
                                                                    where qc_resultsnift.Item_id=qc_resultsniftsub.Item_id
                                                                    and qc_resultsnift.Cli_code=qc_resultsniftsub.Cli_code
                                                                    and qc_resultsnift.per_id=qc_resultsniftsub.per_id
                                                                    and qc_resultsniftsub.Topic_id='T005'
																	and qc_resultsnift.Item_id='$objResult[Item_id]'
																	and qc_resultsnift.Cli_code='$objResult[Cli_code]'";
																	$objQuerya = mysqli_query($con,$strSQLa);  
																	$objResulta = mysqli_fetch_array($objQuerya);

																	$counttotal = $objResulta['AVG(result)'];
																	//$counttotala=$counttotal*3;
																	echo number_format( $counttotal, 2 );
																	
																	


																		?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	    echo "/";
																	     
																	}else if($counttotal>=2.5){
																	    
																	    
																	}
																	?></td>
                                              <td align="center" width="70"><?PHP
                                                                    
																	if($counttotal=='0'){
																	    
																	    
																	}else if($counttotal<'2.5' AND $counttotal>'0'){
																	    
																	   
																	     
																	}else if($counttotal>=2.5){
																	    
																	     echo "/";
																	}
																	?></td>
                                              <td width="70" align="center"><?php echo $objResult['Cli_record'] ?></td>
                                              <td width="100"><?php echo $objResult['Cli_checker'] ?></td>
                                              <td width="74"><?php echo $objResult['Cli_note']; 
                                                                    
																	?></td>
                                            </tr>
                                            <?php
                                                            }

                                                        ?>
                                          </tbody>
                                        </table>
                                        <?
                                                
											}
										?>

										
										  </div>
												
									  </div>
											</div>
										</div>
									</div>
								</div>

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->


			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->
		<script src="../assets/js/jquery-2.1.4.min.js"></script>

		<!-- <![endif]-->

		<!--[if IE]>
<script src="assets/js/jquery-1.11.3.min.js"></script>
<![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="../assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->

		<!-- ace scripts -->
		<script src="../assets/js/ace-elements.min.js"></script>
		<script src="../assets/js/ace.min.js"></script>

		<!-- inline scripts related to this page -->
	</body>
</html>
