<?php

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

include("config.inc.php");

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


if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}
$querylog="SELECT RI_SatementofItems 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_ReferenceByCostcenter,0) As module_ReferenceByCostcenter,".
			 " ifNull(Module_Delivery,0) As Module_Delivery, ifNull(Module_Grn,0) As Module_Grn, ifNull(Module_SerialNo,0) As Module_SerialNo ,Ifnull(Module_RestrictProjectReport,0) as Module_RestrictProjectReport ".
             " ,ifNull(Module_Heatno,0) As Module_Heatno, IfNull(module_expiredate,0) As module_expiredate,   ".
			 " 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);
}

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


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


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


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



$querylog="SELECT  language 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);
	}



$querylang="select language, buttonclear, save, print, find, clear, results, page, search, pending from ".$_SESSION['dbLabel'].".buttons_label 
where language='$language'";


$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
   extract($rows);
		
 
		
	}
	
	
$querylang="select

`Language`, clear, preview, exportexcel, `Date`, Currency Currencyalias, Options, AllMovementOptions, `From`, PrintPrice, Purchase, Transfer, ShowProject, `To`, UpdatedMeanCost, ReturnPurchase, Production, ShowCostcenter, ShowTransactionRemainingValues, Sales, Adjustment, ShowReportHeader, ReturnSales, ProductionRequest, Periods, ItemCodeDescription, TransferWarehouse, ItemGroup, ItemSubGroup, ItemCategory, Warehouse, Project, CostCenter


 from ".$_SESSION['dbLabel'].".report_inventory_label 
where language='$language'";

$_SESSION['sessionlang'] = $querylang;

$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
          extract($rows);
	}
	
	
	

$query_navigator = "SELECT LANGUAGE,
       ClearPage,
       Excel,
       Save,
       Print,
       Addd,
       Search,
       Pending,
       CopyJV,
       PaymentRequests,
       ExportExcel,
	   cancell,
	   Preview
FROM ".$_SESSION['dbLabel'].".mainform_label
WHERE LANGUAGE = '".$Language."'";
$result_navigator = mysql_query($query_navigator, $connection);
$row_navigator    = mysql_fetch_array($result_navigator);
extract($row_navigator);

	
$query_language  = "select user_account, Language from ".$_SESSION['dbLabel'].".login  where user_account = '".$_SESSION['useraccount']."'";
$result_language = mysql_query($query_language, $connection); 
$row_language    = mysql_fetch_array($result_language);
extract($row_language);

$query_field26  = "select clear,preview,export_excel,currency,statement_items

From ".$_SESSION['dbLabel'].".tranlate_label
where Language = '".$Language."'"; 
$result_field26 = mysql_query($query_field26, $connection); 
$row_field26    = mysql_fetch_array($result_field26);
extract($row_field26);	
	
	
	
	
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 type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->

<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>


<link type="text/css" href="js/calendar/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="js/calendar/jquery.datepick.js"></script>

<link type="text/css" href="js/grid/scripts/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="js/grid/scripts/jquery-ui.min.js"></script>

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


