<?php


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

include("config.inc.php");

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


//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 ".
             " From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$querylog="SELECT RA_Aging 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;


$querysetup ="select base1, base2, grid_color1, grid_color2, if(DefaultBase=1, base1, base2) as defaultcurr, date_format(aginDate,'%d/%m/%Y') from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
$rowsetup=mysql_fetch_row($resultsetup);
$defaultcurr = $rowsetup[4];
$aginDate = $rowsetup[5];



// Setting Initial Values For Parameters
// $querydate=" Select Date_Format(Min(Journal_date),'%d/%m/%Y') As DefaultFromDate, ".
$querydate=" Select Date_Format(Min(Journal_date),'%d/%m/%Y') As DefaultFromDate, ".
           " Date_Format(Max(Journal_date),'%d/%m/%Y') As DefaultToDate, Date_Format(NOW(),'%d/%m/%Y') As DefaultAgingDate ".
		   " From JournalDt ";
$resultdate=mysql_query($querydate,$connection) or die(mysql_error());
$rowdate=mysql_fetch_row($resultdate);

if (!isset($fromdate))  {
	// if($aginDate == '')
	  $fromdate = $rowdate[0];
	// else 
	// $fromdate = $aginDate;
}
if (!isset($todate))    $todate = $rowdate[1];
if (!isset($agingdate)) $agingdate = $rowdate[2];
  
if (!isset($rangefrom)) $rangefrom = '-0.5'  ;
if (!isset($rangeto))   $rangeto = '0.5'  ; 
   
if (!isset($daysfrom)) $daysfrom = '0'  ;
if (!isset($daysto))   $daysto = '90'  ; 
   

$querysalesmen= " select distinct clientsalesmen ".
			    " from ".$_SESSION['dbLabel'].".loginstk ".
			    " where user_account='".$_SESSION['useraccount']."' and Upper(loginstk.company_name) = Upper('".$_SESSION['dbName']."')  ".
			    " and (clientsalesmen != ''  and clientsalesmen is not null) ";
			  
$salesmenresult = mysql_query($querysalesmen,$connection) or die(mysql_error());
$salesmenexist   = mysql_num_rows($salesmenresult);
if ($salesmenexist>0) $supplierstatus='disabled';
else	$supplierstatus='enabled';
			
$query="select ifnull(ShowReportHeader,0) as ShowReportHeader from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."'  and Upper(loginstk.company_name) = Upper('".$_SESSION['dbName']."') ";
$result=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result)){
	extract($rows);
}
if($ShowReportHeader=='')
	$ShowReportHeader=1;

print <<< HERE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

