<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
	header("location:../index.php");
}

include("config.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

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

/*	
if ($ExporttoExcel==1)
	$ExporttoExcelStatus= 'button';
else
	$ExporttoExcelStatus= 'hidden';	*/
	
	

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

$printaccess=$Print;


//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter, ".
			 " ifNull(Module_Pack,0) As Module_Pack, ifNull(Module_Weight,0) as Module_Weight, ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ".
			 " ifNull(Module_Transportation,0) As Module_Transportation,IfNull(Module_RestrictProjectReport,0) As Module_RestrictProjectReport, ".
			 " IfNull(module_expiredate,0) As module_expiredate ".
             " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$query="select ifnull(ShowReportHeader,0) as ShowReportHeader from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' ";
$result=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result)){
	extract($rows);
}
if($ShowReportHeader=='')
	$ShowReportHeader=1;

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

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

if (empty($fromdate)) $fromdate = displayToday();
if (empty($todate))   $todate   = displayToday();

print <<< HERE
<!DOCTYPE>
<html>
<head>
<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 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" language="javascript">
<!--





function MoveLevel12(option) {
	var ob = document.form1.availgroupby;
	var leng = ob.options.length;
	
	var vSelectedOptionValue='';
	var vSelectedOptionName='';
	var vSelectedCount=0;
	
	if(ob.selectedIndex == -1) {
		alert('No selection is done.');
		return;
	}
	
	while (ob.selectedIndex != -1)
    {
        if (ob.selectedIndex != -1) {
			vSelectedCount = vSelectedCount + 1;
			vSelectedOptionName  = ob.options[ob.selectedIndex].text;
			vSelectedOptionValue = ob.options[ob.selectedIndex].value;
		}	
        ob.options[ob.selectedIndex].selected = false;
    }

	if (vSelectedCount == 1) {
		if (option == 1) {
			document.form1.groupbylevel1name.value  = vSelectedOptionName;
			document.form1.groupbylevel1value.value = vSelectedOptionValue;
		}	
		else {
			document.form1.groupbylevel2name.value  = vSelectedOptionName;
			document.form1.groupbylevel2value.value = vSelectedOptionValue;
		}	
	}	
	else
		alert ('Not allowed multi selection for Level 1 and 2');
		
	
}

function RemoveLevel12(option) {
	var x = document.form1;
	
	if (option == 1) {
		x.groupbylevel1name.value = '';
		x.groupbylevel1value.value = '';
	}	
	else {
		x.groupbylevel2name.value = '';
		x.groupbylevel2value.value = '';
	}	
}

function MoveLevel3() {
	var ob = document.form1.availgroupby;
	var leng = ob.options.length;
	var TargetElement = document.form1.assigngroupby.options;
	
	var vExists = 0;
	
	if(ob.selectedIndex == -1) {
		alert('No selection is done.');
		return;
	}
	
	if(TargetElement[0] != null) {
		if (TargetElement[0].value=='') 
			TargetElement[0] = null;
	}	

		
	while (ob.selectedIndex != -1)
    {  
        if (ob.selectedIndex != -1) {
		
			vExists = 0;
			for(i=0; i < TargetElement.length; i++) {
				if (TargetElement[i].value == ob.options[ob.selectedIndex].value)
					vExists = 1;
			}
			
			if (vExists == 0)
				TargetElement[TargetElement.length] = new Option(ob.options[ob.selectedIndex].text, ob.options[ob.selectedIndex].value);
		}	  

		ob.options[ob.selectedIndex].selected = false;
    }

	
}

function RemoveLevel3() {
	var ob = document.form1.assigngroupby;
	var leng = ob.options.length;
	
	if(ob.selectedIndex == -1) {
		alert('No selection is done.');
		return;
	}
	
	while (ob.selectedIndex != -1)
    {  
        if (ob.selectedIndex != -1) 
			  ob.options[ob.selectedIndex] = null;
    }
	
}



