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




$querylog="SELECT RA_FinancialAccounts as loginaccess, ExporttoExcel from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";
	$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
	}
if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	

	
$querylog="select * from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['useraccount']."'";
$resultlog=mysql_query($querylog) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
extract($rows);

}
$printaccess=$Print;
print <<< HERE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HERE;


$querysetup ="select base1, base2, if(DefaultBase=1, base1, base2) as defaultcurr from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
$rowsetup=mysql_fetch_row($resultsetup);
$defaultcurr = $rowsetup[2];


// Setting Initial Values For Parameters
$querydate=" Select Date_Format(Min(Journal_date),'%d/%m/%Y') As DefaultFromDate, ".
           " Date_Format(Max(Journal_date),'%d/%m/%Y') As DefaultToDate ".
		   " From JournalDt ";
$resultdate=mysql_query($querydate,$connection) or die(mysql_error());
$rowdate=mysql_fetch_row($resultdate);

if (!isset($fromdate))
  $fromdate = $rowdate[0];
if (!isset($todate))
  $todate = $rowdate[1];
  

  
$querycurrency="select Currency_code from currency order by currency_code";
$resultcurrency=mysql_query($querycurrency,$connection) or die(mysql_error());

//$queryfinancialtype="Select FinancialType_Code, FinancialType_Name  From FinancialType Where FinancialType_RelatedCode Is Null Order by FinancialType_Order";
$queryfinancialtype=" Select FinancialTot_Code, FinancialTot_Label  From FinancialTotLabel ".
                    " Where (FinancialTot_RelatedCode Is Null or FinancialTot_RelatedCode = '') ".
					" Order by FinancialTot_Code";
$resultfinancialtype=mysql_query($queryfinancialtype, $connection) or die(mysql_error());


$querydflproject="select project_code as defaultproject from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
extract($rows);

}
$querydflcostcent="select costcent_code as defaultcostcent from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
extract($rows);

}

$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$HTTP_SESSION_VARS['dbLabel'].".loginstk on project.project_code like concat(loginstk.project_code,'%') ".
			  " where user_account='".$HTTP_SESSION_VARS['useraccount']."' ".
			  " and (loginstk.project_code is not null and loginstk.project_code != '') ".
			  " order by project.project_code";
			  
$projectresult = mysql_query($queryproject,$connection) or die(mysql_error());
$projectrows   = mysql_num_rows($projectresult);
if ($projectrows == 0)
    $queryproject=" select distinct project_code, project_name from project order by project_code ";			  
$resultproject=mysql_query($queryproject,$connection) or die(mysql_error());


$querycostcent=" select distinct costcent.costcent_code, costcent_name ".
               " from costcent left join ".$HTTP_SESSION_VARS['dbLabel'].".loginstk on costcent.costcent_code like concat(loginstk.costcent_code,'%') ".
 			   " where user_account='".$HTTP_SESSION_VARS['useraccount']."' ".
			   " and (loginstk.costcent_code is not null and loginstk.costcent_code != '') ".
 			   " order by costcent.costcent_code";
			  
$costcentresult = mysql_query($querycostcent,$connection) or die(mysql_error());
$costcentrows   = mysql_num_rows($costcentresult);
if ($costcentrows == 0)
    $querycostcent=" select distinct costcent_code, costcent_name from costcent order by costcent_code ";			  
$resultcostcent=mysql_query($querycostcent,$connection) or die(mysql_error());


$querytreelevel = " Select Distinct FinancialTot_Level ".
                  " From FinancialTotLabel ".
				  " Where FinancialTot_Level > 1 and FinancialTot_Level Is Not Null ".
				  " Order by FinancialTot_Level ";
			  
$resulttreelevel = mysql_query($querytreelevel,$connection) or die(mysql_error());		

print <<< HERE

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->
<script type="text/javascript" language="javascript">
<!--

