<?php


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

include("config.inc.php");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");


$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_TransactionJV as loginaccess,Print as printaccess, ExporttoExcel as exportaccess 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);
	}
	//echo $querylog;
	//echo $loginaccess;
	

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

}


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

//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);
}



//Projects List
$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$HTTP_SESSION_VARS['dbLabel'].".loginstk on project.project_code like concat(ifnull(loginstk.project_code,project.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());
$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 ".$HTTP_SESSION_VARS['dbLabel'].".loginstk on costcent.costcent_code like concat(ifnull(loginstk.costcent_code,costcent.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());
$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 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);
}
	
//Get Default Coscenter
$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);
}

if ((!isset($fromproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1)
	$fromproject = $defaultproject;
if ((!isset($toproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1)
	$toproject = $defaultproject;
if ((!isset($fromcostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$fromcostcent = $defaultcostcent;	
if ((!isset($tocostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$tocostcent = $defaultcostcent;	

if (empty($fromdate)) $fromdate = displayToday();
if (empty($todate))   $todate   = displayToday();
	
print <<< HERE


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

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



function changestatus(option) {
x=document.form1;

if(option==1){
	if (x.ShowJV.checked)    x.ShowOtherSide.checked = false;
	}
else	
if(option==2)	
	if (x.ShowOtherSide.checked)    x.ShowJV.checked = false;


}

function PrintPreview(printaccess) {
	var str = '';
	x=document.form1;
	
	for (var i=0; i < x.Voucher.length; i++)
	{
		if (x.Voucher[i].checked)
		{
		  var VoucherType = x.Voucher[i].value;
		}
	}
	
	for (var i=0; i < x.dbcd.length; i++)
	{
		if (x.dbcd[i].checked)
		{
		  var dbcdType = x.dbcd[i].value;
		}
	}
	
	for (var i=0; i < x.date.length; i++)
	{
		if (x.date[i].checked)
		{
		  var vardate = x.date[i].value;
		}
	}
	
	
	for (var i=0; i < x.GrpBy.length; i++)
	{
		if (x.GrpBy[i].checked)
		{
		  var varGrpBy = x.GrpBy[i].value;
		}
	}
	
	
	for (var i=0; i < x.Journal.length; i++)
	{
		if (x.Journal[i].checked)
		{
		  var varJournal= x.Journal[i].value;
		}
	}
	
	
	var vFromRef = x.fromref.value;
	var vToRef = x.toref.value;
	var vFromDate = x.fromdate.value;
	var vToDate = x.todate.value;
    var vFromLedger = x.fromledger.value;
	var vToLedger = x.toledger.value;
	var vFromSalesman = x.fromsalesman.value;
	var vToSalesman = x.tosalesman.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	
	
	varDesc = 0;
	if (x.ShowDesc.checked)    varDesc = 1;

	varProjectHeader = 0;
	if (x.ShowProjectHeader.checked)   varProjectHeader = 1;
	
	varProjectDetail = 0;
	if (x.ShowProjectDetail.checked)    varProjectDetail = 1;	
	
	varChecks = 0;
	if (x.ShowChecks.checked)    varChecks = 1;
	
	varCollections = 0;
	if (x.collections.checked)    varCollections = 1;
	
	varShowJV = 0;
	if (x.ShowJV.checked)    varShowJV = 1;
	
	varShowOtherSide = 0;
	if (x.ShowOtherSide.checked)    varShowOtherSide = 1;
	
	var ReportName = 'Form_ListOfReceipt_Preview.php';
	if (varCollections == 1) ReportName = 'Rep_SalesmanCollections.php';
	

	str = ReportName+'?VoucherType='+VoucherType+'&dbcdType='+dbcdType+'&fromref='+vFromRef+'&toref='+vToRef+'&option='+vardate+'&fromdate='+vFromDate+'&todate='+vToDate+'&varDesc='+varDesc+'&varProjectHeader='+varProjectHeader+'&varProjectDetail='+varProjectDetail+'&varChecks='+varChecks
					+'&fromledger='+vFromLedger+'&toledger='+vToLedger+'&varJournal='+varJournal+'&varGrpBy='+varGrpBy+'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&fromsalesman='+vFromSalesman+'&tosalesman='+vToSalesman+'&ShowJV='+varShowJV+'&ShowOtherSide='+varShowOtherSide;
	
	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 = '';
	x=document.form1;
	
	for (var i=0; i < x.Voucher.length; i++)
	{
		if (x.Voucher[i].checked)
		{
		  var VoucherType = x.Voucher[i].value;
		}
	}
	
	for (var i=0; i < x.dbcd.length; i++)
	{
		if (x.dbcd[i].checked)
		{
		  var dbcdType = x.dbcd[i].value;
		}
	}
	
	for (var i=0; i < x.date.length; i++)
	{
		if (x.date[i].checked)
		{
		  var vardate = x.date[i].value;
		}
	}
	
	
	for (var i=0; i < x.GrpBy.length; i++)
	{
		if (x.GrpBy[i].checked)
		{
		  var varGrpBy = x.GrpBy[i].value;
		}
	}
	
	
	for (var i=0; i < x.Journal.length; i++)
	{
		if (x.Journal[i].checked)
		{
		  var varJournal= x.Journal[i].value;
		}
	}
	
	
	var vFromRef = x.fromref.value;
	var vToRef = x.toref.value;
	var vFromDate = x.fromdate.value;
	var vToDate = x.todate.value;
    var vFromLedger = x.fromledger.value;
	var vToLedger = x.toledger.value;
	var vFromSalesman = x.fromsalesman.value;
	var vToSalesman = x.tosalesman.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	
	
	varDesc = 0;
	if (x.ShowDesc.checked)    varDesc = 1;

	varProjectHeader = 0;
	if (x.ShowProjectHeader.checked)   varProjectHeader = 1;
	
	varProjectDetail = 0;
	if (x.ShowProjectDetail.checked)    varProjectDetail = 1;	
	
	varChecks = 0;
	if (x.ShowChecks.checked)    varChecks = 1;
	
	varCollections = 0;
	if (x.collections.checked)    varCollections = 1;
	
	var ReportName = 'Exp_ListOfReceipt.php';
	if (varCollections == 1) ReportName = 'Exp_SalesmanCollections.php';
	
	str = ReportName+'?VoucherType='+VoucherType+'&dbcdType='+dbcdType+'&fromref='+vFromRef+'&toref='+vToRef+'&option='+vardate+'&fromdate='+vFromDate+'&todate='+vToDate+'&varDesc='+varDesc+'&varProjectHeader='+varProjectHeader+'&varProjectDetail='+varProjectDetail+'&varChecks='+varChecks+'&fromledger='+vFromLedger+'&toledger='+vToLedger+'&varJournal='+varJournal+'&varGrpBy='+varGrpBy
					+'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&fromsalesman='+vFromSalesman+'&tosalesman='+vToSalesman;
	
	window.open(str);	
}	
	
	
function showlistLedger(str){
	window.open('select_ledger.php?item='+str);
} 
function showlistsalesman(str){
  window.open('select_salesman.php?item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


</script>


<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>

<title>List of Transaction</title>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20101112" media="screen"></link>
<script type="text/javascript" src="dhtmlgoodies_calendar.js?random=20100118"></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'>List of Transaction</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=\"PrintPreview('".$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><td width=15% height='19' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";
echo"</label> ";
echo"Voucher</span></td>";


echo"<td width=45% height='19' colspan='4' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";
echo"</label> ";
echo"Receipts</span>";
echo"<br><span class='style8'>";
echo"</td>";

echo"<td width=40% height='19' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";
echo"</label> ";
echo"Group by</span></td></tr>";

echo"<tr><td width=15% align='left' bgcolor='#F5F5F5' rowspan='3'>";
echo"<span class='style8'><label>
	<input name='Voucher' id='Voucher' type='radio' value='1' checked></label>";
echo"Receipts</span>";


echo"<br><span class='style8'><label>
	<input name='Voucher' id='Voucher' type='radio' value='2'></label>";
echo"Payments</span>";

	
echo"<br><span class='style8'><label>
	<input name='Voucher' id='Voucher' type='radio' value='3'></label>";
echo"Debit Notes</span>";


echo"<br><span class='style8'><label>
	<input name='Voucher' id='Voucher' type='radio' value='4'></label>";
echo"Credit Notes</span>";


echo"</td>";



echo"<td width=30% height='15' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";

if ($_POST['date']=="1" || $_POST['date']=="")
    echo "<input name='date' id='date' type='radio' value='1' checked>";
else	
    echo "<input name='date' id='date' type='radio' value='1'>";
	
echo"</label> ";
echo"Date</span>";

echo"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
echo"<span class='style8'><label>";
if ($_POST['date']=="1" || $_POST['date']=="")
    echo "<input name='date' id='date' type='radio' value='2'>";
else	
    echo "<input name='date' id='date' type='radio' value='2'>";
	
echo"</label> ";
echo"Value Date</span></td>";


echo"<td width=15% height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

if ($_POST['date']=="2" )
    echo "<input name='date' id='date' type='radio' value='3' >";
else	
   echo "<input name='date' id='date' type='radio' value='3' >";				

echo"</label>";
echo"Reference</span></td>";

echo"<td width=40%  bgcolor='#F5F5F5'><span class='style8'><label>
<input name='GrpBy' id='GrpBy' type='radio' value='1' checked></label>";
echo"None &nbsp &nbsp  </span><bgcolor='#F5F5F5'><span class='style8'>
<label><input name='GrpBy' id='GrpBy' type='radio' value='2'></label>Salesman &nbsp &nbsp </span>
<bgcolor='#F5F5F5'><span class='style8'>
<label><input name='GrpBy' id='GrpBy' type='radio' value='3'></label>Ledger No.</span>
</td>";

echo"</tr>";



echo"<tr>";
echo"<td width=5% valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"<td width=25% valign='middle' bgcolor='#F5F5F5' ><input type='text' name='fromdate' value='$fromdate' maxlength='10' size='10'>&nbsp;";
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=5% align='left' bgcolor='#F5F5F5' class='style8'>From</td>";
echo"<td width=10% valign='middle' bgcolor='#F5F5F5' ><input type='text' name='fromref' value='$fromref' size='10'>";
echo"</label></td>";

echo"<td width=40% height='19' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";
echo"</label> ";
echo"Journals</span></td>";

echo"</tr>";


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

echo"<td width=5%  align='left' bgcolor='#F5F5F5' class='style8'>To </td>";
echo"<td width=10% valign='middle' bgcolor='#F5F5F5' ><input type='text' name='toref'  value='$toref' size='10'>";
echo"</label></td>";

echo"<td width=40%  bgcolor='#F5F5F5'><span class='style8'><label>
<input name='Journal' id='Journal' type='radio' value='1' checked></label>";
echo"All &nbsp &nbsp &nbsp &nbsp</span><bgcolor='#F5F5F5'><span class='style8'>
<label><input name='Journal' id='Journal' type='radio' value='2'></label>Confirmed &nbsp &nbsp </span>
<bgcolor='#F5F5F5'><span class='style8'>
<label><input name='Journal' id='Journal' type='radio' value='3'></label>Not Confirmed</span>
</td>";

echo"</tr>";
    
echo"<tr>";
echo"	<td height='19'  colspan='6' align='left' bgcolor='#F5F5F5'><span class='style8'>Ledger Number/Name</span></td>";
echo"</tr>";
echo"<tr><td width='45%' colspan='3'  valign='top' bgcolor='#F5F5F5'><table border='0'>";
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>From</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromledger'  value='$fromledger' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromledgername'  value='$fromledgername' size='30'>
				<img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(1); return false'>";
echo"		</label></td>
		</tr>";		
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='toledger'  value='$toledger' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='toledgername'  value='$toledgername' size='30'>
				<img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(2); return false'>";
echo"		</label></td>
		</tr>";
echo "</table></td>";

echo"<td colspan='2' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='1' checked></label>";
echo"Credit Accounts</span>";
echo"<br><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='2'></label>Debit Accounts</span>";
echo"<br><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='3'></label>Both</span></td>";

echo"<td rowspan='3' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"<input name='ShowDesc' type='checkbox' id='ShowDesc' value='1'>Show Description <br>";
echo"</label></span>";

echo"<span class='style8'><label>";
echo"<input name='ShowProjectHeader' type='checkbox' id='ShowProjectHeader' value='1' checked>Show Project/Costcenter(Header) <br>";
echo"<input name='ShowProjectDetail' type='checkbox' id='ShowProjectDetail' value='1'>Show Project/Costcenter(Detail) <br>";
echo"</label></span>";

echo"<span class='style8'><label>";
echo"<input name='ShowChecks' type='checkbox' id='ShowChecks' value='1'>";
echo"Show Checks</label></span>";

echo"<br><span class='style8'><label>";
echo"<input name='ShowJV' type='checkbox' id='ShowJV' onclick='changestatus(1)' value='1'>";
echo"Show Detailed JV</label></span>";

echo"<br><span class='style8'><label>";
echo"<input name='ShowOtherSide' type='checkbox' onclick='changestatus(2)' id='ShowOtherSide' value='1'>";
echo"Show Other Side</label></span>";
echo"  </td></tr>";




echo"<tr><td bgcolor='#F5F5F5' colspan='3'><span class='style8'>Salesman Code / Description <label><input name='collections' type='checkbox' id='collections' value='1'>Collections Per Salesman</label></span></td><tr>";
echo"<tr><td colspan='3' valign='top' bgcolor='#F5F5F5'><table border='0'>";
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>From</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromsalesman'  value='$fromsalesman' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromsalesmandesc'  value='$fromsalesmandesc' size='30'>
				<img src='img/btnopen.jpg' title=' Select Salesman '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistsalesman(1); return false'>";
echo"		</label></td>
		</tr>";		
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='tosalesman'  value='$tosalesman' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='tosalesmandesc'  value='$tosalesmandesc' size='30'>
				<img src='img/btnopen.jpg' title=' Select Salesman '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistsalesman(2); return false'>";
echo"		</td>
		</tr>";
echo "</table></td></tr>";

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


		
		
echo" <tr>";

if ($Module_Project == 1) 
	echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Project </span></td>";
else 	
	echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
	
if ($Module_CostCenter == 1)	
	echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>CostCenter</span></td>";
else
	echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";	
echo" </tr>";

echo" <tr>";

if ($Module_Project == 1) {
	echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
			<td width='45%' colspan='4' bgcolor='#F5F5F5'> <span class='style8'><select name='fromproject' id='fromproject' style='width:400px'>";
			echo"<option></option>";
			while($prj=mysql_fetch_row($resultfromproject)){
			echo"<option ";
				if (($fromproject==$prj[0]) || ($defaultproject==$prj[0]))
					echo " selected ";
			echo" value='$prj[0]'>$prj[0] / $prj[1]</option>";
			}
			echo"</select>";
			echo"</span></td>";
} else {
	echo"   <td colspan='5' align='right' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
}			

if ($Module_CostCenter == 1){
	echo"	<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
			<td width='45%' colspan='2' align='left' bgcolor='#F5F5F5' ><span class='style8'>
			<select name='fromcostcent' id='fromcostcent' style='width:400px'>";
			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>";
			echo"</span></td>";	
} else {
	echo"   <td colspan='3' align='right' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
}
			
echo" </tr>";

echo" <tr>";

if ($Module_Project == 1) {
	echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
			<td width='45%' colspan='4' bgcolor='#F5F5F5'> <span class='style8'><select name='toproject' id='toproject' style='width:400px'>";
			echo"<option></option>";
			while($prj=mysql_fetch_row($resulttoproject)){
			echo"<option ";
				if (($toproject==$prj[0]) || ($defaultproject==$prj[0]))
					echo " selected ";
			echo" value='$prj[0]'>$prj[0] / $prj[1]</option>";
			}
			echo"</select>";
			echo"</span></td>";
} else {
	echo"   <td colspan='5' align='right' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
	echo"	<input type='hidden' name='fromproject' id='fromproject' value=''>
			<input type='hidden' name='toproject' id='toproject' value=''>";
}			

if ($Module_CostCenter == 1){
	echo"	<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
			<td width='45%' colspan='2' align='left' bgcolor='#F5F5F5' ><span class='style8'>
			<select name='tocostcent' id='tocostcent' style='width:400px'>";
			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>";
			echo"</span></td>";	
} else {
	echo"   <td colspan='3' align='right' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
	echo"	<input type='hidden' name='fromcostcent' id='fromcostcent' value=''>
			<input type='hidden' name='tocostcent' id='tocostcent' value=''>";
}
			
echo" </tr>";

	echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>"; 
 echo" </table>
 
</form>
</body>
</html>";

//Return Date in DD/MM/YYYY format
function displayFromDate($data){
	return "01/01/".substr($data, 6, 4);		
}
//Return Today's Date in DD/MM/YYYY format
function displayToday(){
	return strftime("%d")."/".strftime("%m")."/".strftime("%Y");
}


?>
