<?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['lcode']!=""){

$query1="select warehouse_code,warehouse_name from warehouse where warehouse_code='".$_GET['lcode']."'";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
extract($rows);
//$cgcode=$Ledger_number.",".$Ledger_name;
}

$post="1";
//header("location:header3.php");
}

?>

<!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>Untitled Document</title>
<script type="text/javascript" language="javascript">
function postitem(){
x=document.form1;
item1=x.item1.value;

if(item1=="1"){
opener.document.form1.fromcode.value=document.form1.code1.value;
opener.document.form1.fromname.value=document.form1.desc1.value;
self.close();
}else if(item1=="2"){
opener.document.form1.tocode.value=document.form1.code1.value;
opener.document.form1.toname.value=document.form1.desc1.value;
self.close();
}
}

function clearform()
{
  document.form1.PLedger_number.value='';
  document.form1.PLedger_name.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="800" border="0" align="center">
    <tr>
      <th colspan="5" bgcolor="#DDDDDD"><span class="style1">ALL REGISTERED CLIENTS </span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Warehouse  <br> Code / Name</span></td>
      <td bgcolor="#DDDDDD"><input type="text" name="PLedger_number" value="<?php echo $PLedger_number; ?>"  />
        <input name="code1" type="hidden" id="code1"  value="<?php echo $warehouse_code; ?>"></td>
      <td bgcolor="#DDDDDD"><input type="text" name="PLedger_name"  value="<?php echo $PLedger_name; ?>" size='35'/>
	    <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 $warehouse_name; ?>" /></td>
      <td bgcolor="#DDDDDD"><input name="item1" type="hidden" id="item1" value="<?php echo $_GET['item']; ?>" /></td>
    </tr>
<?php if($post=="1") { ?>
<script type="text/javascript" language="javascript">
x=document.form1;
item1=x.item1.value;

if(item1=="1"){
opener.document.form1.fromcode.value=document.form1.code1.value;
opener.document.form1.fromname.value=document.form1.desc1.value;
self.close();
}else if(item1=="2"){
opener.document.form1.tocode.value=document.form1.code1.value;
opener.document.form1.toname.value=document.form1.desc1.value;
self.close();
}
</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="136"><span class="style2">Warehouse Code </span></td>
      <td width="411" colspan="2"><span class="style2">Warehouse Name </span></td>
      <td width="57"><span class="style3"></span></td>
    </tr>
<?php
$query1=" select warehouse_code, warehouse_name from warehouse ".
        " where warehouse_code like '".$PLedger_number."%' ".
		" and warehouse_name like '%".$PLedger_name."%' ".
		" order by warehouse_code";
		

$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_warehouse.php?lcode=<?php echo $warehouse_code; ?>&item=<?php echo $_GET['item']; ?>"><?php echo $warehouse_code; ?></a></td>
      <td colspan="2"><a href="select_warehouse.php?lcode=<?php echo $warehouse_code; ?>&item=<?php echo $_GET['item']; ?>"><?php echo $warehouse_name; ?></a></td>
      <td>&nbsp;</td>
    </tr>
<?php
}
?>
  </table>
</form>
</body>
</html>