function printPrev(printaccess)
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
  
	for (var i=0; i < document.form1.masterby.length; i++)
	{
		if (document.form1.masterby[i].checked)
		{
			var varmasterby = document.form1.masterby[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.prfmarby.length; i++)
	{
		if (document.form1.prfmarby[i].checked)
		{
			var varprfmarby = document.form1.prfmarby[i].value;
		}
	}
  
	for (var i=0; i < document.form1.zeroprint.length; i++)
	{
		if (document.form1.zeroprint[i].checked)
		{
			var varzeroprint = document.form1.zeroprint[i].value;
		}
	}
 
 for (var i=0; i < document.form1.vatprint.length; i++)
	{
		if (document.form1.vatprint[i].checked)
		{
			var varvatprint = document.form1.vatprint[i].value;
		}
	}
  
	for (var i=0; i < document.form1.promprint.length; i++)
	{
		if (document.form1.promprint[i].checked)
		{
			var varpromprint = document.form1.promprint[i].value;
		}
	}
	
	for (var i=0; i < document.form1.sellprice.length; i++)
	{
		if (document.form1.sellprice[i].checked)
		{
			var varsellprice = document.form1.sellprice[i].value;
		}
	}
	
	for (var i=0; i < document.form1.activeclt.length; i++)
	{
		if (document.form1.activeclt[i].checked)
		{
			var varactiveclt = document.form1.activeclt[i].value;
		}
	}
	
	for (var i=0; i < document.form1.activeitem.length; i++)
	{
		if (document.form1.activeitem[i].checked)
		{
			var varactiveitem = document.form1.activeitem[i].value;
		}
	}
	for (var i=0; i < document.form1.activehist.length; i++)
	{
		if (document.form1.activehist[i].checked)
		{
			var varactivehist = document.form1.activehist[i].value;
		}
	}
	
	
	//Getting Group By Levels 1 and 3
	vargroupby1   = document.form1.groupbylevel1value.value;
	vargroupby2   = document.form1.groupbylevel2value.value;
  
	//Getting Assigngroupby Values for level 3
	var ob = document.form1.assigngroupby;
	var vargroupby3 = '';
	for (var i = 0; i < ob.options.length; i++) {
		if (vargroupby3.length > 0)
			vargroupby3 += ",";
			
		vargroupby3 += ob.options[i].value;
	}
  
	// If No Group By Option Selected
	if (vargroupby3 == '') vargroupby3 = 1;

	 
	varprtcost = 0;
	if (document.form1.prtcost.checked) 
		varprtcost = 1;	 


	varprttransp = 0;
	if (document.form1.prtTransp) 
	if (document.form1.prtTransp.checked) 
		varprttransp = 1;	 

	varupdmeancost = 0;
	if (document.form1.updmeancost.checked) 
		varupdmeancost = 1;	

	varprtqtyexist = 0;
	if (document.form1.prtqtyexist.checked) 
		varprtqtyexist = 1;	 
	
	varprtdisc = 0;
	if (document.form1.prtdisc.checked) 
		varprtdisc = 1;	 	
	
	varprtdt = 0;
	if (document.form1.prtdt.checked)
		varprtdt = 1;		
	
	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varprtdt = 1;
	
	varprtsubdt = 0;
	if (document.form1.prtsubdt.checked)
		varprtsubdt = 1;			
	
	varpackitem = 0;
	if(document.getElementById('packitem')){
		if (document.form1.packitem.checked)
			varpackitem = 1;
	}
	
	varpricettc = 0;
	if(document.getElementById('pricettc')){
		if (document.form1.pricettc.checked)
			varpricettc = 1;
	}
	
	varoption = 1;
	if (document.form1.option.checked)
		varoption = 2;
		
	varsalesbywarehouse = 0;
	if (document.form1.salesbywarehouse.checked)
		varsalesbywarehouse = 1;
	varshowgroup = 0;
	if (document.form1.showgroup.checked)
		varshowgroup = 1;	
	varshowsubgroup = 0;
	if (document.form1.showsubgroup.checked)
		varshowsubgroup = 1;
	varshowcategory = 0;
	if (document.form1.showcategory.checked)
		varshowcategory = 1;

	varshowweight = 0;
	if (document.getElementById('showweight')) {
		if (document.form1.showweight.checked)
			varshowweight = 1;	
	}
		
	varcltrebate = 0;
	if (document.form1.cltrebate.checked)
		varcltrebate = 1;
		
	vsaleshist = 0;
	if (document.form1.saleshist.checked)
		vsaleshist = 1;
		
	varshowrebatedt = 0;
	if (document.form1.showrebatedt.checked)
		varshowrebatedt = 1;
		
	varshowrebatesubdt = 0;
	if (document.form1.showrebatesubdt.checked)
		varshowrebatesubdt = 1;
		
	varshowsales = 0;
	if (document.form1.showsales.checked)
		varshowsales = 1;
	varshowretsales = 0;
	if (document.form1.showretsales.checked)
		varshowretsales = 1;
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked) varshowunit2qty = 1;	
	}
	
	varprtheader = 0;
	if (document.form1.prtheader.checked)    varprtheader = 1;

	varprtamt = 0;
	if (document.form1.prtamt.checked) 	  varprtamt = 1;
	varprtvat = 0;
	if (document.form1.prtvat.checked) 	  varprtvat = 1;
	varprtamtvat = 0;
	if (document.form1.prtamtvat.checked) varprtamtvat = 1;
	varshowsellprice = 0;
	if (document.form1.showsellprice.checked) varshowsellprice = 1;
	
	 if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
	}
	
	var showwht = 0;
	if(document.getElementById("showwht").checked)
		var showwht = 1;
	
	var cashtype = '';
	if(document.getElementById('cashtype'))
		cashtype = document.getElementById('cashtype').value;
	
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = document.form1.fromitem.value;
	vartoitem     = document.form1.toitem.value;
	varfromgrp    = document.form1.fromgroup.value;
	vartogrp      = document.form1.togroup.value;
	varfromsubgrp = document.form1.fromsubgroup.value;
	vartosubgrp   = document.form1.tosubgroup.value;
	varfromprj    = document.form1.fromproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	varfromclient    = document.form1.fromclient.value;
	vartoclient      = document.form1.toclient.value;
	varfromsupplier  = document.form1.fromsupplier.value;
	vartosupplier    = document.form1.tosupplier.value;
	
	varfromsupplier1  = document.form1.fromsupplier1.value;
	vartosupplier1    = document.form1.tosupplier1.value;

	varfromsalesman  = document.form1.fromsalesman.value;
	vartosalesman    = document.form1.tosalesman.value;
	varfromwarehouse = document.form1.fromwarehouse.value;
	varfromarea      = document.form1.fromarea.value;
	varsubproj       = document.form1.subproj.value;
	varsubcostcent   = document.form1.subcostcent.value;
	varcltrating	 = document.form1.cltrating.value;
	varfromcat    = document.form1.fromcategory.value;
	vartocat      = document.form1.tocategory.value;
  
	varsubproj       = varsubproj.replace(/%/g,'-');
	varsubcostcent   = varsubcostcent.replace(/%/g,'-');
  
	var showDBN = 0;
	if (document.getElementById('showDBN').checked)
		showDBN = 1;
	
	if (varsalesbywarehouse == 1) {
		str =   'Rep_ClientSalesByWarehouse.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient
			   +'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&zeroprint='+varzeroprint+'&vatprint='+varvatprint+'&promprint='+varpromprint
			   +'&showgroup='+varshowgroup+'&showsubgroup='+varshowsubgroup+'&showcategory='+varshowcategory+'&prtcost='+varprtcost+'&PrtTransp='+varprttransp
			   +'&pricettc='+varpricettc+'&subproj='+varsubproj+'&subcostcent='+varsubcostcent+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&activeclt='+varactiveclt+'&activeitem='+varactiveitem;
	} 
	else if (varcltrebate == 1) {
		str =   'Rep_ClientRebate.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst+'&PrtTransp='+varprttransp
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&showrebatedt='+varshowrebatedt
			   +'&showrebatesubdt='+varshowrebatesubdt+'&activeclt='+varactiveclt+'&activeitem='+varactiveitem+'&prtheader='+varprtheader;
	}
	else if (vsaleshist == 1) {
		
	
		str =   'Rep_Saleshistory.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst+'&PrtTransp='+varprttransp
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&showrebatedt='+varshowrebatedt
			   +'&showrebatesubdt='+varshowrebatesubdt+'&activeclt='+varactiveclt+'&activeitem='+varactivehist+'&prtheader='+varprtheader;
	}
	else {
		str =   'Rep_ClientSales.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&zeroprint='+varzeroprint+'&vatprint='+varvatprint+'&promprint='+varpromprint
			   +'&option='+varoption+'&prfmarby='+varprfmarby+'&groupby1='+vargroupby1+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3
			   +'&masterby='+varmasterby+'&prtcost='+varprtcost+'&updmeancost='+varupdmeancost+'&prtdt='+varprtdt+'&prtsubdt='+varprtsubdt+'&PrtTransp='+varprttransp
			   +'&packitem='+varpackitem+'&pricettc='+varpricettc+'&prtqtyexist='+varprtqtyexist+'&prtdisc='+varprtdisc+'&subproj='+varsubproj
			   +'&subcostcent='+varsubcostcent+'&cltrating='+varcltrating+'&showweight='+varshowweight+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&showsales='+varshowsales+'&showretsales='+varshowretsales+'&prtamt='+varprtamt+'&prtvat='+varprtvat+'&prtamtvat='+varprtamtvat
			   +'&showsellprice='+varshowsellprice+'&sellprice='+varsellprice+'&showunit2qty='+varshowunit2qty+'&activeclt='+varactiveclt+'&activeitem='+varactiveitem+'&prtheader='+varprtheader
			   +'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk+'&showwht='+showwht+'&cashtype='+cashtype+'&showDBN='+showDBN;
	}
	
	if (printaccess==1)
		window.open(str);
	else
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
 
}