<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.date.length; i++)
	{
		if (document.form1.date[i].checked)
		{
			var vardate = document.form1.date[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;
		}
	}
	 
	for (var i=0; i < document.form1.orderby.length; i++)
	{
		if (document.form1.orderby[i].checked)
		{
			var varorderby = document.form1.orderby[i].value;
		}
	}
  
	for (var i=0; i < document.form1.balorderby.length; i++)
	{
		if (document.form1.balorderby[i].checked)
		{
			var varbalorderby = document.form1.balorderby[i].value;
		}
	}
  
  
	for (var i=0; i < document.form1.accountno.length; i++)
	{
		if (document.form1.accountno[i].checked)
		{
			var varaccountno = document.form1.accountno[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.duebal.length; i++)
	{
		if (document.form1.duebal[i].checked)
		{
			var varduebal = document.form1.duebal[i].value;
		}
	}
	
  
  
    //Getting Group By Levels 1 and 3
	vargroupby1   = document.form1.groupbylevel1value.value;
	vargroupby2   = document.form1.groupbylevel2value.value;
	vartermsdays   = document.form1.termsdays.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;
	
	
	
	varriskbal = 0;
	if (document.form1.riskbal.checked)
		varriskbal = 1;			
	
	varshowbal = 0;
	if (document.form1.showbal.checked)
		varshowbal = 1;
	
	varlastbal = 0;
	if (document.form1.lastbal.checked)
		varlastbal = 1;	

	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;
		
	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varshowdetail = 1;	

	varshownondues = 0;
	if (document.form1.shownondues.checked)
		varshownondues = 1;
		
	varprtheader = 0;
	if (document.form1.prtheader.checked)
		varprtheader = 1;
		
	varshowaddress = 0;
	if (document.form1.showaddress.checked)
		varshowaddress = 1;
		
	varprtcstjour = 0;
	if (document.form1.prtcstjour.checked)
		varprtcstjour = 1;
	
	varbyledgergrp = 0;
	if (document.form1.byledgergrp.checked)
		varbyledgergrp = 1;
	
  
	varfromdate     = document.form1.fromdate.value;
	vartodate       = document.form1.todate.value;
	varagingdate    = document.form1.agingdate.value;
	varfromledger   = document.form1.fromledger.value;
	vartoledger     = document.form1.toledger.value;
	varfromsalesman = document.form1.fromsalesman.value;
	vartosalesman   = document.form1.tosalesman.value;
	varfromprj      = document.form1.fromproject.value;
	varfromcst      = document.form1.fromcostcent.value;
	varcltprj       = document.form1.clientproject.value;
	varcltcst       = document.form1.clientcostcent.value;
	varrangefrom    = document.form1.rangefrom.value;
	varrangeto      = document.form1.rangeto.value;
	varsubproj      = document.form1.subproj.value;
	varsubcostcent  = document.form1.subcostcent.value;
  
	varsubproj      = varsubproj.replace(/%/g,'-');
	varsubcostcent  = varsubcostcent.replace(/%/g,'-');
	
	var vshowvdate = 0;
	if(document.getElementById('showvdate').checked)
		vshowvdate = 1;
	
	varreport = '';
	if (varoption == 1)
		varreport = 'Rep_Aging.php';
	else if (varoption == 2)
		varreport = 'Rep_AgingDetail.php';  
  
    
	str = varreport +'?fromdate='+varfromdate+'&todate='+vartodate+'&agingdate='+varagingdate+'&fromledger='+varfromledger+'&toledger='+vartoledger
					+'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromproject='+varfromprj+'&fromcst='+varfromcst
					+'&cltcst='+varcltcst+'&cltprj='+varcltprj+'&rangefrom='+varrangefrom+'&rangeto='+varrangeto+'&groupby1='+vargroupby1
					+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3+'&dateoption='+vardate+'&orderby='+varorderby+'&lastbal='+varlastbal
					+'&balorderby='+varbalorderby+'&accountno='+varaccountno+'&curr='+varcurrency+'&riskbal='+varriskbal+'&showbal='+varshowbal
					+'&showdetail='+varshowdetail+'&shownondues='+varshownondues+'&subproj='+varsubproj+'&subcostcent='+varsubcostcent
					+'&duebal='+varduebal+'&prtheader='+varprtheader+'&showaddress='+varshowaddress+'&prtcstjour='+varprtcstjour+'&termsdays='+vartermsdays
					+'&showvdate='+vshowvdate+'&byledgergrp='+varbyledgergrp;
				 
	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.date.length; i++)
	{
		if (document.form1.date[i].checked)
		{
			var vardate = document.form1.date[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;
		}
	}
	 
	for (var i=0; i < document.form1.orderby.length; i++)
	{
		if (document.form1.orderby[i].checked)
		{
			var varorderby = document.form1.orderby[i].value;
		}
	}
  
	for (var i=0; i < document.form1.balorderby.length; i++)
	{
		if (document.form1.balorderby[i].checked)
		{
			var varbalorderby = document.form1.balorderby[i].value;
		}
	}
  
  
	for (var i=0; i < document.form1.accountno.length; i++)
	{
		if (document.form1.accountno[i].checked)
		{
			var varaccountno = document.form1.accountno[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.duebal.length; i++)
	{
		if (document.form1.duebal[i].checked)
		{
			var varduebal = document.form1.duebal[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;
	
	
	
	varriskbal = 0;
	if (document.form1.riskbal.checked)
		varriskbal = 1;			
	
	varshowbal = 0;
	if (document.form1.showbal.checked)
		varshowbal = 1;
	
	varlastbal = 0;
	if (document.form1.lastbal.checked)
		varlastbal = 1;	
	
	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;
		
	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varshowdetail = 1;	

	varshownondues = 0;
	if (document.form1.shownondues.checked)
		varshownondues = 1;
		
	varprtheader = 0;
	if (document.form1.prtheader.checked)
		varprtheader = 1;
		
	varshowaddress = 0;
	if (document.form1.showaddress.checked)
		varshowaddress = 1;
		
	varprtcstjour = 0;
	if (document.form1.prtcstjour.checked)
		varprtcstjour = 1;

  
	varfromdate     = document.form1.fromdate.value;
	vartodate       = document.form1.todate.value;
	varagingdate    = document.form1.agingdate.value;
	varfromledger   = document.form1.fromledger.value;
	vartoledger     = document.form1.toledger.value;
	varfromsalesman = document.form1.fromsalesman.value;
	vartosalesman   = document.form1.tosalesman.value;
	varfromprj      = document.form1.fromproject.value;
	varfromcst      = document.form1.fromcostcent.value;
	varcltprj       = document.form1.clientproject.value;
	varcltcst       = document.form1.clientcostcent.value;
	varrangefrom    = document.form1.rangefrom.value;
	varrangeto      = document.form1.rangeto.value;
	varsubproj      = document.form1.subproj.value;
	varsubcostcent  = document.form1.subcostcent.value;
  
	varsubproj      = varsubproj.replace(/%/g,'-');
	varsubcostcent  = varsubcostcent.replace(/%/g,'-');
	
	var vshowvdate = 0;
	if(document.getElementById('showvdate').checked)
		vshowvdate = 1;
	
	var varbyledgergrp = 0;
	if(document.getElementById('byledgergrp').checked)
		varbyledgergrp = 1;
	
	varreport = '';
	if (varoption == 1)
		varreport = 'Exp_Aging.php';
	else if (varoption == 2)
		varreport = 'Exp_AgingDetail.php';  
  
    
	str = varreport +'?fromdate='+varfromdate+'&todate='+vartodate+'&agingdate='+varagingdate+'&fromledger='+varfromledger+'&toledger='+vartoledger
					+'&fromsalesman='+varfromsalesman+'&tosalesman='+vartosalesman+'&fromproject='+varfromprj+'&fromcst='+varfromcst
					+'&cltcst='+varcltcst+'&cltprj='+varcltprj+'&rangefrom='+varrangefrom+'&rangeto='+varrangeto+'&groupby1='+vargroupby1
					+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3+'&dateoption='+vardate+'&orderby='+varorderby+'&lastbal='+varlastbal
					+'&balorderby='+varbalorderby+'&accountno='+varaccountno+'&curr='+varcurrency+'&riskbal='+varriskbal+'&showbal='+varshowbal
					+'&showdetail='+varshowdetail+'&shownondues='+varshownondues+'&subproj='+varsubproj+'&subcostcent='+varsubcostcent
					+'&duebal='+varduebal+'&prtheader='+varprtheader+'&showaddress='+varshowaddress+'&prtcstjour='+varprtcstjour
					+'&showvdate='+vshowvdate+'&byledgergrp='+varbyledgergrp;

	window.open(str);

}


function showlistledger(str){

  var str1;
  for (var i=0; i < document.form1.accountno.length; i++)
  {
    if (document.form1.accountno[i].checked)
    {
      str1 = document.form1.accountno[i].value;
    }
  }

  
  window.open('select_accountno.php?item='+str+'&accountoption='+str1,'mywindow','width=800,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 CheckAccountNo() {

	var x= document.form1;
	var ob = document.form1.assigngroupby;
	
	for (var i=0; i < x.accountno.length; i++)
    {
      
		if (x.accountno[i].checked && (x.accountno[i].value == '1'  || x.accountno[i].value == '3' ))
		{ 
			//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;
			}
		  
			ob.disabled = true;
		}
		else if (x.accountno[i].checked && x.accountno[i].value == '2')
		{	  
			ob.disabled = false;
		}
    }
	
		

}

function LoadOptions() {
	x = document.form1;
    win = window.open('List_ReportsOptionsTemplates.php?formname=aging', '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=0&templateid='+vTemplateId+'&formname=aging', '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 setShowPer(vPer){
	var perChked = 0;
	if(document.getElementById('showPer'+vPer).checked)
		perChked = 1;
	
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			{ 	
				var data = xmlhttp.responseText.split("[BRK]");

			}
		}
	  }

	 xmlhttp.open("GET","Form_Aging_Action.php?action=setPeriod&period="+vPer+"&perChked="+perChked,true);

	  
	xmlhttp.send();
	
}

function ClearPage() {
	x = document.form1;
	
	//x.templateid.value = '';
	//x.action='Form_Aging.php';
	//x.submit();
	
	window.location ='Form_Aging.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;
	}
	

}

function SelectRecord(PPeriodId,PPeriod) {
	x = document.form1;
	
	x.txtPeriodId.value = PPeriodId;
	x.txtPeriod.value = PPeriod;
}

function SubmitRecord() {
	x = document.form1;
	
	var vPeriodId = x.txtPeriodId.value;
	
	if (vPeriodId != '') x.actionmode.value='editperiod';
	else x.actionmode.value='insertperiod';
	
	x.submit();
}

-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Aging</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}
.style4{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 0px;
}
-->
</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
	<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>
</head>
<body>
HERE;

echo "<form id='form1' name='form1' method='post' action='$_SERVER[PHP_SELF]' >
		<input type='hidden' name='templateid' value='$templateid'>
		<input type='hidden' name='actionmode' value='$actionmode'>";
		
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'>Aging</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  ".
					 " From ReportsOptions_Templates ".
					 " Where   Template_Id = '".$templateid."'";
	//echo $querytemplate;	
//ReportsOptions_Templates.User_Account = '".$_SESSION['useraccount']."' ".	
	$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;	
	
	
	$fromproject    = $FromProject_Code;
	$fromcostcent   = $FromCostcent_Code;
	$clientproject  = $FromMasterProject_Code;
	$clientcostcent = $FromMasterCostcent_Code;
	
	$fromledger 	= $FromLedger_Number;
	$toledger 		= $ToLedger_Number;
	$fromsalesman   = $FromSalesman_Code;
	$tosalesman     = $ToSalesman_Code;
	
	$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 ($FromLedger_Number != '')		  $reportoptions .= "-> Ledger From: ". $FromLedger_Number . "  To: ". $ToLedger_Number ."\n";
	if ($FromSalesman_Code != '')		  $reportoptions .= "-> Salesman From: ". $FromSalesman_Code . "  To: ". $ToSalesman_Code ."\n";
	if ($FromProject_Code != '')   		  $reportoptions .= "-> Shipment Ref From: ". $FromProject_Code . "\n";
	if ($FromCostcent_Code != '') 		  $reportoptions .= "-> Costcent From: ". $FromCostcent_Code . "\n";
	if ($FromMasterProject_Code != '')    $reportoptions .= "-> Master Shipment Ref From: ". $FromMasterProject_Code . "\n";
	if ($FromMasterCostcent_Code != '')   $reportoptions .= "-> Master Costcent From: ". $FromMasterCostcent_Code . "\n";

  
}
 
if (isset($_POST['actionmode']) && $_POST['actionmode'] == 'insertperiod' && $_POST['txtPeriod'] != "") {
	$sub_query  = "insert into aging (Period,report_name) values ('".$_POST['txtPeriod']."','aging') ";
	$sub_result = mysql_query($sub_query);

	$actionmode = "";
}
else if (isset($_POST['actionmode']) && $_POST['actionmode'] == 'editperiod' && $_POST['txtPeriodId'] != "") {
	$sub_query  = "update aging set Period='".$_POST['txtPeriod']."' where id='".$_POST['txtPeriodId']."' ";
	$sub_result = mysql_query($sub_query);
	
	$actionmode = "";
}

echo" <tr>";	  
echo"   <td width='25%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td>";
echo"   <td width='20%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='20%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Options </span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Order By </span></td>";
echo"   <td width='20%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input type='checkbox' name='lastbal' id='lastbal' value='1' />Order By Last Balance</label></span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='20%'  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='20%' rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='curr'>Currency</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='$rowsetup[0]' "; if($defaultcurr == $rowsetup[0]) echo "checked"; echo">$rowsetup[0]</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='$rowsetup[1]' "; if($defaultcurr == $rowsetup[1]) echo "checked"; echo">$rowsetup[1]</label></span></td>";


echo"   <td width='20%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($option=="1" || $option=="")
           echo "<input name='option' type='radio' value='1' checked />";
		else	
		   echo "<input name='option' type='radio' value='1' />";
		echo "Aging</label></span>";
echo"   <br><span class='style8'><label>";
		if ($option=="2")
           echo "<input name='option' type='radio' value='2' checked />";
		else	
		   echo "<input name='option' type='radio' value='2' />";
		echo "Detail Aging</label></span></td>";	

		
echo"   <td width='15%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($orderby=="1" || $orderby=="")
           echo "<input name='orderby' type='radio' value='1' checked />";
		else	
		   echo "<input name='orderby' type='radio' value='1' />";
		echo "Account No.</label></span>";
echo"   <br><span class='style8'><label>";
		if ($orderby=="2")
           echo "<input name='orderby' type='radio' value='2' checked />";
		else	
		   echo "<input name='orderby' type='radio' value='2' />";
		echo "Account Name</label></span></td>";	
		
echo"   <td width='20%' rowspan='2' valign='top' bgcolor='#F5F5F5' ><span class='style8'><label>";
		if ($balorderby=="1")
           echo "<input name='balorderby' type='radio' value='1' checked />";
		else	
		   echo "<input name='balorderby' type='radio' value='1' />";
		echo "Ascending</label></span>";
echo"   <br><span class='style8'><label>";
		if ($balorderby=="2" || $balorderby=="")
           echo "<input name='balorderby' type='radio' value='2' checked />";
		else	
		   echo "<input name='balorderby' type='radio' value='2' />";
		echo "Descending</label></span></td>";	
				
echo" </tr>";

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

echo" <tr>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Aging up to date ";
echo"      <input type='text' name='agingdate' value='$agingdate' maxlength='10' size='10'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.agingdate,'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 rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <label><input type='checkbox' name='showbal' id='showbal' value='1'  />Show Balances Between</label><br>";
echo"      &nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='rangefrom' value='$rangefrom' maxlength='10' style='width:60px;' >&nbsp;&&nbsp;";
echo"      <input type='text' name='rangeto' value='$rangeto' maxlength='10' style='width:60px;'></span>";
echo"<br>";
echo"<br>";
if($termsdays == '') $termsdays = '';
echo"     <span class='style8'> <label>Show Days >= </label><input type='text' name='termsdays'  id='termsdays'  value='$termsdays' style='width:50px'><br>";


echo"</td>";

echo"   <td rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <label><input type='checkbox' name='riskbal' id='riskbal' value='1'  />Risk Balance</label><br>";
echo"      <label><input type='checkbox' name='shownondues' id='shownondues' value='1' checked />Show Non Dues</label><br>";

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"      <label>Show Report Header</label><br>";





echo"      <label><input name='showaddress' type='checkbox' id='showaddress' value='1' />Show Address/Phone</label><br>";
echo"      <label><input name='prtcstjour' type='checkbox' id='prtcstjour' value='1' />Detail Shipment Ref / CostCent</label><br>
			<label><input name='byledgergrp' type='checkbox' id='byledgergrp' value='1' />Group by Ledger Group</label>
			</span></td>";

echo"   <td colspan='2' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($duebal=="1" || $duebal=="")
           echo "<input name='duebal' type='radio' value='1' checked />";
		else	
		   echo "<input name='duebal' type='radio' value='1' />";
		echo "Aging of Due Balances</label></span>";
echo"   <br><span class='style8'><label>";
		if ($duebal=="2")
           echo "<input name='duebal' type='radio' value='2' checked />";
		else	
		   echo "<input name='duebal' type='radio' value='2' />";
		echo "Aging of Non Due Balances</label></span></td>";
echo" </tr>";



echo" <tr>";
echo"   <td colspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <label><input name='date' type='radio' value='1'  >Date</label>";
echo"      <br><label><input name='date' type='radio' value='2'  checked='checked' >Value Date</label>";
echo " <br><label><input name='showvdate' id='showvdate' type='checkbox' value='1' checked>Show Value Date</label>";
echo "</span></td> ";
//echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

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

echo" <tr>";



echo"   <td width='65%' colspan='5' valign='top' bgcolor='#F5F5F5'>";
echo" 	<table border='0' align='left' width='100%' cellpadding=0 cellspacing=3>";

echo"   <tr height='15'>";
echo"    <td bgcolor='#F5F5F5'><span class='style8'>Aging by </span></td>";
echo"    <td colspan='3'  bgcolor='#F5F5F5'><span class='style8'>Group By </span>";
echo"      <span class='style8'><label><input type='checkbox' name='showdetail' id='showdetail' value='1' checked />Show Detail</label></span></td>";
echo"   </tr>";

echo"   <tr>";
echo"   <td width='20%' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($accountno=="1")
           echo "<input name='accountno' type='radio' value='1'  checked $supplierstatus/>";
		else
			echo "<input name='accountno' type='radio' value='1'  $supplierstatus/>";
		echo "Suppliers</label></span>";
echo"   <br><span class='style8'><label>";
		
		if ($accountno=="2" || $accountno=="" )
           echo "<input name='accountno' type='radio' value='2'  checked />";
		else	   
		   echo "<input name='accountno' type='radio' value='2'  />";
		   
		echo "Clients</label></span></td>";		

		
echo"     <td width='25%' valign='top' bgcolor='#F5F5F5'>";
echo"		<select name='availgroupby' multiple='multiple' size='8'>    
				<option value='3'  name='Salesman'>Salesman</option>
				<option value='20' name='Transaction Shipment Ref(Parent)'>Transaction Shipment Ref(Parent)</option>
				<option value='4' name='Transaction Shipment Ref(Detail)'>Transaction Shipment Ref(Detail)</option>
				<option value='21' name='Archieve Shipment Ref(Parent)'>Archieve Shipment Ref(Parent)</option>
				<option value='5' name='Archieve Shipment Ref(Detail)'>Archieve Shipment Ref(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='9'  name='Business Type'>Business Type</option>
				<option value='10' name='Profit Center'>Profit Center</option>
			</select>";
echo"   </td>";

echo"   <td width='20%' 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='35%' valign='top' bgcolor='#F5F5F5'>";
echo"   	<span class='style8'><input type='hidden' name='groupbylevel1value' value='$groupbylevel1value' style='width:185px;'></span>";
echo"   	<span class='style8'><input type='hidden' name='groupbylevel2value' value='$groupbylevel2value' style='width:185px;'></span>";
echo"   	<span class='style8'><input type='text' name='groupbylevel1name' value='$groupbylevel1name' style='width:185px;' readonly></span><br>";
echo"   	<span class='style8'><input type='text' name='groupbylevel2name' value='$groupbylevel2name' style='width:185px;' readonly></span><br>";
echo"   	<span class='style8'>
			<select name='assigngroupby' multiple='multiple' size='5' style='width:191px; height=150px;'>  ";  
			
			if ($groupbylevel3value !=''){
				$level3values = explode(",", $groupbylevel3value);
				$level3names  = explode(",", $groupbylevel3name);
				
				$k = 0;
				foreach ($level3values as $level3value) { echo $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></tr>";
echo"   </table></td>";


echo"   <td width='20%' valign='top' bgcolor='#F5F5F5'><div style='margin-top:10px; width:120px; height:150px; overflow-x:auto;'>
		<table border='0' cellpadding='0' cellspacing='1' >
		<col width='60px'>
		<col width='30px'>
		<tr>
			<td align='center' class='style8'>Period</td>
			<td align='center' class='style8'>&nbsp;</td>
		</tr>
		<tr>
			<td align='center' style='border-bottom:1px solid black;'>
				<input type='hidden' name='txtPeriodId' id='txtPeriodId' value=''>
				<input type='text' name='txtPeriod' id='txtPeriod' value='' maxlength='10' style='width:55px;'>
			</td>
			<td align='center' style='border-bottom:1px solid black;'>
				<input type='button' id='imgSubmit' onclick=\"SubmitRecord(); return false;\" title='Submit Record' style='width:20px; height:20px; vertical-align:middle; cursor:pointer; outline:none; border:0px; background-image:url(img/confirm-1.png)' >
			</td>
		</tr>";
	
		$ct=0;
		$queryperiods  = " select id, period, name, ifnull(showPeriod,0) from aging where report_name = 'aging' order by period ";
		$resultperiods = mysql_query($queryperiods,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($resultperiods)){
			$ct+=1;

			if($ct%2==0)
			{
				$Color="style='cursor:pointer;color:#0000FF;background-color:".$rowsetup[2]."'";
			} else {
				$Color="style='cursor:pointer;color:#0000FF;background-color:".$rowsetup[3]."'";	
			}
		
			echo "<tr $Color  height='20px;'>";
			echo "	<td align='right' onclick=\"SelectRecord('$rows[0]','$rows[1]');\"><span class='style4'>$rows[1]</span></td>";
			echo "	<td align='left' style='padding-left:5px;'><span class='style4'><input type='checkbox' name='showPer$rows[1]' id='showPer$rows[1]' value='$rows[3]' ".($rows[3]==1?'checked':'')." onclick=\"setShowPer('$rows[1]');\"></span></td>";
			echo "</tr>";
		}	
		
echo"	</table>	
		</div></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' bgcolor='#F5F5F5' ><span class='style8'>";
echo"  		<textarea name='reportoptions' rows='6' cols='100' readonly >".htmlspecialchars(str_replace("<br>", "\n", $reportoptions), ENT_QUOTES)."</textarea>
			</span>
		</td>";
echo" </tr>";

echo"   <input type='hidden' name='fromledger' id='fromledger' size='10' value='".$fromledger."' />
		<input type='hidden' name='toledger' id='toledger' size='10' value='".$toledger."' />
		<input type='hidden' name='fromsalesman' id='fromsalesman' size='10' value='".$fromsalesman."' />
    	<input type='hidden' name='tosalesman' id='tosalesman' size='10' value='".$tosalesman."' />
		<input type='hidden' name='fromproject' id='fromproject' size='10' value='".$fromproject."' />
		<input type='hidden' name='fromcostcent' id='fromcostcent' size='10' value='".$fromcostcent."' />
		<input type='hidden' name='clientcostcent' id='clientcostcent' size='10' value='".$clientcostcent."' />
		<input type='hidden' name='clientproject' id='clientproject' size='10' value='".$clientproject."' />
		<input type='hidden' name='subproj' id='subproj' style='width:120px' value='".$subproj."' />
		<input type='hidden' name='subcostcent' id='subcostcent' style='width:120px' value='".$subcostcent."' />";
    

echo" <tr height='15'>";
echo"   <td colspan='6' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   /* <tr>
      <td colspan='6' 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>";

?>