<?php


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

include("config.inc.php");

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


$querylog="SELECT RI_InvComparisonReport as loginaccess, print as printaccess , ExporttoExcel from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");

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

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

HERE;

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_Delivery,0) As Module_Delivery, ifNull(Module_Grn,0) As Module_Grn ".
             " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


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

$querysetup ="select base1, base2, if(DefaultBase=1, base1, base2) as defaultcurr from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
$rowsetup=mysql_fetch_row($resultsetup);
$defaultcurr = $rowsetup[2];

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

$resultfromproject=mysql_query($queryproject,$connection) or die(mysql_error());
$resulttoproject  =mysql_query($queryproject,$connection) or die(mysql_error());


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


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


//Item Groups List
$querygroup=" select distinct group_code,group_name ".
			" from grouping where group_code in (select group_code from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['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 ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['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());


//Warehouse List
$querywarehouse=" select distinct warehouse.warehouse_code, warehouse_name ".
				" from warehouse where warehouse_code in (select warehouse_code from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk ".
				"                                         where user_account='".$HTTP_SESSION_VARS['useraccount']."' ".
				"                                         and (loginstk.warehouse_code is not null and loginstk.warehouse_code != '') ) ".
				" order by warehouse.warehouse_code";
$resultwh = mysql_query($querywarehouse,$connection) or die(mysql_error());
$whexist   = mysql_num_rows($resultwh);
if ($whexist == 0 || $FI_RepRestrictWarehouse == 0)
	$querywarehouse="select warehouse_code,warehouse_name from warehouse order by warehouse_code";
	
$resultfromwarehouse=mysql_query($querywarehouse,$connection) or die(mysql_error());
$resulttowarehouse  =mysql_query($querywarehouse,$connection) or die(mysql_error());


//Item Category List
$querycategory= " select distinct 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());

//Client Business Type List
$querybustype=" select distinct Client_BusinessType from clients where Client_BusinessType is not null and Client_BusinessType != '' order by Client_BusinessType";
$resultfrombustype=mysql_query($querybustype,$connection) or die(mysql_error());
$resulttobustype=mysql_query($querybustype,$connection) or die(mysql_error());