function exportExcel()
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
	for (var i=0; i < document.form1.masterby.length; i++)
	{
		if (document.form1.masterby[i].checked)
		{
			var varmasterby = document.form1.masterby[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.prfmarby.length; i++)
	{
		if (document.form1.prfmarby[i].checked)
		{
			var varprfmarby = document.form1.prfmarby[i].value;
		}
	}
  
	for (var i=0; i < document.form1.zeroprint.length; i++)
	{
		if (document.form1.zeroprint[i].checked)
		{
			var varzeroprint = document.form1.zeroprint[i].value;
		}
	}
  
	for (var i=0; i < document.form1.promprint.length; i++)
	{
		if (document.form1.promprint[i].checked)
		{
			var varpromprint = document.form1.promprint[i].value;
		}
	}
	
	for (var i=0; i < document.form1.sellprice.length; i++)
	{
		if (document.form1.sellprice[i].checked)
		{
			var varsellprice = document.form1.sellprice[i].value;
		}
	}
	
	for (var i=0; i < document.form1.activeclt.length; i++)
	{
		if (document.form1.activeclt[i].checked)
		{
			var varactiveclt = document.form1.activeclt[i].value;
		}
	}
	
	for (var i=0; i < document.form1.activeitem.length; i++)
	{
		if (document.form1.activeitem[i].checked)
		{
			var varactiveitem = document.form1.activeitem[i].value;
		}
	}
  for (var i=0; i < document.form1.vatprint.length; i++)
	{
		if (document.form1.vatprint[i].checked)
		{
			var varvatprint = document.form1.vatprint[i].value;
		}
	}
 	for (var i=0; i < document.form1.activehist.length; i++)
	{
		if (document.form1.activehist[i].checked)
		{
			var varactivehist = document.form1.activehist[i].value;
		}
	}
	
  	varprttransp = 0;
	if (document.form1.prtTransp) 
	if (document.form1.prtTransp.checked) 
		varprttransp = 1;	 
		
	//Getting Group By Levels 1 and 2
	vargroupby1   = document.form1.groupbylevel1value.value;
	vargroupby2   = document.form1.groupbylevel2value.value;
  
	//Getting Assigngroupby Values for level 3
	var ob = document.form1.assigngroupby;
	var vargroupby3 = '';
	for (var i = 0; i < ob.options.length; i++) {
		if (vargroupby3.length > 0)
			vargroupby3 += ",";
			
		vargroupby3 += ob.options[i].value;
	}
  
	// If No Group By Option Selected
	if (vargroupby3 == '') vargroupby3 = 1;

	vsaleshist = 0;
	if (document.form1.saleshist.checked)
		vsaleshist = 1;
		
	varprtcost = 0;
	if (document.form1.prtcost.checked) 
		varprtcost = 1;	

	varupdmeancost = 0;
	if (document.form1.updmeancost.checked) 
		varupdmeancost = 1;	

	varprtqtyexist = 0;
	if (document.form1.prtqtyexist.checked) 
		varprtqtyexist = 1;	

	varprtdisc = 0;
	if (document.form1.prtdisc.checked) 
		varprtdisc = 1; 	 
	
	varprtdt = 0;
	if (document.form1.prtdt.checked)
		varprtdt = 1;	

	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varprtdt = 1;	
	
	varprtsubdt = 0;
	if (document.form1.prtsubdt.checked)
		varprtsubdt = 1;			
	
	varpackitem = 0;
	if(document.getElementById('packitem')){
		if (document.form1.packitem.checked)
			varpackitem = 1;
	}
	
	varpricettc = 0;
	if(document.getElementById('pricettc')){
		if (document.form1.pricettc.checked)
			varpricettc = 1;	
	}
	
	varoption = 1;
	if (document.form1.option.checked)
		varoption = 2;
		
	varsalesbywarehouse = 0;
	if (document.form1.salesbywarehouse.checked)
		varsalesbywarehouse = 1;
	varshowgroup = 0;
	if (document.form1.showgroup.checked)
		varshowgroup = 1;	
	varshowsubgroup = 0;
	if (document.form1.showsubgroup.checked)
		varshowsubgroup = 1;
	varshowcategory = 0;
	if (document.form1.showcategory.checked)
		varshowcategory = 1;	

	varshowweight = 0;
	if (document.getElementById('showweight')) {
		if (document.form1.showweight.checked)
			varshowweight = 1;	
	}
		
	varcltrebate = 0;
	if (document.form1.cltrebate.checked)
		varcltrebate = 1;
		
	varshowrebatedt = 0;
	if (document.form1.showrebatedt.checked)
		varshowrebatedt = 1;
		
	varshowrebatesubdt = 0;
	if (document.form1.showrebatesubdt.checked)
		varshowrebatesubdt = 1;
		
	varshowsales = 0;
	if (document.form1.showsales.checked)
		varshowsales = 1;
	varshowretsales = 0;
	if (document.form1.showretsales.checked)
		varshowretsales = 1;
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked) varshowunit2qty = 1;	
	}
	
	varprtamt = 0;
	if (document.form1.prtamt.checked) 	  varprtamt = 1;
	varprtvat = 0;
	if (document.form1.prtvat.checked) 	  varprtvat = 1;
	varprtamtvat = 0;
	if (document.form1.prtamtvat.checked) varprtamtvat = 1;
	varshowsellprice = 0;
	if (document.form1.showsellprice.checked) varshowsellprice = 1;

	
	 if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
	}
	
	var showwht = 0;
	if(document.getElementById("showwht").checked)
		var showwht = 1;
	
	var cashtype = '';
	if(document.getElementById('cashtype'))
		cashtype = document.getElementById('cashtype').value;
	
	var showDBN = 0;
	if (document.getElementById('showDBN').checked)
		showDBN = 1;
	
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = document.form1.fromitem.value;
	vartoitem     = document.form1.toitem.value;
	varfromgrp    = document.form1.fromgroup.value;
	vartogrp      = document.form1.togroup.value;
	varfromsubgrp = document.form1.fromsubgroup.value;
	vartosubgrp   = document.form1.tosubgroup.value;
	varfromprj    = document.form1.fromproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	varfromclient    = document.form1.fromclient.value;
	vartoclient      = document.form1.toclient.value;
	varfromsupplier  = document.form1.fromsupplier.value;
	vartosupplier    = document.form1.tosupplier.value;
	varfromsupplier1  = document.form1.fromsupplier1.value;
	vartosupplier1    = document.form1.tosupplier1.value;
	varfromsalesman  = document.form1.fromsalesman.value;
	vartosalesman    = document.form1.tosalesman.value;
	varfromwarehouse = document.form1.fromwarehouse.value;
	varfromarea      = document.form1.fromarea.value;
	varsubproj       = document.form1.subproj.value;
	varsubcostcent   = document.form1.subcostcent.value;
	varcltrating	 = document.form1.cltrating.value; 
	varfromcat    = document.form1.fromcategory.value;
	vartocat      = document.form1.tocategory.value;
  
	varsubproj       = varsubproj.replace(/%/g,'-');
	varsubcostcent   = varsubcostcent.replace(/%/g,'-');
	
	if (vsaleshist == 1) {
		
	
		str =   'Rep_Saleshistory.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst+'&PrtTransp='+varprttransp
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&showrebatedt='+varshowrebatedt
			   +'&showrebatesubdt='+varshowrebatesubdt+'&activeclt='+varactiveclt+'&activeitem='+varactivehist+'&prtexcel=1';
	} else
	if (varsalesbywarehouse == 1) {
		str =   'Exp_ClientSalesByWarehouse.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&PrtTransp='+varprttransp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&zeroprint='+varzeroprint+'&vatprint='+varvatprint+'&promprint='+varpromprint
			   +'&showgroup='+varshowgroup+'&showsubgroup='+varshowsubgroup+'&showcategory='+varshowcategory+'&prtcost='+varprtcost
			   +'&pricettc='+varpricettc+'&subproj='+varsubproj+'&subcostcent='+varsubcostcent+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&activeclt='+varactiveclt+'&activeitem='+varactiveitem;
	} 
	else if (varcltrebate == 1) {
		str =   'Exp_ClientRebate.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&PrtTransp='+varprttransp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&showrebatedt='+varshowrebatedt
			   +'&showrebatesubdt='+varshowrebatesubdt+'&activeclt='+varactiveclt+'&activeitem='+varactiveitem;
	}
	else {
    
		str =   'Exp_ClientSales.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromclient='+varfromclient+'&toclient='+vartoclient+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
			   +'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&PrtTransp='+varprttransp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromproject='+varfromprj+'&fromcostcent='+varfromcst
			   +'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&zeroprint='+varzeroprint+'&vatprint='+varvatprint+'&promprint='+varpromprint
			   +'&option='+varoption+'&prfmarby='+varprfmarby+'&groupby1='+vargroupby1+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3
			   +'&masterby='+varmasterby+'&prtcost='+varprtcost+'&updmeancost='+varupdmeancost+'&prtdt='+varprtdt+'&prtsubdt='+varprtsubdt
			   +'&packitem='+varpackitem+'&pricettc='+varpricettc+'&prtqtyexist='+varprtqtyexist+'&prtdisc='+varprtdisc+'&subproj='+varsubproj
			   +'&subcostcent='+varsubcostcent+'&cltrating='+varcltrating+'&showweight='+varshowweight+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&showsales='+varshowsales+'&showretsales='+varshowretsales+'&prtamt='+varprtamt+'&prtvat='+varprtvat+'&prtamtvat='+varprtamtvat
			   +'&showsellprice='+varshowsellprice+'&sellprice='+varsellprice+'&showunit2qty='+varshowunit2qty+'&activeclt='+varactiveclt+'&activeitem='+varactiveitem
			   +'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk+'&showwht='+showwht+'&cashtype='+cashtype+'&showDBN='+showDBN;
	}		   
  
	window.open(str);
  
}
function showlistitem(str){

	window.open('select_item.php?item='+str,'mywindow','width=900,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 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 CheckPrintCost() {
    var x= document.form1;
	if (x.prtcost.checked == true) {
	    
		for (var i=0; i < x.prfmarby.length; i++)
		{
			x.prfmarby[i].disabled = false;
		}
	}  
	else { 
	    
		for (var i=0; i < x.prfmarby.length; i++)
		{
			x.prfmarby[i].disabled = true;
		}
	}
}

function CheckPrintDetail() {
    var x= document.form1;
	if (x.prtdt.checked == true) {
	    x.prtsubdt.disabled = false;
		x.prtsubdt.checked  = true;
		x.option.disabled = false;
		x.option.checked  = false;
	}  
	else { 
	    x.prtsubdt.disabled = true;
		x.prtsubdt.checked  = false;
		x.option.disabled = true;
		x.option.checked  = false;
	}
}

function CheckShowRebateDetail() {
    var x= document.form1;
	if (x.showrebatedt.checked == true) {
	    x.showrebatesubdt.disabled = false;
	}  
	else { 
	    x.showrebatesubdt.disabled = true;
		x.showrebatesubdt.checked  = false;
	}
}

function CheckGroupBy() {
    var x= document.form1;
    for (var i=0; i < x.groupby.length; i++)
	{ 
		if (x.groupby[i].checked) {
			if (x.groupby[i].value == 1)
			{
				x.prtdt.checked  = true;
				x.prtdt.disabled = true;
			} else 
			{
				x.prtdt.checked  = true;
				x.prtdt.disabled = false;
			}
		}   
		
	}

}

function LoadOptions() {
	x = document.form1;
    win = window.open('List_ReportsOptionsTemplates.php?formname=clientsales', 'List_ReportsOptionsTemplates', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1040,height=450,top=100,left=0');		
	win.creator = self;
	win.focus();		

}

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

}



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

function AddOption(selectId, text, value) {
	var ob = document.form1.assigngroupby;
	var i = ob.options.length;
	var o = new Option(text,value);
	ob.options[i] = o;
	
}

function RemoveOption(selectId) {
	var ob = document.form1.assigngroupby;
	
	//Empty Assigngroupby Values
	for (var k=0; k < ob.options.length; k++) {
		ob.options[k].selected = true;
	}
	
	while (ob.selectedIndex != -1)
	{  
		if (ob.selectedIndex != -1) 
		  ob.options[ob.selectedIndex] = null;
	}
	

}


-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Client Sales</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=''>
		<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'>Client Sales</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='button' id='btnClear' name='btnClear' onclick='ClearPage();return false;' 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" <button type='button' id='btnLoadOptions' name='btnLoadOptions' onClick=\"LoadOptions()\"; title='Load Template'><span><span>Load Options</span></span></button>";  
	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%">';


//Load Reports Options Template
if ($templateid != '') {
	$querytemplate = " Select Groupby_Level1Value, Groupby_Level2Value, Groupby_Level3Value, Groupby_Level1Name, Groupby_Level2Name, Groupby_Level3Name, ".
					 " JournalType_alltypes, JournalType_exclude, JournalType_types,  FromLedger_Number, ToLedger_Number, FromClient_Code, ToClient_Code, ".
					 " FromSupplier_Code, ToSupplier_Code, FromSalesman_Code, ToSalesman_Code, FromItem_Code, ToItem_Code, FromWarehouse_Code, ToWarehouse_Code, ".
					 " FromGroup_Code, ToGroup_Code, FromSubgroup_Code, ToSubgroup_Code, FromProject_Code, ToProject_Code, FromMasterProject_Code, ToMasterProject_Code, ".
					 " FromCostcent_Code, ToCostcent_Code, FromMasterCostcent_Code, ToMasterCostcent_Code, FromArea_Code, ToArea_Code  ".
					 " From ReportsOptions_Templates ".
					 " Where ReportsOptions_Templates.User_Account = '".$_SESSION['useraccount']."' ".
					 " And   Template_Id = '".$templateid."'";
	//echo $querytemplate;			   
	$resulttemplate=mysql_query($querytemplate,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resulttemplate)){
	  extract($rows);
	}			   
	
	$groupbylevel1value = $Groupby_Level1Value;
	$groupbylevel2value = $Groupby_Level2Value;
	$groupbylevel3value = $Groupby_Level3Value;
	$groupbylevel1name  = $Groupby_Level1Name;
	$groupbylevel2name  = $Groupby_Level2Name;
	$groupbylevel3name  = $Groupby_Level3Name;
	
	$fromitem     = $FromItem_Code;
	$toitem       = $ToItem_Code;
	$fromgroup    = $FromGroup_Code;
	$togroup      = $ToGroup_Code;
	$fromsubgroup = $FromSubgroup_Code;
	$tosubgroup   = $ToSubgroup_Code;
	$fromproject  = $FromProject_Code;
	$fromcostcent = $FromCostcent_Code;
	
	$fromclient    = $FromClient_Code;
	$toclient      = $ToClient_Code;
	$fromsupplier  = $FromSupplier_Code;
	$tosupplier    = $ToSupplier_Code;
	$fromsalesman  = $FromSalesman_Code;
	$tosalesman    = $ToSalesman_Code;
	$fromwarehouse = $FromWarehouse_Code;
	$fromarea      = $FromArea_Code;

	//$reportoptions = "Group by: ".$Groupby_Level1Name.",".$Groupby_Level2Name.",".$Groupby_Level3Name ."\n" . "Filter by: \n";
	$reportoptions = "Group by:  ";
	if ($Groupby_Level1Name != '' ) $reportoptions = $reportoptions . $Groupby_Level1Name.", ";
	if ($Groupby_Level2Name != '' ) $reportoptions = $reportoptions . $Groupby_Level2Name.", ";
	if ($Groupby_Level3Name != '' ) $reportoptions = $reportoptions . $Groupby_Level3Name.", ";
	$reportoptions = substr($reportoptions, 0, strlen($reportoptions)-2) . "\n" . "Filter by: \n";
	
	if ($FromItem_Code != '')      $reportoptions .= "-> Item From: ". $FromItem_Code . "  To: ". $ToItem_Code ."\n";
	if ($FromGroup_Code != '')     $reportoptions .= "-> Group From: ". $FromGroup_Code . "  To: ". $ToGroup_Code ."\n";
	if ($FromSubgroup_Code != '')  $reportoptions .= "-> SubGroup From: ". $FromSubgroup_Code . "  To: ". $ToSubgroup_Code ."\n";
	if ($FromProject_Code != '')   $reportoptions .= "-> Project From: ". $FromProject_Code . "\n";
	if ($FromCostcent_Code != '')  $reportoptions .= "-> Costcent From: ". $FromCostcent_Code . "\n";
	if ($FromClient_Code != '')    $reportoptions .= "-> Client From: ". $FromClient_Code . "  To: ". $ToClient_Code ."\n";
	if ($FromSupplier_Code != '')  $reportoptions .= "-> Supplier From: ". $FromSupplier_Code . "  To: ". $ToSupplier_Code ."\n";
	if ($FromSalesman_Code != '')  $reportoptions .= "-> Salesman From: ". $FromSalesman_Code . "  To: ". $ToSalesman_Code ."\n";
	if ($FromWarehouse_Code != '') $reportoptions .= "-> Warehouse From: ". $FromWarehouse_Code . "\n";
	if ($FromArea_Code != '') 	   $reportoptions .= "-> Area From: ". $FromArea_Code . "\n";
	
	
}
echo" <tr>";	  
echo"   <td width='13%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td> ";
if($module_expiredate == 1){
echo"   <td width='15%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"     <label><input name='edatechk' id='edatechk' type='checkbox' > Expire Date </label> ";
echo"</span></td> ";
}
echo"   <td width='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Master By </span></td>";
echo"   <td width='45%' colspan='2' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Options </span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='3%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='10%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate'  id='fromdate' value='$fromdate' maxlength='10' size='6'>";
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>";
if($module_expiredate == 1){
	echo"   <td width='15%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span>";
	echo"   <span class='style8'>";
	echo"      <input type='text' name='fromedate' value='$fromedate' maxlength='10' size='6'>";
	echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.fromedate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
}
echo"   <td width='10%' rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='currency1'>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='10%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($masterby=="1" || $masterby=="")
           echo "<input name='masterby' type='radio' value='1' checked />";
		else	
		   echo "<input name='masterby' type='radio' value='1' />";
		echo "Client</label></span>";
