<?php
session_start();

include("config.inc.php");

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

$query1="select grid_color1,grid_color2 from setup";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
extract($rows);

}

if($_GET['heatno_no']!=""){

	$query1="select * from heatno where heatno_no='".$_GET['heatno_no']."'";
	$result1=mysql_query($query1,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($result1)){
    	extract($rows);
	}

    $post="1";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Select Heatno</title>
<script type="text/javascript" language="javascript">

function clearform()
{
  document.form1.PItem_Description.value='';
  document.form1.PItem_Code.value='';

}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style1 {
	color: #333333;
	font-weight: bold;
}
.style2 {
	color: #999999;
	font-weight: bold;
}
.style3 {color: #999999}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="700" border="0" align="center">
    <tr>
      <th colspan="2" bgcolor="#DDDDDD"><span class="style1"> ITEMS </span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD" width="300"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Item  <br> Code / Desc.</span></td>
      <td bgcolor="#DDDDDD" width="400"><input type="text" name="PItem_Code" value="<?php echo $PItem_Code; ?>" size=19 />
        <input name="code1" type="hidden" id="code1"  value="<?php echo $heatno_no; ?>">
      <input type="text" name="PItem_Description"  value="<?php echo $PItem_Description; ?>" size='15'/>
	    <input type="submit" name="Submit" value="Find" style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		<input type="button" name="cancelbtn" value="Cancel" onclick='clearform();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
        <input name="desc1" type="hidden" id="desc1" value="<?php echo $HeatNo_type; ?>" />
      <input name="heatno" type="hidden" id="heatno" value="<?php echo $_GET['heatno']; ?>" /></td>
    </tr>
<?php if($post=="1") { ?>
<script type="text/javascript" language="javascript">
x=document.form1;
heatno=x.heatno.value;

if(heatno=="1"){
	opener.document.form1.fromheatno.value=document.form1.code1.value;
	opener.document.form1.fromheatnotype.value=document.form1.desc1.value;
	opener.document.form1.toheatno.value=document.form1.code1.value;
	opener.document.form1.toheatnotype.value=document.form1.desc1.value;
	self.close();
}else if(heatno=="2"){
	opener.document.form1.toheatno.value=document.form1.code1.value;
	opener.document.form1.toheatnotype.value=document.form1.desc1.value;
	self.close();
}
if(heatno=="3"){
	opener.document.form1.fromheatno1.value=document.form1.code1.value;
	opener.document.form1.fromheatnotype1.value=document.form1.desc1.value;
	opener.document.form1.toheatno1.value=document.form1.code1.value;
	opener.document.form1.toheatnotype1.value=document.form1.desc1.value;
	self.close();
}else if(heatno=="4"){
	opener.document.form1.toheatno1.value=document.form1.code1.value;
	opener.document.form1.toheatnotype1.value=document.form1.desc1.value;
	self.close();
}

</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td><span class="style2">Item Code </span></td>
      <td colspan="1"><span class="style2">Item Description </span></td>
      
    </tr>
<?php
$query1=" select HeatNo_No, HeatNo_type from HeatNo ".
        " where HeatNo_No like '%".$PItem_Code."%' ".
		" and HeatNo_type like '%".$PItem_Description."%' ";		
 
$result1=mysql_query($query1,$connection) or die(mysql_error());
 
  
while($rows=mysql_fetch_array($result1)){
extract($rows);

$ct+=1;

if($ct%2==0)
{
	$Color="style='color:#0000FF;background-color:".$grid_color1."'";
	
	}else{
		
	$Color="style='color:#0000FF;background-color:".$grid_color2."'";	
}

?>
    <tr <?php echo $Color; ?>>
      <td align="left"><a href="select_heatno.php?heatno=<?php echo $heatno; ?>&heatno_no=<?php echo $HeatNo_No; ?>&HeatNo_type=<?php echo $HeatNo_type; ?>"><?php echo $HeatNo_No; ?></a></td>
      <td align="left" colspan="2"><a href="select_heatno.php?heatno=<?php echo $heatno; ?>&heatno_no=<?php echo $HeatNo_No; ?>&HeatNo_type=<?php echo $HeatNo_type; ?>"><?php echo $HeatNo_type; ?></a></td>
   
    </tr>
<?php
}
?>
  </table>
</form>
</body>
</html>
