<?php


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

include("config.inc.php");

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

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

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

$querylog="SELECT RI_Inventory as loginaccess, print as printaccess, 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';		*/


//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, ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ".
			 " ifNull(Module_SerialNo,0) As Module_SerialNo, ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter ".
			 " ,IfNull(Module_RestrictProjectReport,0) As Module_RestrictProjectReport,ifnull(Module_BatchNo,0) as Module_BatchNo ".
             " 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 ".$_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);
}

$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 ".$_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());
$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());
$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);
}

//Warehouse List
$querywarehouse=" select distinct warehouse.warehouse_code, warehouse_name ".
				" from warehouse where warehouse_code in (select warehouse_code from ".$_SESSION['dbLabel'].".loginstk ".
				"                                         where user_account='".$_SESSION['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());
$resultfromtranswh=mysql_query($querywarehouse,$connection) or die(mysql_error());
$resulttotranswh=mysql_query($querywarehouse,$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());

//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());



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

if ((!isset($fromproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1 && $Module_RestrictProjectReport==1)
	$fromproject = $defaultproject;
if ((!isset($toproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1 && $Module_RestrictProjectReport==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 = displayToday();
if (empty($todate))   $todate   = displayToday();
	
print <<< HERE

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->
<script type="text/javascript" language="javascript">
<!--
function MoveLevel12(option) {
	var ob = document.form1.availgroupby;
	var leng = ob.options.length;
	
	var vSelectedOptionValue='';
	var vSelectedOptionName='';
	var vSelectedCount=0;
	
	if(ob.selectedIndex == -1) {
		alert('No selection is done.');
		return;
	}
	
	while (ob.selectedIndex != -1)
    {
        if (ob.selectedIndex != -1) {
			vSelectedCount = vSelectedCount + 1;
			vSelectedOptionName  = ob.options[ob.selectedIndex].text;
			vSelectedOptionValue = ob.options[ob.selectedIndex].value;
		}	
        ob.options[ob.selectedIndex].selected = false;
    }

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


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

  window.open('select_ItemLocation.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 RemoveLevel12(option) {
	var x = document.form1;
	
	if (option == 1) {
		x.groupbylevel1name.value = '';
		x.groupbylevel1value.value = '';
	}	
	else {
		x.groupbylevel2name.value = '';
		x.groupbylevel2value.value = '';
	}	
}

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

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

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

	
}

function RemoveLevel3() {
	var ob = document.form1.assigngroupby;
	var leng = ob.options.length;
	
	if(ob.selectedIndex == -1) {
		alert('No selection is done.');
		return;
	}
	
	while (ob.selectedIndex != -1)
    {  
        if (ob.selectedIndex != -1) 
			  ob.options[ob.selectedIndex] = null;
    }
	
}
/*
function ApplyWarehouse(obj){
	if (obj.checked)
	{
		document.form1.groupby[0].disabled=true;
		document.form1.groupby[1].disabled=true;
		document.form1.groupby[2].disabled=true;
		document.form1.groupby[4].disabled=true;
		document.form1.groupby[3].checked=true;
	}
	else
	{
		document.form1.groupby[0].disabled=false;
		document.form1.groupby[1].disabled=false;
		document.form1.groupby[2].disabled=false;
		document.form1.groupby[4].disabled=false;
	}

}*/

function CheckSerialAvailable() {
	x = document.form1;
	var vPSerialNo = x.fromserial.value;
	
	if (vPSerialNo == '') {
		alert('Please add serial no.');
	} else {	
	
		XPos = (screen.availHeight - 200) / 2;
		YPos = (screen.availWidth - 300) / 2;
		win = window.open('Form_CheckSerialAvailable.php?PSerialNo='+vPSerialNo, 'Form_CheckSerialAvailable', 'titlebar=no,toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no, width=300,height=200,left='+YPos+',top='+XPos);		
		win.creator = self;
		win.focus();
	}
	
}

function SelectTransOption()
{
	var x = document.form1;
	
	if (x.alltrans.checked) {
		x.TransPI.checked= true;
		x.TransPR.checked= true;
		x.TransSI.checked= true;
		x.TransSR.checked= true;
		x.TransTR.checked= true;
		x.TransPD.checked= true;
		x.TransAD.checked= true;
		x.TransSO.checked= true;
	}
}

function EnableDetailedOptions() {
	var x = document.form1;
	if (x.detailed.checked) {
		x.alltrans.disabled = false;
		x.TransPI.disabled= false;
		x.TransPR.disabled= false;
		x.TransSI.disabled= false;
		x.TransSR.disabled= false;
		x.TransTR.disabled= false;
		x.TransPD.disabled= false;
		x.TransAD.disabled= false;
		x.TransSO.disabled= false;
	} else {
		x.alltrans.disabled = true;
		x.TransPI.disabled= true;
		x.TransPR.disabled= true;
		x.TransSI.disabled= true;
		x.TransSR.disabled= true;
		x.TransTR.disabled= true;
		x.TransPD.disabled= true;
		x.TransAD.disabled= true;
		x.TransSO.disabled= true;
	}

}

function SetPrintCost() {
	var x = document.form1;
	if (x.packitem.checked) {
		x.prtcost.checked  = false;
		x.prtcost.disabled = true;
	} else {
		x.prtcost.disabled = false;
	}
	
}
/*
function SelectGroupBy() {
	var x = document.form1;
	
	for (var i=0; i < document.form1.groupby.length; i++)
	{
		if (document.form1.groupby[i].checked)
		{
			var vargroupby = document.form1.groupby[i].value;
		}
	}

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

function SelectShowDetail() {
	var x = document.form1;

	if (x.showdetail.checked) {
		x.packitem.disabled = false;
		if (document.getElementById('byserial')) x.byserial.disabled = false;
	} else {
		x.packitem.checked  = false;
		x.packitem.disabled = true;
		if (document.getElementById('byserial')) x.byserial.checked  = false;
		if (document.getElementById('byserial')) x.byserial.disabled = true;
	}
}

function PrintPrev(printaccess)
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
		
	for (var i=0; i < document.form1.orderby.length; i++)
	{
		if (document.form1.orderby[i].checked)
		{
			var varorderby = document.form1.orderby[i].value;
		}
	}	 
  
	/*for (var i=0; i < document.form1.groupby.length; i++)
	{
		if (document.form1.groupby[i].checked)
		{
			var vargroupby = document.form1.groupby[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.zeroprint.length; i++)
	{
		if (document.form1.zeroprint[i].checked)
		{
			var varzeroprint = document.form1.zeroprint[i].value;
		}
	}
	
	for (var i=0; i < document.form1.itemprint.length; i++)
	{
		if (document.form1.itemprint[i].checked)
		{
			var varitemprint = document.form1.itemprint[i].value;
			
			
		}
	}

	//Getting Group By Levels 1 and 3
	vargroupby1   = document.form1.groupbylevel1value.value;
	vargroupby2   = document.form1.groupbylevel2value.value;
  	
	//Getting Assigngroupby Values for level 3
	var ob = document.form1.assigngroupby;
	var vargroupby3 = '';
	for (var i = 0; i < ob.options.length; i++) {
		if (vargroupby3.length > 0)
			vargroupby3 += ",";
			
		vargroupby3 += ob.options[i].value;
	}
  
	// If No Group By Option Selected
	if (vargroupby3 == '') vargroupby3 = 1;

	varprtqty = 0;
	if (document.form1.prtqty.checked)
		varprtqty = 1;
	vmaxexists = '';
	if (document.form1.maxexists.value != '')
		vmaxexists = document.form1.maxexists.value;
		
	varprtprice = 0;
	if (document.form1.prtprice.checked)	varprtprice = 1;
	varprtprice1 = 0;
	if (document.form1.prtprice1.checked)	varprtprice1 = 1;
	varprtprice2 = 0;
	if (document.form1.prtprice2.checked)	varprtprice2 = 1;
	varprtprice3 = 0;
	if (document.form1.prtprice3.checked)	varprtprice3 = 1;
	varprtprice4 = 0;
	if (document.form1.prtprice4.checked)	varprtprice4 = 1;
	varprtprice5 = 0;
	if (document.form1.prtprice5.checked)	varprtprice5 = 1;
		

	varprtcost = 0;
	if (document.form1.prtcost.checked) 
		varprtcost = 1;	 
		
	varprtlpprice = 0;
	if (document.getElementById('prtlpprice')) {
		if (document.form1.prtlpprice.checked) 
			varprtlpprice = 1;	 
	}
		
	varabvmax = 0;
	if (document.form1.abvmax.checked) 
		varabvmax = 1;	 
	
	varblwmin = 0;
	if (document.form1.blwmin.checked)
		varblwmin = 1;	
	
	varexistqty = 0;
	if (document.form1.existqty.checked) 
		varexistqty = 1;		
	
	varbooking=0;
	if (document.form1.booking.checked)
		varbooking = 1;
  
	varbyserial = 0;
	if (document.getElementById('byserial')) {
		if (document.form1.byserial.checked) 
			varbyserial = 1; 
	}	
	varshowunmove = 0;
	if (document.form1.showunmove.checked) 
		varshowunmove = 1; 	
		
	varshowunsold = 0;
	if (document.form1.showunsold.checked) 
		varshowunsold = 1; 
		
	varpackitem = 0;
	if (document.form1.packitem.checked)
		varpackitem = 1;
		
	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;	
		
	varshowweight = 0;
	if (document.form1.showweight.checked)
		varshowweight = 1;
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked)
			varshowunit2qty = 1;	
	}
	
	varshownegativeqty = 0;
	if (document.getElementById('shownegativeqty')) {
		if (document.form1.shownegativeqty.checked)
			varshownegativeqty = 1;	
	}
	
	varshowbarcode2 = 0;
	if (document.form1.showbarcode2.checked)
		varshowbarcode2 = 1;
		
	varnonstock = 0;
	if (document.form1.nonstock.checked)
		varnonstock = 1;
		
		
	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varshowdetail = 1;	
		
	varinvperwarehouse = 0;
	if (document.form1.invperwarehouse.checked)
		varinvperwarehouse = 1;
	varshowgroup = 0;
	if (document.form1.showgroup.checked)
		varshowgroup = 1;	
	varshowsubgroup = 0;
	if (document.form1.showsubgroup.checked)
		varshowsubgroup = 1;
	varshowcategory = 0;
	if (document.form1.showcategory.checked)
		varshowcategory = 1;
	varprtheader = 0;
	if (document.form1.prtheader.checked)    varprtheader = 1;
	
	vHtn = 0;
	if (document.form1.Htn)
	if (document.form1.Htn.checked) vHtn = 1;	
  
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = encodeURIComponent(document.form1.fromitem.value);
	vartoitem     = encodeURIComponent(document.form1.toitem.value);
	
	if(document.form1.fromheatno)
	varfromheatno   = document.form1.fromheatno.value;
	else
	varfromheatno   ='';
	
	if(document.form1.toheatno)
	vartoheatno     = document.form1.toheatno.value;
	else vartoheatno='';
	
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
	varfromgrp    = document.form1.fromgroup.value;
	vartogrp      = document.form1.togroup.value;
	varfromwrh    = document.form1.fromwarehouse.value;
	vartowrh      = document.form1.towarehouse.value;
	varfromcur    = document.form1.fromcur.value;
	varfromsubgrp = document.form1.fromsubgroup.value;
	vartosubgrp   = document.form1.tosubgroup.value;
	varfromcat    = document.form1.fromcategory.value;
	vartocat      = document.form1.tocategory.value;

	varfromsupplier   = document.form1.fromsupplier.value;
	vartosupplier     = document.form1.tosupplier.value;
	
	let frombatchno   = document.form1.frombatchno.value;
	let tobatchno     = document.form1.tobatchno.value;
	
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;

	let vprtLoc = 0;	
	if (document.getElementById('prtLoc').checked)	
	vprtLoc = 1;
	let vprtSelectedPeriod = 0;	
	if (document.getElementById('prtSelectedPeriod').checked)	
	vprtSelectedPeriod = 1;



	
	let vloc1 = '';	
	if (document.getElementById('loc1').value)
	vloc1 = document.getElementById('loc1').value;
	let vloc2 = '';	
	if (document.getElementById('loc2').value)
	vloc2 = 	document.getElementById('loc2').value;
	let vloc3 = '';	
	if (document.getElementById('loc3').value)
	vloc3 = 	document.getElementById('loc3').value;


	var vinventoryLite=0;
	if (document.getElementById('inventoryLite').checked)	
	vinventoryLite = 1;

	if(vinventoryLite == 1){
		str =   'Rep_InventoryLite.php?fromdate='+varfromdate;
	}
	else if (varinvperwarehouse == 1) {
		str =   'Rep_InventoryPerWarehouse.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&cur='+varcurrency+'&zeroprint='+varzeroprint+'&prtcost='+varprtcost+'&abvmax='+varabvmax+'&blwmin='+varblwmin
			   +'&showgroup='+varshowgroup+'&showsubgroup='+varshowsubgroup+'&showcategory='+varshowcategory+'&nonstock='+varnonstock
			   +'&orderby='+varorderby+'&fromcur='+varfromcur+'&showunmove='+varshowunmove+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&showunsold='+varshowunsold+'&itemprint='+varitemprint+'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch;
	} else {
		str =   'Rep_Inventory.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem+'&fromheatno='+varfromheatno+'&toheatno='+vartoheatno
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&cur='+varcurrency+'&zeroprint='+varzeroprint+'&abvmax='+varabvmax+'&blwmin='+varblwmin
			   +'&prtprice='+varprtprice+'&prtcost='+varprtcost+'&prtqty='+varprtqty+'&orderby='+varorderby
			   +'&fromcur='+varfromcur+'&existqty='+varexistqty+'&booking='+varbooking+'&byserial='+varbyserial+'&showunmove='+varshowunmove
			   +'&showweight='+varshowweight+'&packitem='+varpackitem+'&showdetail='+varshowdetail+'&showunit2qty='+varshowunit2qty+'&shownegativeqty='+varshownegativeqty
			   +'&groupby1='+vargroupby1+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&showbarcode2='+varshowbarcode2+'&nonstock='+varnonstock+'&prtprice1='+varprtprice1+'&prtprice2='+varprtprice2+'&prtprice3='+varprtprice3+'&vShowHeatno='+vHtn
			   +'&prtprice4='+varprtprice4+'&prtprice5='+varprtprice5+'&prtlpprice='+varprtlpprice+'&showunsold='+varshowunsold+'&itemprint='+varitemprint+'&prtheader='+varprtheader
			   +'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch+'&prtLoc='+vprtLoc+'&loc1='+vloc1+'&loc2='+vloc2+'&loc3='+vloc3+'&maxexists='+vmaxexists
			   +'&vselectedperiod='+vprtSelectedPeriod;
	}		   
		   
	if (printaccess==1)
		window.open(str);
	else
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function ExportExcel()
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
	
	x = document.form1;
		
	for (var i=0; i < document.form1.orderby.length; i++)
	{
		if (document.form1.orderby[i].checked)
		{
			var varorderby = document.form1.orderby[i].value;
		}
	}	 
  
	/*for (var i=0; i < document.form1.groupby.length; i++)
	{
		if (document.form1.groupby[i].checked)
		{
			var vargroupby = document.form1.groupby[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.zeroprint.length; i++)
	{
		if (document.form1.zeroprint[i].checked)
		{
			var varzeroprint = document.form1.zeroprint[i].value;
		}
	}
	
	for (var i=0; i < document.form1.itemprint.length; i++)
	{
		if (document.form1.itemprint[i].checked)
		{
			var varitemprint = document.form1.itemprint[i].value;
			
			
		}
	}
	
	//Getting Group By Levels 1 and 3
	vargroupby1   = document.form1.groupbylevel1value.value;
	vargroupby2   = document.form1.groupbylevel2value.value;
  
	//Getting Assigngroupby Values for level 3
	var ob = document.form1.assigngroupby;
	var vargroupby3 = '';
	for (var i = 0; i < ob.options.length; i++) {
		if (vargroupby3.length > 0)
			vargroupby3 += ",";
			
		vargroupby3 += ob.options[i].value;
	}
  
	// If No Group By Option Selected
	if (vargroupby3 == '') vargroupby3 = 1;

	varprtqty = 0;
	if (document.form1.prtqty.checked)
		varprtqty = 1;
	
	vmaxexists = '';
	if (document.form1.maxexists.value != '')
		vmaxexists = document.form1.maxexists.value;
		
		
	varprtprice = 0;
	if (document.form1.prtprice.checked)	varprtprice = 1;
	varprtprice1 = 0;
	if (document.form1.prtprice1.checked)	varprtprice1 = 1;
	varprtprice2 = 0;
	if (document.form1.prtprice2.checked)	varprtprice2 = 1;
	varprtprice3 = 0;
	if (document.form1.prtprice3.checked)	varprtprice3 = 1;
	varprtprice4 = 0;
	if (document.form1.prtprice4.checked)	varprtprice4 = 1;
	varprtprice5 = 0;
	if (document.form1.prtprice5.checked)	varprtprice5 = 1;

	varprtcost = 0;
	if (document.form1.prtcost.checked) 
		varprtcost = 1;	 
	
	varprtlpprice = 0;
	if (document.getElementById('prtlpprice')) {
		if (document.form1.prtlpprice.checked) 
			varprtlpprice = 1;	 
	}
		
	varabvmax = 0;
	if (document.form1.abvmax.checked) 
		varabvmax = 1;	 
	
	varblwmin = 0;
	if (document.form1.blwmin.checked)
		varblwmin = 1;	
	
	varexistqty = 0;
	if (document.form1.existqty.checked) 
		varexistqty = 1;		
	
	varbooking=0;
	if (document.form1.booking.checked)
		varbooking = 1;
  
	varbyserial = 0;
	if (document.getElementById('byserial')) {
		if (document.form1.byserial.checked) 
			varbyserial = 1; 
	}
	vardetailed = 0;
	if (document.form1.detailed.checked)
		vardetailed = 1;
		
	varshowunmove = 0;
	if (document.form1.showunmove.checked) 
		varshowunmove = 1; 	
		
	varshowunsold = 0;
	if (document.form1.showunsold.checked) 
		varshowunsold = 1; 

	varpackitem = 0;
	if (document.form1.packitem.checked)
		varpackitem = 1;	
	
	varshowdetail = 0;
	if (document.form1.showdetail.checked)
		varshowdetail = 1;	
		
	varshowweight = 0;
	if (document.form1.showweight.checked)
		varshowweight = 1;	
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked)
			varshowunit2qty = 1;	
	}
	
	varshowbarcode2 = 0;
	if (document.form1.showbarcode2.checked)
		varshowbarcode2 = 1;
		
	varnonstock = 0;
	if (document.form1.nonstock.checked)
		varnonstock = 1;
	
	//If No Group By Option Selected	
	if (vargroupby3 == 1 && vargroupby1 == '' && vargroupby2 == '')
		varshowdetail = 1;
		
	varinvperwarehouse = 0;
	if (document.form1.invperwarehouse.checked)
		varinvperwarehouse = 1;
	varshowgroup = 0;
	if (document.form1.showgroup.checked)
		varshowgroup = 1;	
	varshowsubgroup = 0;
	if (document.form1.showsubgroup.checked)
		varshowsubgroup = 1;
	varshowcategory = 0;
	if (document.form1.showcategory.checked)
		varshowcategory = 1;	
		
	varshownegativeqty = 0;
	if (document.getElementById('shownegativeqty')) {
		if (document.form1.shownegativeqty.checked)
			varshownegativeqty = 1;	
	}

	
	
	varTransPI = 0; varTransPR = 0; varTransSI = 0; varTransSR = 0; 
	varTransTR = 0; varTransPD = 0; varTransAD = 0; varTransSO = 0;
	if (x.TransPI.checked) varTransPI = 1;
	if (x.TransPR.checked) varTransPR = 1;
	if (x.TransSI.checked) varTransSI = 1;
	if (x.TransSR.checked) varTransSR = 1;
	if (x.TransTR.checked) varTransTR = 1;
	if (x.TransPD.checked) varTransPD = 1;
	if (x.TransAD.checked) varTransAD = 1;	
	if (x.TransSO.checked) varTransSO = 1;	
		
	varfromdate  = document.form1.fromdate.value;
	vartodate    = document.form1.todate.value;
	varfromitem  = encodeURIComponent(document.form1.fromitem.value);
	vartoitem    = encodeURIComponent(document.form1.toitem.value);
	varfromprj   = document.form1.fromproject.value;
	vartoprj     = document.form1.toproject.value;
	varfromcst   = document.form1.fromcostcent.value;
	vartocst     = document.form1.tocostcent.value;
	varfromgrp   = document.form1.fromgroup.value;
	vartogrp     = document.form1.togroup.value;
	varfromwrh   = document.form1.fromwarehouse.value;
	vartowrh     = document.form1.towarehouse.value;
	varfromcur   = document.form1.fromcur.value;
	varfromtranswh  = document.form1.fromtranswh.value;
	vartotranswh    = document.form1.totranswh.value;
	varfromsubgrp   = document.form1.fromsubgroup.value;
	vartosubgrp     = document.form1.tosubgroup.value;
	varfromcat      = document.form1.fromcategory.value;
	vartocat        = document.form1.tocategory.value;

	varfromsupplier   = document.form1.fromsupplier.value;
	vartosupplier     = document.form1.tosupplier.value;
	
	let frombatchno   = document.form1.frombatchno.value;
	let tobatchno     = document.form1.tobatchno.value;
	
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;
  
	RepName = 'Exp_Inventory.php';
    if (vardetailed == 1)   RepName = 'Exp_InventoryDetail.php';
	

	
	let vprtLoc = 0;	
	if (document.getElementById('prtLoc').checked)	
	vprtLoc = 1


	let vprtSelectedPeriod = 0;	
	if (document.getElementById('prtSelectedPeriod').checked)	
	vprtSelectedPeriod = 1;


	var vinventoryLite=0;
	if (document.getElementById('inventoryLite').checked)	
	vinventoryLite = 1;

	if(vinventoryLite == 1){
		str =   'Rep_InventoryLite.php?exp=1&fromdate='+varfromdate;
	}
	else 
	if (varinvperwarehouse == 1) {
		str =   'Exp_InventoryPerWarehouse.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&cur='+varcurrency+'&zeroprint='+varzeroprint+'&prtcost='+varprtcost+'&abvmax='+varabvmax+'&blwmin='+varblwmin
			   +'&showgroup='+varshowgroup+'&showsubgroup='+varshowsubgroup+'&showcategory='+varshowcategory+'&nonstock='+varnonstock
			   +'&orderby='+varorderby+'&fromcur='+varfromcur+'&showunmove='+varshowunmove+'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier
			   +'&showunsold='+varshowunsold+'&itemprint='+varitemprint+'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch;
	} else {
		str =   RepName+'?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat
			   +'&cur='+varcurrency+'&zeroprint='+varzeroprint+'&abvmax='+varabvmax+'&blwmin='+varblwmin
			   +'&prtprice='+varprtprice+'&prtcost='+varprtcost+'&prtqty='+varprtqty+'&orderby='+varorderby
			   +'&fromcur='+varfromcur+'&existqty='+varexistqty+'&booking='+varbooking+'&byserial='+varbyserial+'&showunmove='+varshowunmove+'&shownegativeqty='+varshownegativeqty
			   +'&showweight='+varshowweight+'&packitem='+varpackitem+'&showdetail='+varshowdetail+'&fromtranswh='+varfromtranswh+'&totranswh='+vartotranswh
			   +'&TransPI='+varTransPI+'&TransPR='+varTransPR+'&TransSI='+varTransSI+'&TransSR='+varTransSR+'&TransTR='+varTransTR
			   +'&TransPD='+varTransPD+'&TransAD='+varTransAD+'&TransSO='+varTransSO+'&showunit2qty='+varshowunit2qty+'&groupby1='+vargroupby1+'&groupby2='+vargroupby2+'&groupby3='+vargroupby3
			   +'&fromsupplier='+varfromsupplier+'&tosupplier='+vartosupplier+'&showbarcode2='+varshowbarcode2+'&nonstock='+varnonstock+'&prtprice1='+varprtprice1+'&prtprice2='+varprtprice2
			   +'&prtprice3='+varprtprice3+'&prtprice4='+varprtprice4+'&prtprice5='+varprtprice5+'&prtlpprice='+varprtlpprice+'&showunsold='+varshowunsold+'&itemprint='+varitemprint
			   +'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch+'&prtLoc='+vprtLoc+'&maxexists='+vmaxexists
			   +'&vselectedperiod='+vprtSelectedPeriod;
	}		   
		   
	window.open(str);
	
}

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 showlistgroup(str){
	window.open('list_grouping.php?str='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
 
function showlistsubgroup(str){
	window.open('list_subgroup.php?str='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
 
function showlistCategory(str){
	window.open('list_categories.php?str='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
 
 
function showlistProjects(str){
	window.open('List_Project_orderbycode.php?str='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
} 
function showlistwarehouses(str){
	window.open('List_Warehouses.php?str='+str,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
} 
function showlistcostcent(str){
	window.open('List_CostCenter_orderbycode.php?str='+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){
	
	var x = document.form1;
	varfromitem   = encodeURIComponent(document.form1.fromitem.value);
	vartoitem     = encodeURIComponent(document.form1.toitem.value);
	
	if(str==1){
		vItem_Code = document.form1.fromitem.value;
		vPItem_Description = x.fromitemdesc.value;
	}
	if(str==2){
		vItem_Code = document.form1.toitem.value;
		vPItem_Description = x.toitemdesc.value;
	}

	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 showListBatch(index){
	window.open("List_BatchNo.php?frm=14&index="+index+"&PItem_Code=&PWarehouseCode=","Batch No","width=800px,height=600px");
}
-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inventory</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'>Inventory</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='clearbtn' name='clearbtn'  title='Clear Page'><span><span>Clear</span></span></button>";
	
	echo"<button type='button' id='preview' name='preview'  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='20%' 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='12%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo"   <td width='15%' height='19' colspan='1' align='center' bgcolor='#F5F5F5'><span class='style8'>Order By </span></td>";
echo"   <td width='30%' height='19' align='center' bgcolor='#F5F5F5' colspan='1'><span class='style8'>Existing Quantities Options </span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5' colspan='1'><span class='style8'>Items</span></td>";
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='15%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate' value='$fromdate' maxlength='10' size='10'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.fromdate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
echo"   <td width='18%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value='currency1'>Currency</label></span>";
echo"      <span class='style8'><select name='fromcur' id='fromcur'>";
		echo"<option></option>";
		while($curf=mysql_fetch_row($resultcurrency)){
		echo"<option ";
			if ($fromcur==$curf[0])
				echo " selected ";
		echo" value='$curf[0]'>$curf[0] </option>";
		}
		echo"</select></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='12%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span>";		
echo"   </td>";

echo"   <td width='15%' colspan='1' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        if ($orderby=="1" || $orderby=="")
           echo "<input name='orderby' type='radio' value='1' checked />";
		else	
		   echo "<input name='orderby' type='radio' value='1' />";
		echo "List by Code</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($orderby=="2" )
           echo "<input name='orderby' type='radio' value='2' checked />";
		else	
		   echo "<input name='orderby' type='radio' value='2' />";
		echo "List by Description</label></span></td>";   		
		
echo"   <td width='30%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        if ($zeroprint=="1" )
           echo "<input name='zeroprint' type='radio' value='1' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='1' />";
		echo "Zero Quantities</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($zeroprint=="2")
           echo "<input name='zeroprint' type='radio' value='2' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='2' />";
		echo "Without Zero Quantities</label></span>";   		
echo"   <br><span class='style8'><label>";
        if ($zeroprint=="3" || $zeroprint=="")
           echo "<input name='zeroprint' type='radio' value='3' checked />";
		else	
		   echo "<input name='zeroprint' type='radio' value='3' />";
		echo "All</label></span></td>";   				

echo"   <td width='15%' rowspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
        if ($itemprint=="0" )
           echo "<input name='itemprint' id='itemprint[0]' type='radio' value='0' checked />";
		else	
		   echo "<input name='itemprint' id='itemprint[0]' type='radio' value='0' />";
		echo "Not Printed</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($itemprint=="1")
           echo "<input name='itemprint' id='itemprint[1]' type='radio' value='1' checked />";
		else	
		   echo "<input name='itemprint' id='itemprint[1]' type='radio' value='1' />";
		echo "Printed </label></span>";   		
echo"   <br><span class='style8'><label>";
        if ($itemprint=="2" || $itemprint=="")
           echo "<input name='itemprint' id='itemprint[2]' type='radio' value='2' checked />";
		else	
		   echo "<input name='itemprint' id='itemprint[2]' type='radio' value='2' />";
		echo "All</label></span></td>";   		
				
echo" </tr>";

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

echo" <tr>";
echo"   <td colspan='7' valign='top' bgcolor='#F5F5F5'>";
echo" 	<table border='0' align='left' width='90%' cellpadding=0 cellspacing=1>";
echo"   <tr><td width='30%' valign='top' bgcolor='#F5F5F5'>";
echo"		<select name='availgroupby' multiple='multiple' size='8' style='width:250px;'>    
				<option value='20' name='Transaction Project(Parent)'>Transaction Project(Parent)</option>
				<option value='4' name='Transaction Project(Detail)'>Transaction Project(Detail)</option>
				<option value='21' name='Project(Parent)'>Project(Parent)</option>
				<option value='5' name='Project(Detail)'>Project(Detail)</option>
				<option value='22' name='Transaction Costcenter(Parent)'>Transaction Costcenter(Parent)</option>
				<option value='6' name='Transaction Costcenter(Detail)'>Transaction Costcenter(Detail)</option>
				<option value='23' name='Costcenter(Parent)'>Costcenter(Parent)</option>
				<option value='7' name='Costcenter(Detail)'>Costcenter(Detail)</option>
				<option value='24' name='Warehouse(Parent)'>Warehouse(Parent)</option>
				<option value='8' name='Warehouse(Detail)'>Warehouse(Detail)</option>
				<option value='25' name='Group(Parent)'>Group(Parent)</option>
				<option value='10' name='Group(Detail)'>Group(Detail)</option>
				<option value='26' name='Subgroup(Parent)'>Subgroup(Parent)</option>
				<option value='11' name='Subgroup(Detail)'>Subgroup(Detail)</option>
				<option value='12' name='Category'>Category</option>
				<option value='13' name='Supplier'>Supplier</option>
			</select>";
echo"   </td>";

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

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

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

echo" </tr>";

echo" <tr>";	  
//echo"   <td width='38%' colspan='3' align='left' bgcolor='#F5F5F5'><span class='style8'><label>";
//echo"   <td width='12%'  align='left' bgcolor='#F5F5F5'><span class='style8'>Group By</span></td> ";
echo"   <td colspan='4' align='left' bgcolor='#F5F5F5'><span class='style8'>Options</span></td>";
echo"   <td colspan='2'  align='left' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input type='checkbox' name='invperwarehouse' id='invperwarehouse' value='1' />Inventory Per Warehouse</label></span></td>";
echo"   <td width='25%'  align='left' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='detailed' type='checkbox' id='detailed' value='1' onclick='EnableDetailedOptions()'/> Detailed Inventory(Excel)</label></span></td>";
echo" </tr>";

$ShowCostMode  = '';
$ShowCostCheck = 'checked';
if($FI_ShowCostPrice == 0)  {
	$ShowCostMode  = 'disabled';	
	$ShowCostCheck = 'unchecked';	
}

echo" <tr>";
echo"   <td width='20%' colspan='2' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='prtprice' type='checkbox' id='prtprice' value='1' checked />Print Selling Price</label></span>";
echo"   <br>&nbsp;<span class='style8'><label>";
echo"      <input name='prtprice1' type='checkbox' id='prtprice1' value='1' checked />I</label></span>";
echo"   <span class='style8'><label>";
echo"      <input name='prtprice2' type='checkbox' id='prtprice2' value='1' />II</label></span>";
echo"   <span class='style8'><label>";
echo"      <input name='prtprice3' type='checkbox' id='prtprice3' value='1' />III</label></span>";
echo"   <span class='style8'><label>";
echo"      <input name='prtprice4' type='checkbox' id='prtprice4' value='1' />IV</label></span>";
echo"   <span class='style8'><label>";
echo"      <input name='prtprice5' type='checkbox' id='prtprice5' value='1' />V</label></span>";


echo"   <br><span class='style8'><label>";
echo"      <input name='prtcost' type='checkbox' id='prtcost' value='1' $ShowCostCheck  $ShowCostMode />Print Mean Cost</label></span>";

if ($FI_ShowCostPrice == 1) {
	echo"   <br><span class='style8'><label>";
	echo"      <input name='prtlpprice' type='checkbox' id='prtlpprice' value='1' />Print Last Purchase Price</label></span>";
} else {echo"      <input name='prtlpprice' type='hidden' id='prtlpprice' value='0' /></label></span>";}

echo"   <br><span class='style8'><label>";
echo"      <input name='prtqty' type='checkbox' id='prtqty' value='1' checked/>Print Quantity</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='packitem' type='checkbox' id='packitem' value='1' onclick='SetPrintCost();' />Packed Item</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='showdetail' type='checkbox' id='showdetail' value='1' checked onclick='SelectShowDetail();'/>Show Details</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='nonstock' type='checkbox' id='nonstock' value='1' />Show Non Stock</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='abvmax' type='checkbox' id='abvmax' value='1' />Above Maximum</label></span>";	
echo"   <br><span class='style8'><label>";
echo"      <input name='blwmin' type='checkbox' id='blwmin' value='1' />Below Minimum</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='inventoryLite' type='checkbox' id='inventoryLite' value='1' />Lite Version</label></span>";
echo "	</td>";   		
		
echo"   <td width='30%' colspan='2' valign='top' bgcolor='#F5F5F5'>";
echo"   <span class='style8'><label>";
echo"      <input name='existqty' type='checkbox' id='existqty' value='1' />Show Existing Quantity Only</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='booking' type='checkbox' id='booking' value='0' />Show Booking Quantity</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='showunmove' type='checkbox' id='showunmove' value='1' />Show Unmoved Items</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input name='showunsold' type='checkbox' id='showunsold' value='1' />Show Unsold Items</label></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='showbarcode2' type='checkbox' id='showbarcode2' value='1' />Show Bracode2</label></span>";

if ($Module_DoubleUnit == 1) {
	echo"   <br><span class='style8'><label>";
	echo"      <input name='showunit2qty' type='checkbox' id='showunit2qty' value='1' />Show Unit2 Qty</label></span>";
}

	echo"   <br><span class='style8'><label>";
	echo"      <input name='shownegativeqty' type='checkbox' id='shownegativeqty' value='1' />Show Negative Qty Only</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><br>";
if ($Module_BatchNo == 1)
echo"      <input type='checkbox' name='showbatch' id='showbatch' value='1'  unchecked />Show Batch No</label><br>";
else echo"      <input type='hidden' name='showbatch' id='showbatch' value='0'  unchecked /> "; 	
echo"      <label><input type='checkbox' name='prtLoc' id='prtLoc' value='1'  />show Location</label><br>";
echo"      <label><input type='checkbox' name='prtSelectedPeriod' id='prtSelectedPeriod' value='1'  />for selected period</label><br>";

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

echo"   <td width='25%' colspan='2' valign='top' bgcolor='#F5F5F5'>";
echo"	   <span class='style8'><label>";
echo"      &nbsp;<label><input type='checkbox' name='showgroup' id='showgroup' value='1' checked />Show Group</label><br>";
echo"      &nbsp;<label><input type='checkbox' name='showsubgroup' id='showsubgroup' value='1' checked />Show SubGroup</label><br>";
echo"      &nbsp;<label><input type='checkbox' name='showcategory' id='showcategory' value='1' checked />Show Category</label><br>";
echo"      &nbsp;<label>Show Qty Exists less than </label><br>";
echo"      &nbsp;<label><input type='number' name='maxexists' id='maxexists'  /> </label></span><br>";

if($Module_Heatno == 1)	
	echo"    <span class='style8'>&nbsp;<label><input type='checkbox' name='Htn' id='Htn' value='Htn' checked/>Show HeatNo</span></label>";
	echo"<br>";
	echo"<br>";
	
if ($Module_SerialNo == 1) {
	echo"	   <span class='style8'><label>";
	echo"      <input type='checkbox' name='byserial' id='byserial' value='1'";
				   echo isset($byserial)?"checked":'';  echo "/>";
	echo"      By Serial No.</label></span>";
	echo"   <br><div id='left' style='position:relative; top:5px; width:230px; float:left; border-width:1px; border-style:dotted; border-color:black;'>";
	echo"      <table border='0' align='left' width='100%' cellspacing='0'>";
	echo"          <tr><td align='left'><span class='style8'><label>SerialNo:</label></span></td>";
	echo"          	   <td align='left'> <input type='text' name='fromserial' id='fromserial' size='20' value='".$fromserial."' /> </td></tr>";
	echo"          <tr><td align='center' colspan='2'> <button type='button' id='serialavail' name='serialavail'  onClick='CheckSerialAvailable();return false;' title='Check Serial Availability'><span><span>Check Availability</span></span></button>
			</td></tr>";
	echo"      </table></div>";
}
echo"   </td>";

echo"   <td width='25%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <label><input type='checkbox' name='alltrans' id='alltrans' value='1' onclick='SelectTransOption();' checked disabled/>All Movement Options</label>";

echo"   <div id='main' style='position:relative; left:5px; top:0px; width:260px; height:80px;'>";
echo"   <div id='left' style='position:relative; top:0px; width:150px; float:left; border-width:0px; border-style:dotted; border-color:black;'>";
 
if ($Module_Grn == 1)
	echo"  <label><input type='checkbox' name='TransPI' id='TransPI' value='GRN' checked disabled/>Good Receive Note</label><br>";
else 
	echo"  <label><input type='checkbox' name='TransPI' id='TransPI' value='PI' checked disabled/>Purchase</label><br>";
	
echo"      <label><input type='checkbox' name='TransPR' id='TransPR' value='PR' checked disabled/>Return Purchase</label><br>";

if ($Module_Delivery == 0) {
	echo"  <label><input type='checkbox' name='TransSI' id='TransSI' value='SI' checked disabled/>Sales</label><br>";
	echo"  <label><input type='checkbox' name='TransSR' id='TransSR' value='SR' checked disabled/>Return Sales</label><br>";
} else {
	echo"  <label><input type='checkbox' name='TransSI' id='TransSI' value='DI' checked disabled/>Delivery</label><br>";
	echo"  <label><input type='checkbox' name='TransSR' id='TransSR' value='DR' checked disabled/>Return Delivery</label><br>";
}
echo"   </div>";

echo"   <div id='right' style='position:absolute; left:5px; top:0px; width:100px; float:right; margin-left: 155px; border-width:0px; border-style:dotted; border-color:black;'>";
echo"      <label><input type='checkbox' name='TransTR' id='TransTR' value='TR' checked disabled/>Transfer</label><br>";
echo"      <label><input type='checkbox' name='TransPD' id='TransPD' value='PD' checked disabled/>Production</label><br>";
echo"      <label><input type='checkbox' name='TransAD' id='TransAD' value='AD' checked disabled/>Adjustment</label><br>";
echo"      <label><input type='checkbox' name='TransSO' id='TransSO' value='SO' checked disabled/>Sales Order</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>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Item Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Group Code</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='3' 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='30' value='".$fromitemdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...'  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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='fromgroup' type='text' id='fromgroup' size='12' value='".$fromgroup."' />
		<input name='fromgroup_name' type='text' id='fromgroup_name' size='30' value='".$fromgroup_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  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='showlistgroup(17); '><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='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toitem' type='text' id='toitem' size='12' value='".$toitem."' />
        <input name='toitemdesc' type='text' id='toitemdesc' size='30' value='".$toitemdesc."' />
        <input name='btncode2' type='hidden' id='btncode2' 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='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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='togroup' type='text' id='togroup' size='12' value='".$togroup."' />
		<input name='togroup_name' type='text' id='togroup_name' size='30' value='".$togroup_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Group to' />
		</label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item From ' 
				onClick='showlistgroup(18); '><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>";



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>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Item SubGroup</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Item Category</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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='fromsubgroup' type='text' id='fromsubgroup' size='12' value='".$fromsubgroup."' />
		<input name='fromsubgroup_name' type='text' id='fromsubgroup_name' size='30' value='".$fromsubgroup_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Group to' />
		</label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item From ' 
				onClick='showlistsubgroup(13); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='fromcategory' type='text' id='fromcategory' size='12' value='".$fromcategory."' />
		<input name='fromcategory_name' type='text' id='fromcategory_name' size='30' value='".$fromcategory_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  from' />
		</label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
				onClick='showlistCategory(11); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='tosubgroup' type='text' id='tosubgroup' size='12' value='".$tosubgroup."' />
		<input name='tosubgroup_name' type='text' id='tosubgroup_name' size='30' value='".$tosubgroup_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Group to' />
		</label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
				onClick='showlistsubgroup(14); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
		<input name='tocategory' type='text' id='tocategory' size='12' value='".$tocategory."' />
		<input name='tocategory_name' type='text' id='tocategory_name' size='30' value='".$tocategory_name."' />
		<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
		</label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
				onClick='showlistCategory(12); '><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='4' bgcolor='#F5F5F5'><span class='style8'>Project Code</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Warehouse</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' bgcolor='#F5F5F5' ><span class='style8'>";
        echo"   <label>
                <input name='fromproject' type='text' id='fromproject' size='12' value='".$fromproject."' />
                <input name='fromproject_name' type='text' id='fromproject_name' size='30' value='".$fromproject_name."' />
                <input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
                </label>
                </span>
                <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
                        onClick='showlistProjects(31); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
        echo"   <label>
                <input name='fromwarehouse' type='text' id='fromwarehouse' size='12' value='".$fromwarehouse."' />
                <input name='fromwarehouse_name' type='text' id='fromwarehouse_name' size='30' value='".$fromwarehouse_name."' />
                <input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
                </label>
                </span>
                <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
                        onClick='showlistwarehouses(22); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> 
                </td>";

echo" </tr>";

echo" <tr>
<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
<input name='toproject' type='text' id='toproject' size='12' value='".$toproject."' />
<input name='toproject_name' type='text' id='toproject_name' size='30' value='".$toproject_name."' />
<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
</label>
</span>
<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
        onClick='showlistProjects(32); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
<input name='towarehouse' type='text' id='towarehouse' size='12' value='".$towarehouse."' />
<input name='towarehouse_name' type='text' id='towarehouse_name' size='30' value='".$towarehouse_name."' />
<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
</label>
</span>
<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
        onClick='showlistwarehouses(23); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> 
</td>";

echo" </tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>CostCenter Code</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Transfer Warehouse</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' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromcostcent' type='text' id='fromcostcent' size='12' value='".$fromcostcent."' />
        <input name='fromcostcent_name' type='text' id='fromcostcent_name' size='30' value='".$fromcostcent_name."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
        </label>
        </span>
        <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
                onClick='showlistcostcent(11); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
<input name='fromtranswh' type='text' id='fromtranswh' size='12' value='".$fromtranswh."' />
<input name='fromtranswh_name' type='text' id='fromtranswh_name' size='30' value='".$fromtranswh_name."' />
<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
</label>
</span>
<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
        onClick='showlistwarehouses(24); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> 
</td>";

echo" </tr>";

echo" <tr>
<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='tocostcent' type='text' id='tocostcent' size='12' value='".$tocostcent."' />
        <input name='tocostcent_name' type='text' id='tocostcent_name' size='30' value='".$tocostcent_name."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
        </label>
        </span>
        <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
                onClick='showlistcostcent(12); '><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='3' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
<input name='totranswh' type='text' id='totranswh' size='12' value='".$totranswh."' />
<input name='totranswh_name' type='text' id='totranswh_name' size='30' value='".$totranswh_name."' />
<input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Category  to' />
</label>
</span>
<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Sub group  to ' 
        onClick='showlistwarehouses(25); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> 
</td>";				 		
echo" </tr>";


echo" <tr height=18><td colspan='7'>&nbsp;</td></tr>";
echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Supplier</span></td>";
echo"<td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Location</span></td>";
echo"</tr>";
echo" <tr>
	  <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
      <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>
	  <label>
        <input name='fromsupplier' type='text' id='fromsupplier' size='15' value='";
		
		echo $_POST['fromsupplier']; echo"' />";
echo"   <input name='fromsuppdesc' type='text' id='fromsuppdesc' size='30' value='";

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

	  </td>";
echo"<td  width='5%' > <span class='style8'># 1</span></td> 
<td colspan='3' bgcolor='#F5F5F5'> 
  <input name='loc1' type='text' id='loc1' size='30' value='' style='width:300px;'>
  
  <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Location 1' onClick='showlistlocations(1);' ><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
  <td>";
	  
echo"	  </tr>";

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


echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo"	<td  width='5%' > <span class='style8'># 3</span></td> 
	  <td colspan='3' bgcolor='#F5F5F5'> 
		<input name='loc3' type='text' id='loc3' size='30' value='' style='width:300px;'>
		
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Location 3' onClick='showlistlocations(3);' ><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
		<td>";
	  echo"</tr>";

if ($Module_BatchNo == 1)
echo" <tr>
		<td colspan='7' bgcolor='#F5F5F5'><span class='style8'>Batch No</span></td>
	</tr>
	<tr>
		<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='frombatchno' id='frombatchno' value='$frombatchno' style='width:380px;' >
			<img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showListBatch('1');\"  /></span></label>
		</td>
	</tr>
	<tr>
		<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='tobatchno' id='tobatchno' value='$tobatchno' style='width:380px;' >
			<img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showListBatch('2');\"  /></span>
		</td
	 </tr>
	 <tr>
		<td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>
	</tr>";
else echo "<input type='hidden' name='frombatchno' id='frombatchno' value=''><input type='hidden' name='tobatchno' id='tobatchno' value='' >";	
 /*   <tr>
      <td colspan='7' 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 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");
}
	  
?>