function printPrev(printaccess)
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < document.form1.reportoption.length; i++)
	{
		if (document.form1.reportoption[i].checked)
		{
			var varreportoption = document.form1.reportoption[i].value;
		}
	}
	 
	for (var i=0; i < document.form1.showledger.length; i++)
	{
		if (document.form1.showledger[i].checked)
		{
			var showledgertype = document.form1.showledger[i].value;
		}
	}
	 
  
	for (var i=0; i < document.form1.currency.length; i++)
	{
		if (document.form1.currency[i].checked)
		{
			var varcurrency = document.form1.currency[i].value;
		}
	}
  

	varshowdetail = 0;
	if (document.form1.showdetail.checked)    varshowdetail = 1;			
	
	varshowproject = 0;
	if (document.form1.showproject.checked)   varshowproject = 1;
	
	varshowcostcenter = 0;
	if (document.form1.showcostcenter.checked)   varshowcostcenter = 1;	
	
	varprintgrpproject = 0;
	if (document.form1.printgrpproject.checked)  varprintgrpproject = 1;	
	
	varprintdetproject = 0;
	if (document.form1.printdetproject.checked)  varprintdetproject = 1;			
	
	varshowprevbal = 0;
	if (document.form1.showprevbal.checked)    varshowprevbal = 1;			
	
	varshowzerobal = 0;
	if (document.form1.showzerobal.checked)    varshowzerobal = 1;			
	
	varmonthdist = 0;
	if (document.form1.monthdist.checked)    varmonthdist = 1;			 	
	
	varincomebycst = 0;
	if (document.form1.incomebycst.checked)   varincomebycst = 1;			 		
	
	varincomebyprj = 0;
	if (document.form1.incomebyprj.checked)   varincomebyprj = 1;		
	
	varparentprjcost = 0;
	if (document.form1.parentprjcost.checked)   varparentprjcost = 1;	

	varshowstock = 0;
	if (document.form1.showstock.checked)   varshowstock = 1;	
  
	varfromdate     = document.form1.fromdate.value;
	vartodate       = document.form1.todate.value;
	varfromprj      = document.form1.fromproject.value;
	varfromcst      = document.form1.fromcostcent.value;
	vartreelevel    = document.form1.treelevel.value;
  
  
   
	str =    'Rep_FinancialReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromproject='+varfromprj+'&fromcst='+varfromcst
			+'&reportoption='+varreportoption+'&showledgertype='+showledgertype+'&curr='+varcurrency+'&showdetail='+varshowdetail+'&showproject='+varshowproject
			+'&showcostcenter='+varshowcostcenter+'&printgrpproject='+varprintgrpproject+'&printdetproject='+varprintdetproject
			+'&showprevbal='+varshowprevbal+'&monthdist='+varmonthdist+'&treelevel='+vartreelevel+'&incomebycst='+varincomebycst
			+'&incomebyprj='+varincomebyprj+'&parentprjcost='+varparentprjcost+'&showstock='+varshowstock+'&showzerobal='+varshowzerobal;
		   
	if (printaccess==1) 
		window.open(str);
	else
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function ExportExcel()
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < document.form1.reportoption.length; i++)
	{
		if (document.form1.reportoption[i].checked)
		{
			var varreportoption = document.form1.reportoption[i].value;
		}
	}
	 
	for (var i=0; i < document.form1.showledger.length; i++)
	{
		if (document.form1.showledger[i].checked)
		{
			var showledgertype = document.form1.showledger[i].value;
		}
	}
	 
  
	for (var i=0; i < document.form1.currency.length; i++)
	{
		if (document.form1.currency[i].checked)
		{
			var varcurrency = document.form1.currency[i].value;
		}
	}
  

	varshowdetail = 0;
	if (document.form1.showdetail.checked)    varshowdetail = 1;			
	
	varshowproject = 0;
	if (document.form1.showproject.checked)   varshowproject = 1;
	
	varshowcostcenter = 0;
	if (document.form1.showcostcenter.checked)   varshowcostcenter = 1;	
	
	varprintgrpproject = 0;
	if (document.form1.printgrpproject.checked)  varprintgrpproject = 1;	
	
	varprintdetproject = 0;
	if (document.form1.printdetproject.checked)  varprintdetproject = 1;			
	
	varshowprevbal = 0;
	if (document.form1.showprevbal.checked)    varshowprevbal = 1;			
	
	varshowzerobal = 0;
	if (document.form1.showzerobal.checked)    varshowzerobal = 1;			
  
	varmonthdist = 0;
	if (document.form1.monthdist.checked)    varmonthdist = 1;			 	
	
	varincomebycst = 0;
	if (document.form1.incomebycst.checked)   varincomebycst = 1;			 		
	
	varincomebyprj = 0;
	if (document.form1.incomebyprj.checked)   varincomebyprj = 1;		
	
	varparentprjcost = 0;
	if (document.form1.parentprjcost.checked)   varparentprjcost = 1;	

	varshowstock = 0;
	if (document.form1.showstock.checked)   varshowstock = 1;	
  
	varfromdate     = document.form1.fromdate.value;
	vartodate       = document.form1.todate.value;
	varfromprj      = document.form1.fromproject.value;
	varfromcst      = document.form1.fromcostcent.value;
	vartreelevel    = document.form1.treelevel.value;
  
  
   
	str =    'Exp_FinancialReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromproject='+varfromprj+'&fromcst='+varfromcst
			+'&reportoption='+varreportoption+'&showledgertype='+showledgertype+'&curr='+varcurrency+'&showdetail='+varshowdetail+'&showproject='+varshowproject
			+'&showcostcenter='+varshowcostcenter+'&printgrpproject='+varprintgrpproject+'&printdetproject='+varprintdetproject
			+'&showprevbal='+varshowprevbal+'&monthdist='+varmonthdist+'&treelevel='+vartreelevel+'&incomebycst='+varincomebycst
			+'&incomebyprj='+varincomebyprj+'&parentprjcost='+varparentprjcost+'&showstock='+varshowstock+'&showzerobal='+varshowzerobal;
		   
	window.open(str);
	
}

