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

}

$query_grouping="select group_code from grouping where Increment='".$Increment."'";
$result_grouping=mysql_query($query_grouping,$connection) or die(mysql_error());
$rowgrouping=mysql_fetch_row($result_grouping);
$group_code=$rowgrouping[0];



?>

<!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 Jour Types</title>
<script type="text/javascript" language="javascript">

function clearform()
{
  document.form1.PRef.value='';
  document.form1.action='Form_Grouping_TransactionTypes.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>

<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"> Journal Types</span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Supplier <br> Code / Name</span></td>
      <td bgcolor="#DDDDDD"><input type="text" name="PRef" value="<?php echo $PRef; ?>"  />
        <input name="code1" type="text" id="code1"  value="<?php echo $lcode;?>">
	   <input name="Increment" type="hidden"   value="<?php echo $Increment; ?>">
	
     
        <input name="desc1" type="hidden" id="desc1" value="<?php echo $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($post=="1") { ?>
	
		
<script type="text/javascript" language="javascript">

	
	document.form1.action='Form_Grouping_TransactionTypes_Actions.php';
	document.form1.submit();

</script>

<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="136"><span class="style2">Jourtype Code </span></td>
      <td width="411" colspan="1"><span class="style2">Jourtype Name </span></td>
  
    </tr>
<?php
$query1=" select TYPE_NAME,Type_Desc ".
		" from transactionsetup 
		left join jourtype on jourtype.TYPE_NAME=transactionsetup.Journal_type
		where group_code='".$group_code."'";
		
		$query1=$query1." and (TYPE_NAME like"."('%".$PRef."%') or Type_Desc like"."('%".$PRef."%'))
		 order by TYPE_NAME";
	

//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="Form_Grouping_TransactionTypes.php?post=1&lcode=<?php echo $rows[0]; ?>&Increment=<?php echo $Increment; ?>"><?php echo $rows[0]; ?></a></td>
      <td colspan="1"><a href="Form_Grouping_TransactionTypes.php?post=1&lcode=<?php echo $rows[0]; ?>&Increment=<?php echo $Increment; ?>"><?php echo $rows[1]; ?></a></td>

    </tr>
	
<?php }?>

  </table>
  
 <?php  if($closewindow=='1'){
			echo"<script type='text/javascript'>";
			echo"self.close();";
			echo"</script>";
		}
?>
 </form>
</body>
</html>
