<?php
session_start();

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

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");

$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2 from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
extract($rowsetup);
}

print<<<HERE

<html>
<head>
<script type="text/javascript" language="javascript">

function Edit_Record(warehouse_code){


opener.document.warehouse.mode.value='edit';
opener.document.warehouse.warehouse_code.value=warehouse_code;
opener.warehouse.submit();
self.close();
}

function confirm_delete(Code) {
	document.warehouse.action="Form_warehouse1_Actions.php?mode=delete&warehousecode="+Code;
		document.warehouse.submit();
	}
	
	
function findfield(){
document.warehouse.key.value=' ';
document.warehouse.action='form_warehousesearch1.php';
document.warehouse.submit();
}

function cancelfield(){
document.warehouse.key.value=' ';
document.warehouse.action='form_warehousesearch1.php?mode=';
document.warehouse.submit();
}


</script>
</head>
<body>
HERE;

echo"
<form name='warehouse' method='post'>
<table border=1 width=100%>

<tr bgcolor='#DDDDDD'>
	    <td align='center' colspan='5'><span class='style16'>List of warehouse</span></td></tr>
	  <tr bgcolor='#DDDDDD' height=30px>
	    <td align='left' colspan='3'><span class='style11'>Search by Code</span></td>";

echo"<td><input type='button' onclick=findfield();  value='find'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'>";
echo"<input type='button' onclick=cancelfield(); value='cancel'
style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'>";


echo"<input type=text name='key' value='$key'></td></tr>";
$query="select warehouse_code,warehouse_name from warehouse";
$query=$query."  where warehouse_code like '%$key%' or warehouse_name like '%$key%'    " ; 
 
//echo$query;

$result=mysql_query($query,$connection);	
 while ($row=mysql_fetch_row($result)){
 		
	extract($rows);
	$ct+=1;

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

	echo'<tr '.$Color.'>';
	
print<<<HERE
<td align=center width='3%'><img border='0' src='images/button_edit.png' width='12' height='13' title='Edit Detail' onmouseover="this.style.cursor='pointer'" onclick="Edit_Record('$row[0]')" $ModMode></td>

<td align=center width='3%'><img border='0' src='images/c_delete.png' width='9' height='10' title='Delete Detail' onmouseover="this.style.cursor='pointer'" OnClick="confirm_delete('$code');" $DelMode></td>
HERE;

 
 
echo"</a></td><td>&nbsp;$row[0]</td><td>$row[1]</td></tr>";

}

echo"
</table>
</form>
</body>
</html>
";


?>