function EnablePrintPrjCst() {
  x = document.form1;
  
  if (x.showproject.checked || x.showcostcenter.checked) {
	 x.printgrpproject.checked = false;
	 x.printgrpproject.disabled = false;
	 
	 if(x.showdetail.checked) {
		x.printdetproject.checked = false;
		x.printdetproject.disabled = false;
	 }
  } else {
	 x.printgrpproject.checked = false;
	 x.printgrpproject.disabled = true;
	 x.printdetproject.checked = false;
	 x.printdetproject.disabled = true;
  
  }
	

}

function EnablePrintPrjCstDt() {
  x = document.form1;
  
  if ((x.showproject.checked || x.showcostcenter.checked) && x.showdetail.checked ) {
		if (x.incomebycst.checked || x.incomebyprj.checked) {
			x.printdetproject.checked = true;
			x.printdetproject.disabled = true;
		} else {
			x.printdetproject.checked = false;
			x.printdetproject.disabled = false;
		}	
  } else {
	 x.printdetproject.checked = false;
	 x.printdetproject.disabled = true;
  }

}

function EnableIncomeByCst() {
	x = document.form1;
	
	if (x.incomebycst.checked) {
		x.printgrpproject.checked = true;
		x.printgrpproject.disabled = true;
		x.showcostcenter.checked = true;
		x.showcostcenter.disabled = true;
		x.showproject.checked = false;
		x.showproject.disabled = true;
		x.monthdist.checked = false;
		x.monthdist.disabled = true;
		x.incomebyprj.checked = false;
		x.incomebyprj.disabled = true;
		
		for (var i=0; i < document.form1.reportoption.length; i++)
		{
			document.form1.reportoption[i].disabled = true;
		}
		
	} else {
		x.printgrpproject.checked = false;
		x.printgrpproject.disabled = false;
		x.showcostcenter.checked = false;
		x.showcostcenter.disabled = false;
		x.showproject.checked = false;
		x.showproject.disabled = false;
		x.monthdist.checked = false;
		x.monthdist.disabled = false;
		x.incomebyprj.checked = false;
		x.incomebyprj.disabled = false;
		
		for (var i=0; i < document.form1.reportoption.length; i++)
		{
			document.form1.reportoption[i].disabled = false;
		}
	}

}

