<?php

session_start();
if($_SESSION['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($_SESSION['dbName'],$connection) or die("Could not find DB");

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

HERE;

$querylog="SELECT RA_StatmentofCostcenter as loginaccess, Print as printaccess, ExporttoExcel 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);
}
if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	
	
if ($ExporttoExcel==1) $ExporttoExcelStatus= 'button';
else $ExporttoExcelStatus= 'hidden';	
	

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter ".
             " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

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

$queryjvtype="select type_name from jourtype order by type_name";
$resultjvtype=mysql_query($queryjvtype,$connection) or die(mysql_error());


$querylog=" select ifNull(FI_RepRestrictProject,0) As FI_RepRestrictProject, ifNull(FI_RepRestrictCostcenter,0) As FI_RepRestrictCostcenter ".
          " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."') ";
$resultlog=mysql_query($querylog) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

//Projects List
$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$_SESSION['dbLabel'].".loginstk on project.project_code like concat(ifnull(loginstk.project_code,project.project_code),'%') ".
			  " where user_account='".$_SESSION['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());
$projectexist  = mysql_num_rows($projectresult);	
if ($projectexist == 0 || $FI_RepRestrictProject == 0)
    $queryproject=" select distinct project_code, project_name from project order by project_code ";	  

$resultfromproject=mysql_query($queryproject,$connection) or die(mysql_error());
$resulttoproject  =mysql_query($queryproject,$connection) or die(mysql_error());

//Costcenter List
$querycostcent=" select distinct costcent.costcent_code, costcent_name ".
               " from costcent left join ".$_SESSION['dbLabel'].".loginstk on costcent.costcent_code like concat(ifnull(loginstk.costcent_code,costcent.costcent_code),'%') ".
			   " where user_account='".$_SESSION['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());
$costcentexist  = mysql_num_rows($costcentresult);		  
if ($costcentexist == 0 || $FI_RepRestrictCostcenter == 0)
    $querycostcent=" select distinct costcent_code, costcent_name from costcent order by costcent_code ";			  
	
$resultfromcostcent=mysql_query($querycostcent,$connection) or die(mysql_error());
$resulttocostcent  =mysql_query($querycostcent,$connection) or die(mysql_error());


//Get Default Project
$querydflproject="select log.project_code as defaultproject,project_name as defaultprojname from ".$_SESSION['dbLabel'].".loginstk as log 
					left join project on project.project_code = log.project_code where user_account='".$_SESSION['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
	extract($rows);
}
//Get Default Coscenter
$querydflcostcent="select log.costcent_code as defaultcostcent, costcent_name as defaultcostcentname from ".$_SESSION['dbLabel'].".loginstk as log 
					left join costcent on costcent.costcent_code = log.costcent_code where user_account='".$_SESSION['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
	extract($rows);
}

if ((!isset($fromproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1){
	$fromproject = $defaultproject;
	$fromprojectdesc = $defaultprojname;
}
if ((!isset($toproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1){
	$toproject = $defaultproject;
	$toprojectdesc = $defaultprojname;
}	
if ((!isset($fromcostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1){	
	$fromcostcent = $defaultcostcent;	
	$fromcostcentdesc = $defaultcostcentname;
}
if ((!isset($tocostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1){	
	$tocostcent = $defaultcostcent;	
	$tocostcentdesc = $defaultcostcentname;
}
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)
{
	var str='';
  	
 
	for (var i=0; i < document.form1.currency.length; i++)
	{
		if (document.form1.currency[i].checked)
		{
			var varcurrency = document.form1.currency[i].value;
		}
	}
	for (var i=0; i < document.form1.groupby.length; i++)
	{
		if (document.form1.groupby[i].checked)
		{
			var vargroupby = document.form1.groupby[i].value;
		}
	}
	for (var i=0; i < document.form1.report.length; i++)
	{
		if (document.form1.report[i].checked)
		{
			var varreport = document.form1.report[i].value;
		}
	}
	for (var i=0; i < document.form1.balance.length; i++)
	{
		if (document.form1.balance[i].checked)
		{
			var varbalance = document.form1.balance[i].value;
		}
	}
	 
  
	varexclude = 0;
	if (document.form1.exclude.checked)
		varexclude = 1;	
	
	varalltypes = 0;
	if (document.form1.alltypes.checked)
		varalltypes = 1;	
	
	var checkname;
	var x, varjvtype;
	varjvtype = '';
	for (var i=1; i <= document.form1.i.value; i++)
	{
		checkname='type'+i;
	
		x = document.getElementById(checkname);
		if (varalltypes == 0 && x.checked) 
			varjvtype = varjvtype+",'"+x.value+"'";
    
	}
	varjvtype = varjvtype.substr(1);
  
	
	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;			
	
	varmonthly = 0;
	if (document.form1.monthly.checked)
		varmonthly = 1;
		
	varprtvaluedate = 0;
	if (document.form1.prtvaluedate.checked)
		varprtvaluedate = 1;	
	varprtjvtype = 0;
	if (document.form1.prtjvtype.checked)
		varprtjvtype = 1;	
	varprtprevbal = 0;
	if (document.form1.prtprevbal.checked)
		varprtprevbal = 1;		
		
	varparentprjcost = 0;
	if (document.form1.parentprjcost.checked)
		varparentprjcost = 1;		
	
	  
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromledger = document.form1.fromledger.value;
	vartoledger   = document.form1.toledger.value;
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
	
	varfromcst = encodeURIComponent(varfromcst);
	vartocst = encodeURIComponent(vartocst);
	varfromprj = encodeURIComponent(varfromprj);
	vartoprj = encodeURIComponent(vartoprj);
	
	if(document.getElementById("projectper").checked)
		var projectper = 1;
	else if(!document.getElementById("projectper").checked)
		var projectper = 0;
	
	if(document.getElementById("costcentper").checked)
		var costcentper = 1;
	else if(!document.getElementById("costcentper").checked)
		var costcentper = 0;
	
	if (varreport == 1 || varreport == 3) {
		if (varmonthly == 1)
			ReportName = 'Rep_BalanceProjCostMonthly.php';
		else
			ReportName = 'Rep_BalanceProjCost.php';	
	} else	{
		ReportName = 'Rep_StatementProjCost.php';
	}	
	
	
	str =   ReportName+'?option=2&fromdate='+varfromdate+'&todate='+vartodate+'&fromledger='+varfromledger+'&toledger='+vartoledger
           +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
		   +'&currency='+varcurrency+'&groupby='+vargroupby+'&balance='+varbalance+'&prtvaluedate='+varprtvaluedate+'&prtjvtype='+varprtjvtype
		   +'&prtprevbal='+varprtprevbal+'&showdetail='+varshowdetail+'&alltypes='+varalltypes+'&exclude='+varexclude+'&jvtype='+varjvtype
		   +'&parentprjcost='+varparentprjcost+'&report='+varreport+'&projectper='+projectper+'&costcentper='+costcentper;
  
	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()
{
	var str='';
  	

	for (var i=0; i < document.form1.currency.length; i++)
	{
		if (document.form1.currency[i].checked)
		{
			var varcurrency = document.form1.currency[i].value;
		}
	}
	for (var i=0; i < document.form1.groupby.length; i++)
	{
		if (document.form1.groupby[i].checked)
		{
			var vargroupby = document.form1.groupby[i].value;
		}
	}
	for (var i=0; i < document.form1.report.length; i++)
	{
		if (document.form1.report[i].checked)
		{
			var varreport = document.form1.report[i].value;
		}
	}
	for (var i=0; i < document.form1.balance.length; i++)
	{
		if (document.form1.balance[i].checked)
		{
			var varbalance = document.form1.balance[i].value;
		}
	}
	 
  
	varexclude = 0;
	if (document.form1.exclude.checked)
		varexclude = 1;	
	
	varalltypes = 0;
	if (document.form1.alltypes.checked)
		varalltypes = 1;	
	
	var checkname;
	var x, varjvtype;
	varjvtype = '';
	for (var i=1; i <= document.form1.i.value; i++)
	{
		checkname='type'+i;
	
		x = document.getElementById(checkname);
		if (varalltypes == 0 && x.checked) 
			varjvtype = varjvtype+",'"+x.value+"'";
    
	}
	varjvtype = varjvtype.substr(1);
  
	
	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;			
	
	varmonthly = 0;
	if (document.form1.monthly.checked)
		varmonthly = 1;
		
	varprtvaluedate = 0;
	if (document.form1.prtvaluedate.checked)
		varprtvaluedate = 1;	
	varprtjvtype = 0;
	if (document.form1.prtjvtype.checked)
		varprtjvtype = 1;	
	varprtprevbal = 0;
	if (document.form1.prtprevbal.checked)
		varprtprevbal = 1;		
		
	varparentprjcost = 0;
	if (document.form1.parentprjcost.checked)
		varparentprjcost = 1;		
	
	  
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromledger = document.form1.fromledger.value;
	vartoledger   = document.form1.toledger.value;
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
  
  if(document.getElementById("projectper").checked)
		var projectper = 1;
	else if(!document.getElementById("projectper").checked)
		var projectper = 0;
	
	if(document.getElementById("costcentper").checked)
		var costcentper = 1;
	else if(!document.getElementById("costcentper").checked)
		var costcentper = 0;
	
	if (varreport == 1 || varreport == 3) {
		if (varmonthly == 1)
			ReportName = 'Exp_BalanceProjCostMonthly.php';
		else
			ReportName = 'Exp_BalanceProjCost.php';	
	} else	{
		ReportName = 'Exp_StatementProjCost.php';
	}
	varfromcst = encodeURIComponent(varfromcst);
	vartocst = encodeURIComponent(vartocst);
	varfromprj = encodeURIComponent(varfromprj);
	vartoprj = encodeURIComponent(vartoprj);
	
	str =   ReportName+'?option=2&fromdate='+varfromdate+'&todate='+vartodate+'&fromledger='+varfromledger+'&toledger='+vartoledger
           +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
		   +'&currency='+varcurrency+'&groupby='+vargroupby+'&balance='+varbalance+'&prtvaluedate='+varprtvaluedate+'&prtjvtype='+varprtjvtype
		   +'&prtprevbal='+varprtprevbal+'&showdetail='+varshowdetail+'&alltypes='+varalltypes+'&exclude='+varexclude+'&jvtype='+varjvtype
		   +'&parentprjcost='+varparentprjcost+'&report='+varreport+'&projectper='+projectper+'&costcentper='+costcentper;
  
  
	window.open(str);
  
}

function showlistledger(str){

	var str1 = 1;
  
	var selectpage;
	selectpage = 'select_ledger.php?item='+str+'&accountoption='+str1;	  
  
	window.open(selectpage,'mywindow','width=800,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function select_alljvtypes() {
   
	var checkname;
	var x;
	for (var i=1; i <= document.form1.i.value; i++)
	{
		checkname='type'+i;
	
		x = document.getElementById(checkname);
		if (document.form1.alltypes.checked) 
			x.checked = true;
		else
			x.checked = false;
    
	}
  
	if (document.form1.alltypes.checked) {
		document.form1.exclude.checked = false;
		document.form1.exclude.disabled = true;
	}	 
	else
		document.form1.exclude.disabled = false;
}

function SelectReport(option) {
	var x = document.form1;
	
	if (option == 1) {
		x.monthly.disabled 		= false;
		x.showdetail.checked  	= true;
		x.showdetail.disabled 	= false;
		x.prtvaluedate.disabled = true;
		x.prtjvtype.disabled 	= true;
		x.prtprevbal.disabled 	= true;
		
		for (var i=0; i < x.groupby.length; i++)
		{
			x.groupby[i].disabled = false;
		}
	} 
	else if (option == 2) {
		x.monthly.checked  		= false;
		x.monthly.disabled 		= true;
		x.showdetail.checked  	= true;
		x.showdetail.disabled 	= true;
		x.prtvaluedate.checked  = false;
		x.prtvaluedate.disabled = false;
		x.prtjvtype.checked  	= false;
		x.prtjvtype.disabled  	= false;
		x.prtprevbal.checked  	= true;
		x.prtprevbal.disabled 	= false;
		
		for (var i=0; i < x.groupby.length; i++)
		{
			x.groupby[i].disabled = true;
		}
	}
	else if (option == 3) {
		x.monthly.checked  		= false;
		x.monthly.disabled 		= false;
		x.showdetail.checked  	= true;
		x.showdetail.disabled 	= false;
		x.prtvaluedate.disabled = true;
		x.prtjvtype.disabled 	= true;
		x.prtprevbal.disabled 	= true;
		
		for (var i=0; i < x.groupby.length; i++)
		{
			x.groupby[i].disabled = true;
		}
	}

}
function showlistProject(str){

  window.open('List_SorProject.php?frm=29&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function showlistCostcenter(str){

  window.open('List_SorCostcenter.php?frm=29&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function usePerc(str){
	if(str == 1){
		if(document.getElementById("projectper").checked){
			document.getElementById("toproject").disabled = true;
			document.getElementById("toprojectdesc").disabled = true;
		}else if(!document.getElementById("projectper").checked){
			document.getElementById("toproject").disabled = false;
			document.getElementById("toprojectdesc").disabled = false;
		}
	}
	if(str == 2){
		if(document.getElementById("costcentper").checked){
			document.getElementById("tocostcent").disabled = true;
			document.getElementById("tocostcentdesc").disabled = true;
		}else if(!document.getElementById("costcentper").checked){
			document.getElementById("tocostcent").disabled = false;
			document.getElementById("tocostcentdesc").disabled = false;
		}
	}
}

-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Report of CostCenter</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'>Report of CostCenter</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 height="534" 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='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Group by</span></td>";
echo"   <td width='20%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Reports</span></td>";
echo"   <td width='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Balance </span></td>";
echo"   <td width='25%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Options </span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
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='10%' rowspan='3' valign='top' 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='15%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='groupby' type='radio' value='1' checked='checked'>Ledger</label></span>";

echo"   <br><span class='style8'><label>";

echo"      <input name='groupby' type='radio' value='2'>CostCenter</label></span>";

echo"   <br><span class='style8'><label>";
echo"      <input name='groupby' type='radio' value='3'>Show Ledger statement</label></span>";
echo"   <br><br><span class='style8'><label><input type='checkbox' name='parentprjcost' id='parentprjcost' value='1' />Parent CostCenter</label></span>";

echo"</td>";

echo"   <td width='20%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='report' type='radio' value='1' checked='checked' onclick='SelectReport(this.value)'>Balance of CostCenter</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='report' type='radio' value='3' onclick='SelectReport(this.value)'>Balance of Costcent-Shipment Ref</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='report' type='radio' value='2' onclick='SelectReport(this.value)'>Statement of CostCenter</label></span></td>";

		
echo"   <td width='10%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='balance' type='radio' value='1' checked='checked'>All</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='balance' type='radio' value='2'> > 0 </label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='balance' type='radio' value='3'> < 0 </label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='balance' type='radio' value='4'> = 0 </label></span></td>";
		
echo"   <td width='25%' rowspan='3' valign='top' bgcolor='#F5F5F5' valign='top' ><span class='style8'><label>";
echo"      <input name='showdetail' type='checkbox' id='showdetail' value='1' checked />Show Details</label></span>";	
echo"   <br><span class='style8'><label>";
echo"      <input name='monthly' type='checkbox' id='monthly' value='1'  />Monthly Balance</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtvaluedate' type='checkbox' id='prtvaluedate' value='1' disabled />Show Value Date</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtjvtype' type='checkbox' id='prtjvtype' value='1' disabled />Show JV Type</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtprevbal' type='checkbox' id='prtprevbal' value='1' checked disabled />Show Previous Balance</label></span></td>";
				
echo" </tr>";

echo" <tr height='15px'>";
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 height='15px'>";
echo"   <td valign='top' bgcolor='#F5F5F5' colspan='2'>&nbsp;</td>";
echo" </tr>";

echo" <tr height='15px'>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr height='15px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Ledger No. / Name </span></td>";
echo"   <td bgcolor='#F5F5F5'><span class='style8'> ";
echo"   	<label><input name='alltypes' type='checkbox' id='alltypes' value='1' onclick='select_alljvtypes();' checked/>All Types</label>";
echo"   	<label><input name='exclude' type='checkbox' id='exclude' value='1' disabled/>Exclude</label></span></td>";
echo"   <td  bgcolor='#F5F5F5' colspan='2'><span class='style8'>&nbsp; </span></td>";
echo" </tr>";



echo" <tr height='15px'>";	  
echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <input name='fromledger' type='text' id='fromledger' size='10' value='".$fromledger."' />
        <input name='fromledgername' type='text' id='fromledgername' size='35' value='".$fromledgername."' />
		</span><label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Ledger From ' 
             onClick='showlistledger(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='20%' rowspan='5' valign='top' bgcolor='#F5F5F5'><div style='overflow:auto; height:120px; width:80px;' ><table border='0'><tr><td>";
		
		$i = 0;
		while($jvtype=mysql_fetch_row($resultjvtype)){
		   $i = $i + 1;
		   $type  = 'type'.$i;
		   $$type = $jvtype[0];
		   
		   echo"<span class='style8'><label>";
           echo"<input name='$type' type='checkbox' id='$type' value='".$$type."' checked/> $jvtype[0] </label></span>";
		}
		echo "<input type='hidden' name='i' value='$i'>";
		echo "</td></tr></table></div></td>";   

echo"   <td align='left' colspan='2' rowspan='5' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   
echo" <tr height='15px'>";	  
echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <input name='toledger' type='text' id='toledger' size='10' value='".$toledger."' />
        <input name='toledgername' type='text' id='toledgername' size='35' value='".$toledgername."' />
		</span><label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Ledger To ' 
             onClick='showlistledger(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo" </tr>";

if ($Module_CostCenter == 1) {
	
	echo" <tr height='15px'>";
	echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>CostCenter</span></td><td><span class='style8'><input type='checkbox' name='costcentper' id='costcentper' onclick=\"usePerc(2);\">use % </span></td>";
	echo" </tr>";

	echo" <tr height='15px'>";	  
	echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
	echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
	echo "<input type='text' name='fromcostcent' id='fromcostcent' value='$fromcostcent' style='width:150px;' maxlength='20'  />";
	echo " <input type='text' name='fromcostcentdesc' id='fromcostcentdesc' value='$fromcostcentdesc' style='width:102px;'  /></span>";
	echo " <label><span class='style1'><img src='img/btnopen.jpg' title=' Select Costcenter ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick='showlistCostcenter(1); ' /></span></label></td>";

			/*echo "<select name='fromcostcent' id='fromcostcent' style='width:345px'>";
			echo"<option></option>";
			while($cstf=mysql_fetch_row($resultfromcostcent)){
			echo"<option ";
				if (($fromcostcent==$cstf[0]) || ($defaultcostcent==$cstf[0]))
					echo " selected ";
			echo" value='$cstf[0]'>$cstf[0] / $cstf[1]</option>";
			}
			echo"</select></span></td>";*/
	echo" </tr>";

	echo" <tr height='15px'>";	  
	echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
	echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
	echo "<input type='text' name='tocostcent' id='tocostcent' value='$tocostcent' style='width:150px;' maxlength='20'  />";
	echo " <input type='text' name='tocostcentdesc' id='tocostcentdesc' value='$tocostcentdesc' style='width:102px;'   /></span>";
	echo " <label><span class='style1'><img src='img/btnopen.jpg' title=' Select Costcenter ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick='showlistCostcenter(4); ' /></span></label></td>";

			/*echo "<select name='tocostcent' id='tocostcent' style='width:345px'>";
			echo"<option></option>";
			while($cstt=mysql_fetch_row($resulttocostcent)){
			echo"<option ";
				if (($tocostcent==$cstt[0]) || ($defaultcostcent==$cstt[0]))
					echo " selected ";
			echo" value='$cstt[0]'>$cstt[0] / $cstt[1]</option>";
			}
			echo"</select></span></td>";*/
	echo" </tr>";
} else {
	echo" <tr>";
	echo"   <td colspan='4' bgcolor='#F5F5F5'>";
	echo"	<input type='hidden' name='fromcostcent' id='fromcostcent' value=''>
			<input type='hidden' name='tocostcent' id='tocostcent' value=''>";
	echo" </tr>";		
	
	echo" <tr><td colspan='4' bgcolor='#F5F5F5'>&nbsp;</td></tr>";
	echo" <tr><td colspan='4' bgcolor='#F5F5F5'>&nbsp;</td></tr>";
}


if ($Module_Project == 1){
	
	echo" <tr height='15px'>";
	echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Shipment Ref</span></td><td><span class='style8'><input type='checkbox' name='projectper' id='projectper' onclick=\"usePerc(1);\">use % </span></td>";
	echo"   <td colspan='3' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";		
	echo" </tr>";

	echo" <tr height='15px'>";	  
	echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
	echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
	echo "<input type='text' name='fromproject' id='fromproject' value='$fromproject' style='width:150px;' maxlength='20'  />";
	echo " <input type='text' name='fromprojectdesc' id='fromprojectdesc' value='$fromprojectdesc' style='width:130px;'   /></span>";
	echo " <label><span class='style1'><img src='img/btnopen.jpg' title=' Select Project ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(1); '  /></span></label></td>";
	
	/*echo "<select name='fromproject' id='fromproject' style='width:345px'>";
			echo"<option></option>";
			while($prjf=mysql_fetch_row($resultfromproject)){
			echo"<option ";
				if (($fromproject==$prjf[0]) || ($defaultproject==$prjf[0]))
					echo " selected ";
			echo" value='$prjf[0]'>$prjf[0] / $prjf[1]</option>";
			}
			echo"</select></span></td>";*/
	echo"   <td align='left' colspan='3' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";		
	echo" </tr>";
	
	echo" <tr height='15px'>";	  
	echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
	echo"   <td width='40%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
	echo "<input type='text' name='toproject' id='toproject' value='$toproject' style='width:150px;' maxlength='20'  />";
	echo " <input type='text' name='toprojectdesc' id='toprojectdesc' value='$toprojectdesc' style='width:130px;'   /></span>";
	echo " <label><span class='style1'><img src='img/btnopen.jpg' title=' Select Project ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(3); '  /></span></label></td>";
	
	/*echo "<select name='toproject' id='toproject' style='width:345px'>";
			echo"<option></option>";
			while($prjt=mysql_fetch_row($resulttoproject)){
			echo"<option ";
				if (($toproject==$prjt[0]) || ($defaultproject==$prjt[0]))
					echo " selected ";
			echo" value='$prjt[0]'>$prjt[0] / $prjt[1]</option>";
			}
			echo"</select></span></td>";*/
	echo"   <td align='left' colspan='3' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";				
	echo" </tr>";
	
} else {
	echo"	<input type='hidden' name='fromproject' id='fromproject' value=''>
			<input type='hidden' name='toproject' id='toproject' value=''></td>";

}


echo" <tr height='30'>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   /* <tr>
      <td colspan='7' align='center' bgcolor='#F5F5F5'>
		<input type='reset'  name='btnClear' value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' />
		<input type='button' name='btnPreview' id='btnPreview' value='Preview' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"PrintPrev('".$printaccess."')\"; />
		<input type='".$ExporttoExcelStatus."' name='btnExcel' id='btnExcel' value='Export Excel' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"ExportExcel()\";/>	  
      </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>";

?>