echo"   <br><span class='style8'><label>";
		if ($masterby=="2")
           echo "<input name='masterby' type='radio' value='2' checked />";
		else	
		   echo "<input name='masterby' type='radio' value='2' />";
		echo "Item</label></span>";	

// 1 Commulative   2 Detail		
echo"   <div style='left:10px; top:3px; width:100px;'><span class='style8'><label>";
echo"      <input type='checkbox' name='option' id='option' value='1' />Detailed</label></span>";		
//echo"   </td>";


///echo"   <td width='15%' rowspan='2' valign='top' bgcolor='#F5F5F5'>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtdt' type='checkbox' id='prtdt' value='1' onClick='CheckPrintDetail();' checked />Print Detail</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtsubdt' type='checkbox' id='prtsubdt' value='1' checked />Print Subdetail</label></span>";		


if($Module_Transportation==1){
echo"   <br><span class='style8'><label>";
echo"      <input name='prtTransp' type='checkbox' id='prtTransp' value='1' checked />Print Transport</label></span>";		
}
echo"  </div> </td>";

		
echo"   <td width='48%' rowspan='5' valign='top' bgcolor='#F5F5F5'>";
echo"   <div id='main' style='position:relative; left:5px; top:5px; width:450px; height:90px;'>";
echo"   <div id='left' style='position:relative; top:5px; width:200px; float:left; '>";
echo"   <div style='position:relative; width:195px; height:15px; text-align:center;'><span class='style8' style='text-decoration:underline;'> Promotion </span></div>";
echo"   <span class='style8'><label>";
        if ($promprint=="1" )
           echo "<input name='promprint' type='radio' value='1' checked />";
		else	
		   echo "<input name='promprint' type='radio' value='1' />";
		echo "Promotion Only</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($promprint=="2")
           echo "<input name='promprint' type='radio' value='2' checked />";
		else	
		   echo "<input name='promprint' type='radio' value='2' />";
		echo "Without Promotion</label></span>";   		