all = 0;  // 0 means 'no', 1 means 'yes'



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;
		}
	}
	 
	
	varsearchserial = 0;
	if (document.getElementById('searchserial')) {
		if (x.searchserial.checked) varsearchserial = 1;	 
	}
	
	varprtcost = 0;
	if (x.prtcost.checked) varprtcost = 1;	 

	varupdmeancost = 0;
	if (x.updmeancost.checked) varupdmeancost = 1;
	
	vPrj = 0;
	if (x.Prj)
	if (x.Prj.checked) vPrj = 1;
	
	vCst = 0;
	if (x.Cst)
	if (x.Cst.checked) vCst = 1;
	
	vHtn = 0;
	if (x.Htn)
	if (x.Htn.checked) vHtn = 1;
	
	varshowserials = 0;
	if (document.getElementById('showserials')) {
		if (x.showserials.checked) varshowserials = 1;
	}	
		
	varTransPI = 0; varTransPR = 0; varTransSI = 0; varTransSR = 0; 
	varTransTR = 0; varTransPD = 0; varTransAD = 0; varTransPRT = 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.TransPRT.checked) varTransPRT = 1;
	 
  
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromitem   = encodeURIComponent(x.fromitem.value);
	vartoitem     = encodeURIComponent(x.toitem.value);
	varfromwrh    = x.fromwhcode.value;
	//+' | '+x.fromwhdesc.value;
	vartowrh      = x.towhcode.value;
	//+' | '+x.towhdesc.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;
	varfromtranswh  = x.fromtranswh.value;
	vartotranswh    = x.totranswh.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
  
	let frombatchno   = x.frombatchno.value;
	let tobatchno     = x.tobatchno.value;
	
  if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
	}
	
	if(x.fromheatno)
	varfromheatno   = x.fromheatno.value;
	else
	varfromheatno   = '';
	
	if(x.toheatno)
	vartoheatno     = x.toheatno.value;
	else vartoheatno='';
	
	var showTransValue = 0;
	if(document.getElementById('showTransValue').checked)
		showTransValue = 1;
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;

	let vshowUser = 0;	
	if (document.getElementById('showUser').checked)	
	vshowUser = 1;

	str =   'Rep_StatementofItems.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&fromheatno='+varfromheatno+'&toheatno='+vartoheatno
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh+'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp
		   +'&fromcategory='+varfromcat+'&tocategory='+vartocat+'&fromtranswh='+varfromtranswh+'&totranswh='+vartotranswh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&prtcost='+varprtcost+'&updmeancost='+varupdmeancost+'&searchserial='+varsearchserial+'&TransPI='+varTransPI+'&TransPR='+varTransPR
		   +'&TransSI='+varTransSI+'&TransSR='+varTransSR+'&TransTR='+varTransTR+'&TransPD='+varTransPD+'&TransAD='+varTransAD+'&TransPRT='+varTransPRT+'&curr='+varcurrency+'&vShowProject='+vPrj
		   +'&vShowCostcenter='+vCst+'&vShowHeatno='+vHtn +'&showserials='+varshowserials+'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk+'&showTransValue='+showTransValue
		   +'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch+'&showUser='+vshowUser;
		   
		   
	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 kdItem(choice,e,app)
{   
	 x = document.form1;
	if(app==0){
		var clientcode = x.fromitem.value;
		if(clientcode=='')
		var clientcode = x.fromitemdesc.value;
	} else {
		var clientcode = x.toitem.value;
		if(clientcode=='')
		var clientcode = x.toitemdesc.value;
	}	
    var intKey = (window.Event) ? e.which : e.keyCode;
	
		
    if (intKey == 13) { //enter key
	
	
		var xmlhttp = getXMLHttpRequest();	
		
		
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				 
									
						
						if(app==0){ 
						if(data[1]!=''){
								x.fromitem.value = data[1];
								x.fromitemdesc.value = data[2];
									if(x.toitem.value==''){
									x.toitem.value = data[1];
									x.toitemdesc.value = data[2];
									
									}
						}
						else {
								showlistitem(1);
								
							}	
					} else {
						if(data[1]!=''){
								x.toitem.value = data[1];
								x.toitemdesc.value = data[2];
						}
						else showlistitem(2);						
					}
					
					
					 
			}
		}
	    
		xmlhttp.open("GET","Form_statementofitems_action.php?mode=getitem&clientcode="+clientcode+"&choice="+choice);
		xmlhttp.send();
	
      
			
			
    }
	
	
  


}


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;
		}
	}
	 
	
	varsearchserial = 0;
	if (document.getElementById('searchserial')) {
		if (x.searchserial.checked) varsearchserial = 1;	 
	}
	
	varprtcost = 0;
	if (x.prtcost.checked) varprtcost = 1;	 

	varupdmeancost = 0;
	if (x.updmeancost.checked) varupdmeancost = 1;
	
	varshowserials = 0;
	if (document.getElementById('showserials')) {
		if (x.showserials.checked) varshowserials = 1;
	}
	
	vPrj = 0;
	if (x.Prj)
	if (x.Prj.checked) vPrj = 1;
	
	vCst = 0;
	if (x.Cst)
	if (x.Cst.checked) vCst = 1;
	
	vHtn = 0;
	if (x.Htn)
	if (x.Htn.checked) vHtn = 1;
	
	varTransPI = 0; varTransPR = 0; varTransSI = 0; varTransSR = 0; 
	varTransTR = 0; varTransPD = 0; varTransAD = 0; varTransPRT=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.TransPRT.checked) varTransPRT = 1; 
  
	varfromdate   = x.fromdate.value;
	vartodate     = x.todate.value;
	varfromitem   = encodeURIComponent(x.fromitem.value);
	vartoitem     = encodeURIComponent(x.toitem.value);
	varfromwrh    = x.fromwhcode.value;
	//+' | '+x.fromwhdesc.value;
	vartowrh    = x.towhcode.value;
	//+' | '+x.towhdesc.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;
	varfromtranswh  = x.fromtranswh.value;
	vartotranswh    = x.totranswh.value;
	varfromprj    = x.fromproject.value;
	vartoprj      = x.toproject.value;
	varfromcst    = x.fromcostcent.value;
	vartocst      = x.tocostcent.value;
	let frombatchno   = x.frombatchno.value;
	let tobatchno     = x.tobatchno.value;
	
	 if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
	}
	
	if(x.fromheatno)
	varfromheatno   = x.fromheatno.value;
	else
	varfromheatno   = '';
	
	if(x.toheatno)
	vartoheatno     = x.toheatno.value;
	else vartoheatno='';
	
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;

	str =   'Exp_StatementofItems.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+'&fromtranswh='+varfromtranswh+'&totranswh='+vartotranswh
			+'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&prtcost='+varprtcost+'&updmeancost='+varupdmeancost+'&searchserial='+varsearchserial
			+'&TransPI='+varTransPI+'&TransPR='+varTransPR+'&TransSI='+varTransSI+'&TransSR='+varTransSR+'&TransTR='+varTransTR+'&TransPD='+varTransPD+'&TransAD='+varTransAD+'&TransPRT='+varTransPRT
			+'&curr='+varcurrency+'&vShowProject='+vPrj+'&vShowCostcenter='+vCst+'&showserials='+varshowserials+'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk
			+'&fromheatno='+varfromheatno+'&toheatno='+vartoheatno+'&vShowHeatno='+vHtn
			+'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch;
		   
		   
	window.open(str);


}