if ((!isset($fromproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1)
	$fromproject = $defaultproject;
if ((!isset($toproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1)
	$toproject = $defaultproject;
if ((!isset($fromcostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$fromcostcent = $defaultcostcent;	
if ((!isset($tocostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$tocostcent = $defaultcostcent;	

if (empty($fromdate))	
	$fromdate = displayFromDate(displayToday());
if (empty($todate))	
	$todate = displayToday();
	
$ShowCostMode  = '';
$ShowCostCheck = 'checked';
if($FI_ShowCostPrice == 0)  {
	$ShowCostMode  = 'disabled';	
	$ShowCostCheck = 'unchecked';	
}	
	
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">

<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->
<script type="text/javascript" language="javascript">
<!--


function PrintPrev(printaccess)
{
	var x = document.form1;
	
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
  
	for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
		  var varcurrency = x.currency[i].value;
		}
	}
	 
	for (var i=0; i < x.period.length; i++)
	{
		if (x.period[i].checked)
		{
		  var varperiod = x.period[i].value;
		}
	}
	
	for (var i=0; i < x.groupby.length; i++)
	{
		if (x.groupby[i].checked)
		{
		  var vargroupby = x.groupby[i].value;
		}
	}
	
	for (var i=0; i < x.transtype.length; i++)
	{
		if (x.transtype[i].checked)
		{
		  var vartranstype = x.transtype[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;
		}
	}
	
	varshowdetail = 0;
	if (x.showdetail.checked)	varshowdetail = 1;	
		
	varprtqty = 0;
	if (x.prtqty.checked)		varprtqty = 1;
	
	varprtamt = 0;
	if (x.prtamt.checked)		varprtamt = 1;
	
	varprtprice = 0;
	if (x.prtprice.checked)	varprtprice = 1;

	varprtcost = 0;
	if (x.prtcost.checked) 	varprtcost = 1;		
	
	varprtqtyexist = 0;
	if (x.prtqtyexist.checked) varprtqtyexist = 1;		
		
	varprtqtySO = 0;
	if (x.prtqtySO.checked) 	varprtqtySO = 1;		

	varprtqtyPO = 0;
	if (x.prtqtyPO.checked) 	varprtqtyPO = 1;
	
	var prtprices = document.getElementsByName('prtpricecol[]');
	var varprices = 0;
	for(var i=0; i < prtprices.length; i++){
		if(prtprices[i].checked)
			varprices += ','+prtprices[i].value;	
	}
	 
	varprtshortage = 0;
	if (x.prtshortage.checked) 	varprtshortage = 1;
	varprtavg = 0;
	if (x.prtavg.checked) 	varprtavg = 1;
	
	varallitems = 0;
	if (x.showallitems.checked) 	varallitems = 1;
	
	vsalesproduction = 0;
	if (x.salesproduction.checked) 	vsalesproduction = 1;
	
	varprtgroup = 0;
	if (x.prtgroup.checked) 	varprtgroup = 1;
	varprtsubgroup = 0;
	if (x.prtsubgroup.checked) 	varprtsubgroup = 1;
	varprtcategory = 0;
	if (x.prtcategory.checked) 	varprtcategory = 1;
	varprtcolor = 0;
	if (x.prtcolor.checked) 	varprtcolor = 1;
	varprtsize = 0;
	if (x.prtsize.checked)   	varprtsize = 1;
	
	varprtcharges = 0;
	if (x.prtcharges.checked)  	varprtcharges = 1;
	
	
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromitem   = x.fromitem.value;
	vartoitem     = x.toitem.value;
	varfromwrh    = x.fromwarehouse.value;
	vartowrh	  = x.towarehouse.value;
	varfromgrp    = x.fromgroup.value;
	vartogrp      = x.togroup.value;
	varfromsubgrp = x.fromsubgroup.value;
	vartosubgrp   = x.tosubgroup.value;
	varfromcat    = x.fromcategory.value;
	vartocat      = x.tocategory.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	varfromclt    = x.fromclient.value;
	vartoclt      = x.toclient.value;
	varfromsupp   = x.fromsupplier.value;
	vartosupp     = x.tosupplier.value;
	varfromslmn   = x.fromsalesman.value;
	vartoslmn     = x.tosalesman.value;
	varfrombustype = x.frombustype.value;
	vartobustype   = x.tobustype.value;
	vqtyamount   	= x.qtyamount.value;
  
	if (varperiod == 4 || varperiod == 5) {
		str =   'Rep_ProjectGroupReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&transtype='+vartranstype
			   +'&fromclient='+varfromclt+'&toclient='+vartoclt+'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtcost='+varprtcost+'&promprint='+varpromprint;
	}
	else if (vsalesproduction==1)	
		str =   'Rep_SalesProductionReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&groupby='+vargroupby+'&transtype='+vartranstype
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtprice='+varprtprice+'&sellprices='+varprices
			   +'&prtcost='+varprtcost+'&prtqtyexist='+varprtqtyexist+'&prtqtySO='+varprtqtySO+'&prtqtyPO='+varprtqtyPO+'&showdetail='+varshowdetail
			   +'&prtavg='+varprtavg+'&prtshortage='+varprtshortage+'&showallitems='+varallitems+'&fromclient='+varfromclt+'&toclient='+vartoclt
			   +'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&prtgroup='+varprtgroup+'&prtsubgroup='+varprtsubgroup+'&prtcategory='+varprtcategory+'&prtcolor='+varprtcolor+'&prtsize='+varprtsize
			   +'&prtcharges='+varprtcharges+'&frombustype='+varfrombustype+'&tobustype='+vartobustype+'&promprint='+varpromprint+'&qtyamount='+vqtyamount;
	else {
		str =   'Rep_InvComparisonReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&groupby='+vargroupby+'&transtype='+vartranstype
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtprice='+varprtprice+'&sellprices='+varprices
			   +'&prtcost='+varprtcost+'&prtqtyexist='+varprtqtyexist+'&prtqtySO='+varprtqtySO+'&prtqtyPO='+varprtqtyPO+'&showdetail='+varshowdetail
			   +'&prtavg='+varprtavg+'&prtshortage='+varprtshortage+'&showallitems='+varallitems+'&fromclient='+varfromclt+'&toclient='+vartoclt
			   +'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&prtgroup='+varprtgroup+'&prtsubgroup='+varprtsubgroup+'&prtcategory='+varprtcategory+'&prtcolor='+varprtcolor+'&prtsize='+varprtsize
			   +'&prtcharges='+varprtcharges+'&frombustype='+varfrombustype+'&tobustype='+vartobustype+'&promprint='+varpromprint;
	}	
		
		   
		   
	if (printaccess==1)
		window.open(str);
	else
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
}
 
function ExportExcel() {
	var x = document.form1;
	
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
  	
  
	for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
		  var varcurrency = x.currency[i].value;
		}
	}
	 
	for (var i=0; i < x.period.length; i++)
	{
		if (x.period[i].checked)
		{
		  var varperiod = x.period[i].value;
		}
	}
	
	for (var i=0; i < x.groupby.length; i++)
	{
		if (x.groupby[i].checked)
		{
		  var vargroupby = x.groupby[i].value;
		}
	}
	
	vsalesproduction = 0;
	if (x.salesproduction.checked) 	vsalesproduction = 1;
	
	for (var i=0; i < x.transtype.length; i++)
	{
		if (x.transtype[i].checked)
		{
		  var vartranstype = x.transtype[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;
		}
	}
	
	varshowdetail = 0;
	if (x.showdetail.checked)	varshowdetail = 1;	
		
	varprtqty = 0;
	if (x.prtqty.checked)		varprtqty = 1;
	
	varprtamt = 0;
	if (x.prtamt.checked)		varprtamt = 1;
	
	varprtprice = 0;
	if (x.prtprice.checked)	varprtprice = 1;

	varprtcost = 0;
	if (x.prtcost.checked) 	varprtcost = 1;		
	
	varprtqtyexist = 0;
	if (x.prtqtyexist.checked) varprtqtyexist = 1;		
		
	varprtqtySO = 0;
	if (x.prtqtySO.checked) 	varprtqtySO = 1;		

	varprtqtyPO = 0;
	if (x.prtqtyPO.checked) 	varprtqtyPO = 1;
	
	var prtprices = document.getElementsByName('prtpricecol[]');
	var varprices = 0;
	for(var i=0; i < prtprices.length; i++){
		if(prtprices[i].checked)
			varprices += ','+prtprices[i].value;	
	}
	 
	varprtshortage = 0;
	if (x.prtshortage.checked) 	varprtshortage = 1;
	varprtavg = 0;
	if (x.prtavg.checked) 	varprtavg = 1;
	
	varallitems = 0;
	if (x.showallitems.checked) 	varallitems = 1;
	
	varprtgroup = 0;
	if (x.prtgroup.checked) 	varprtgroup = 1;
	varprtsubgroup = 0;
	if (x.prtsubgroup.checked) 	varprtsubgroup = 1;
	varprtcategory = 0;
	if (x.prtcategory.checked) 	varprtcategory = 1;
	varprtcolor = 0;
	if (x.prtcolor.checked) 	varprtcolor = 1;
	varprtsize = 0;
	if (x.prtsize.checked)   	varprtsize = 1;
	
	varprtcharges = 0;
	if (x.prtcharges.checked)  	varprtcharges = 1;
	
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromitem   = x.fromitem.value;
	vartoitem     = x.toitem.value;
	varfromwrh    = x.fromwarehouse.value;
	vartowrh	  = x.towarehouse.value;
	varfromgrp    = x.fromgroup.value;
	vartogrp      = x.togroup.value;
	varfromsubgrp = x.fromsubgroup.value;
	vartosubgrp   = x.tosubgroup.value;
	varfromcat    = x.fromcategory.value;
	vartocat      = x.tocategory.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	varfromclt    = x.fromclient.value;
	vartoclt      = x.toclient.value;
	varfromsupp   = x.fromsupplier.value;
	vartosupp     = x.tosupplier.value;
	varfromslmn   = x.fromsalesman.value;
	vartoslmn     = x.tosalesman.value;
	varfrombustype = x.frombustype.value;
	vartobustype   = x.tobustype.value;
  
  
	if (varperiod == 4 || varperiod == 5) {
		str =   'Exp_ProjectGroupReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&transtype='+vartranstype
			   +'&fromclient='+varfromclt+'&toclient='+vartoclt+'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtcost='+varprtcost+'&promprint='+varpromprint;
	} else if (vsalesproduction==1)	
		str =   'Rep_SalesProductionReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&groupby='+vargroupby+'&transtype='+vartranstype
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtprice='+varprtprice+'&sellprices='+varprices
			   +'&prtcost='+varprtcost+'&prtqtyexist='+varprtqtyexist+'&prtqtySO='+varprtqtySO+'&prtqtyPO='+varprtqtyPO+'&showdetail='+varshowdetail
			   +'&prtavg='+varprtavg+'&prtshortage='+varprtshortage+'&showallitems='+varallitems+'&fromclient='+varfromclt+'&toclient='+vartoclt
			   +'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&prtgroup='+varprtgroup+'&prtsubgroup='+varprtsubgroup+'&prtcategory='+varprtcategory+'&prtcolor='+varprtcolor+'&prtsize='+varprtsize
			   +'&prtcharges='+varprtcharges+'&frombustype='+varfrombustype+'&tobustype='+vartobustype+'&promprint='+varpromprint+'&export=1'+'&qtyamount='+vqtyamount;	
	else {
		str =   'Exp_InvComparisonReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromwarehouse='+varfromwrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&groupby='+vargroupby+'&transtype='+vartranstype
			   +'&period='+varperiod+'&prtqty='+varprtqty+'&prtamt='+varprtamt+'&prtprice='+varprtprice+'&sellprices='+varprices
			   +'&prtcost='+varprtcost+'&prtqtyexist='+varprtqtyexist+'&prtqtySO='+varprtqtySO+'&prtqtyPO='+varprtqtyPO+'&showdetail='+varshowdetail
			   +'&prtavg='+varprtavg+'&prtshortage='+varprtshortage+'&showallitems='+varallitems+'&fromclient='+varfromclt+'&toclient='+vartoclt
			   +'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&fromsalesman='+varfromslmn+'&tosalesman='+vartoslmn
			   +'&prtgroup='+varprtgroup+'&prtsubgroup='+varprtsubgroup+'&prtcategory='+varprtcategory+'&prtcolor='+varprtcolor+'&prtsize='+varprtsize
			   +'&prtcharges='+varprtcharges+'&frombustype='+varfrombustype+'&tobustype='+vartobustype+'&promprint='+varpromprint;
	}		   
		   
	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 SelectTransType(option)
{
	var x = document.form1;
	
	if (option == 'PI' || option == 'PR' || option == 'PIR')
	{
		x.prtcharges.disabled = false;
	} else {
		x.prtcharges.disabled = true;
		x.prtcharges.checked  = false;
	}
	
}

function SelectGroupBy() {
	var x = document.form1;
	
	for (var i=0; i < x.groupby.length; i++)
	{
		if (x.groupby[i].checked)
		{
			var vargroupby = x.groupby[i].value;
		}
	}

	if (vargroupby == 1) {
		x.showdetail.checked  = true;
		x.showdetail.disabled = true;
	} else {
		x.showdetail.checked  = true;
		x.showdetail.disabled = false;
	}
}

function SelectOption() {
	var x = document.form1;
	
	for (var i=0; i < x.period.length; i++)
	{
		if (x.period[i].checked)
		{
			var varperiod = x.period[i].value;
		}
	}

	if (varperiod == 4 || varperiod == 5) {
		for (var i=0; i < x.groupby.length; i++)
		{
			x.groupby[i].disabled = true;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[1].checked = true;
			x.currency[0].disabled = true;
		}
		
		x.showdetail.disabled = true;
		x.prtprice.disabled = true;
		
		x.prtqtyexist.disabled = true;
		x.prtqtySO.disabled = true;
		x.prtqtyPO.disabled = true;
		x.prtshortage.disabled = true;
		x.prtavg.disabled = true;
		x.showallitems.disabled = true;
		x.prtgroup.disabled = true;
		x.prtsubgroup.disabled = true;
		x.prtcategory.disabled = true;
		x.prtcolor.disabled = true;
		x.prtsize.disabled = true;
		
		var prtprices = document.getElementsByName('prtpricecol[]');
		for(var i=0; i < prtprices.length; i++){
			prtprices[i].disabled = true;
		}
		
		
	} else {
		for (var i=0; i < x.groupby.length; i++)
		{
			x.groupby[i].disabled = false;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[0].disabled = false;
		}
		
		x.showdetail.disabled = true;
		x.prtprice.disabled = false;
		
		x.prtqtyexist.disabled = false;
		x.prtqtySO.disabled = false;
		x.prtqtyPO.disabled = false;
		x.prtshortage.disabled = false;
		x.prtavg.disabled = false;
		x.showallitems.disabled = false;
		x.prtgroup.disabled = false;
		x.prtsubgroup.disabled = false;
		x.prtcategory.disabled = false;
		x.prtcolor.disabled = false;
		x.prtsize.disabled = false;
		
		var prtprices = document.getElementsByName('prtpricecol[]');
		for(var i=0; i < prtprices.length; i++){
			prtprices[i].disabled = false;
		}
	}
}

-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Comparison 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>
</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'>Comparison 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 height="534" 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='12%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Report Options</span></td>";
echo"   <td width='10%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='11%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>Group By</span></td>";
echo"   <td width='50%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Transaction Type</span></td>";
echo" </tr>";

echo" <tr>";	  
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' style='width:80px;'>";
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='12%' valign='top' rowspan='3' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='period' type='radio' value='1' onclick='SelectOption();'>Daily</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='period' type='radio' value='2' checked onclick='SelectOption();'>Monthly</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='period' type='radio' value='3' onclick='SelectOption();'>Period</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='period' type='radio' value='4' onclick='SelectOption();'>Project Wise</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='period' type='radio' value='5' onclick='SelectOption();'>CostCent Wise</label></span>";
echo"   </td>";

echo"   <td width='10%' valign='top' rowspan='3' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='1'>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>";
echo"   </td>";

echo"   <td width='11%' valign='top' rowspan='4' bgcolor='#F5F5F5'><span class='style8'><label>";
		if ($groupby=="1" || $groupby=="")
           echo "<input name='groupby' type='radio' value='1' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='1' onclick='SelectGroupBy();' />";
		echo "None</label></span>";
echo"   <br><span class='style8'><label>";
		if ($groupby=="2")
           echo "<input name='groupby' type='radio' value='2' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='2' onclick='SelectGroupBy();' />";
		echo "Group</label></span>";		
echo"   <br><span class='style8'><label>";
		if ($groupby=="3")
           echo "<input name='groupby' type='radio' value='3' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='3' onclick='SelectGroupBy();' />";
		echo "SubGroup</label></span>";				
echo"   <br><span class='style8'><label>";
		if ($groupby=="4")
           echo "<input name='groupby' type='radio' value='4' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='4' onclick='SelectGroupBy();' />";
		echo "Category</label></span>";						
echo"   <br><span class='style8'><label>";
		if ($groupby=="5")
           echo "<input name='groupby' type='radio' value='5' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='5' onclick='SelectGroupBy();' />";
		echo "Warehouse</label></span>";
echo"   <br><span class='style8'><label>";
		if ($groupby=="6")
           echo "<input name='groupby' type='radio' value='6' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='6' onclick='SelectGroupBy();' />";
		echo "Project</label></span>";	
echo"   <br><span class='style8'><label>";
		if ($groupby=="7")
           echo "<input name='groupby' type='radio' value='7' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='7' onclick='SelectGroupBy();' />";
		echo "CostCenter</label></span>";	
echo"   <br><span class='style8'><label>";
		if ($groupby=="8")
           echo "<input name='groupby' type='radio' value='8' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='8' onclick='SelectGroupBy();' />";
		echo "Client</label></span>";			
echo"   <br><span class='style8'><label>";
		if ($groupby=="10")
           echo "<input name='groupby' type='radio' value='10' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='10' onclick='SelectGroupBy();' />";
		echo "Client Group</label></span>";
echo"   <br><span class='style8'><label>";
		if ($groupby=="9")
           echo "<input name='groupby' type='radio' value='9' checked onclick='SelectGroupBy();' />";
		else	
		   echo "<input name='groupby' type='radio' value='9' onclick='SelectGroupBy();' />";
		echo "Supplier</label></span>";			
echo"   </td>";


echo"   <td width='50%' colspan='2' rowspan='4' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
echo"   <div id='main' style='position:relative; left:5px; top:0px; width:450px; height:140px;'>";

echo"   <div id='left' style='position:relative; top:0px; width:220px; float:left;'>";
echo"  	   <label><input name='transtype' type='radio' value='PI' onclick='SelectTransType(this.value);'>Purchase</label><br>";
echo"  	   <label><input name='transtype' type='radio' value='PR' onclick='SelectTransType(this.value);'>Return Purchase</label><br>";
echo"  	   <label><input name='transtype' type='radio' value='PIR' onclick='SelectTransType(this.value);'>Purchase / Return Purchase</label><br>";
echo"  	   <label><input name='transtype' type='radio' value='SI' checked onclick='SelectTransType(this.value);'>Sales</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='SR' onclick='SelectTransType(this.value);'>Return Sales</label><br>";
echo"	   <label><input name='transtype' type='radio' value='SIR' onclick='SelectTransType(this.value);'>Sales/ Return Sales</label><br>";

echo"   </div>";

echo"   <div id='right' style='position:absolute; left:5px; top:0px; width:150px; float:right; margin-left: 230px;'>";
echo" 	   <label><input name='transtype' type='radio' value='AI' onclick='SelectTransType(this.value);'>Adjustment IN</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='AR' onclick='SelectTransType(this.value);'>Adjustment OUT</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='PD' onclick='SelectTransType(this.value);'>Production IN</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='PDT' onclick='SelectTransType(this.value);'>Production OUT</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='TRT' onclick='SelectTransType(this.value);'>Transfer IN</label><br>";
echo" 	   <label><input name='transtype' type='radio' value='TR' onclick='SelectTransType(this.value);'>Transfer OUT</label><br>";
echo"   </div>";
echo"   </div>";

echo"   <div id='main' style='position:relative; left:5px; top:25px; 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='left' style='position:relative; left:5px; top:10px; width:220px; float:right;'>";
echo"      <label><input type='checkbox' name='showallitems' id='showallitems' value='1' />Show All Items</label><br>";
echo"      <label><input type='checkbox' name='salesproduction' id='salesproduction' value='1' />Sales-Production</label><br>";
echo "<input name='qtyamount' type='radio' value='1' />Qty Only<br>";
echo "<input name='qtyamount' type='radio' value='2' />Amount Only<br>";
echo "<input name='qtyamount' type='radio' value='3' checked/>Qty & Amount<br>";

echo"   </div>";		
echo" </div>";




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

echo" <tr>";
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' style='width:80px;'>";
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='25'>";
echo"   <td colspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5' valign='top'><span class='style8'>";
echo"   <div id='main' style='position:relative; left:5px; top:2px; width:395px; height:185px; z-index:0;'>";
echo"   <div id='left' style='position:relative; top:0px; width:230px; float:left; '>";

echo"      <label><input type='checkbox' name='showdetail' id='showdetail' value='1' checked disabled />Show Details</label><br>";
echo"  	   <label><input type='checkbox' name='prtprice' id='prtprice' value='1' checked />Print Selling Price</label><br>&nbsp;";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price1' value='1' checked />I</label>";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price2' value='2'  />II</label>";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price3' value='3'  />III</label>";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price4' value='4'  />IV</label>";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price5' value='5'  />V</label>";
echo"  	   		<label><input type='checkbox' name='prtpricecol[]' id='price6' value='6'  />VI</label><br>";
echo"      <label><input type='checkbox' name='prtcost' id='prtcost' value='1'  $ShowCostMode $ShowCostCheck />Print Mean Cost</label><br>";
echo"      <label><input type='checkbox' name='prtamt' id='prtamt' value='1' checked />Print Amount</label><br>";
echo"      <label><input type='checkbox' name='prtqty' id='prtqty' value='1' checked />Print Quantity</label><br>";
echo"      <label><input type='checkbox' name='prtqtyexist' id='prtqtyexist' value='1' checked />Print Qty Exist</label><br>";
echo"      <label><input type='checkbox' name='prtqtySO' id='prtqtySO' value='1' checked />Print Sorder Qty</label><br>";
echo"      <label><input type='checkbox' name='prtqtyPO' id='prtqtyPO' value='1' checked />Print Porder Qty</label>";
echo"   </div>";

echo"   <div id='right' style='position:absolute; left:5px; top:2px; width:150px; float:right; margin-left: 235px; '>";
echo"      <label><input type='checkbox' name='prtavg' id='prtavg' value='1' checked />Print Average</label><br>";
echo"      <label><input type='checkbox' name='prtshortage' id='prtshortage' value='1' checked />Print Shortage</label><br>";
echo"      <label><input type='checkbox' name='prtgroup' id='prtgroup' value='1' />Print Group </label><br>";
echo"      <label><input type='checkbox' name='prtsubgroup' id='prtsubgroup' value='1' />Print SubGroup</label><br>";
echo"      <label><input type='checkbox' name='prtcategory' id='prtcategory' value='1' />Print Category</label><br>";
echo"      <label><input type='checkbox' name='prtcolor' id='prtcolor' value='1' />Print Item Color</label><br>";
echo"      <label><input type='checkbox' name='prtsize' id='prtsize' value='1' />Print Item Size</label><br>";
echo"      <label><input type='checkbox' name='prtcharges' id='prtcharges' value='1' disabled/>Print Charges</label>";
echo"   </div>";
echo"   </div></span>";
echo"   </td>";
echo" </tr>";

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


echo" <tr height='20'>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Item Code / Description</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Client Code / Description</span></td>";
echo" </tr>";

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

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


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

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

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

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

echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Item Group</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Item SubGroup</span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='4' 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'>From</span></td>";
echo"   <td width='45%'  bgcolor='#F5F5F5' ><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></td>";		
		
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='4' 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'>To</span></td>";
echo"   <td width='45%'  bgcolor='#F5F5F5' ><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></td>";		

echo" </tr>";

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

echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Item Category</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>Warehouse</span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='4' bgcolor='#F5F5F5' ><span class='style8'><select name='fromcategory' id='fromcategory' style='width:400px'>";
		echo"<option></option>";
		while($catf=mysql_fetch_row($resultfromcategory)){
		echo"<option ";
			if ($fromcategory==$catf[0])
				echo " selected ";
		echo" value='$catf[0]'>$catf[0] | $catf[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%'  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>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='4' bgcolor='#F5F5F5' ><span class='style8'><select name='tocategory' id='tocategory' style='width:400px'>";
		echo"<option></option>";
		while($catt=mysql_fetch_row($resulttocategory)){
		echo"<option ";
			if ($tocategory==$catt[0])
				echo " selected ";
		echo" value='$catt[0]'>$catt[0] | $catt[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%'  bgcolor='#F5F5F5' ><span class='style8'><select name='towarehouse' id='towarehouse' style='width:400px'>";
		echo"<option></option>";
		while($wrht=mysql_fetch_row($resulttowarehouse)){
		echo"<option ";
			if ($towarehouse==$wrht[0])
				echo " selected ";
		echo" value='$wrht[0]'>$wrht[0] | $wrht[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";	
echo" </tr>";




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

echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Project </span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>CostCenter</span></td>";
echo" </tr>";

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

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

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

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

echo" <tr>";
echo"   <td colspan='5' bgcolor='#F5F5F5'><span class='style8'>Client Business Type</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

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

echo"   <td width='50%' colspan='2' align='right' bgcolor='#F5F5F5' ><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

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

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