echo"   <br><span class='style8'><label>";
        if ($promprint=="3" || $promprint=="" )
           echo "<input name='promprint' type='radio' value='3' checked />";
		else	
		   echo "<input name='promprint' type='radio' value='3' />";
		echo "All</label></span></div>";
echo"   <div id='right' style='position:absolute; left:5px; top:5px; width:200px; float:right; margin-left: 210px; '>";		
echo"   <div style='position:relative; width:195px; height:15px; text-align:center;'><span class='style8' style='text-decoration:underline;'> Price </span></div>";
echo"   <span class='style8'><label>";
        if ($zeroprint=="1" )
           echo "<input name='zeroprint' type='radio' value='1' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='1' />";
		echo "Zero Price Only</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($zeroprint=="2")
           echo "<input name='zeroprint' type='radio' value='2' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='2' />";
		echo "Without Zero Price</label></span>";   		
echo"   <br><span class='style8'><label>";
        if ($zeroprint=="3" || $zeroprint=="" )
           echo "<input name='zeroprint' type='radio' value='3' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='3' />";
		echo "All</label></span></div>";   				
		
echo"   <div id='right' style='position:absolute; left:170px; top:5px; width:200px; float:right; margin-left: 210px; '>";		
echo"   <div style='position:relative; width:95px; height:15px; text-align:center;'><span class='style8' style='text-decoration:underline;'> VAT </span></div>";
echo"   <span class='style8'><label>";
        if ($vatprint=="1" )
           echo "<input name='vatprint' type='radio' value='1' checked />";
		else	
		   echo "<input name='vatprint' type='radio' value='1' />";
		echo "Vatable Only</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($vatprint=="2")
           echo "<input name='vatprint' type='radio' value='2' checked />";
		else	
		   echo "<input name='vatprint' type='radio' value='2' />";
		echo "None Vatable Only</label></span>";   		
