<?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($_SESSION['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);

}



$str   		= $_GET['str']; if ($str == ""){$str = $_POST["str"];}
$startrange = $_GET['startrange'];if ($startrange == ""){$startrange = $_POST["startrange"];}
$perpage  	= $_GET['perpage'];if ($perpage == ""){$perpage = $_POST["perpage"];}

$PLedger_number   = $_POST["PLedger_number"]; if ($PLedger_number == ""){$PLedger_number = $_GET["PLedger_number"];}  

$querylog="SELECT ifnull(archiving,0)  from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}


?>

<!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>List of Areas</title>
<script type="text/javascript" language="javascript">

function clearform()
{
  document.form1.PLedger_number.value='';
  document.form1.action='List_Area.php';
  document.form1.submit();

}
</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>
<?php
$query="select  Stamp1, Stamp2, Stamp3, Stamp4, Stamp5, Stamp6 From location where code='$lcode'";
//echo $query;
$result1=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
	$Stamp1=$rows[0];
	$Stamp2=$rows[1];
	$Stamp3=$rows[2];
	$Stamp4=$rows[3];
	$Stamp5=$rows[4];
	$Stamp6=$rows[5];
}?>
<body>
<form id="form1" name="form1" method="post" action="">
  <table width="800" border="0" align="center">
    <tr>
      <th colspan="2" bgcolor="#DDDDDD"><span class="style1"> Areas</span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Area <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 $_GET['lcode']; ?> ">
	   <input name="str" type="hidden"   value="<?php echo $str; ?>">
	   <input name="Stamp1" type="hidden"   value="<?php echo $Stamp1; ?>">
	   <input name="Stamp2" type="hidden"   value="<?php echo $Stamp2; ?>">
	   <input name="Stamp3" type="hidden"   value="<?php echo $Stamp3; ?>">
	   <input name="Stamp4" type="hidden"   value="<?php echo $Stamp4; ?>">
	   <input name="Stamp5" type="hidden"   value="<?php echo $Stamp5; ?>">
	   <input name="Stamp6" type="hidden"   value="<?php echo $Stamp6; ?>">
	
     
        <input name="desc1" type="hidden" id="desc1" value="<?php echo $_GET['desc1']; ?>" />
	    <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;'/></td>
   
    </tr>
<?php if($_GET['post']=="1") { ?>



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

var s=document.form1.str.value;



if(document.form1.str.value=='1'){


var d=document.form1.desc1.value;


opener.document.clientdt.area_code.value=document.form1.code1.value;
opener.document.clientdt.areaname.value=document.form1.desc1.value;


}

else if(document.form1.str.value=='2'){
opener.document.clientdt.delivery_areacode.value=document.form1.code1.value;
opener.document.clientdt.delivery_areaname.value=document.form1.desc1.value;


}

else if(document.form1.str.value=='3'){
opener.document.supplierdt.area_code.value=document.form1.code1.value;
opener.document.supplierdt.areaname.value=document.form1.desc1.value;


}


else if(document.form1.str.value=='4'){
opener.document.salesman.area_code.value=document.form1.code1.value;
opener.document.salesman.areaname.value=document.form1.desc1.value;


}
else if(document.form1.str.value=='5'){
opener.document.salesman.area_codedt.value=document.form1.code1.value;
opener.document.salesman.area_namedt.value=document.form1.desc1.value;
}
else if(document.form1.str.value=='6'){
opener.document.clientdt.clientiparea_code.value=document.form1.code1.value;

}
else if(document.form1.str.value=='7'){
opener.document.Manifest.recieptplace.value=document.form1.code1.value;

}
else if(document.form1.str.value=='8'){
opener.document.Manifest.placedelivery.value=document.form1.code1.value;
/*
opener.document.Manifest.stamp1.value=document.form1.Stamp1.value;
opener.document.Manifest.stamp2.value=document.form1.Stamp2.value;
opener.document.Manifest.stamp3.value=document.form1.Stamp3.value;
opener.document.Manifest.stamp4.value=document.form1.Stamp4.value;
opener.document.Manifest.stamp5.value=document.form1.Stamp5.value;
opener.document.Manifest.stamp6.value=document.form1.Stamp6.value;
*/


}

else if(document.form1.str.value=='9'){
opener.document.Port.Port_Location.value=document.form1.code1.value;

}

self.close();

</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="136"><span class="style2">Area code </span></td>
      <td width="411" colspan="1"><span class="style2">Area Name </span></td>
  
    </tr>
<?php




$query1=" select area_code,area_name ".
		" from area ";
		
		$query1=$query1." where if ('$archiving' = '1', area_country=1 , 1=1) AND  (area_code like"."('%".$PLedger_number."%') or area_name like"."('%".$PLedger_number."%'))
		
		 order by area_code";
	

		
//echo $query1;
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){


$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; 
	
	
	?>>
	
	 <?php
		$desc=ereg_replace("'","%27",$rows[1]);
		?>
		
		
      <td align="left"><a href="List_Area.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&desc1=<?php echo $desc; ?>"><?php echo $rows[0]; ?></a></td>
      <td colspan="1"><a href="List_Area.php?str=<?php echo $str; ?>&post=1&lcode=<?php echo $rows[0]; ?>&desc1=<?php echo $desc; ?>"><?php echo $rows[1]; ?></a></td>

    </tr>
	
<?php }?>
  </table>
</form>
</body>
</html>
