<?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_SalesJV as loginaccess, ExporttoExcel, Print 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");
	
if ($ExporttoExcel==1)
	$ExporttoExcelStatus= 'button';
else
	$ExporttoExcelStatus= 'hidden';
	

$printaccess=$Print;


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


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

$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(SalesJV_Date),'%d/%m/%Y') As DefaultFromDate, ".
           " Date_Format(Max(SalesJV_Date),'%d/%m/%Y') As DefaultToDate ".
		   " From SalesJV ";
$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];
  

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

print <<< HERE
<!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=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">
<style type = "text/css">
input[name=profitmargin] {    
        font-size: 11px;
    color: #999999;
    font-weight: bold;
} 
</style>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->

<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>

<link type="text/css" href="js/grid/scripts/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="js/grid/scripts/jquery-ui.min.js"></script>
<script type="text/javascript" language="javascript">
<!--


function PrintPrev(printaccess)
{
 
	var x = document.form1;
	
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < x.option.length; i++)
	{
		if (x.option[i].checked)
		{
			var varoption = x.option[i].value;
		}
	}	 
  
	for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
			var varcurrency = x.currency[i].value;
		}
	}
	
	for (var i=0; i < x.groupby.length; i++)
	{
		if (x.groupby[i].checked)
		{
			var vargroupby = x.groupby[i].value;
		}
	}
	
	for (var i=0; i < x.profitmargin.length; i++)
	{
		if (x.profitmargin[i].checked)
		{
			var varprofitmargin = x.profitmargin[i].value;
		}
	}	
	
  
	varprtdetail = 0;
	if (x.prtdetail.checked) varprtdetail = 1;
	
	varprtpaymentmode = 0;
	if (x.prtpaymentmode.checked) varprtpaymentmode = 1;	 
	
		varprtprProfitMargin = 0;
	if (x.prProfitMargin.checked) varprtprProfitMargin = 1;
	
	
	varsalesinv = 0;
	if (x.salesinv.checked) varsalesinv = 1;
	
 
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromref    = x.fromref.value;
	vartoref      = x.toref.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	varfromclt    = x.fromclient.value;
	vartoclt      = x.toclient.value;
	varfromslmn   = x.fromsalesman.value;
	vartoslmn     = x.tosalesman.value;
  
  
	varreport = '';
	if (varsalesinv == 1)
		varreport = 'Rep_ListofSalesJVAndInvoice.php';
	else 	
		varreport = 'Rep_ListofpmSalesJV.php';
	
	
	if (varprtprProfitMargin == 1)
	{
		varreport = 'Rep_ListofpmSalesJV.php';
 
	}
	
		
	str = varreport +'?fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref+'&toref='+vartoref
					+'&option='+varoption+'&groupby='+vargroupby+'&curr='+varcurrency+'&prtdetail='+varprtdetail
					+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
					+'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst;
					
			 
// append profit margin params				 
			if(1==1)	 	//if (varprtprProfitMargin == 1)
	{
		str =str  +'&prProfitMargin='+varprtprProfitMargin;
        str =str  +'&filtermargin='+varprofitmargin;
	    str = str +'&showpaymentmode=' + varprtpaymentmode;
		 
		
	/*	alert (str);exit; */
	
	}
	
	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 x = document.form1;
	
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < x.option.length; i++)
	{
		if (x.option[i].checked)
		{
			var varoption = x.option[i].value;
		}
	}	 
  
	for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
			var varcurrency = x.currency[i].value;
		}
	}
	
	for (var i=0; i < x.groupby.length; i++)
	{
		if (x.groupby[i].checked)
		{
			var vargroupby = x.groupby[i].value;
		}
	}
	
		for (var i=0; i < x.profitmargin.length; i++)
	{
		if (x.profitmargin[i].checked)
		{
			var varprofitmargin = x.profitmargin[i].value;
		}
	}	


	
  
	varprtdetail = 0;
	if (x.prtdetail.checked) varprtdetail = 1;
	
	varprtpaymentmode = 0;
	if (x.prtpaymentmode.checked) varprtpaymentmode = 1;	 
	
		varprtprProfitMargin = 0;
	if (x.prProfitMargin.checked) varprtprProfitMargin = 1;
	
	 
	
	varsalesinv = 0;
	if (x.salesinv.checked) varsalesinv = 1;

 
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromref    = x.fromref.value;
	vartoref      = x.toref.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	varfromclt    = x.fromclient.value;
	vartoclt      = x.toclient.value;
	varfromslmn   = x.fromsalesman.value;
	vartoslmn     = x.tosalesman.value;
	
	varreport = '';
	if (varsalesinv == 1)
		varreport = 'Exp_ListofSalesJVAndInvoice.php';
	else 	
		varreport = 'Exp_ListofSalesJV.php';
	
	
	str = varreport +'?fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref+'&toref='+vartoref
					+'&option='+varoption+'&groupby='+vargroupby+'&curr='+varcurrency+'&prtdetail='+varprtdetail
					+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
					+'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst;
					
    	str =str  +'&prProfitMargin='+varprtprProfitMargin;
        str =str  +'&filtermargin='+varprofitmargin;
	    str = str +'&showpaymentmode=' + varprtpaymentmode;				
				 
	window.open(str);

}


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

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

function ClearPage() {
	x = document.form1;
	
	//x.templateid.value = '';
	//x.action='Form_ListofSalesJV.php';
	//x.submit();
	
	window.location ='Form_ListofSalesJV.php';
	
}



-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>List Of Sales JV</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]' >
		<input type='hidden' name='templateid' value='$templateid'>";
		