echo"   <br><span class='style8'><label>";
        if ($vatprint=="3" || $vatprint=="" )
           echo "<input name='vatprint' type='radio' value='3' checked />";
		else	
		   echo "<input name='vatprint' type='radio' value='3' />";
		echo "All Customers</label></span></div>";   				
		
echo" </div>";
echo "</td></tr>";

echo" <tr>";
echo"   <td width='3%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='10%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <input type='text' name='todate'  id='todate' value='$todate'  maxlength='10' size='6'>";
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>";
if($module_expiredate == 1){
echo"   <td width='15%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span>";
echo"   <span class='style8' style='padding-left:18px;'>";
echo"      <input type='text' name='toedate' value='$toedate'  maxlength='10' size='6'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.toedate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
}
echo" </tr>";

$querycashtype=" select CashType_Code, CashType_Description, CostCent_Code from cashtype where Journal_Type = 'DI'".
               " order by CashType_Description"; 
$resultcashtype=mysql_query($querycashtype,$connection) or die(mysql_error());
$numrow = mysql_num_rows($resultcashtype);
if($numrow >0){
	echo " <tr> <td align='left' colspan='3'><span class='style8'>Cash Type</span> &nbsp;";
	echo "<select name='cashtype' id='cashtype' style='width:100px;'>";
	echo "<option value ='' ".($cashtype == ''?'selected':'')." ></option>";
	while($row = mysql_fetch_row($resultcashtype)){
		echo "<option value='$row[0]' ".($delivery_cashType==$row[0]?'selected':'').">$row[1]</option>";
	}
	echo "</select></td>";
	echo "</tr>";
}

echo "<tr><td colspan='6' bgcolor='#F5F5F5'><span class='style8'>Periods: <select name='period' id='period' onchange=\"setdateperiods(this.value,'fromdate','todate')\" >
		<option value=0></option>
		<option value=1>Today</option>
		<option value=2>Week</option>
		<option value=3>This Month</option>
		<option value=4>1st Quarter</option>
		<option value=5>2nd Quarter</option>
		<option value=6>3rd Quarter</option>
		<option value=7>Last Quarter</option>
		<option value=8>This Year</option>
	</select></td></tr>";
	
	
echo" <tr>";
echo"   <td colspan='6' bgcolor='#F5F5F5'><table width=100%><col width=20%><col width=20%><col width=20%><col width=20%><col width=20%>";

echo "<tr><td colspan='2'>";
echo "<div style='width: 100%;height:auto;float: left;'><span class='style8'>";
echo"   <div id='main' style='position:relative; top:5px; width:450px; height:230px;float: left;'>";
echo"   <div id='left' style='position:relative; top:5px; width:200px; height:100px; float:left;'>";
echo"   <div style='position:relative; width:195px; height:15px; text-align:center; '><span class='style8' style='text-decoration:underline;'> Profit Margin By & Cost </span></div>";
echo"   <div style='position:relative; left:2px; top:5px; width:190px;'>";
echo"   <span class='style8'><label>";
		if ($prfmarby=="1" || $prfmarby=="")
           echo "<input name='prfmarby' type='radio' value='1' checked />";
		else	
		   echo "<input name='prfmarby' type='radio' value='1' />";
		echo "Selling Amount</label></span>";