function EnableIncomeByPrj() {
	x = document.form1;
	
	if (x.incomebyprj.checked) {
		x.printgrpproject.checked = true;
		x.printgrpproject.disabled = true;
		x.showcostcenter.checked = false;
		x.showcostcenter.disabled = true;
		x.showproject.checked = true;
		x.showproject.disabled = true;
		x.monthdist.checked = false;
		x.monthdist.disabled = true;
		x.incomebycst.checked = false;
		x.incomebycst.disabled = true;
		
		for (var i=0; i < document.form1.reportoption.length; i++)
		{
			document.form1.reportoption[i].disabled = true;
		}
		
	} else {
		x.printgrpproject.checked = false;
		x.printgrpproject.disabled = false;
		x.showcostcenter.checked = false;
		x.showcostcenter.disabled = false;
		x.showproject.checked = false;
		x.showproject.disabled = false;
		x.monthdist.checked = false;
		x.monthdist.disabled = false;
		x.incomebycst.checked = false;
		x.incomebycst.disabled = false;
		
		for (var i=0; i < document.form1.reportoption.length; i++)
		{
			document.form1.reportoption[i].disabled = false;
		}
	}

}

-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Financial Report</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.style1 {
	color: #FF0000;
	font-family: "Times New Roman", Times, serif;
	font-size: 20px;
}
.style8 {font-size: 11px; color: #999999; font-weight: bold; }
.style11 {font-size: 11px}
body {
	margin-top: 0px;
}
-->
</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
	<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>
</head>
<body>
HERE;

echo "<form id='form1' name='form1' method='post' action='$_SERVER[PHP_SELF]'>";

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>Financial Report</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='30'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";
		
	echo" <button type='reset' id='btnClear' name='btnClear'  title='Clear'><span><span>Clear</span></span></button>";
	echo"<button type='button' id='btnPreview' name='btnPreview'  onClick=\"printPrev('".$printaccess."')\"; title='Preview'><span><span>Preview</span></span></button>";

	if ($ExporttoExcel==1){
		echo" <button type='button' id='btnExcel' name='btnExcel' onClick=\"ExportExcel()\"; title='Export Excel'><span><span>Export Excel</span></span></button>";
	}
  
echo"	</td></tr></table>";
echo"</td></tr>";				

		
echo"<tr><td id='content-body'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
   <tr bgcolor='#F7F7F7'><td valign='top' align='left' colspan='10'>";		
echo '  <table border="0" align="center" width="100%">';

echo" <tr>";	  
echo"   <td width='20%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='25%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Reports </span></td>";
echo"   <td width='40%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>&nbsp; </span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='15%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate' value='$fromdate' maxlength='10' size='10'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.fromdate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
echo"   <td width='15%' valign='top' rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='$rowsetup[0]' "; if($defaultcurr == $rowsetup[0]) echo "checked"; echo">$rowsetup[0]</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='$rowsetup[1]' "; if($defaultcurr == $rowsetup[1]) echo "checked"; echo">$rowsetup[1]</label></span></td>";


echo"   <td width='25%' rowspan='2' valign='top' bgcolor='#F5F5F5' height='130'><div style='overflow:auto; height:130px; width:200px;' >
<table border='0' cellpadding='0' cellspacing='0'>";
$i=0;
		while($fintype=mysql_fetch_row($resultfinancialtype)){
			$i = $i + 1;
			
			echo "<tr><td>";
			echo "<span class='style8'><label>";
			echo "<input name='reportoption' type='radio' value='$fintype[0]'  ";
			if ($i == 1) echo " checked ";
			echo "/>".$fintype[1]."</label></span></td></tr>";
			
		}
echo "</table></div></td>";		

		
echo"   <td width='40%' rowspan='2' valign='top' bgcolor='#F5F5F5'>
<table>
<tr><td><input type='radio' name='showledger'  id='showledger' checked value='-1'><span class='style8'><label>Hide Ledger Number</label></span></td></tr>
<tr><td><input type='radio' name='showledger'  id='showledger' checked value='0'><span class='style8'><label>Show Ledger Number</label></span></td></tr>
<tr><td><input type='radio' name='showledger'  id='showledger' value='1'><span class='style8'><label>Show CO-Number</label></span></td></tr>
</table>

</td>";
				
echo" </tr>";

echo" <tr>";
echo"   <td width='5%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='15%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <input type='text' name='todate' value='$todate'  maxlength='10' size='10'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.todate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='35%' colspan='3' align='left' valign='top' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <label><input type='checkbox' name='showproject' id='showproject' value='1' onclick='EnablePrintPrjCst();' />Show Project</label><br>";
echo"      <label><input type='checkbox' name='showcostcenter' id='showcostcenter' value='1' onclick='EnablePrintPrjCst();' />Show Costcenter</label><br>";
echo"      <label>&nbsp;&nbsp;<input type='checkbox' name='printgrpproject' id='printgrpproject' value='1' disabled/>Print Project/Costcenter for group</label><br>";
echo"      <label><input type='checkbox' name='showdetail' id='showdetail' value='1' onclick='EnablePrintPrjCstDt();' />Show Ledger Details</label><br>";
echo"      <label>&nbsp;&nbsp;<input type='checkbox' name='printdetproject' id='printdetproject' value='1' disabled/>Print Project/Costcenter for ledger detail</label>";
echo"   </span></td>";
echo "<td></td>";
echo"   <td width='25%' align='left' valign='top' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <label><input type='checkbox' name='showprevbal' id='showprevbal' value='1' />With Previous Balance</label><br>";
echo"      <label><input type='checkbox' name='showzerobal' id='showzerobal' value='1' checked/>Show Zero Balance</label><br>";
echo"      <label><input type='checkbox' name='showstock' id='showstock' value='1' />Show Stock Variation</label><br>";
echo"      <label><input type='checkbox' name='monthdist' id='monthdist' value='1' />Monthly Distribution</label><br>";
echo"      <label><input type='checkbox' name='incomebycst' id='incomebycst' value='1' onclick='EnableIncomeByCst();' />Income by Costcenter</label><br>";
echo"      <label><input type='checkbox' name='incomebyprj' id='incomebyprj' value='1' onclick='EnableIncomeByPrj();' />Income by Project</label><br>";
echo"      <label><input type='checkbox' name='parentprjcost' id='parentprjcost' value='1' />Parent Project/Costcenter</label>";
echo"   </span></td>";
			 
echo"   <td width='40%' valign='top' bgcolor='#F5F5F5'>&nbsp;</td>";
echo" </tr>";

   
echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>&nbsp; </span></td>";
echo" </tr>";
echo" <tr>";	  
echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>Project</span></td>";
echo"   <td width='30%'  colspan='2' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <select name='fromproject' id='fromproject' style='width:270px'>";
		echo"<option></option>";
		while($prj=mysql_fetch_row($resultproject)){
		echo"<option ";
			if (($fromproject==$prj[0]) || ($defaultproject==$prj[0]))
				echo " selected ";
		echo" value='$prj[0]'>$prj[0] / $prj[1]</option>";
		}
		echo"</select></span></td>";
			 
echo"   <td width='25%' valign='middle' bgcolor='#F5F5F5' ><span class='style8'> Tree Level";
echo"   <select name='treelevel' id='treelevel' style='width:50px'>";
		echo"<option></option>";
		while($level=mysql_fetch_row($resulttreelevel)){
		echo"<option ";
			if ($treelevel==$level[0])
				echo " selected ";
		echo" value='$level[0]'>$level[0]</option>";
		}
		echo"</select>";
		echo"</span></td>";			
			 
echo"   <td width='40%' valign='top' bgcolor='#F5F5F5'>&nbsp;  </td>";	
echo" </tr>";

echo" <tr>";	
echo"   <td width='5%' align='left' bgcolor='#F5F5F5' ><span class='style8'>CostCenter</span></td>";	
echo"   <td width='30%' colspan='2' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <select name='fromcostcent' id='fromcostcent' style='width:270px'>";
		echo"<option></option>";
		while($cst=mysql_fetch_row($resultcostcent)){
		echo"<option ";
			if (($fromcostcent==$cst[0]) || ($defaultcostcent==$cst[0]))
				echo " selected ";
		echo" value='$cst[0]'>$cst[0] / $cst[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";	
		
echo"   <td width='65%' colspan='2' valign='top' bgcolor='#F5F5F5'>&nbsp;</td>";				 
echo" </tr>";



echo" <tr height='15'>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   /* <tr>
      <td colspan='5' align='center' bgcolor='#F5F5F5'>
	  <input name='clearbtn' type='reset'  value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' />
	  <input name='preview' type='button' id='preview' value='Preview' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"printPrev('".$printaccess."')\"; />
	  
      </td>
    </tr>*/
		echo"   </table></td></tr>"; 
	echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>"; 
 echo" </table>
 
</form>
</body>
</html>";

?>