Print <<<HERE
<script type = "text/javascript">
$(document).ready(function()
{
	$("#prProfitMargin").change(function() {
    if(this.checked) {
 
 
    //   $("#prtdetail").prop('checked', false);
	 //  $("#salesinv").prop('checked', false);	   
	//   $("#prtdetail").prop('disabled', 'disabled');
	 //  $("#salesinv").prop('disabled', 'disabled');
	   
    //    $("#option1").prop("checked", true); 
 	//   $("#option2").prop('disabled', 'disabled');
    }
	else
	{
	//  $("#prtdetail").prop('disabled','' );
	//  $("#salesinv").prop('disabled', '');
	//  $("#option2").prop('disabled', '');
	 
	}
});
}
);

</script>
HERE;
 

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 Sales JV</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" valign="top" width="100%">';


echo" <tr>";	  
echo"   <td width='20%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo "		<input name='option' id='option1' type='radio' value='1' checked />Date</span></td>";
echo"   <td width='18%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo "		<input name='option' id='option2' type='radio' value='2' />Reference</span></td>";
echo"   <td width='12%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'> Currency</span></td>";
echo"   <td width='20%' height='19' colspan='2' align='center' bgcolor='#F5F5F5'><span class='style8'>Group By</span></td>";
echo"   <td width='30%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>Options</span></td>";
echo" </tr>";

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

echo"   <td width='12%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo "		<input name='currency' type='radio' value='' />Currency</label></span>";
echo"   <br><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='20%' colspan='2' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($groupby=="1" || $groupby=="")
           echo "<input name='groupby' type='radio' value='1' checked  />";
		else	
		   echo "<input name='groupby' type='radio' value='1'  />";
		echo "None</label></span>";
echo"   <br><span class='style8'><label>";
		if ($groupby=="2")
           echo "<input name='groupby' type='radio' value='2' checked  />";
		else	
		   echo "<input name='groupby' type='radio' value='2'  />";
		echo "Client</label></span>";			
echo"   <br><span class='style8'><label>";
		if ($groupby=="3")
           echo "<input name='groupby' type='radio' value='3' checked  />";
		else	
		   echo "<input name='groupby' type='radio' value='3'  />";
		echo "Salesman</label></span>";			
echo"   <br><span class='style8'><label>";
		if ($groupby=="4")
           echo "<input name='groupby' type='radio' value='4' checked  />";
		else	
		   echo "<input name='groupby' type='radio' value='4'  />";
		echo "Shipment Ref</label></span>";	
echo"   <br><span class='style8'><label>";
		if ($groupby=="5")
           echo "<input name='groupby' type='radio' value='5' checked  />";
		else	
		   echo "<input name='groupby' type='radio' value='5'  />";
		echo "CostCenter</label></span>";	
echo "	</td>";	
		
echo"   <td width='30%' rowspan='3' valign='top' bgcolor='#F5F5F5' style = \"    font-size: 11px; color: #999999; font-weight: bold;\">  ";

echo  "<span class='style8'> 
 <label><input type='checkbox' name='prProfitMargin' id='prProfitMargin' value='1' />Include Profit Margin Report</label>
   </span> <br> <input type=\"radio\"  name=\"profitmargin\" value=\"Selling Price\" checked=\"checked\" >Selling Price 
  <input type=\"radio\"  name=\"profitmargin\" value=\"Cost\"> Cost<hr><br>";
 


echo "<span class='style8'>";
echo"      <label><input type='checkbox' name='prtpaymentmode' id='prtpaymentmode' value='1' />Show Payment Mode</label></span><br>";
 
echo "<span class='style8'>";
echo"      <label><input type='checkbox' name='prtdetail' id='prtdetail' value='1' />With Details</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <label><input type='checkbox' name='salesinv' id='salesinv' value='1' />Include Sales Invoice</label>";
echo"   </span></td>";
echo" </tr>";

echo" <tr height='25'>";
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"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='13%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='toref' value='$toref' maxlength='10' size='10'>";
echo"    </span></td>";
echo" </tr>";

echo" <tr height='25'>";
echo"   <td colspan='4' valign='top' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Client Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Salesman Code / Description</span></td>";
echo" </tr>";



echo" <tr>";	  
echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='4' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <input name='fromclient' type='text' id='fromclient' size='15' value='".$fromclient."' />
        <input name='fromdesc' type='text' id='fromdesc' size='39' value='".$fromdesc."' />
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Client From ' 
             onClick='showlistclient(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>";
echo"	</td>";

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromsalesman' type='text' id='fromsalesman' size='15' value='".$fromsalesman."' />
        <input name='fromsalesmandesc' type='text' id='fromsalesmandesc' size='39' value='".$fromsalesmandesc."' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Salesman From ' 
             onClick='showlistsalesman(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";
echo"</tr>";

			 
echo" <tr>";	  
echo"   <td width='5%'  align='left' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='4' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <input name='toclient' type='text' id='toclient' size='15' value='".$toclient."' />
        <input name='todesc' type='text' id='todesc' size='39' value='".$todesc."' />
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Client To ' 
             onClick='showlistclient(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>";
echo"	</td>";

echo"   <td width='5%' align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";	
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='tosalesman' type='text' id='tosalesman' size='15' value='".$tosalesman."' />
        <input name='tosalesmandesc' type='text' id='tosalesmandesc' size='39' value='".$tosalesmandesc."' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Salesman To ' 
             onClick='showlistsalesman(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>"; 
echo" </tr>";

echo" <tr>";
echo"   <td colspan='8' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr>";

if ($Module_Project == 1) 
	echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Shipment Ref </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" <tr height='30'>";
echo"   <td colspan='8' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
    /*<tr>
      <td colspan='8' align='center' bgcolor='#F5F5F5'>
	  <input type='button' name='btnClear' value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"ClearPage()\"; />
	  <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>";

?>