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

}



?>

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

function CloseePage(){
	opener.document.cst.action='Form_CSTjour.php';
	opener.document.cst.submit();
	self.close();
}

function clearform()
{
  document.form1.PLedger_number.value='';
  document.form1.action='List_distper.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="3" bgcolor="#DDDDDD"><span class="style1"> Projects </span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Project <br> Code / Name</span></td>
      <td bgcolor="#DDDDDD" colspan=2><input type="text" name="PLedger_number" value="<?php echo $PLedger_number; ?>"  />
        <input name="code1" type="hidden" id="code1"  value="<?php echo $lcode; ?>">
		 <input name="journaldt_id" type="hidden"   value="<?php echo $journaldt_id; ?>">
		<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">

var journaldtid=document.form1.journaldt_id.value;
var code=document.form1.code1.value;
document.form1.action="Form_Journal_Actions.php?distperid="+code+'&cstmode=insertDist&journaldt_id='+journaldtid;
document.form1.submit();



</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td width="136"><span class="style2">Project Code </span></td>
      <td width="411" colspan="2"><span class="style2">Project  Name </span></td>
      
    </tr>
<?php
$query1="  SELECT DistPer_id,DistPer_code,DistPer_Desc FROM DistPer";
		
$query1=$query1." where DistPer_code like"."('%".$PLedger_number."%') or DistPer_Desc like"."('%".$PLedger_number."%')
		 order by DistPer_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; ?>>
      <td align="left"><a href="List_distper.php?journaldt_id=<?php echo $journaldt_id?>&post=1&lcode=<?php echo $rows[0]; ?>"><?php echo $rows[1]; ?></a></td>
      <td colspan="2"><a href="List_distper.php?journaldt_id=<?php echo $journaldt_id?>&post=1&lcode=<?php echo $rows[0]; ?>"><?php echo $rows[2]; ?></a></td>

    </tr>
<?php
}

if($closepage=='1') {

	echo'<script type="text/javascript" language="javascript">CloseePage();';
	echo"</script>";

}

function explodeword($date)
{

$trim = explode('/',$date);
$trim = "$trim[2]"."-"."$trim[1]"."-"."$trim[0]";
return $trim;
}
?>
  </table>
</form>
</body>
</html>
