<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");
include("function.inc.php");
include("Functions_Trans.php");
set_time_limit(0);

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if($closeWin == '') $closeWin = 0;

print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<title>Search Confirmed Preparation Order</title>
<script type="text/javascript" language="javascript">

function clacltotalAct(){
	var x =document.prodinfo;
	
	var strddt1 = document.getElementById("txtpackingdt_amountAct").value;
	var strddt2 = document.getElementById("txtpackingdt_nbrAct").value;
	
	var strddt3 = document.getElementById("txtpackingdt_amountAct2").value;
	var strddt4 = document.getElementById("txtpackingdt_nbrAct2").value;
	
	if( strddt1>=0 && strddt2>=0 && strddt3>=0 && strddt4>=0 ){
		document.getElementById("txttotalAct").value=strddt1*strddt2;
		document.getElementById("txttotalAct2").value=strddt3*strddt4;
		if(document.getElementById("txttotalStrd").value != ''){
			var dt1 = document.getElementById("txttotalAct").value; 
			var dt2 = document.getElementById("txttotalStrd").value; 
			var dt3 = document.getElementById("txttotalAct2").value;
			
			var dtotal = parseInt(dt1) + parseInt(dt2)+parseInt(dt3);
			document.getElementById("txttotalSum").value = dtotal;
		}
	}
	
}




function clacltotalStrd(){
	var x =document.prodinfo;
	
	var strddt1 = document.getElementById("txtpackingdt_amountStrd").value;
	var strddt2 = document.getElementById("txtpackingdt_nbrStrd").value;
	if( strddt1>=0 && strddt2>=0){
		document.getElementById("txttotalStrd").value=strddt1*strddt2;
		if(document.getElementById("txttotalAct").value != '')
			var dt1 = document.getElementById("txttotalAct").value; 
			var dt2 = document.getElementById("txttotalStrd").value; 
			var dtotal = parseInt(dt1) + parseInt(dt2);
			document.getElementById("txttotalSum").value = dtotal;
	}
	
	
}

function SubmitInfo(txtPrdId){
	var x =document.prodinfo;
	var mainmode = 'updateinfo';
	
	x.action = "Form_Assemble_Actions.php?mainmode="+mainmode+"&mode=&SPrdId="+txtPrdId;
	x.submit();
	
}

function CloseForm(){
	opener.document.production.value=document.prodinfo.txttotalSum.value;
	opener.document.production.submit();
	self.close();
}
</script>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}

.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}

.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}

.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #000000 ;font-size: 10px;}

</style>

</head>
<body>
<form name='prodinfo' method='post' action=''>
<input type='hidden' name='newbatchno' id='newbatchno' value='$newbatchno'>
<input type='hidden' name='newRemark' id='newRemark' value='$newRemark'>

HERE;


	  echo"<table cellpadding='0' cellspacing='0' border='0'  align='left' style='table-layout:fixed'  width='1150px'>";
echo"<tr>
		<td id='search-top1' style='height:34px; width:31px;'>&nbsp;</td>
	  	<td id='search-top2' style='height:34px;' align='center' valign='middle'>
			<table border='0'>
			<tr><td></td></tr>
			</table>
		</td>
		<td id='search-top3' style='height:34px; width:31px;'>&nbsp;</td>
	</tr>";

echo"<tr><td id='search-content1' style='width:31px;'>&nbsp;</td>
		 <td id='search-content2' >";
		 
echo"<table border='0' cellspacing='1' style='table-layout:fixed'>
	  <col width=200>
	  <col width=100>
	  <col width=100>
	  <col width=100>";
	  
	  
$query = "select item_Shade, production_shadeAct, item_Strength , production_strengthAct, production_prevBatchno , production_referenceStd ,
		production_viscosityDirect, production_viscosityReduced, packingdt_amountStrd, packingdt_nbrStrd , packingdt_amountAct,
		packingdt_nbrAct, item_reducer, Item_UnitSalesDesc, item_retarder, item_ViscosityDirect,item_ViscosityReduced,production_gloss,production_Adhesion,item_gloss,item_Adhesion,
		production_Alkali,production_scuff,item_Alkali,item_scuff,packingdt_amountAct2,packingdt_nbrAct2 from temp_production
		left join items on items.item_code = temp_production.item_code
		where Production_id=$txtPrdId"; //echo $query;
$res = mysql_query($query,$connection);
$rows = mysql_fetch_row($res);	

$txtprodshadestrd = $rows[0];
$txtprodshadeact = $rows[1];
$txtprodstrengthstrd = $rows[2];
$txtprodstrengthact = $rows[3];
$txtproduction_prevBatchno = $rows[4];
$txtproduction_referenceStd = $rows[5];

$txtproduction_viscosityDirect = $rows[6];
$txtproduction_viscosityReduced = $rows[7];

$txtproduction_gloss = $rows[17];
$txtproduction_Adhesion = $rows[18];

