<?php

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

include("config.inc.php");
ini_set('max_execution_time', $config['ReportTimeExecution']);

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

}

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

	$query1="select * from items where item_code='".$_GET['icode']."'";
	$result1=mysql_query($query1,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($result1)){
	extract($rows);
	//$iccode=$Item_Code.",".$Item_Description;

	}
	$_GET['post']="1";
}


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

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



?>

<!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 Account Type</title>

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

function clearform()
{
	document.form1.Pacc_Code.value='';
	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;
	font-size: 12px;
}
.style3 {color: #999999}
.style4{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="800" border="0" align="center">
    <tr>
      <th colspan="3" bgcolor="#DDDDDD"><span class="style1">Search for Account Type </span></th>
    </tr>
  
   <tr>
   <td bgcolor="#DDDDDD" colspan="2" > <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Account Type  <br> Code / Name.</span></td>
  
      
      <th bgcolor="#DDDDDD" align='left'><input type="hidden" name="textfield2" value="<?php echo $Item_Code; ?>"  />
	  <input type="text" name="Pacc_Code" value="<?php echo $Pacc_Code; ?>"  />
	  <input type="hidden" name="str" value="<?php echo $str; ?>"  />
	  <input type="hidden" name="Acctype_code" value="<?php echo $_GET['Acctype_code']; ?>"  />
	  <input type="hidden" name="Acctype_name" value="<?php echo $_GET['Acctype_name']; ?>"  />
    
	      
	        <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="Clear" value="Clear" onclick="clearform();"
			 style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		</tD><th>
        
      <input name="item1" type="hidden" id="item1" value="<?php echo $_GET['item']; ?>" /></th>
      
    </tr>


<?php if($_GET['post']=="1") { ?>
<script type="text/javascript" language="javascript">
x=document.form1;
str=x.str.value;

if(str=="1"){
opener.document.clientdt.client_checkaccount.value=document.form1.Acctype_code.value;


self.close();
}



</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="110"><span class="style2">Account Code </span></td>
      <td width="411" colspan="2"><span class="style2">Account Name </span></td>
    
    </tr>
<?php
$query1="select Acctype_code,Acctype_name from acctype ";

if ($Pacc_Code !='')
$query1 = $query1 ." where (Acctype_code like '%".$Pacc_Code."%' or  Acctype_name like '%".$Pacc_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='font-size:12px;color:#0000FF;background-color:".$grid_color1."'";
	
	}else{
		
	$Color="style='font-size:12px;color:#0000FF;background-color:".$grid_color2."'";	
}

?>
    <tr <?php echo $Color; ?>>
      <td align="left"><a href="List_AccountTypes.php?post=1&str=<?php echo $str; ?>&Acctype_code=<?php echo $Acctype_code; ?>&Acctype_name=<?php echo $Acctype_name; ?>"><span class="style4"><?php echo $Acctype_code; ?></span></a></td>
      <td colspan="2"><a href="List_AccountTypes.php?post=1&str=<?php echo $str; ?>&Acctype_code=<?php echo $Acctype_code; ?>&Acctype_name=<?php echo $Acctype_name; ?>"><span class="style4"><?php echo $Acctype_name; ?></span></a></td>
    
      
    </tr>
<?php
}
?>
  </table>
</form>
</body>
</html>