echo"   <br><span class='style8'><label>";
		if ($prfmarby=="2")
           echo "<input name='prfmarby' type='radio' value='2' checked />";
		else	
		   echo "<input name='prfmarby' type='radio' value='2' />";
		echo "Cost Amount</label></span></div>";	

$ShowCostMode  = '';
$ShowCostCheck = 'checked';
if($FI_ShowCostPrice == 0)  {
	$ShowCostMode  = 'disabled';	
	$ShowCostCheck = 'unchecked';	
}
		
		
echo"   <div style='position:relative; left:2px; top:10px; width:190px;'>";		
echo"   <span class='style8'><label>";
echo"      <input name='prtcost' type='checkbox' id='prtcost' value='1' onClick='CheckPrintCost();' $ShowCostCheck  $ShowCostMode />Print Cost</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='updmeancost' type='checkbox' id='updmeancost' value='1' $ShowCostMode />Updated Mean Cost</label></span>";

echo"   <br><br><span class='style8'><label>";
echo"      <input name='showsellprice' type='checkbox' id='showsellprice' value='1' />Show Selling Price</label></span>";
echo"   <br><span class='style8'>&nbsp;&nbsp;";
echo"      <label><input type='radio' name='sellprice' value='1' checked />I</label>";
echo"      <label><input type='radio' name='sellprice' value='2' />II</label>";
echo"      <label><input type='radio' name='sellprice' value='3' />III</label>";
echo"      <label><input type='radio' name='sellprice' value='4' />IV</label>";
echo"      <br>&nbsp;&nbsp;";
echo"      <label><input type='radio' name='sellprice' value='5' />V</label>";
echo"      <label><input type='radio' name='sellprice' value='6' />VI</label></span>";
echo" </div>";		

echo"   <div id='right' style='position:absolute; left:5px; top:5px; width:200px; float:right; margin-left: 210px;'>";
echo"   <div style='position:relative; width:195px; height:15px; text-align:center;'><span class='style8' style='text-decoration:underline;'> Others </span></div>";
echo"   <div><span class='style8'><label>";

if($Module_Pack==1){
	echo"      <input name='packitem' type='checkbox' id='packitem' value='1' />Packed Item</label></span>";
}

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

if($Salesttc==1){
	echo"      <input name='pricettc' type='checkbox' id='pricettc' value='1' "; 
		   if($Salesttc==1) echo "checked"; else echo '';  
	echo"     />Sales TTC</label></span>";
}
echo"   <br><span class='style8'><label>";
echo"      <input name='prtqtyexist' type='checkbox' id='prtqtyexist' value='1' />Print Qty Exists</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtamt' type='checkbox' id='prtamt' value='1' checked />Print Sales Amount</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtvat' type='checkbox' id='prtvat' value='1' checked />Print VAT</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtamtvat' type='checkbox' id='prtamtvat' value='1' checked />Print Total Sales+VAT</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='prtdisc' type='checkbox' id='prtdisc' value='1' />Print Discount Amount</label></span>";

if ($Module_Weight == 1) {
	echo"   <br><span class='style8'><label>";
	echo"      <input name='showweight' type='checkbox' id='showweight' value='1' />Show Weight</label></span>";
}	
echo"   <br><span class='style8'><label>";
echo"      <input name='showsales' type='checkbox' id='showsales' value='1' checked />Show Sales</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='showretsales' type='checkbox' id='showretsales' value='1' checked />Show Return Sales</label></span>";
echo"   <br><span class='style8'><label>";
if($ShowReportHeader== 1 && $module_ReferenceByCostcenter== 1)
	echo"      <input name='prtheader' type='checkbox' id='prtheader' value='1' checked />";
else
if($ShowReportHeader== 0 && $module_ReferenceByCostcenter== 1)
	echo"      <input name='prtheader' type='checkbox' id='prtheader' value='1'  />";
else
if($module_ReferenceByCostcenter== 0)
	echo"      <input name='prtheader' type='checkbox' id='prtheader' value='1' checked />";
else
	echo"      <input name='prtheader' type='checkbox' id='prtheader' value='1'  />";
echo"      Show Report Header";
echo"      <br><input name='showDBN' type='checkbox' id='showDBN' value='0'  /> Show Credit/Debit Note";
echo "</label></span>";

if ($Module_DoubleUnit == 1) {
	echo"   <br><span class='style8'><label>";
	echo"      <input name='showunit2qty' type='checkbox' id='showunit2qty' value='1' />Show Unit2 Qty</label></span>";
}
echo" </div>";
echo "</div>";
echo" </div>";
echo" </td>";
echo "<td><div><span class='style8'>
		 <label><input type='checkbox' name='salesbywarehouse' id='salesbywarehouse' value='1' />Sales By Warehouse</label><br>
		<label><input type='checkbox' name='showgroup' id='showgroup' value='1' checked />Show Group</label><br>
		<label><input type='checkbox' name='showsubgroup' id='showsubgroup' value='1' checked />Show SubGroup</label><br>
		<label><input type='checkbox' name='showcategory' id='showcategory' value='1' checked />Show Category</label><br><br>
		<label><input type='checkbox' name='cltrebate' id='cltrebate' value='1' />Client Rebate Report</label><br>
		<label><input type='checkbox' name='showrebatedt' id='showrebatedt' value='1' onClick='CheckShowRebateDetail();' checked />Show Details</label><br>
		<label><input type='checkbox' name='showrebatesubdt' id='showrebatesubdt' value='1'  />Show Sub Details</label><br>
		<label><input type='checkbox' name='showwht' id='showwht' value='1'  />Show WHT Amounts</label>
		</span></div></td>";
echo "<td><div><span class='style8'>
		<label><input type='radio' name='activeclt' value='1' />Active Clients</label><br>
		<label><input type='radio' name='activeclt' value='2' />Inactive Clients</label><br>
		<label><input type='radio' name='activeclt' value='3' checked />Both</label><br><br>
		<label><input type='radio' name='activeitem' value='1' />Active Items</label><br>
		<label><input type='radio' name='activeitem' value='2' />Inactive Items</label><br>
		<label><input type='radio' name='activeitem' value='3' checked />Both</label>
		</span></div></td>";
