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


$querylog="SELECT RI_PurchaseReports 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 ifNull(FI_RepRestrictProject,0) As FI_RepRestrictProject, ifNull(FI_RepRestrictCostcenter,0) As FI_RepRestrictCostcenter, ".
		  " ifNull(FI_RepRestrictWarehouse,0) As FI_RepRestrictWarehouse, ifNull(Print,0) As Print ".
          " 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, 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());


$querywarehouse="select warehouse_code,warehouse_name from warehouse order by warehouse_code";
$resultfromwarehouse=mysql_query($querywarehouse,$connection) or die(mysql_error());

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter,".
			 " ifNull(Module_Delivery,0) As Module_Delivery, ifNull(Module_Grn,0) As Module_Grn, ifNull(Module_SerialNo,0) As Module_SerialNo ,Ifnull(Module_RestrictProjectReport,0) as Module_RestrictProjectReport ".
             " ,ifNull(Module_Heatno,0) As Module_Heatno,ifNull(Module_RandomeSupplier,0) As Module_RandomeSupplier ".
			 " 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;

//Projects List
$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$_SESSION['dbLabel'].".loginstk on project.project_code like concat(ifnull(loginstk.project_code,project.project_code),'%') ".
			  " where user_account='".$_SESSION['useraccount']."' ".
			  " and (loginstk.project_code is not null and loginstk.project_code != '') ".
			  " order by project.project_code";
$projectresult = mysql_query($queryproject,$connection) or die(mysql_error());
$projectrows   = mysql_num_rows($projectresult);
if ($projectrows == 0 || $FI_RepRestrictProject == 0)
    $queryproject=" select distinct project_code, project_name from project order by project_code ";
			  
$resultfromproject = mysql_query($queryproject,$connection) or die(mysql_error());
$projectrows       = mysql_num_rows($resultfromproject);
$resulttoproject   = mysql_query($queryproject,$connection) or die(mysql_error());

//Costcenter List
$querycostcent=" select distinct costcent.costcent_code, costcent_name ".
               " from costcent left join ".$_SESSION['dbLabel'].".loginstk on costcent.costcent_code like concat(ifnull(loginstk.costcent_code,costcent.costcent_code),'%') ".
			   " where user_account='".$_SESSION['useraccount']."' ".
			   " and (loginstk.costcent_code is not null and loginstk.costcent_code != '') ".
			   " order by costcent.costcent_code";
$costcentresult = mysql_query($querycostcent,$connection) or die(mysql_error());
$costcentexist  = mysql_num_rows($costcentresult);		  
if ($costcentexist == 0 || $FI_RepRestrictCostcenter == 0)
    $querycostcent=" select distinct costcent_code, costcent_name from costcent order by costcent_code ";			  
	
$resultfromcostcent= mysql_query($querycostcent,$connection) or die(mysql_error());
$costcentrows      = mysql_num_rows($resultfromcostcent);
$resulttocostcent  = mysql_query($querycostcent,$connection) or die(mysql_error());


//Get Default Project
$querydflproject="select project_code as defaultproject from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
	extract($rows);
}
	
//Get Default Coscenter
$querydflcostcent="select costcent_code as defaultcostcent from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
	extract($rows);
}

//Area List
$queryarea=" select distinct area_code, area_name from area order by area_code";
$resultfromarea=mysql_query($queryarea,$connection) or die(mysql_error());


//Item Groups List
$querygroup=" select distinct group_code,group_name ".
			" from grouping where group_code in (select group_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."') ".
			" order by group_code";
$resultgroup = mysql_query($querygroup,$connection) or die(mysql_error());
$groupexist   = mysql_num_rows($resultgroup);



if ($groupexist == 0)
	$querygroup="select distinct group_code,group_name from grouping order by group_code";
$resultfromgroup=mysql_query($querygroup,$connection) or die(mysql_error());
$resulttogroup=mysql_query($querygroup,$connection) or die(mysql_error());



//Item SubGroups List
$querysubgroup=" select distinct subgroup_code,subgroup_name ".
			" from subgroup where subgroup_code in (select subgroup_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."') ".
			" order by subgroup_code";
