<?php
 

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



$querylog="SELECT print as printaccess, ifNull(FI_Grn,0) As FI_Grn, ifNull(FI_Purchases,0) As FI_Purchases, ExporttoExcel, FI_Delivery, FI_ReturnDelivery, FI_ReturnSales, FI_Sales, 
			FI_PurchaseOrder, FI_Purchases, FI_ReturnPurchase, FI_Adjustment , FI_Transfer
			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);
}

$querymodule=" Select ifnull(module_delivery,0) as module_delivery ".
				" From Module ";
				
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$querylog="SELECT RI_ListTransaction as loginaccess 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");
	
	

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

}


$querysalessetup="select Salesttc from salessetup";
$resultsalessetup=mysql_query($querysalessetup,$connection) or die(mysql_error());
while($rowssalessetup=mysql_fetch_array($resultsalessetup)){
  extract($rowssalessetup);
}

$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];

$querydflproject="select project_code as defaultproject from ".$_SESSION['dbLabel'].".loginstk 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);

}

$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$_SESSION['dbLabel'].".loginstk on project.project_code like concat(loginstk.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());
$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());


$querysordertype="select Sorder_Type, Sorder_TypeName from sordertype where FormType = 'Sorder' order by Sorder_Type";
$resultsordertype=mysql_query($querysordertype,$connection) or die(mysql_error());

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" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>


<link type="text/css" href="js/calendar/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="js/calendar/jquery.datepick.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 cgr7(){
x=document.form1;
//code1a=x.code1a.value;
document.form1.action="select_client.php?item=1";
document.form1.btncode1.submit();

}

function cgr8(){
x=document.form1;
//code2a=x.code2a.value;
document.form1.action="select_client.php?item=2";
document.form1.btncode2.submit();

}

all = 0;  // 0 means 'no', 1 means 'yes'