$txtpackingdt_amountStrd = $rows[8];
$txtpackingdt_nbrStrd = $rows[9];

$txtpackingdt_amountAct = $rows[10];
$txtpackingdt_nbrAct = $rows[11];

$txtReducer = $rows[12];
$txtRetarder = $rows[14];

$txtitem_ViscosityDirect = $rows[15];
$txtitem_ViscosityReduced = $rows[16];

$txtitem_gloss = $rows[19];
$txtitem_Adhesion = $rows[20];

$txtproduction_Alkali = $rows[21];
$txtproduction_scuff = $rows[22];

$txtitem_Alkali = $rows[23];
$txtitem_scuff = $rows[24];


$txtpackingdt_amountAct2 = $rows[25];
$txtpackingdt_nbrAct2 = $rows[26];

echo "<tr height='50' bgcolor='#F7F7F7'><td><span class='style1'>Quality Assurance:</span></td><td><span class='style1'>standard</span></td><td><span class='style1'>Actual</span></td>";
echo "</tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Shade</span></td><td><input type='text' name='txtprodshadestrd' id='txtprodshadestrd' value='$txtprodshadestrd' style='width:80px;' readonly></td><td><input type='text' name='txtprodshadeact' id='txtprodshadeact' value='$txtprodshadeact' style='width:80px;' ></td></tr>";	

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Strength</span></td><td><input type='text' name='txtprodstrengthstrd' id='txtprodstrengthstrd' value='$txtprodstrengthstrd' style='width:80px;' readonly></td><td><input type='text' name='txtprodstrengthact' id='txtprodstrengthact' value='$txtprodstrengthact'  style='width:80px;' ></td></tr>";	

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Previous Batch No.</span></td><td colspan='2'><input type='text' name='txtproduction_prevBatchno' id='txtproduction_prevBatchno' value='$txtproduction_prevBatchno' style='width:80px;'></td></tr>";	

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Reference Std</span></td><td colspan='2'><input type='text' name='txtproduction_referenceStd' id='txtproduction_referenceStd' value='$txtproduction_referenceStd' style='width:80px;'></td></tr>";	

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Viscosity Direct</span></td><td><input type='text' name='txtitem_ViscosityDirect' id='txtitem_ViscosityDirect' value='$txtitem_ViscosityDirect' style='width:80px;'></td>
<td><input type='text' name='txtproduction_viscosityDirect' id='txtproduction_viscosityDirect' value='$txtproduction_viscosityDirect' style='width:80px;'></td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Viscosity Reduced</span></td><td><input type='text' name='txtitem_ViscosityReduced' id='txtitem_ViscosityReduced' value='$txtitem_ViscosityReduced' style='width:80px;'></td>
	<td><input type='text' name='txtproduction_viscosityReduced' id='txtproduction_viscosityReduced' value='$txtproduction_viscosityReduced' style='width:80px;'></td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Gloss</span></td><td><input type='text' name='txtitem_gloss' id='txtitem_gloss' value='$txtitem_gloss' style='width:80px;'></td>
<td><input type='text' name='txtproduction_gloss' id='txtproduction_gloss' value='$txtproduction_gloss' style='width:80px;'></td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Adhesion</span></td><td><input type='text' name='txtitem_Adhesion' id='txtitem_Adhesion' value='$txtitem_Adhesion' style='width:80px;'></td>
	<td><input type='text' name='txtproduction_Adhesion' id='txtproduction_Adhesion' value='$txtproduction_Adhesion' style='width:80px;'></td></tr>";


echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Alkali Resistance</span></td><td><input type='text' name='txtitem_Alkali' id='txtitem_Alkali' value='$txtitem_Alkali' style='width:80px;'></td>
<td><input type='text' name='txtproduction_Alkali' id='txtproduction_Alkali' value='$txtproduction_Alkali' style='width:80px;'></td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Scuff Resistance</span></td><td><input type='text' name='txtitem_scuff' id='txtitem_scuff' value='$txtitem_scuff' style='width:80px;'></td>
	<td><input type='text' name='txtproduction_scuff' id='txtproduction_scuff' value='$txtproduction_scuff' style='width:80px;'></td></tr>";

	
	
echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Reducer</span></td><td colspan='2'><input type='text' name='txtReducer' id='txtReducer' value='$txtReducer' style='width:80px;' readonly></td></tr>";
echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Retarder</span></td><td colspan='2'><input type='text' name='txtRetarder' id='txtRetarder' value='$txtRetarder' style='width:80px;' readonly></td></tr>";
echo "<tr height='30'><td></td></tr>";
echo "<tr height='50' bgcolor='#F7F7F7'><td colspan='3'><span class='style1'>Dispatch Instructions</span></td></tr>";
echo "<tr height='30' bgcolor='#F7F7F7'><td colspan='3'><span class='style1'>Packing Details :</td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Standard : </span></td>
<td ><input type='text' name='txtpackingdt_amountStrd' id='txtpackingdt_amountStrd' value='$txtpackingdt_amountStrd' style='width:80px;' onkeyup=\"clacltotalStrd();\"></td>";
	echo "<td><input type='text' name='txtpackingdt_nbrStrd' id='txtpackingdt_nbrStrd' value='$txtpackingdt_nbrStrd' style='width:80px;' onkeyup=\"clacltotalStrd();\"></td>";
	if($txtpackingdt_amountStrd != '' || $txtpackingdt_nbrStrd != '' )
		$txttotalStrd = $txtpackingdt_amountStrd * $txtpackingdt_nbrStrd;
	else $txttotalStrd = 0;
	echo "<td align='right'><input type='text' name='txttotalStrd' id='txttotalStrd' value='$txttotalStrd' style='width:80px;border:none;' readonly><td align='left'>$rows[13]</td></td>";
	echo "</tr>";
	
echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Actual  : </span></td><td><input type='text' name='txtpackingdt_amountAct' id='txtpackingdt_amountAct' value='$txtpackingdt_amountAct' style='width:80px;' onkeyup=\"clacltotalAct();\"></td>";
	echo "<td><input type='text' name='txtpackingdt_nbrAct' id='txtpackingdt_nbrAct' value='$txtpackingdt_nbrAct' style='width:80px;' onkeyup=\"clacltotalAct();\"></td>";
	if($txtpackingdt_amountAct != '' || $txtpackingdt_nbrAct != '' )
		$txttotalAct = $txtpackingdt_amountAct * $txtpackingdt_nbrAct;
	else $txttotalAct = 0;
	echo "<td align='right'><input type='text' name='txttotalAct' id='txttotalAct' value='$txttotalAct' style='width:80px;border:none;' readonly></td><td align='left'>$rows[13]</td>";
	echo "</tr>";
	
echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Actual 2 : </span></td><td><input type='text' name='txtpackingdt_amountAct2' id='txtpackingdt_amountAct2' value='$txtpackingdt_amountAct2' style='width:80px;' onkeyup=\"clacltotalAct();\"></td>";
	echo "<td><input type='text' name='txtpackingdt_nbrAct2' id='txtpackingdt_nbrAct2' value='$txtpackingdt_nbrAct2' style='width:80px;' onkeyup=\"clacltotalAct();\"></td>";

	if($txtpackingdt_amountAct2 != '' || $txtpackingdt_nbrAct2 != '' )
		$txttotalAct2 = $txtpackingdt_amountAct2 * $txtpackingdt_nbrAct2;
	else $txttotalAct2 = 0;
	
	echo "<td align='right'><input type='text' name='txttotalAct2' id='txttotalAct2' value='$txttotalAct2' style='width:80px;border:none;' readonly></td><td align='left'>$rows[13]</td>";
	echo "</tr>";	
	
	
	
	$txttotalSum = $txttotalAct + $txttotalStrd+$txttotalAct2;
echo "<tr height='30' bgcolor='#F7F7F7'><td><span class='style1'>Yield : </span></td><td></td>
<td align='right' colspan='2'><input type='text' name='txttotalSum' id='txttotalSum' value='$txttotalSum' style='width:80px;border:none;' readonly></td>";
echo "<td align='right' colspan='2'>$rows[13]</td></tr>";

echo "<tr height='30' bgcolor='#F7F7F7'>
<td><span class='style1'></span></td>
<td></td>
       <td align='right'><span class='style4'>";
		echo" <button type='button' id='btnsubInfo' name='btnsubInfo' onclick='SubmitInfo($txtPrdId);return false;' title='Submit Info'><span><span>Submit</span></span></button>";
		
		echo "</td>";
		echo "<td>";
		echo" <button type='button' id='btnclose' name='btnclose' onclick='CloseForm();return false;' title='Close'><span><span>Close</span></span></button>";
		echo "</td>";




	
echo"</table></div></td><td id='search-content3' style='width:31px;'>&nbsp;</td></tr>";		


	
echo"	<tr >
		<td id='search-bottom1' style='height:34px; width:31px;'>&nbsp;</td>
		<td id='search-bottom2' style='height:34px; width:920px;' valign='top'><table width='100%' border=0 height=28px>
		<tr><td style='width:280px;'>&nbsp;</td><td align='right' style='width:74px;border-right:1px solid #000000;'>";
		
	
		
		echo"</td><td width='150' align='left'>";
		
		
		echo"</td><td width='170'>&nbsp;</td></tr>";
		echo"</table></td><td id='search-bottom3' style='height:34px; width:31px;'>&nbsp;</td>";

echo"</td></tr></table>";
	

if($closeWin == 1){
	echo "<script>CloseForm();</script>";
}
          

		  

print <<<HERE

</form>
</body>

HERE;

?>