$resultsubgroup = mysql_query($querysubgroup,$connection) or die(mysql_error());
$subgroupexist   = mysql_num_rows($resultsubgroup);



if ($subgroupexist == 0)
	$querysubgroup="select distinct subgroup_code,subgroup_name from subgroup order by subgroup_code";
$resultfromsubgroup=mysql_query($querysubgroup,$connection) or die(mysql_error());
$resulttosubgroup=mysql_query($querysubgroup,$connection) or die(mysql_error());

$querycategory="select category_code,category_name from category order by category_code";
$resultfromcategory=mysql_query($querycategory,$connection) or die(mysql_error());
$resulttocategory=mysql_query($querycategory,$connection) or die(mysql_error());

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

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

HERE;



print <<< HERE

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

<title>Purchase Report</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>
<SCRIPT type="text/javascript">
function showlistheatno(str){

	window.open('Select_HeatNo.php?heatno='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

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 cgr7(){
x=document.form1;
//code1a=x.code1a.value;
document.form1.action="select_item.php?item=1";
document.form1.btncode1.submit();

}

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

}

function changeoption(obj){
if (obj.value != 1 )
{
	document.form1.PurchasePrintSubDetail.disabled = false;
	document.form1.PurchasePrintDetail.checked = true;
}	
else
{
document.form1.PurchasePrintSubDetail.disabled = true;
document.form1.PurchasePrintSubDetail.checked = false;
document.form1.PurchasePrintDetail.checked = true;
}
}

function changewarehousearea(obj){

if (obj.checked==true)
	{
	document.form1.fromwarehouse.value=null;
	document.form1.fromwarehouse.disabled = true;
	document.form1.fromarea.value=null;
	document.form1.fromarea.disabled = true;
	}
else
		{
		document.form1.fromwarehouse.disabled = false;
		document.form1.fromarea.disabled = false;
		}

}
function printPrev(printaccess)
{
  width = screen.width - 10;
  height = screen.height - 66;
  var str='';
  	
    
  for (var i=0; i < document.form1.groupby.length; i++)
  {
    if (document.form1.groupby[i].checked)
    {
      var vargroupby = document.form1.groupby[i].value;
    }
  }
  
  for (var i=0; i < document.form1.masterbyoption.length; i++)
  {
    if (document.form1.masterbyoption[i].checked)
    {
      var varmasterby = document.form1.masterbyoption[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.options.length; i++)
  {
    if (document.form1.options[i].checked)
    {
      var varoptions = document.form1.options[i].value;
    }
  }
  
  for (var i=0; i < document.form1.purchasecatg.length; i++)
  {
    if (document.form1.purchasecatg[i].checked)
    {
      var varpurchasecatg = document.form1.purchasecatg[i].value;
    }
  }

  
    
  varpurchaseoption=0;
  if (document.form1.purchaseoption.checked) 
     varpurchaseoption = 1;	 
	
  varPurchasePrintDetail = 0;
  if (document.form1.PurchasePrintDetail.checked)
    varPurchasePrintDetail = 1;	
	
  varPurchasePrintSubDetail = 0;
  if (document.form1.PurchasePrintSubDetail.checked)
    varPurchasePrintSubDetail = 1;		
	
  varshowweight = 0;
  if (document.form1.showweight.checked)
	varshowweight = 1;		

 varshowwdiscount = 0;
  if (document.form1.showwdiscount.checked)
	varshowwdiscount = 1;		
	
varshowzero = 0;
  if (document.form1.showzero.checked)
	varshowzero = 1;	

	varprtheader = 0;
	if (document.form1.prtheader.checked)    varprtheader = 1;	
	  
	var showinvno = 0;
	if (document.getElementById('showinvno').checked)	
		showinvno = 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;
  
  varfromproject   = document.form1.fromproject.value;
  vartoproject     = document.form1.toproject.value;
  
  varfromcategory   = document.form1.fromcategory.value;
  vartocategory     = document.form1.tocategory.value;
 
  varfromsupplier  = document.form1.fromsupplier.value;
  vartosupplier    = document.form1.tosupplier.value;
  if(document.form1.fromsupplier1)
  varfromsupplier1  = document.form1.fromsupplier1.value;
  else
  varfromsupplier1 ='';
  if(document.form1.fromsupplier1)
  vartosupplier1    = document.form1.tosupplier1.value;
  else
  vartosupplier1 ='';

  varfromwarehouse = document.form1.fromwarehouse.value;
  varfromarea      = document.form1.fromarea.value;
  	if(document.form1.fromheatno)
  	varfromheatno   = document.form1.fromheatno.value;
  	else
	varfromheatno   = '';
	if(document.form1.toheatno)
		vartoheatno     = document.form1.toheatno.value;
	else 
		vartoheatno ='';
	
	varfromcostcent   = document.form1.fromcostcent.value;
	vartocostcent     = document.form1.tocostcent.value;
	varUserAcc     = '';
	if(document.form1.userAcc)
		varUserAcc     = document.form1.userAcc.value;
	 
	vHtn = 0;
	if (document.form1.Htn)
	if (document.form1.Htn.checked) vHtn = 1;	
  	
  str =   'Rep_Purchase.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem+'&fromheatno='+varfromheatno+'&toheatno='+vartoheatno
           +'&fromclient='+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier+'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1+'&fromgroup='+varfromgrp+'&tosubgroup='+vartosubgrp+'&fromsubgroup='+varfromsubgrp+'&togroup='+vartogrp
           +'&fromcategory='+varfromcategory+'&tocategory='+vartocategory+'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea+'&curr='+varcurrency+'&groupby='+vargroupby+'&masterby='+varmasterby
		   +'&purchaseoption='+varpurchaseoption+'&PurchasePrintSubDetail='+varPurchasePrintSubDetail+'&PurchasePrintDetail='+varPurchasePrintDetail+'&vShowHeatno='+vHtn
		   +'&options='+varoptions+'&showweight='+varshowweight+'&showwdiscount='+varshowwdiscount+'&showzero='+varshowzero+'&prtheader='+varprtheader
		   +'&purchasecatg='+varpurchasecatg+'&fromproject='+varfromproject+'&toproject='+vartoproject+'&fromcostcent='+varfromcostcent+'&tocostcent='+vartocostcent
		   +'&showinvno='+showinvno+'&UserAcc='+varUserAcc;

  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(printaccess)
{
  width = screen.width - 10;
  height = screen.height - 66;
  var str='';
  	
    
  for (var i=0; i < document.form1.groupby.length; i++)
  {
    if (document.form1.groupby[i].checked)
    {
      var vargroupby = document.form1.groupby[i].value;
    }
  }
  
  for (var i=0; i < document.form1.masterbyoption.length; i++)
  {
    if (document.form1.masterbyoption[i].checked)
    {
      var varmasterby = document.form1.masterbyoption[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.options.length; i++)
  {
    if (document.form1.options[i].checked)
    {
      var varoptions = document.form1.options[i].value;
    }
  }
  

   for (var i=0; i < document.form1.purchasecatg.length; i++)
  {
    if (document.form1.purchasecatg[i].checked)
    {
      var varpurchasecatg = document.form1.purchasecatg[i].value;
    }
  }
    
  varpurchaseoption=0;
  if (document.form1.purchaseoption.checked) 
     varpurchaseoption = 1;	 
	
  varPurchasePrintDetail = 0;
  if (document.form1.PurchasePrintDetail.checked)
    varPurchasePrintDetail = 1;	
	
  varPurchasePrintSubDetail = 0;
  if (document.form1.PurchasePrintSubDetail.checked)
    varPurchasePrintSubDetail = 1;		
	
  varshowweight = 0;
  if (document.form1.showweight.checked)
	varshowweight = 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;
  
  varfromcategory   = document.form1.fromcategory.value;
  vartocategory     = document.form1.tocategory.value;
 
  varfromsupplier  = document.form1.fromsupplier.value;
  vartosupplier    = document.form1.tosupplier.value;
  if(document.form1.fromsupplier1)
  varfromsupplier1  = document.form1.fromsupplier1.value;
  else 
  varfromsupplier1  = '';
  if(document.form1.tosupplier1)
  vartosupplier1    = document.form1.tosupplier1.value;
  else
  vartosupplier1 ='';
  varfromwarehouse = document.form1.fromwarehouse.value;
  varfromarea      = document.form1.fromarea.value;
  
  varfromproject   = document.form1.fromproject.value;
  vartoproject     = document.form1.toproject.value;
  
  varfromcostcent   = document.form1.fromcostcent.value;
  vartocostcent     = document.form1.tocostcent.value;
	
     varshowwdiscount = 0;
  if (document.form1.showwdiscount.checked)
	varshowwdiscount = 1;		
	
varshowzero = 0;
  if (document.form1.showzero.checked)
	varshowzero = 1;

	var showinvno = 0;
	if (document.getElementById('showinvno').checked)	
		showinvno = 1;
	
  str =   'Exp_Purchase.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
           +'&fromclient='+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier+'&fromsupplier1='+varfromsupplier1+'&tosupplier1='+vartosupplier1
		   +'&fromgroup='+varfromgrp+'&tosubgroup='+vartosubgrp+'&fromsubgroup='+varfromsubgrp+'&togroup='+vartogrp
           +'&fromcategory='+varfromcategory+'&tocategory='+vartocategory+'&fromwarehouse='+varfromwarehouse+'&fromarea='+varfromarea
		   +'&curr='+varcurrency+'&groupby='+vargroupby+'&masterby='+varmasterby+'&purchaseoption='+varpurchaseoption
		   +'&PurchasePrintSubDetail='+varPurchasePrintSubDetail+'&PurchasePrintDetail='+varPurchasePrintDetail
		   +'&options='+varoptions+'&showweight='+varshowweight+'&showwdiscount='+varshowwdiscount+'&showzero='+varshowzero
		   +'&purchasecatg='+varpurchasecatg+'&fromproject='+varfromproject+'&toproject='+vartoproject+'&fromcostcent='+varfromcostcent+'&tocostcent='+vartocostcent
		   +'&showinvno='+showinvno;
   window.open(str);
  
}

</script>
	</head>
<body>
HERE;


echo "<form id='form1' name='form1' method='post' action='$_SERVER[PHP_SELF]'>";

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>Purchase Report</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='30'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";
		
	echo" <button type='reset' id='btnClear' name='btnClear'  title='Clear'><span><span>Clear</span></span></button>";
		echo"<button type='button' id='btnPreview' name='btnPreview'  onClick=\"printPrev('".$printaccess."')\"; title='Preview'><span><span>Preview</span></span></button>";

	if ($ExporttoExcel==1){
		echo" <button type='button' id='btnExcel' name='btnExcel' onClick=\"exportExcel()\"; title='Export Excel'><span><span>Export Excel</span></span></button>";

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

		
echo"<tr><td id='content-body'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
   <tr bgcolor='#F7F7F7'><td valign='top' align='left' colspan='10'>";		

echo '  <table border="0" align="center" width="100%">';

echo" <tr >";	  
echo"   <td width='17%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td> ";
echo"   <td width='18%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Master By </span></td>";
echo"   <td width='20%' height='19' colspan='2' align='center' bgcolor='#F5F5F5'><span class='style8'>Options </span></td>";
echo"   <td width='20%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Group by </span></td>";
echo"   <td width='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Category </span></td>";
echo" </tr>";



echo" <tr height='15px'>";	  
echo"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='12%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate' value='$fromdate' maxlength='10' size='8'>";
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='18%' rowspan='3'  valign='top'  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='15%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        
echo "<input name='masterbyoption' type='radio' value='1'  ";
if ($masterbyoption=='')
	echo " checked ";
	echo"/>Supplier</label></span>";   
echo"   <br><span class='style8'><label>";
        
           echo "<input name='masterbyoption' type='radio' value='2'  />Items</label></span>";   		
echo"   <br><span class='style8'><label>";
        

		
echo"   <td width='20%' rowspan='3' colspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        
           echo "<input name='options' type='radio' value='1' ";
		   if ($options=='')
			echo " checked ";
echo"		   />Cumulative</label></span>";   
echo"   <br><span class='style8'><label>";
        
           echo "<input name='options' type='radio' value='2'  />Detail</label></span>";   		
echo"   <br><br>";
echo"<span class='style8'><input name='purchaseoption' type='checkbox' id='purchaseoption' onclick='changewarehousearea(this)' value='1'>Enable Options</span><br>";
echo"<span class='style8'><input name='PurchasePrintDetail' ";
	if ($PurchasePrintDetail=='')
		echo " checked ";
	echo" type='checkbox' id='PurchasePrintDetail' value='1'>Print Detail</span><br>";
echo"<span class='style8'><input name='PurchasePrintSubDetail' type='checkbox' id='PurchasePrintSubDetail' value='1'>Print Sub Detail</span>";
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='showwdiscount' type='checkbox' id='showwdiscount' value='1' /> Items With Discount </label></span>";

if($Module_Heatno == 1)	
	echo"    <span class='style8'>&nbsp;<label><input type='checkbox' name='Htn' id='Htn' value='Htn' checked/>Show HeatNo</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</label></span>";

echo"<br><span class='style8'><label>";
echo"     <input name='showzero' type='checkbox' id='showzero' value='1' /> Show Zero Amount only</label></span>";
echo"<br><span class='style8'><label>";
echo"     <input name='showinvno' type='checkbox' id='showinvno' value='1' /> Show Invoice No</label></span>";
echo"</td>";  		
		
echo"   <td width='20%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        
           echo "<input name='groupby' type='radio' value='1' onclick='changeoption(this)' ";
		   if ($groupby=='')
			echo " checked ";
		   echo"/>None</label></span>";   
echo"   <br><span class='style8'><label><input name='groupby' onclick='changeoption(this)' type='radio' value='2' />";
		echo "Supplier</label></span>";   		
echo"   <br><span class='style8'><label>";
         echo "<input name='groupby' type='radio' value='3' onclick='changeoption(this)'/>Group</label></span>";   				
		
echo"   <br><span class='style8'><label>";
         echo "<input name='groupby' type='radio' value='4' onclick='changeoption(this)'/>SubGroup</label></span>";   				

echo"   <br><span class='style8'><label>";
         echo "<input name='groupby' type='radio' value='5' onclick='changeoption(this)'/>Category</label></span>";   				
echo"   <br><span class='style8'><label>";
         echo "<input name='groupby' type='radio' value='6' onclick='changeoption(this)'/>Area</label></span></td>";  
		 
echo"   <td width='10%' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'>
			<label><input name='purchasecatg' type='radio' value='0' />Local</label><br>
			<label><input name='purchasecatg' type='radio' value='1' />Import</label><br>
			<label><input name='purchasecatg' type='radio' value='2' checked />Both</label></span>
		</td>";		 
echo" </tr>";



echo" <tr height='15px'>";
echo"   <td width='5%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='12%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <input type='text' name='todate' value='$todate'  maxlength='10' size='8'>";
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 height='40px'>";
echo"   <td width='5%' valign='top' bgcolor='#F5F5F5'><span class='style8'></span></td>";
echo"   <td width='12%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"</td>";


echo" </tr>";
echo "</table>";
echo '  <table border="0" align="center" width="100%">';
echo" <tr height='35px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Item Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Category</span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromitem' type='text' id='fromitem' size='15' value='".$fromitem."' />
        <input name='fromitemdesc' type='text' id='fromitemdesc' size='35' value='".$fromitemdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' onclick='cgr7()' style='width:20px; height:20px; border:thin;' title='Select Item From' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item From ' 
             onClick='showlistitem(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
 <span class='style8'><select name='fromcategory' id='fromcategory' style='width:400px'>";
		echo"<option></option>";
		while($categoryf=mysql_fetch_row($resultfromcategory)){
		echo"<option ";
			if ($fromcategory==$categoryf[0])
				echo " selected ";
		echo" value='$categoryf[0]'>$categoryf[0] | $categoryf[1]</option>";
		}
		echo"</select>";
		echo"</span>
</label>
";
        
echo" </tr>";
   
echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toitem' type='text' id='toitem' size='15' value='".$toitem."' />
        <input name='toitemdesc' type='text' id='toitemdesc' size='35' value='".$toitemdesc."' />
        <input name='btncode2' type='hidden' id='btncode2' value='...' onclick='cgr8()' style='width:20px; height:20px; border:thin;' title='Select Item To' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item To ' 
             onClick='showlistitem(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='5%' align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";	
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        </label>
 <span class='style8'><select name='tocategory' id='tocategory' style='width:400px'>";
		echo"<option></option>";
		while($categoryf=mysql_fetch_row($resulttocategory)){
		echo"<option ";
			if ($tocategory==$categoryf[0])
				echo " selected ";
		echo" value='$categoryf[0]'>$categoryf[0] | $categoryf[1]</option>";
		}
		echo"</select>";
		echo"</span>
		</span>
      <label></label></td>"; 
echo" </tr>";



if($Module_Heatno==1){
echo" <tr height='20'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>HeatNo";
echo"   </span></td>";

echo"</tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromheatno' type='text' id='fromheatno' size='15' value='".$fromheatno."' />
        <input name='fromheatnotype' type='text' id='fromheatnotype' size='35' value='".$fromheatnotype."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' style='width:20px; height:20px; border:thin;' title='Select HeatNo' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select HeatNo ' 
             onClick='showlistheatno(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";
echo"</td>";


echo" </tr>";


echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toheatno' type='text' id='toheatno' size='15' value='".$toheatno."' />
        <input name='toheatnotype' type='text' id='toheatnotype' size='35' value='".$toheatnotype."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' style='width:20px; height:20px; border:thin;' title='Select Item To' />
        </label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item To ' 
             onClick='showlistheatno(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";
echo"</td>";


echo" </tr>";
}



echo" <tr height='35px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Supplier Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Subgroup</span></td>";
echo" </tr>";



echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromsupplier' type='text' id='fromsupplier' size='15' value='".$fromsupplier."' />
        <input name='fromsuppdesc' type='text' id='fromsuppdesc' size='35' value='".$fromsuppdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' onclick='cgr7()' style='width:20px; height:20px; border:thin;' title='Select Supplier From' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier From ' 
             onClick='showlistSupplier(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <span class='style8'><select name='fromsubgroup' id='fromsubgroup' style='width:400px'>";
		echo"<option></option>";
		while($subgrpf=mysql_fetch_row($resultfromsubgroup)){
		echo"<option ";
			if ($fromsubgroup==$subgrpf[0])
				echo " selected ";
		echo" value='$subgrpf[0]'>$subgrpf[0] | $subgrpf[1]</option>";
		}
		echo"</select>";
		echo"</span>
 
        </label>
      </span>
</td>";
echo" </tr>";

   
echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='tosupplier' type='text' id='tosupplier' size='15' value='".$tosupplier."' />
        <input name='tosuppdesc' type='text' id='tosuppdesc' size='35' value='".$tosuppdesc."' />
        <input name='btncode2' type='hidden' id='btncode2' value='...' onclick='cgr8()' style='width:20px; height:20px; border:thin;' title='Select Supplier To' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier To ' 
             onClick='showlistSupplier(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='5%' align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";	
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <span class='style8'><select name='tosubgroup' id='tosubgroup' style='width:400px'>";
		echo"<option></option>";
		while($subgrpt=mysql_fetch_row($resulttosubgroup)){
		echo"<option ";
			if ($tosubgroup==$subgrpt[0])
				echo " selected ";
		echo" value='$subgrpt[0]'>$subgrpt[0] | $subgrpt[1]</option>";
		}
		echo"</select>";
		echo"</span>
        </label>
      </span>
</td>"; 
echo" </tr>";


echo" <tr height='35px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Group Code</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Warehouse</span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'><select name='fromgroup' id='fromgroup' style='width:400px'>";
		echo"<option></option>";
		while($grpf=mysql_fetch_row($resultfromgroup)){
		echo"<option ";
			if ($fromgroup==$grpf[0])
				echo " selected ";
		echo" value='$grpf[0]'>$grpf[0] | $grpf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";					 

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";			 		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'><select name='fromwarehouse' id='fromwarehouse' style='width:400px'>";
		echo"<option></option>";
		while($wrhf=mysql_fetch_row($resultfromwarehouse)){
		echo"<option ";
			if ($fromwarehouse==$wrhf[0])
				echo " selected ";
		echo" value='$wrhf[0]'>$wrhf[0] / $wrhf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";		
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'><select name='togroup' id='togroup' style='width:400px'>";
		echo"<option></option>";
		while($grpt=mysql_fetch_row($resulttogroup)){
		echo"<option ";
			if ($togroup==$grpt[0])
				echo " selected ";
		echo" value='$grpt[0]'>$grpt[0] | $grpt[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>Area</span></td>";			 		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'><select name='fromarea' id='fromarea'>";
		echo"<option></option>";
		while($areaf=mysql_fetch_row($resultfromarea)){
		echo"<option ";
			if ($fromarea==$areaf[0])
				echo " selected ";
		echo" value='$areaf[0]'>$areaf[0] / $areaf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";		
echo" </tr>";


echo" <tr height='35px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Project Code</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>CostCenter Code</span></td>";
echo" </tr>";

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

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";			 		
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>
		<select name='fromcostcent' id='fromcostcent' style='width:400px'>";
		if ($costcentrows > 1) echo"<option></option>";
		while($cstf=mysql_fetch_row($resultfromcostcent)){
			echo"<option ";
			if (($fromcostcent==$cstf[0]) || ($defaultcostcent==$cstf[0]))
				echo " selected ";
			echo" value='$cstf[0]'>$cstf[0] / $cstf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";	
echo" </tr>";

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

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";			 
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>
		<select name='tocostcent' id='tocostcent' style='width:400px'>";
		if ($costcentrows > 1) echo"<option></option>";
		while($cstt=mysql_fetch_row($resulttocostcent)){
			echo"<option ";
			if (($tocostcent==$cstt[0]) || ($defaultcostcent==$cstt[0]))
				echo " selected ";
			echo" value='$cstt[0]'>$cstt[0] / $cstt[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";
echo" </tr>";
if($Module_RandomeSupplier == 1){
echo" <tr height='35px'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Supplier (1)</span></td>";
 echo" </tr>";

echo" <tr>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromsupplier1' type='text' id='fromsupplier1' size='15' value='".$fromsupplier1."' />
        <input name='fromsuppdesc1' type='text' id='fromsuppdesc1' size='35' value='".$fromsuppdesc1."' />
         </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier From ' 
             onClick='showlistSupplier(3); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";
echo"</tr><tr height='35px'>";
echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";			 		
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='tosupplier1' type='text' id='tosupplier1' size='15' value='".$tosupplier1."' />
        <input name='tosuppdesc1' type='text' id='tosuppdesc1' size='35' value='".$tosuppdesc1."' />
         </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Supplier From ' 
             onClick='showlistSupplier(4); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";
echo" </tr>";
}


echo"<TR>";

echo"   <td width='5%'  align='right' bgcolor='#F5F5F5' ><span class='style8'>User </span></td>";			 		
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"<select id='userAcc' name = 'userAcc'>";

	echo"<option value=''></option>";
$queryUsers = 'select distinct user_Account  from ' . $_SESSION['dbLabel'] . '.users ';
$resUsers = mysql_query($queryUsers,$connection);
while($rowusers = mysql_fetch_array($resUsers)){
	echo"<option value='$rowusers[0]'>$rowusers[0]</option>";
}
echo"</select>";
echo" 		</span></label></td>";


print <<<HERE
<SCRIPT type="text/javascript">

if (document.form1.groupby[1].checked)
	{
		document.form1.PurchasePrintSubDetail.enabled = true;
		document.form1.PurchasePrintDetail.checked = true;
	}
else
	{
		document.form1.PurchasePrintSubDetail.disabled = true;
		document.form1.PurchasePrintSubDetail.checked = false;
	}
	

</script>
HERE;

echo" <tr>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
 /* 
echo"
    <tr>
      <td colspan='9' align='center' bgcolor='#F5F5F5'>
	  <input name='clearbtn' type='reset'  value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' />
	  <input name='preview' type='button' id='Preview' 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()\";/>
";*/
	
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");
}

?>