echo "<td><div style='float:left;width: 140px;'><span class='style8'><label><input type='checkbox' name='saleshist' id='saleshist' value='1' />Sales History</label><br>
      <label><input type='radio' name='activehist' value='1' />Qty</label><br>
     <label><input type='radio' name='activehist' value='2' />Total Price</label><br>
     <label><input type='radio' name='activehist' value='3' checked />Both</label>
	</span></div></td>";
echo "</tr></table></td>";
echo "</tr>";


echo" <tr>";	  
echo"   <td width='52%' colspan='5' align='left' bgcolor='#F5F5F5'><span class='style8'>Group By</span></td> ";
//echo"   <td width='20%' align='left' bgcolor='#F5F5F5'><span class='style8'>Profit Margin By & Cost</span></td>";
//echo"   <td width='35%' align='left' bgcolor='#F5F5F5'><span class='style8'>Others</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td width='52%' colspan='5' valign='top' bgcolor='#F5F5F5'>";
echo" 	<table border='0' align='left' width='100%' cellpadding=0 cellspacing=1>";
echo"   <tr><td width='30%' valign='top' bgcolor='#F5F5F5'>";
echo"		<select name='availgroupby' multiple='multiple' size='8'>    
				<option value='2' name='Supplier'>Supplier</option>
				<option value='3' name='Salesman'>Salesman</option>
				<option value='20' name='Transaction Project(Parent)'>Transaction Project(Parent)</option>
				<option value='4' name='Transaction Project(Detail)'>Transaction Project(Detail)</option>
				<option value='21' name='Archieve Project(Parent)'>Archieve Project(Parent)</option>
				<option value='5' name='Archieve Project(Detail)'>Archieve Project(Detail)</option>
				<option value='22' name='Transaction Costcenter(Parent)'>Transaction Costcenter(Parent)</option>
				<option value='6' name='Transaction Costcenter(Detail)'>Transaction Costcenter(Detail)</option>
				<option value='23' name='Archieve Costcenter(Parent)'>Archieve Costcenter(Parent)</option>
				<option value='7' name='Archieve Costcenter(Detail)'>Archieve Costcenter(Detail)</option>
				<option value='24' name='Warehouse(Parent)'>Warehouse(Parent)</option>
				<option value='8' name='Warehouse(Detail)'>Warehouse(Detail)</option>
				<option value='9' name='Business Type'>Business Type</option>
				<option value='25' name='Group(Parent)'>Group(Parent)</option>
				<option value='10' name='Group(Detail)'>Group(Detail)</option>
				<option value='26' name='Subgroup(Parent)'>Subgroup(Parent)</option>
				<option value='11' name='Subgroup(Detail)'>Subgroup(Detail)</option>
				<option value='12' name='Category'>Category</option>
				<option value='13' name='Profit Center'>Profit Center</option>
				<option value='27' name='Area(Parent)'>Area(Parent)</option>
				<option value='14' name='Area(Detail)'>Area(Detail)</option> ";
if($module_expiredate == 1)				
echo "<option value='16' name='grpedate'>Expire Date</option> ";		
echo"		</select>";
echo"   </td>";

echo"   <td width='30%' valign='middle' bgcolor='#F5F5F5'>";
echo"   	<div style='text-align: center;' class='style8'>Level 1 <input type='button' name='btnSelLevel1' value=' > ' onClick='MoveLevel12(1);' title='Add'>  <input type='button' name='btnUnSelLevel1' value=' < ' onClick='RemoveLevel12(1);' title='Remove'></div><br>";
echo"   	<div style='text-align: center;' class='style8'>Level 2 <input type='button' name='btnSelLevel2' value=' > ' onClick='MoveLevel12(2);' title='Add'>  <input type='button' name='btnUnSelLevel2' value=' < ' onClick='RemoveLevel12(2);' title='Remove'></div><br>";
echo"   	<div style='text-align: center;' class='style8'>Level 3 <input type='button' name='btnSelLevel3' value=' > ' onClick='MoveLevel3();'   title='Add'>  <input type='button' name='btnUnSelLevel3' value=' < ' onClick='RemoveLevel3();'   title='Remove'></div>";
echo"   </td>";

echo"   <td width='40%' valign='top' bgcolor='#F5F5F5'>";
echo"   	<span class='style8'><input type='hidden' name='groupbylevel1value' value='$groupbylevel1value' style='width:165px;'></span>";
echo"   	<span class='style8'><input type='hidden' name='groupbylevel2value' value='$groupbylevel2value' style='width:165px;'></span>";
echo"   	<span class='style8'><input type='text' name='groupbylevel1name' value='$groupbylevel1name' style='width:165px;' readonly></span><br>";
echo"   	<span class='style8'><input type='text' name='groupbylevel2name' value='$groupbylevel2name' style='width:165px;' readonly></span><br>";
echo"   	<span class='style8'>
			<select name='assigngroupby' multiple='multiple' size='5' style='width:171px; height=150px;'>  ";  
			if ($groupbylevel3value !=''){
				$level3values = explode(",", $groupbylevel3value);
				$level3names  = explode(",", $groupbylevel3name);
				
				$k = 0;
				foreach ($level3values as $level3value) {
					$level3names  = explode(",", $groupbylevel3name);
					echo"<option value='$level3value' name='$level3names[$k]'>$level3names[$k]</option>";
					
					$k = $k + 1;
				}

			
			}
			else
				echo"<option value='' name=''></option>";
				
echo"		</select></span>";
echo"   </td>";

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

echo" </tr>";



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



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

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

echo" <tr>";
echo"   <td colspan='6' bgcolor='#F5F5F5'><span class='style8'>Selected Options</span></td>";
echo" </tr>";


echo" <tr>";	  
echo"   <td colspan='6' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"  		<textarea name='reportoptions' rows='6' cols='100' readonly >".htmlspecialchars(str_replace("<br>", "\n", $reportoptions), ENT_QUOTES)."</textarea>
			</span>";

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='fromclient' id='fromclient' style='width:120px' value='".$fromclient."' />
			<input type='hidden' name='toclient' id='toclient' style='width:120px' value='".$toclient."' />
			<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."' />
        </td>";
		
echo" </tr>";
   

echo" <tr>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   /* <tr>
      <td colspan='9' 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()\";/>	  
	  <input type='button' name='btnLoadOptions' id='btnLoadOptions' value='Load Options' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"LoadOptions()\"; title='Load Template' />
	  <input type='button' name='btnSelectOptions' id='btnSelectOptions' value='Select Options' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"SelectOptions()\"; title='Select Options' />
      </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>";

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

	  
?>