function showlistProject(str){

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

function SelectOptions() {
	x = document.form1;
	vTemplateId = x.templateid.value;
	
    win = window.open('Form_ReportsOptions.php?isseloption=1&templateid='+vTemplateId+'&formname=ListofTransaction', 'Form_ReportsOptions', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1230,height=650,top=30,left=0');
	win.creator = self;
	win.focus();		

}


function PrintPrev(module,printaccess)
{

	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < document.form1.date.length; i++)
	{
		if (document.form1.date[i].checked)
		{
			var vardate = document.form1.date[i].value;
		}
	}	 
  
	for (var i=0; i < document.form1.transaction.length; i++)
	{
		if (document.form1.transaction[i].checked)
		{
			var vartrans = document.form1.transaction[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;
		}
	}
  
	for (var i=0; i < document.form1.option.length; i++)
	{
		if (document.form1.option[i].checked)
		{
			var varoption = document.form1.option[i].value;
		}
	}

	var checkboxname;
	var x, varsordertype;
	varsordertype = '';
	for (var i=1; i <= document.form1.i.value; i++)
	{
		checkboxname='sordertype'+i;
	
		x = document.getElementById(checkboxname);
		if (x.checked) 
			varsordertype = varsordertype+",'"+x.value+"'";
	}
	varsordertype = varsordertype.substr(1);
    
    
	varsalesboth = 0;
	if (document.form1.salesboth)
	if (document.form1.salesboth.checked) 	varsalesboth = 1;
	 
	vardeliveryboth = 0;
	if (module == 1 )
	if (document.form1.deliveryboth)
		if (document.form1.deliveryboth.checked)   vardeliveryboth = 1;	 
		
	varpurchaseboth = 0;
	if (document.form1.purchaseboth)
	if (document.form1.purchaseboth.checked)    varpurchaseboth = 1;		
	
	varshowdetail = 0;
	if (document.form1.detail)
	if (document.form1.detail.checked)    varshowdetail = 1;	

	vargrpproject = 0;
	if (document.form1.grpproject)
	if (document.form1.grpproject.checked)   vargrpproject = 1;		
	
	vargrpsupplier = 0;
	if (document.form1.grpsupplier)
	if (document.form1.grpsupplier.checked)   vargrpsupplier = 1;			
	
	vargrpclient = 0;
	if (document.form1.grpclient)
	if (document.form1.grpclient.checked)   vargrpclient = 1;				
	
	varpricettc = 0;
	if (document.form1.pricettc)
	if (document.form1.pricettc.checked)   varpricettc = 1;	
	
	vargrpstatus = 0;
	if (document.form1.grpstatus)
	if (document.form1.grpstatus.checked)    vargrpstatus = 1;	
	
	varchckSaleRep = 0;
	if (document.form1.chckSaleRep)
	if (document.form1.chckSaleRep.checked)    varchckSaleRep = 1;	
	
	chkDetailPrjctCost = 0;
	if (document.form1.chkDetailPrjctCost)
	if (document.form1.chkDetailPrjctCost.checked)    chkDetailPrjctCost = 1;	


	chksepareteinvoice = 0;
	if (document.form1.chksepareteinvoice)
	if (document.form1.chksepareteinvoice.checked)    chksepareteinvoice = 1;	
	
	let showProjCostName = 0;
	if (document.getElementById('showProjCostName').checked)
		showProjCostName = 1;


  
	varfromdate = document.form1.fromdate.value;
	vartodate   = document.form1.todate.value;
	varfromref  = document.form1.fromref.value;
	vartoref    = document.form1.toref.value;
	varfromclt  = document.form1.fromclient.value;
	vartoclt    = document.form1.toclient.value;
	varfromsupp = document.form1.fromsupplier.value;
	vartosupp   = document.form1.tosupplier.value;
	varfromproject = document.form1.fromproject.value;
	varsalesman = document.form1.clientsalesman.value;
	varsalesmanname = document.form1.clientsalesmanname.value;
	varfromitem = document.form1.fromitem.value;
	vartoitem   = document.form1.toitem.value;
	varfromsalesman = document.form1.fromsalesman.value;
	vartosalesman   = document.form1.tosalesman.value;
	varfromgroup = document.form1.fromgroup.value;
	vartogroup   = document.form1.togroup.value;
	varfromsubgroup = document.form1.fromsubgroup.value;
	vartosubgroup   = document.form1.tosubgroup.value;
	varfromcostcent = document.form1.fromcostcent.value;
	varfromwarehouse   = document.form1.fromwarehouse.value;
	varfromcategory = document.form1.fromcategory.value;
	vartocategory   = document.form1.tocategory.value;
  
	var chckitems = 0;
	if(document.getElementById("chckitem")) 
	if(document.getElementById("chckitem").checked) var chckitems = 1;
	
	var delIds = '';
	delIds = document.getElementById('delIds').value;
	
	if ((vartrans == 'DI') || (vartrans=='DR')) {
		str = 'rep_listofsales.php';
	
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient+'&transaction='+vartrans
			+'&cur='+varcurrency+'&salesboth='+varsalesboth+'&showdetail='+varshowdetail+'&deliveryboth='+vardeliveryboth
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject+'&pricettc='+varpricettc+'&show_reason='+document.form1.show_reason.value;
	}	
	else if ((vartrans == 'SI') || (vartrans=='SR') )	{
		if (module==0) {
			if (vartrans == 'SI') vartrans = 'DI';
			if (vartrans == 'SR') vartrans = 'DR';
		}
		if(vartrans == 'DI' && chckitems == 1)
			str = 'rep_listofsalesByItems.php';
		else if(vartrans == 'DI' && varchckSaleRep == 1)
			str = 'Rep_ListSalesItemsByClients.php';
		else 
		str = 'rep_listofsales.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient+'&transaction='+vartrans
			+'&cur='+varcurrency+'&salesboth='+varsalesboth+'&showdetail='+varshowdetail+'&deliveryboth='+vardeliveryboth
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject+'&pricettc='+varpricettc
			+'&salesman='+varsalesman+'&salesmanname='+varsalesmanname+'&option='+varoption+'&chckitems='+chckitems+'&show_reason='+document.form1.show_reason.value;
		if(vartrans == 'DI' && chckitems == 1)
			str = str+'&delIds='+delIds;
	}  
	else if (vartrans == 'TR') {
		str = 'rep_listoftransfer.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&transaction='+vartrans+'&cur='+varcurrency+'&showdetail='+varshowdetail
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject;
	}
	else if ((vartrans == 'PI') || (vartrans=='PR')) {
		str = 'rep_listofpurchases.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromsupp='+varfromsupp+'&tosupp='+vartosupp+'&transaction='+vartrans
			+'&cur='+varcurrency+'&purchaseboth='+varpurchaseboth+'&showdetail='+varshowdetail
			+'&grpsupplier='+vargrpsupplier+'&grpproject='+vargrpproject+'&fromproject='+varfromproject;
	}
	else if (vartrans == 'SO')	{
		if (chkDetailPrjctCost == 1)
			str = 'rep_listofdetailedsalesorder.php';
		else 
		str = 'rep_listofsalesorder.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient
			+'&transaction='+vartrans+'&cur='+varcurrency+'&showdetail='+varshowdetail+'&grpproject='+vargrpproject
			+'&fromproject='+varfromproject+'&option='+varoption+'&grpstatus='+vargrpstatus+'&sordertype='+varsordertype
			+'&salesman='+varsalesman+'&salesmanname='+varsalesmanname;
	} 
	else if (vartrans == 'AD')	{
		str = 'Rep_ListofAdjustment.php';
		
		varadjustin = 0;
		if (document.form1.AdjustIN.checked)    varadjustin = 1;
		varadjustout = 0;
		if (document.form1.AdjustOUT.checked)    varadjustout = 1;
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&grpproject='+vargrpproject+'&fromproject='+varfromproject
			+'&AdjustIN='+varadjustin+'&AdjustOUT='+varadjustout+'&cur='+varcurrency+'&showdetail='+varshowdetail;
			
			
	}   
  //alert(vartrans);
  
  str += '&chksepareteinvoice='+chksepareteinvoice+'&showProjCostName='+showProjCostName;

  varfromcostcent = document.form1.fromcostcent.value;
  varfromwarehouse   = document.form1.fromwarehouse.value;

  str = str+'?fromitem='+varfromitem+'&toitem='+vartoitem+'&fromsalesman='+varfromsalesman
			+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgroup
			+'&togroup='+vartogroup+'&fromsubgroup='+varfromsubgroup
			+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
			+'&tocategory='+vartocategory+'&fromcostcent='+varfromcostcent
			+'&fromwarehouse='+varfromwarehouse;
			
	if ((vartrans=='DI') || (vartrans=='DR') || (vartrans=='SI') || (vartrans=='SR') || (vartrans=='TR') || 
		(vartrans=='PI') || (vartrans=='PR') || (vartrans=='SO') || (vartrans=='AD')) {

		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(module) {
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < document.form1.date.length; i++)
	{
		if (document.form1.date[i].checked)
		{
			var vardate = document.form1.date[i].value;
		}
	}	 
  
	for (var i=0; i < document.form1.transaction.length; i++)
	{
		if (document.form1.transaction[i].checked)
		{
			var vartrans = document.form1.transaction[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;
		}
	}
  
	for (var i=0; i < document.form1.option.length; i++)
	{
		if (document.form1.option[i].checked)
		{
			var varoption = document.form1.option[i].value;
		}
	}

	var checkboxname;
	var x, varsordertype;
	varsordertype = '';
	for (var i=1; i <= document.form1.i.value; i++)
	{
		checkboxname='sordertype'+i;
	
		x = document.getElementById(checkboxname);
		if (x.checked) 
		varsordertype = varsordertype+",'"+x.value+"'";
	}
	varsordertype = varsordertype.substr(1);
    
    
	varsalesboth = 0;
	if (document.form1.salesboth)
	if (document.form1.salesboth.checked) 	varsalesboth = 1;
	 
	vardeliveryboth = 0;
	if (module == 1 )
		if (document.form1.deliveryboth)
		if (document.form1.deliveryboth.checked) vardeliveryboth = 1;	 
		
	varpurchaseboth = 0;
	if (document.form1.purchaseboth)
	if (document.form1.purchaseboth.checked) varpurchaseboth = 1;		
	
	varshowdetail = 0;
	if (document.form1.detail)
	if (document.form1.detail.checked)	varshowdetail = 1;	

	vargrpproject = 0;
	if (document.form1.grpproject)
	if (document.form1.grpproject.checked)	vargrpproject = 1;		
	
	vargrpsupplier = 0;
	if (document.form1.grpsupplier)
	if (document.form1.grpsupplier.checked) 	vargrpsupplier = 1;			
	
	vargrpclient = 0;
	if (document.form1.grpclient)
	if (document.form1.grpclient.checked)	vargrpclient = 1;				
	
	varpricettc = 0;
	if (document.form1.pricettc)
	if (document.form1.pricettc.checked)	varpricettc = 1;	
	
	vargrpstatus = 0;
	if (document.form1.grpstatus)
	if (document.form1.grpstatus.checked)	vargrpstatus = 1;	
	
	varchckSaleRep = 0;
	if (document.form1.chckSaleRep)
	if (document.form1.chckSaleRep.checked)    varchckSaleRep = 1;	
	
	var chkDetailPrjctCost = 0;
	if (document.form1.chkDetailPrjctCost)
	if (document.form1.chkDetailPrjctCost.checked)    chkDetailPrjctCost = 1;	

	let showProjCostName = 0;
	if (document.getElementById('showProjCostName').checked)
		showProjCostName = 1;
	
	varfromdate = document.form1.fromdate.value;
	vartodate   = document.form1.todate.value;
	varfromref  = document.form1.fromref.value;
	vartoref    = document.form1.toref.value;
	varfromclt  = document.form1.fromclient.value;
	vartoclt    = document.form1.toclient.value;
	varfromsupp = document.form1.fromsupplier.value;
	vartosupp   = document.form1.tosupplier.value;
	varfromproject = document.form1.fromproject.value;
	varfromitem = document.form1.fromitem.value;
	vartoitem   = document.form1.toitem.value;
	varfromsalesman = document.form1.fromsalesman.value;
	vartosalesman   = document.form1.tosalesman.value;
	varfromgroup = document.form1.fromgroup.value;
	vartogroup   = document.form1.togroup.value;
	varfromsubgroup = document.form1.fromsubgroup.value;
	vartosubgroup   = document.form1.tosubgroup.value;
	varfromcostcent = document.form1.fromcostcent.value;
	varfromwarehouse   = document.form1.fromwarehouse.value;
	varfromcategory = document.form1.fromcategory.value;
	vartocategory   = document.form1.tocategory.value;
  
  
	if ((vartrans == 'DI') || (vartrans=='DR')) {
		if(vartrans == 'DI' && varchckSaleRep == 1)
		str = 'Exp_ListSalesItemsByClients.php';
		else str = 'Exp_ListofSales.php';

		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient+'&transaction='+vartrans
			+'&cur='+varcurrency+'&salesboth='+varsalesboth+'&showdetail='+varshowdetail+'&deliveryboth='+vardeliveryboth
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject+'&pricettc='+varpricettc;
	}	
	else if ((vartrans == 'SI') || (vartrans=='SR') )	{
		if (module==0) {
		if (vartrans == 'SI') vartrans = 'DI';
		if (vartrans == 'SR') vartrans = 'DR';
		}
		if(vartrans == 'DI' && varchckSaleRep == 1)
		str = 'Exp_ListSalesItemsByClients.php';
		else
		str = 'Exp_ListofSales.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient+'&transaction='+vartrans
			+'&cur='+varcurrency+'&salesboth='+varsalesboth+'&showdetail='+varshowdetail+'&deliveryboth='+vardeliveryboth
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject+'&pricettc='+varpricettc;
	}  
	else if (vartrans == 'TR') {
		str = 'Exp_ListofTransfer.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&transaction='+vartrans+'&cur='+varcurrency+'&showdetail='+varshowdetail
			+'&grpproject='+vargrpproject+'&fromproject='+varfromproject;
	}
	else if ((vartrans == 'PI') || (vartrans=='PR')) {
		str = 'Exp_ListofPurchases.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromsupp='+varfromsupp+'&tosupp='+vartosupp+'&transaction='+vartrans
			+'&cur='+varcurrency+'&purchaseboth='+varpurchaseboth+'&showdetail='+varshowdetail
			+'&grpsupplier='+vargrpsupplier+'&grpproject='+vargrpproject+'&fromproject='+varfromproject;
	}
	else if (vartrans == 'SO')	{
		if (chkDetailPrjctCost == 1)
			str = 'Exp_ListofDetailedSalesOrder.php';
		else str = 'Exp_ListofSalesOrder.php';
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&fromclient='+varfromclt+'&toclient='+vartoclt+'&grpclient='+vargrpclient
			+'&transaction='+vartrans+'&cur='+varcurrency+'&showdetail='+varshowdetail+'&grpproject='+vargrpproject
			+'&fromproject='+varfromproject+'&option='+varoption+'&grpstatus='+vargrpstatus+'&sordertype='+varsordertype;
	}  
	else if (vartrans == 'AD')	{
		str = 'Exp_ListofAdjustment.php';
		
		varadjustin = 0;
		if (document.form1.AdjustIN.checked)    varadjustin = 1;
		varadjustout = 0;
		if (document.form1.AdjustOUT.checked)    varadjustout = 1;
	 
		str = str+'?date='+vardate+'&fromdate='+varfromdate+'&todate='+vartodate+'&fromref='+varfromref
			+'&toref='+vartoref+'&grpproject='+vargrpproject+'&fromproject='+varfromproject
			+'&AdjustIN='+varadjustin+'&AdjustOUT='+varadjustout+'&cur='+varcurrency+'&showdetail='+varshowdetail;
	} 
	str += '&showProjCostName='+showProjCostName;
	str = str+'?fromitem='+varfromitem+'&toitem='+vartoitem+'&fromsalesman='+varfromsalesman
	+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgroup
	+'&togroup='+vartogroup+'&fromsubgroup='+varfromsubgroup
	+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
	+'&tocategory='+vartocategory+'&fromcostcent='+varfromcostcent
	+'&fromwarehouse='+varfromwarehouse;
	
	if ((vartrans=='DI') || (vartrans=='DR') || (vartrans=='SI') || (vartrans=='SR') || (vartrans=='TR') || 
		(vartrans=='PI') || (vartrans=='PR') || (vartrans=='SO') || (vartrans=='AD'))
		window.open(str);

}

function SelectOption()
{
	for (var i=0; i < document.form1.transaction.length; i++)
	{
		if (document.form1.transaction[i].checked)
		{
			var vartrans = document.form1.transaction[i].value;
		}
	}
	
	if ((vartrans=='DI' || vartrans=='DR') && (document.form1.detail.checked))
		document.form1.showcost.disabled = false;
	else {
		document.form1.showcost.checked = false;
		document.form1.showcost.disabled = true;
	}	

}
function chkShowReason()
{
	var x = document.form1;
	if(x.chck_show_reason.checked)
	{
		x.show_reason.value = 1;
	}
	else
	{
		x.show_reason.value = 0;
	}
}
function hide(){
  document.getElementById("preview").style.visibility="hidden";
  document.getElementById("clearbtn").style.visibility="hidden";
}
function show(){
  document.getElementById("preview").style.visibility="visible";
  document.getElementById("clearbtn").style.visibility="visible";
}

function SelectPurType(option) {
	if (option == 1) {
		if (document.getElementById('PurType2')) {
			document.form1.PurType2.checked = false;
		}	 
	} else {
		if (document.getElementById('PurType1')) {
			document.form1.PurType1.checked = false;
		}	 
	}
	
}

function showlistsalesman(str){
	for (var i=0; i < document.form1.transaction.length; i++)
	{
		if (document.form1.transaction[i].checked)
		{
			var vartrans = document.form1.transaction[i].value;
		}
	}
	if ((vartrans=='SI') || (vartrans=='SR') || (vartrans=='SO')) {
		var vdate, vcode; 
		vcode=encodeURIComponent(document.form1.clientsalesman.value);
		vname=encodeURIComponent(document.form1.clientsalesmanname.value);
		if(vcode=='')
			vcode=vname;
		window.open('List_Salesmen.php?frm=20&str=20&item='+str+'&PLedger_number='+vcode,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
	}
}

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 showlistSupplier(str){

  window.open('select_supplier.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 disableSalesman(){
	document.getElementById("clientsalesman").disabled = true;
	document.getElementById("clientsalesmanname").disabled = true;
}

function enableSalesman(){
	document.getElementById("clientsalesman").disabled = false;
	document.getElementById("clientsalesmanname").disabled = false;
}

</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 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]'>
<input type='hidden' name='templateid' value='$templateid'>";

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 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 Page'><span><span>Clear</span></span></button>";
     

	 echo" <button type='button' id='preview' name='preview' onClick=\"PrintPrev(".$_SESSION['module'].",'".$printaccess."')\"; title='Preview'><span><span>Preview</span></span></button>";
	

if ($ExporttoExcel==1){
	 echo" <button type='button' id='btnExcel' name='btnExcel' onClick=\"ExportExcel(".$_SESSION['module'].")\"; title='Export Excel'><span><span>Export Excel</span></span></button>";

}	
else{}
	
		echo" <button type='button' id='btnSelectOptions' name='btnSelectOptions' onClick=\"SelectOptions()\"; title='Select Options'><span><span>Select Options</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 ><td width='20%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";

if ($_POST['date']=="date" || $_POST['date']=="")
    echo "<input name='date' id='date' type='radio' value='date' checked />";
else	
    echo "<input name='date' id='date' type='radio' value='date' />";
	
echo"</label> ";
echo"Date</span></td>";
echo"<td width='18%' height='19' colspan='2' align='center' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

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

echo"</label>";
echo"Reference</span></td>";
echo"<td width='17%' colspan='2' align='center' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

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

echo"</label>";
echo"Invoice No </span></td>";
echo"<td width='12%' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";

echo"  <td width='33%' colspan='2' bgcolor='#F5F5F5'><span class='style8'><label>
		<input name='grpstatus' type='checkbox' id='grpstatus' value='1'  ";
	   if($grpstatus==1) echo "checked"; else echo '';  echo"/>";
echo"      Enable Group by SO status </label></span>";

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='5%' align='center' bgcolor='#F5F5F5' class='style8'>From</td>";
echo"      <td width='13%' bgcolor='#F5F5F5' class='style8'><label>";
echo"      <input type='text' name='fromref' value='$fromref' size='10'>";
echo"      </label></td>";
echo"      <td width='5%' align='center' bgcolor='#F5F5F5' class='style8'>From</td>";
echo"      <td width='12%' bgcolor='#F5F5F5' class='style8'><input type='text' name='frominvo' value='$frominvo' size='10'></td>";

echo"      <td width='12%' rowspan='3' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
echo"        <label><input name='currency' type='radio' value='currency1'>Currency</label><br>";
echo"        <label><input name='currency' type='radio' value='$rowsetup[0]' "; if($defaultcurr == $rowsetup[0]) echo "checked"; echo">$rowsetup[0]</label><br>";
echo"        <label><input name='currency' type='radio' value='$rowsetup[1]' "; if($defaultcurr == $rowsetup[1]) echo "checked"; echo">$rowsetup[1]</label>";
echo"      </span></td>";
echo"	   <td width='33%' colspan='2' rowspan='4' bgcolor='#F5F5F5' valign='top'><span class='style8'>";

        if ($_POST['option']=="1" )
            echo "<input name='option' type='radio' value='1' checked >";
        else	
		    echo "<input name='option' type='radio' value='1' >";
			
echo"      Confirmed Sales Order <br>";
	    if ($_POST['option']=="2" )
           echo "<input name='option' type='radio' value='2' checked >";
		else	
		   echo "<input name='option' type='radio' value='2' >";
				
echo"      Unconfirmed Sales Order <br>";
	    if ($_POST['option']=="3" )
           echo "<input name='option' type='radio' value='3' checked >";
		else	
		   echo "<input name='option' type='radio' value='3' >";
				
echo"      Cancelled Sales Order <br>";
	    if ($_POST['option']=="4" || $_POST['option']=="")
           echo "<input name='option' type='radio' value='4' checked >";
		else	
		   echo "<input name='option' type='radio' value='4' >";
				
echo"      All Sales Order <br>";

echo "<input type='checkbox' name='chckitem' id='chckitem'  >";
echo"      Group by Items <br>";
echo "<input type='checkbox' name='chckSaleRep' id='chckSaleRep' value='0'> Sales Report items X clients <br>";
echo"   </td></span>";
echo"    </tr>";



echo"    <tr height='20px'><td></td></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=\"anchor2\" ID=\"anchor2\"><image src='./img/cal.gif' border=0 align=center></image></A>";
echo"      </span></td>";

echo"      <td width='5%' align='center' bgcolor='#F5F5F5' class='style8'>To</td>";
echo"      <td width='13%' bgcolor='#F5F5F5' class='style8'><label>";
echo"      <input type='text' name='toref'  value='$toref' size='10'>";
echo"      </label></td>";
echo"      <td width='5%' align='center' bgcolor='#F5F5F5' class='style8'><label>To</label></td>";
echo"      <td width='12%' bgcolor='#F5F5F5' class='style8'><input type='text' name='toinvo'  value='$toinvo' size='10'>";
echo"      </td>";
//echo"	   <td width='33%' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo"    </tr>";

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

echo"    <tr height='15px'>";
echo"      <td colspan='2' rowspan='3' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
	if ($FI_PurchaseOrder == 1){
        if ($_POST['transaction']=="PO" || $_POST['transaction']=="")
           echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PO' checked  />";
		else	
		   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PO'  />";

echo"      Purchase Order";
	}
	if ($FI_Purchases == 1){
echo"      <br />";
        if ($_POST['transaction']=="PI" )
           echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PI' checked  />";
		else	
		   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PI' />";
				
echo"      Purchase ";
	}
	if ($FI_ReturnPurchase == 1){
echo " <br />";

        if ($_POST['transaction']=="PR" )
           echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PR' checked />";
		else	
		   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='PR' />";

echo"       Return Purchase ";

echo"      <input name='purchaseboth' type='checkbox' id='purchaseboth' value='both1'";
        	   echo isset($_POST['purchaseboth'])?"checked":'';  echo "/>";
echo"      Both";
	}
echo"      </span>";
echo"
        <p class='style8'>
      </p></td>
      <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Supplier Code/Description       </span></td>
      <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>
        <label>
        <input name='grpsupplier' type='checkbox' id='grpsupplier' value='grpsupplier' ";
		echo isset($_POST['grpsupplier'])?"checked":'';  echo "/>";
echo" Enable Group by supplier </label>
      </span></td>";
      //<td bgcolor='#F5F5F5'> &nbsp; </td>
echo"</tr>
    <tr height='15px'>";
	
echo" <td align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
      <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>
	  <label>
        <input name='fromsupplier' type='text' id='fromsupplier' size='15' value='";
		
		echo $_POST['fromsupplier']; echo"' />";
echo"   <input name='fromsuppdesc' type='text' id='fromsuppdesc' size='30' value='";

        echo $_POST['fromsuppdesc']; echo"' />";
echo"   <input name='btncode1' type='hidden' id='btncode1' value='...' onclick='cgr7()' style='width:20px; height:20px; border:thin;' title='Select Supplier From' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier From ' 
             onClick='showlistSupplier(1);' ><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>

      </td>
	  <td bgcolor='#F5F5F5' colspan='2'><span class='style8'> Sales Order Types </span></td> 
    </tr>
    <tr height='15px'>
      <td align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
      <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>
	  <label>
        <input name='tosupplier' type='text' id='tosupplier' size='15' value='";
		 echo $_POST['tosupplier']; echo"' />";
echo"   <input name='tosuppdesc' type='text' id='tosuppdesc' size='30' value='";
         echo $_POST['tosuppdesc']; echo"' />";
echo"  <input name='btncode2' type='hidden' id='btncode2' value='...' onclick='cgr8()' style='width:20px; height:20px; border:thin;' title='Select Supplier To' />
        </label></span>
        <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier To ' 
        onClick='showlistSupplier(2);' ><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
      </td>
	  <td valign='top' colspan='2' rowspan='4' bgcolor='#F5F5F5'>";
	  
	  echo"<div style='overflow:auto; height:80px; width:65px;' ><table border='0'><tr><td>";
		
		$i = 0;
		while($sordertype=mysql_fetch_row($resultsordertype)){
		   $i = $i + 1;
		   $type  = 'sordertype'.$i;
		   $$type = $sordertype[0];
		   
		   echo"<span class='style8'><label>";
           echo"<input name='$type' type='checkbox' id='$type' value='".$$type."' "; 
		   if ($sordertype[0] == 'SO') echo " checked ";
		   echo" /> $sordertype[0] </label></span>";
		}
		echo "<input type='hidden' name='i' value='$i'>";
		echo "</td></tr></table></div>";  

echo" </td>
    </tr>
    
    <tr height='15px'>
      <td colspan='2' rowspan='3' bgcolor='#F5F5F5'><span class='style8'>";
	if($_SESSION['module']=="1"){		
		if ($_POST['transaction']=="DI" )
            echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='DI' checked />";
		else	
		    echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='DI' />";
        
		echo"  Delivery <br />";
				if ($_POST['transaction']=="DR" )
				   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='DR' checked />";
				else	
				   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='DR' />";
				   
		echo"  Return Delivery<br /> 
			  <input name='deliveryboth' type='checkbox' value='both2' ";
			  
			   echo isset($_POST['deliveryboth'])?"checked":'';  echo"/>";
		echo"      Both        ";
	}
echo"      </span></td>
	  
      <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Client Code/Description </span></td>
      
      <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>
        <label>
        <input name='grpclient' type='checkbox' id='grpclient' value='grpclient' ";
		
		 echo isset($_POST['grpclient'])?"checked":'';  echo"/>";
echo"       
      Enable Group by client
      
      </span></td>
	<tr height='15px'>
      <td align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
      <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>
        <label>
        <input name='fromclient' type='text' id='fromclient' size='15' value='";
		
		echo $_POST['fromclient']; echo"' />";
echo"   <input name='fromdesc' type='text' id='fromdesc' size='30' value='";

        echo $_POST['fromdesc']; echo"' />";
echo"   <input name='btncode1' type='hidden' id='btncode1' value='...' onclick='cgr7()' style='width:20px; height:20px; border:thin;' title='Select Client From' />
        </label>
      </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>      
     </td>
	</tr>
    <tr height='15px'>
	   <td align='right' bgcolor='#F5F5F5'><span class='style8'><span class='style8'>To</span></td>
       <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>
        <label>
        <input name='toclient' type='text' id='toclient' size='15' value='";
		 echo $_POST['toclient']; echo"' />";
echo"   <input name='todesc' type='text' id='todesc' size='30' value='";
         echo $_POST['todesc']; echo"' />";
if ($_POST['transaction']=="SO" || $_POST['transaction']=="SI" ||$_POST['transaction']=="SR")
	$disabled ='';
else
	$disabled = 'disabled';
echo"  <input name='btncode2' type='hidden' id='btncode2' value='...' onclick='cgr8()' style='width:20px; height:20px; border:thin;' title='Select Client To' />
        </label></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></td>
	</tr>
    <tr height='15px'>
		<td></td><td></td><td><span class='style8'>Salesman</span></td><td colspan='4' bgcolor='#F5F5F5'>
		<input name='clientsalesman' type='text' id='clientsalesman' size = '15' $disabled />
		<input name='clientsalesmanname' type='text' id='clientsalesmanname' size = '30' $disabled />
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Ledger To ' 
             onClick='showlistsalesman(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>   ";

echo"</td>
    </tr>
    <tr height='15px'>
      <td colspan='2' rowspan='2' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
	if ($FI_SalesOrder == 1){  
        if ($_POST['transaction']=="SO" )
            echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SO' checked />";
        else	
		    echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SO' />";
			
		echo"      Sales Order <br />";
	}
if (($module_delivery == 0 && $FI_Delivery == 1) || ($module_delivery == 1 && $FI_Sales == 1)){
	    if ($_POST['transaction']=="SI" )
           echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SI' checked />";
		else	
		   echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SI' />";
				
echo"      Sales  ";
}
if (($module_delivery == 0 && $FI_ReturnDelivery == 1) || ($module_delivery == 1 && $FI_ReturnSales == 1)){
	    if ($_POST['transaction']=="SR" )
           echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SR' checked />";
		else	
		   echo "<input name='transaction' onclick='enableSalesman();' type='radio' value='SR' />";
				
echo"      Return Sales ";
}
echo "  <br /> ";
if ((($module_delivery == 0 && $FI_Delivery == 1) || ($module_delivery == 1 && $FI_Sales == 1)) && (($module_delivery == 0 && $FI_ReturnDelivery == 1) || ($module_delivery == 1 && $FI_ReturnSales == 1))){
	echo "  <input name='salesboth' type='checkbox' value='both3' ";
	    echo isset($_POST['salesboth'])?"checked":'';  echo"/>";
	echo"  Both ";
}
echo "</span></td>";
if($fromproject == '') { $fromproject=$defaultproject;	$fromprojectname = $defaultprojname;}
echo " <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Project Code/Description </span></td>
      <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>
        <label>
        <input name='grpproject' type='checkbox' id='grpproject' value='grpproject' ";
		
		 echo isset($_POST['grpproject'])?"checked":'';  echo"/>";
echo"       
      Enable Group by project
      
      </span></td>
	  <td colspan='2' bgcolor='#F5F5F5'>&nbsp;</td>
    </tr>
	<tr height='15px'>
	   <td align='right' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>
	   <td colspan='4' bgcolor='#F5F5F5'>";
echo "<input type='text' name='fromproject' id='fromproject' value='$fromproject' style='width:130px;' maxlength='20'  />";	   
echo " <input type='text' name='fromprojectname' id='fromprojectname' value='$fromprojectname' style='width:245px;' maxlength='20'  />";	   
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);\"  />";
		echo"</td>";
echo"	<td colspan='2' bgcolor='#F5F5F5'>&nbsp;</td>
	</tr>
    <tr height='45px'>
      <td colspan='2' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
	  if ($FI_Adjustment == 1){
        if ($_POST['transaction']=="AD" )
           echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='AD' checked />";
		else	
		   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='AD' />";
				
echo" Adjustment<br /> 
      <input name='AdjustIN' type='checkbox' id='AdjustIN' value='1' ";
	   echo isset($_POST['AdjustIN'])?"checked":'';  echo"/>";
echo" IN &nbsp;
      <input name='AdjustOUT' type='checkbox' id='AdjustOUT' value='1' ";
	  echo isset($_POST['AdjustOUT'])?"checked":'';  echo"/>";
echo" OUT ";
	  }
echo "  </span></td>
      <td colspan='2' bgcolor='#F5F5F5' valign='top'>
	   <span class='style8'><label><input name='detail' type='checkbox' id='detail' value='detail'  ";
	   echo isset($_POST['detail'])?"checked":'';  echo"/>";
echo"      Show Detail </label></span><br>
           <span class='style8'><input type='checkbox' name='chck_show_reason' onclick='chkShowReason()'> Show Reason</span>
		   <input type='hidden' name='show_reason' value='0'>
	   <br>
	   <span class='style8'><label><input name='pricettc' type='checkbox' id='pricettc' value='1'  ";
	   if($Salesttc==1) echo "checked"; else echo '';  echo"/>";
echo"      Sales TTC ";


echo"<br><input type='checkbox' name='chksepareteinvoice' id='chksepareteinvoice' >Separate Invoice<br>
		(nb: will work for sales. other checkboxes will be ignored)<br> 
		<input type='checkbox' name='chkDetailPrjctCost' id='chkDetailPrjctCost' >Detail by Project/Costcenter<br>";
echo "<input type='checkbox' name='showProjCostName' id='showProjCostName' value='0'>Show Project/Costcenter Name";
echo "</label></span>";

echo " </td>
	  
	  <td colspan='3' bgcolor='#F5F5F5'>&nbsp; </td>
      <td colspan='2' bgcolor='#F5F5F5'>&nbsp;</td>
    </tr>
    <tr>
	  <td colspan='2' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
	  if ($FI_Transfer == 1){
        if ($_POST['transaction']=="TR" )
           echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='TR' checked />";
		else	
		   echo "<input name='transaction' onclick='disableSalesman();' type='radio' value='TR' />";
				
      echo" Transfer <br />";
	  }
	  echo "<td colspan='5' bgcolor='#F5F5F5'>&nbsp;</td>
		   <td colspan='2' bgcolor='#F5F5F5'>&nbsp;</td>
		</tr> ";
	
	echo"   </table></td></tr>"; 
	
	echo" <tr>";
	echo"   <td colspan='10' align='left'  bgcolor='#F5F5F5' style='padding-left: 15px;'><span class='style8'>Selected Options</span></td>";
	echo" </tr>";
	echo "<tr>";
	echo"   <td colspan='10' bgcolor='#F5F5F5' ><span class='style8'>";
	echo " <input type='hidden' name='delIds' id='delIds' value='$delIds'>";
	/// fady
	echo"   	<input type='hidden' name='fromitem' id='fromitem' style='width:120px' value='".$fromitem."' />
			<input type='hidden' name='toitem' id='toitem' style='width:120px' value='".$toitem."' />
			<input type='hidden' name='fromsupplier' id='fromsupplier' style='width:120px' value='".$fromsupplier."' />
			<input type='hidden' name='tosupplier' id='tosupplier' style='width:120px' value='".$tosupplier."' />
			<input type='hidden' name='fromsupplier1' id='fromsupplier1' style='width:120px' value='".$fromsupplier1."' />
			<input type='hidden' name='tosupplier1' id='tosupplier1' style='width:120px' value='".$tosupplier1."' />
			<input type='hidden' name='fromsalesman' id='fromsalesman' style='width:120px' value='".$fromsalesman."' />
			<input type='hidden' name='tosalesman' id='tosalesman' style='width:120px' value='".$tosalesman."' />
			<input type='hidden' name='fromgroup' id='fromgroup' style='width:120px' value='".$fromgroup."' />
			<input type='hidden' name='togroup' id='togroup' style='width:120px' value='".$togroup."' />
			<input type='hidden' name='fromsubgroup' id='fromsubgroup' style='width:120px' value='".$fromsubgroup."' />
			<input type='hidden' name='tosubgroup' id='tosubgroup' style='width:120px' value='".$tosubgroup."' />
			<input type='hidden' name='fromproject' id='fromproject' style='width:120px' value='".$fromproject."' />
			<input type='hidden' name='fromcostcent' id='fromcostcent' style='width:120px' value='".$fromcostcent."' />
			<input type='hidden' name='fromwarehouse' id='fromwarehouse' style='width:120px' value='".$fromwarehouse."' />
			<input type='hidden' name='fromarea' id='fromarea' style='width:120px' value='".$fromarea."' />
			<input type='hidden' name='cltrating' id='cltrating' style='width:120px' value='".$cltrating."' />
			<input type='hidden' name='subproj' id='subproj' style='width:120px' value='".$subproj."' />
			<input type='hidden' name='subcostcent' id='subcostcent' style='width:120px' value='".$subcostcent."' />
			<input type='hidden' name='fromcategory' id='fromcategory' style='width:120px' value='".$fromcategory."' />
			<input type='hidden' name='tocategory' id='tocategory' style='width:120px' value='".$tocategory."' />";
	
	
	
	
	
	///end 
	echo"  	<textarea name='reportoptions' rows='6' cols='150' readonly >".htmlspecialchars(str_replace("<br>", "\n", $reportoptions), ENT_QUOTES)."</textarea>
			</span>
		</td>";
	echo "</tr>";
	
	
	
	
	
	
 echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>";  
 echo" </table>
 
</form>
</body>
</html>";

// <input name='submit' type='submit' id='submit' value='Search' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'  /> 

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

?>