function showlistitem(str){
	var x = document.form1;
	varfromitem   = encodeURIComponent(x.fromitem.value);
	vartoitem     = encodeURIComponent(x.toitem.value);
	if(str==1){
		vItem_Code = x.fromitem.value;
		vPItem_Description = x.fromitemdesc.value;
	}
	if(str==2){
		vItem_Code = x.toitem.value;
		vPItem_Description = x.toitemdesc.value;
	}
		
	window.open('select_item.php?item='+str+'&PItem_Code='+vItem_Code+'&PItem_Description='+vPItem_Description,'mywindow','width=900,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

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

function SelectTransfer()
{
	var x = document.form1;
	if (x.TransTR.checked) {
		x.fromtranswh.disabled = false;
		x.totranswh.disabled = false;
	} else {
		x.fromtranswh.disabled = true;
		x.totranswh.disabled = true;
	}
}

function SelectPrintPrice() {
	var x = document.form1;
	if (x.prtcost.checked) {
		x.updmeancost.disabled = false;
		x.updmeancost.checked  = false;
	} else {
		x.updmeancost.disabled = true;
		x.updmeancost.checked  = false;
	}

}
function showlistWarehouse(PIndex) {
	XPos = (screen.availHeight - 550) / 2;
	YPos = (screen.availWidth - 850) / 2;
	if(PIndex==0)
		var vWarehouseCode = encodeURIComponent(document.getElementById('fromwhcode').value);
	else if(PIndex==1)
		var vWarehouseCode = encodeURIComponent(document.getElementById('towhcode').value);
	window.open('List_SorWarehouse.php?frm=9&item='+PIndex+'&PWarehouse_Code='+vWarehouseCode,'List_SorWarehouse','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,left='+YPos+',top='+XPos);
}

function showListProject(str){
	window.open('List_SorProject.php?frm=29&item='+str,'Project List', 'width=600px,height=600px');
}

function showlistCostcenter(str){
	window.open('List_SorCostcenter.php?frm=29&item='+str,'Costcenter List', 'width=600px,height=600px');
}

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>$statement_items</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'>".$statementofitems."</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='$ClearPage'><span><span>$ClearPage</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='$ExportExcel'><span><span>$ExportExcel</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='13%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>$Date</span></td> ";
if($module_expiredate == 1){
echo"   <td width='15%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"     <label><input name='edatechk' id='edatechk' type='checkbox' > Expire Date </label> ";
echo"</span></td> ";
}
echo"   <td width='12%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>$Currencyalias</span></td>";
echo"   <td width='18%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>$Options</span></td>";
echo"   <td width='45%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <label><input type='checkbox' name='alltrans' id='alltrans' value='1' onclick='SelectTransOption();' checked/>$AllMovementOptions</label></span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='3%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>$From</span></td>";
echo"   <td width='10%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate'  id='fromdate' value='$fromdate' maxlength='10' size='6'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.fromdate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
if($module_expiredate == 1){
	echo"   <td width='15%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>$From</span>";
	echo"   <span class='style8'>";
	echo"      <input type='text' name='fromedate' value='$fromedate' maxlength='10' size='6'>";
	echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.fromedate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";
}
echo"   <td width='12%' valign='top' rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
echo"      <input name='currency' type='radio' value=''>$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='18%' valign='top' rowspan='2' bgcolor='#F5F5F5'>";
echo"   <span class='style8'><label>";
echo"      <input type='checkbox' name='prtcost' id='prtcost' value='1' $ShowCostCheck  $ShowCostMode onclick='SelectPrintPrice();' />$PrintPrice</label></span>";
echo"   <br><span class='style8'><label>";
echo"      <input type='checkbox' name='updmeancost' id='updmeancost' value='1' $ShowCostMode />$UpdatedMeanCost <br>";
echo"      <input type='checkbox' name='showTransValue' id='showTransValue' value='1' $showTransValue />$ShowTransactionRemainingValues</label></span>";

if ($Module_SerialNo == 1) {
	echo"<br><span class='style8'><label>";
	echo"  <input type='checkbox' name='showserials' id='showserials' value='1' />Show Serials (Excel)</label></span>";
}

echo"   </td>";

echo"   <td width='45%' colspan='2' rowspan='2' bgcolor='#F5F5F5'><span class='style8'>";
echo"   <div id='main' style='position:relative; left:5px; top:0px; width:450px; 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/>Good Receive Note</label><br>";
else 
	echo"  <label><input type='checkbox' name='TransPI' id='TransPI' value='PI' checked/>$Purchase</label><br>";
	
echo"      <label><input type='checkbox' name='TransPR' id='TransPR' value='PR' checked/>$ReturnPurchase</label><br>";

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

echo"   <div id='right' style='position:absolute; left:5px; top:0px; width:150px; float:right; margin-left: 160px; border-width:0px; border-style:dotted; border-color:black;'>";
echo"      <label><input type='checkbox' name='TransTR' id='TransTR' value='TR' onclick='SelectTransfer();' checked/>$Transfer</label><br>";
echo"      <label><input type='checkbox' name='TransPD' id='TransPD' value='PD' checked/>$Production</label><br>";
echo"      <label><input type='checkbox' name='TransAD' id='TransAD' value='AD' checked/>$Adjustment</label><br>";
echo"     <label><input type='checkbox' name='TransPRT' id='TransPRT' value='PRT' />$ProductionRequest</label>";
echo"   </div>";

echo"   <div id='right' style='position:absolute; left:150px; top:0px; width:170px; float:right; margin-left: 160px; border-width:0px; border-style:dotted; border-color:black;'>";

if($Module_Project == 1)
	echo"      <label><input type='checkbox' name='Prj' id='Prj' value='Prj' checked/>$ShowProject</label><br>";

if($Module_CostCenter == 1)	
	echo"      <label><input type='checkbox' name='Cst' id='Cst' value='Cst' checked/>$ShowCostcenter</label><br>";
	
if($Module_Heatno == 1)	
	echo"      <label><input type='checkbox' name='Htn' id='Htn' value='Htn' checked/>Show HeatNo</label><br>";
echo"      <label>";
if($ShowReportHeader== 1 && $module_ReferenceByCostcenter== 1)
	echo"      <input name='prtheader' type='checkbox' id='prtheader' value='1' checked /><BR>";
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"      $ShowReportHeader</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"      <input name='showUser' type='checkbox' id='showUser' value='1' checked /> show user<BR>";
echo"   </div>";


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

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

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

echo"$Periods: <select name='period' id='period' onchange=\"setdateperiods(this.value,'fromdate','todate')\" >";
echo"<option value=0></option>";
echo"<option value=1>Today</option>";
echo"<option value=2>Week</option>";
echo"<option value=3>This Month</option>";
echo"<option value=4>1st Quarter</option>";
echo"<option value=5>2nd Quarter</option>";
echo"<option value=6>3rd Quarter</option>";
echo"<option value=7>Last Quarter</option>";
echo"<option value=8>This Year</option>";
echo"</select>";

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


echo" <tr height='20'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>$ItemCodeDescription";
if ($Module_SerialNo == 1) {
	echo"<label><input type='checkbox' name='searchserial' id='searchserial' value='1' />Search By Serial</label>";
}
echo"   </span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>$TransferWarehouse</span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>$From</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromitem' type='text' id='fromitem' style='width: 120px;' value='".$fromitem."'  onkeydown='return kdItem(0,event,0);'  />
        <input name='fromitemdesc' type='text' id='fromitemdesc' style='width: 250px;' value='".$fromitemdesc."'  onkeydown='return kdItem(1,event,0);'  />
        <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%' bgcolor='#F5F5F5' ><span class='style8'><select name='fromtranswh' id='fromtranswh' style='width:400px'>";
		echo"<option></option>";
		while($whf=mysql_fetch_row($resultfromtranswh)){
		echo"<option ";
			if ($fromtranswh==$whf[0])
				echo " selected ";
		echo" value='$whf[0]'>$whf[0] | $whf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";			 

echo" </tr>";
   
   
   


echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>$To</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toitem' type='text' id='toitem' style='width: 120px;' value='".$toitem."'  onkeydown='return kdItem(0,event,1);' />
        <input name='toitemdesc' type='text' id='toitemdesc' style='width: 250px;' value='".$toitemdesc."'  onkeydown='return kdItem(1,event,1);' />
        <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>      ";

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='totranswh' id='totranswh' style='width:400px'>";
		echo"<option></option>";
		while($wht=mysql_fetch_row($resulttotranswh)){
		echo"<option ";
			if ($totranswh==$wht[0])
				echo " selected ";
		echo" value='$wht[0]'>$wht[0] | $wht[1]</option>";
		}
		echo"</select>";
		echo"</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='30' 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='30' 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='6' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>$ItemGroup</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>$ItemSubGroup</span></td>";
echo" </tr>";

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

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

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>$ItemCategory</span></td>";
echo"   <td colspan='2' bgcolor='#F5F5F5'><span class='style8'>$Warehouse</span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>$From</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'><select name='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'>";

echo"   <label>
        <input name='fromwhcode' type='text' id='fromwhcode' style='width:120px;' value='".$fromwhcode."'  />
        <input name='fromwhdesc' type='text' id='fromwhdesc' style='width:250px;' value='".$fromwhdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' style='width:20px; height:20px; border:thin;' title='Select Warehouse From' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' title=' Select Warehouse From ' 
             onClick='showlistWarehouse(0); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> </td>     ";	

/*	echo"<select name='fromwarehouse' id='fromwarehouse' style='width:400px'><option></option>";
		while($wrhf=mysql_fetch_row($resultfromwarehouse)){
		echo"<option ";
			if ($fromwarehouse==$wrhf[0])
				echo " selected ";
		echo" value='$wrhf[0]'>$wrhf[0] | $wrhf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";	
*/
		
		
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>$To</span></td>";
echo"   <td width='45%'  colspan='3' bgcolor='#F5F5F5' ><span class='style8'><select name='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'>";
echo"   <label>
        <input name='towhcode' type='text' id='towhcode' style='width:120px;' value='".$towhcode."' maxlength=20 />
        <input name='towhdesc' type='text' id='towhdesc' style='width:250px;' value='".$towhdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...' style='width:20px; height:20px; border:thin;' title='Select Warehouse To' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' title=' Select Warehouse To ' 
             onClick='showlistWarehouse(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> </td>     ";	

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




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

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

echo" <tr height='15px'>
	    <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='fromproject' id='fromproject' maxlength='20'  style='width:120px'>
		<input type='text' name='fromprojectdesc' id='fromprojectdesc'style='width:250px'>
		<img src='img/btnopen.jpg' width=15 height=20 title='Select Project' onclick=\"showListProject('1');\">
		</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'>
		<input type='text' name='fromcostcent' id='fromcostcent'  maxlength='20' style='width:120px'>
		<input type='text' name='fromcostcentdesc' id='fromcostcentdesc'  style='width:250px'>
		<img src='img/btnopen.jpg' width=15 height=20 title='select Costcenter' onclick=\"showlistCostcenter('1');\">
		</span></td>";	
echo" </tr>";

echo" <tr height='15px'>
	    <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='toproject' id='toproject' style='width:120px;' maxlength=20>
		<input type='text' name='toprojectdesc' id='toprojectdesc' style='width:250px;' maxlength=20>
		<img src='img/btnopen.jpg' width=15 height=20 title='Select Project' onclick=\"showListProject('3');\">
		</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'>
		<input type='text' name='tocostcent' id='tocostcent' style='width:120px;' maxlength=20>
		<input type='text' name='tocostcentdesc' id='tocostcentdesc' style='width:250px;'>
		<img src='img/btnopen.jpg' width=15 height=20 title='select Costcenter' onclick=\"showlistCostcenter('4');\">
		</span></td>";	
echo" </tr>";

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

if ($Module_BatchNo == 1)
echo "<tr height='15px'>
		<td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Batch No</span></td>
		<td colspan='2' bgcolor='#F5F5F5'><span class='style8'> </span></td>
	</tr>
	<tr height='15px'>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>$From</span></td>	
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><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='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showListBatch('1');\"  /></span></label></span></td>
		<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'></span></td>
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'></span></td>			
	</tr>
	<tr height='15px'>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>$To</span></td>	
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><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='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showListBatch('2');\"  /></span></label></span></td>
		<td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'></span></td>
		<td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'></span></td>			
	</tr>
	<tr>
		<td colspan='6' 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='9' 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");
}
	  
?>