<?php


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

include("config.inc.php");

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


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


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

HERE;

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter, ".
			 " ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ifnull(Module_NewProduction,0) as Module_NewProduction, ".
			 " 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);
}



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


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

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

if (empty($fromedate)) $fromedate = displayToday();
if (empty($toedate))   $toedate   = displayToday();
	
$ShowCostMode  = '';
$ShowCostCheck = 'checked';
if($FI_ShowCostPrice == 0)  {
	$ShowCostMode  = 'disabled';	
	$ShowCostCheck = 'unchecked';	
}	
	
print <<< HERE

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

<script type="text/javascript" src="jquery-1.9.1.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 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 printPrev(printaccess)
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
		
	for (var i=0; i < document.form1.reports.length; i++)
	{
		if (document.form1.reports[i].checked)
		{
			var varreports = document.form1.reports[i].value;
		} 
	}	 
	  
	for (var i=0; i < document.form1.listby.length; i++)
	{
		if (document.form1.listby[i].checked)
		{
			var varlistby = document.form1.listby[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.status.length; i++)
	{
		if (document.form1.status[i].checked)
		{
			var varstatus = document.form1.status[i].value;
		}
	}
	
	for (var i=0; i < document.form1.orderBy.length; i++)
	{
		if (document.form1.orderBy[i].checked)
		{
			var varOrder = document.form1.orderBy[i].value;
		}
	}
		 
		
	varshowdetail	= 0;
	if (document.form1.showdetail.checked )
		varshowdetail = 1;
		
	varshowcost	= 0;
	if (document.form1.showcost.checked )
		varshowcost = 1;
	
	varshowlastprice = 0;
	if(document.form1.showpurprice.checked)
	varshowlastprice = 1;	

	varshowidealqty	= 0;
	if (document.form1.showidealqty.checked )
		varshowidealqty = 1;
		
	varshowqtyexists = 0;
	if (document.form1.showqtyexists.checked )
		varshowqtyexists = 1;
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked)
			varshowunit2qty = 1;	
	}
	
	varprtheader = 0;
	if (document.form1.prtheader.checked)    varprtheader = 1;
		
	
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = document.form1.fromitem.value;
	vartoitem     = document.form1.toitem.value;
	varfromwrh    = document.form1.fromwarehouse.value;
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
	varfromitemRM = document.form1.fromitemRM.value;
	vartoitemRM   = document.form1.toitemRM.value;
	varqtyprod	  = document.form1.qtyprod.value;
	
	varfromgroup 	  = document.form1.fromgroup_code.value;
	vartogroup 	  	  = document.form1.togroup_code.value;
	varfromsubgroup   = document.form1.fromsubgroup_code.value;
	vartosubgroup     = document.form1.tosubgroup_code.value;	
	varfromcategory   = document.form1.fromcategory_code.value;
	vartocategory     = document.form1.tocategory_code.value;
	
	let frombatchno   = document.form1.frombatchno.value;
	let tobatchno     = document.form1.tobatchno.value;
	
	var fromheatno = '';
	if(document.form1.fromheatno)
		fromheatno = document.form1.fromheatno.value;
	var toheatno = '';
	if(document.form1.toheatno)
		toheatno = document.form1.toheatno.value;
	
	if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
			if(document.getElementById("grpedate").checked)
				vargrpedate = 1;
			else vargrpedate = 0;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
			vargrpedate = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
		vargrpedate = 0;
	}
	
	var	vHtn = 0;
	if (document.form1.Htn)
	if (document.form1.Htn.checked) vHtn = 1;	
	
	var dtlWh = 0;
	if(document.getElementById('prtdtlWh').checked)
		dtlWh = 1;
	
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;

	var newproduction = document.getElementById("Module_NewProduction").value;
	
	str1 =  'Rep_ListofProduction.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&fromitemRM='+varfromitemRM+'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty
		   +'&vShowHeatno='+vHtn+'&prtheader='+varprtheader+'&fromgroup='+varfromgroup+'&togroup='+vartogroup
		   +'&fromsubgroup='+varfromsubgroup+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
		   +'&tocategory='+vartocategory+'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk
		   +'&grpedate='+vargrpedate+'&showlastprice='+varshowlastprice+'&fromheatno='+fromheatno+'&toheatno='+toheatno
		   +'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch;
		   
	str2 =  'Rep_ProductionReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&showidealqty='+varshowidealqty+'&listby='+varlistby+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty+'&showlastprice='+varshowlastprice;
	
	str22 =  'Rep_ProductionReport2.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&showidealqty='+varshowidealqty+'&listby='+varlistby+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty+'&showlastprice='+varshowlastprice;	
		   
	str4 =  'Rep_ProductionAnalysis.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency;
	
	if(newproduction == 1)
	str5 =  'Rep_ProductionTemplate2.php?fromitem='+varfromitem+'&toitem='+vartoitem+'&fromdate='+varfromdate+'&todate='+vartodate+'&curr='+varcurrency+
			'&showqtyexists='+varshowqtyexists+'&prtheader='+varprtheader+'&showlastprice='+varshowlastprice;
	else
	str5 =  'Rep_ProductionTemplate.php?fromitem='+varfromitem+'&toitem='+vartoitem+'&qtyprod='+varqtyprod+'&showqtyexists='+varshowqtyexists+'&prtheader='+varprtheader;
	
	str6 =  'Rep_PreProductionTemplate.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&status='+varstatus+'&orderBy='+varOrder;
	
	str7 =  'Rep_ListofFactoryProduction.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&fromitemRM='+varfromitemRM+'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty
		   +'&prtheader='+varprtheader+'&fromgroup='+varfromgroup+'&togroup='+vartogroup
		   +'&fromsubgroup='+varfromsubgroup+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
		   +'&tocategory='+vartocategory+'&showlastprice='+varshowlastprice;
		   
	if (varreports == 1) str = str1;		   
	else if (varreports == 2) {
		if(dtlWh == 1 && varshowcost == 1) str = str22;
		else str = str2;		
	}
	else if (varreports == 4) str = str4;
	else if (varreports == 5) str = str5;
	else if (varreports == 6) str = str6;
	else if (varreports == 7) str = str7;
	
	if (printaccess==1)
		window.open(str);
	else
		window.open(str,"Report", "width=1000,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
		
		
}

function exportExcel()
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
		
	for (var i=0; i < document.form1.reports.length; i++)
	{
		if (document.form1.reports[i].checked)
		{
			var varreports = document.form1.reports[i].value;
		}
	}	 
	
	for (var i=0; i < document.form1.listby.length; i++)
	{
		if (document.form1.listby[i].checked)
		{
			var varlistby = document.form1.listby[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.status.length; i++)
	{
		if (document.form1.status[i].checked)
		{
			var varstatus = document.form1.status[i].value;
		}
	} 
		 
	for (var i=0; i < document.form1.orderBy.length; i++)
	{
		if (document.form1.orderBy[i].checked)
		{
			var varOrder = document.form1.orderBy[i].value;
		}
	}
	
	varshowdetail	= 0;
	if (document.form1.showdetail.checked )
		varshowdetail = 1;
		
	varshowcost	= 0;
	if (document.form1.showcost.checked )
		varshowcost = 1;
	
	varshowlastprice = 0;
	if(document.form1.showpurprice.checked)
	varshowlastprice = 1;	
	
	varshowidealqty	= 0;
	if (document.form1.showidealqty.checked )
		varshowidealqty = 1;
		
	varshowqtyexists = 0;
	if (document.form1.showqtyexists.checked )
		varshowqtyexists = 1;
		
	varshowunit2qty = 0;
	if (document.getElementById('showunit2qty')) {
		if (document.form1.showunit2qty.checked)
			varshowunit2qty = 1;	
	}
	
	varprtheader = 0;
	if (document.form1.prtheader.checked)    varprtheader = 1;
	
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = document.form1.fromitem.value;
	vartoitem     = document.form1.toitem.value;
	varfromwrh    = document.form1.fromwarehouse.value;
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
	varfromitemRM = document.form1.fromitemRM.value;
	vartoitemRM   = document.form1.toitemRM.value;
	varqtyprod	  = document.form1.qtyprod.value;
	 
	varfromgroup 	  = document.form1.fromgroup_code.value;
	vartogroup 	  	  = document.form1.togroup_code.value;
	varfromsubgroup   = document.form1.fromsubgroup_code.value;
	vartosubgroup     = document.form1.tosubgroup_code.value;	
	varfromcategory   = document.form1.fromcategory_code.value;
	vartocategory     = document.form1.tocategory_code.value;
	
	let frombatchno   = document.form1.frombatchno.value;
	let tobatchno     = document.form1.tobatchno.value;
	
	var fromheatno = '';
	if(document.form1.fromheatno)
		fromheatno = document.form1.fromheatno.value;
	var toheatno = '';
	if(document.form1.toheatno)
		toheatno = document.form1.toheatno.value;
	
	 if(document.getElementById("edatechk")){
		if(document.getElementById("edatechk").checked){
			varedatechk = 1;
			varfromedate   = document.form1.fromedate.value;
			vartoedate     = document.form1.toedate.value;
			if(document.getElementById("grpedate").checked)
				vargrpedate = 1;
			else vargrpedate = 0;
		}else {
			varfromedate='';
			vartoedate='';
			varedatechk = 0;
			vargrpedate = 0;
		}
	}else{
		varfromedate='';
		vartoedate='';
		varedatechk = 0;
		vargrpedate = 0;
	}
	
	var	vHtn = 0;
	if (document.form1.Htn)
	if (document.form1.Htn.checked) vHtn = 1;
	
	var dtlWh = 0;
	if(document.getElementById('prtdtlWh').checked)
		dtlWh = 1;
	
	let showbatch = 0;	
	if (document.getElementById('showbatch').checked)	
	showbatch = 1;	

	str1 =  'Exp_ListofProduction.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&fromitemRM='+varfromitemRM+'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty
		   +'&vShowHeatno='+vHtn+'&prtheader='+varprtheader+'&fromgroup='+varfromgroup+'&togroup='+vartogroup
		   +'&fromsubgroup='+varfromsubgroup+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
		   +'&tocategory='+vartocategory+'&fromedate='+varfromedate+'&toedate='+vartoedate+'&edatechk='+varedatechk
		   +'&grpedate='+vargrpedate+'&showlastprice='+varshowlastprice+'&fromheatno='+fromheatno+'&toheatno='+toheatno
		   +'&frombatchno='+frombatchno+'&tobatchno='+tobatchno+'&showbatch='+showbatch;
		   
	str2 =  'Exp_ProductionReport.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&showidealqty='+varshowidealqty+'&listby='+varlistby+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty+'&showlastprice='+varshowlastprice;
		   
	str22 =  'Exp_ProductionReport2.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&showidealqty='+varshowidealqty+'&listby='+varlistby+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty+'&showlastprice='+varshowlastprice;	   
		   
	str3 =  'Exp_ProductionReportCosting.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&curr='+varcurrency;
		   
	str4 =  'Exp_ProductionAnalysis.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitemRM='+varfromitemRM
		   +'&toitemRM='+vartoitemRM+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency;	

	str6 =  'Exp_PreProductionAnalysis.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem
		   +'&toitem='+vartoitem+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&status='+varstatus+'&orderBy='+varOrder;		
	
	str7 =  'Exp_ListofFactoryProduction.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromwarehouse='+varfromwrh+'&fromproject='+varfromprj+'&toproject='+vartoprj
		   +'&fromcostcent='+varfromcst+'&tocostcent='+vartocst+'&curr='+varcurrency+'&showdetail='+varshowdetail
		   +'&showcost='+varshowcost+'&fromitemRM='+varfromitemRM+'&toitemRM='+vartoitemRM+'&showunit2qty='+varshowunit2qty
		   +'&fromgroup='+varfromgroup+'&togroup='+vartogroup+'&fromsubgroup='+varfromsubgroup+'&tosubgroup='+vartosubgroup+'&fromcategory='+varfromcategory
		   +'&tocategory='+vartocategory+'&showlastprice='+varshowlastprice;
		   
	if (varreports == 1) str = str1;		   
	else if (varreports == 2){
		if(dtlWh == 1 && varshowcost == 1) str = str22;
		else str = str2;
	}
	else if (varreports == 3) str = str3;
	else if (varreports == 4) str = str4;
	else if (varreports == 6) str = str6;
	else if (varreports == 7) str = str7;
			   
	window.open(str);
		
}


function SelectReport(option){
	var x = document.form1;
	
	if (option == 1) {
		for (var i=0; i < x.listby.length; i++)
		{
			x.listby[i].disabled = true;
		}
		for (var i=0; i < x.status.length; i++)
		{
			x.status[i].disabled = true;
		}
		
		for (var i=0; i < x.orderBy.length; i++)
		{
			x.orderBy[i].disabled = true;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[i].disabled = false;
		}
		
		x.showidealqty.disabled = true;
		x.showidealqty.checked  = false;
		x.showdetail.disabled = false;
		x.showcost.disabled = false;
		x.showqtyexists.disabled = true;
		x.fromitemRM.disabled = false;
		x.fromitemdescv.disabled = false;
		x.toitemRM.disabled = false;
		x.toitemdescRM.disabled = false;
		x.toheatno1.disabled = false;
		x.toheatnotype1.disabled = false;
		
		$('.SelectrowMaterial').css('display','inline-block');
		
		if (document.getElementById('showunit2qty')) {
			x.showunit2qty.disabled = true;
		}
		
	}
	else if (option == 2) {
		for (var i=0; i < x.listby.length; i++)
		{
			x.listby[i].disabled = false;
		}
		
		for (var i=0; i < x.status.length; i++)
		{
			x.status[i].disabled = true;
		}
		
		for (var i=0; i < x.orderBy.length; i++)
		{
			x.orderBy[i].disabled = true;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[i].disabled = false;
		}
		
		x.showdetail.disabled = false;
		x.showcost.disabled = false;
		x.showidealqty.disabled = false;
		x.showqtyexists.disabled = true;
		x.fromitemRM.disabled = false;
		x.fromitemdescv.disabled = false;
		x.toitemRM.disabled = false;
		x.toitemdescRM.disabled = false;
		x.toheatno1.disabled = false;
		x.toheatnotype1.disabled = false;
		
		$('.SelectrowMaterial').css('display','inline-block');
		
		if (document.getElementById('showunit2qty')) {
			x.showunit2qty.disabled = false;
		}
		
	}
	
	else if (option == 6) {
		for (var i=0; i < x.listby.length; i++)
		{
			x.listby[i].disabled = true;
		}
		
		for (var i=0; i < x.status.length; i++)
		{
			x.status[i].disabled = false;
		}
		
		for (var i=0; i < x.orderBy.length; i++)
		{
			x.orderBy[i].disabled = false;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[i].disabled = true;
		}
		
		x.showdetail.disabled = true;
		x.showcost.disabled = true;
		x.showidealqty.disabled = true;
		x.showqtyexists.disabled = true;
		x.fromitemRM.disabled = true;
		x.fromitemdescv.disabled = true;
		x.toitemRM.disabled = true;
		x.toitemdescRM.disabled = true;
		x.toheatno1.disabled = true;
		x.toheatnotype1.disabled = true;
		
		$('.SelectrowMaterial').css('display','none');
		
		if (document.getElementById('showunit2qty')) {
			x.showunit2qty.disabled = true;
		}
		
	}
	else if (option == 3 || option == 5) {
		for (var i=0; i < x.listby.length; i++)
		{
			x.listby[i].disabled = true;
		}
		
		for (var i=0; i < x.status.length; i++)
		{
			x.status[i].disabled = true;
		}
		
		for (var i=0; i < x.orderBy.length; i++)
		{
			x.orderBy[i].disabled = true;
		}
		
		for (var i=0; i < x.currency.length; i++)
		{
			x.currency[i].disabled = false;
		}
		
		x.showidealqty.disabled = true;
		x.showidealqty.checked  = false;
		x.showdetail.disabled = true;
		x.showdetail.checked = false;
		x.showcost.disabled = true;
		x.showqtyexists.disabled = true;
		x.fromitemRM.disabled = false;
		x.fromitemdescv.disabled = false;
		x.toitemRM.disabled = false;
		x.toitemdescRM.disabled = false;
		x.toheatno1.disabled = false;
		x.toheatnotype1.disabled = false;
		
		$('.SelectrowMaterial').css('display','inline-block');
		
		if (option == 5) x.showqtyexists.disabled = false;
		
		if (document.getElementById('showunit2qty')) {
			x.showunit2qty.disabled = true;
		}
	} else if (option == 7) {
		for (var i=1; i < x.listby.length; i++)
		{
			x.listby[i].disabled = false;
		}
		x.listby[1].checked = true;
	}
}

function SelectListBy(option){
	var x = document.form1;
	
	/*if (option == 1) {
		x.showidealqty.disabled = true;
		x.showidealqty.checked  = false;
	}
	else if (option == 2) {
		x.showidealqty.disabled = false;
		
	}*/
}

function SelectStatus(option){
	var x = document.form1;

}

function SelectOrder(option){
	var x = document.form1;

}
function showCosts(indx){
	if(indx==1){
		if(document.getElementById("showcost").checked){
			document.getElementById("showpurprice").checked=false;
		} 
	} 
	if(indx==2){
		if(document.getElementById("showpurprice").checked){
			document.getElementById("showcost").checked=false;
		} 
	}
	
}
function showlistitem(str,itemtype){

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

function showlistgroups(str){
	window.open('List_Grouping.php?str='+str,'List_Grouping','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistsubgroups(str){
	window.open('List_SubGroup.php?str='+str,'List_SubGroup','width=850,height=400,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,'categorywindow','width=850,height=400,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>List of Production</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'>List of Production</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

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

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

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

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

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

echo" <tr>";	  
echo"   <td width='15%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td> ";
echo"   <td width='8%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>Currency</span></td>";
echo"   <td width='20%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>Reports </span></td>";
echo"   <td width='11%' height='19' align='left ' bgcolor='#F5F5F5'><span class='style8'>List by </span></td>";
echo"   <td width='15%' height='19' align='center' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo"   <td width='15%' height='19' align='left' bgcolor='#F5F5F5'><span class='style8'>Status</span></td>";
echo" </tr>";

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


echo"   <td width='20%' valign='top' rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
        if ($reports=="1" || $reports=="")
           echo "<input name='reports' type='radio' value='1' checked onclick='SelectReport(1);'/>";
		else	
		   echo "<input name='reports' type='radio' value='1' onclick='SelectReport(1);'/>";
		echo "List of Production</label></span>";   
echo"   <br><span class='style8'><label>";
        if ($reports=="2" )
           echo "<input name='reports' type='radio' value='2' checked onclick='SelectReport(2);'/>";
		else	
		   echo "<input name='reports' type='radio' value='2' onclick='SelectReport(2);'/>";
		echo "Production Report</label></span>";
echo"   <br><span class='style8'><label>";
        if ($reports=="5" )
           echo "<input name='reports' type='radio' value='5' checked onclick='SelectReport(5);'/>";
		else	
		   echo "<input name='reports' type='radio' value='5' onclick='SelectReport(5);'/>";
		echo "<input type='hidden' name='Module_NewProduction' id='Module_NewProduction' value='$Module_NewProduction'>";
		echo "Production Template</label></span>";
echo"   <br><span class='style8'><label>";
        if ($reports=="3" )
           echo "<input name='reports' type='radio' value='3' checked onclick='SelectReport(3);'/>";
		else	
		   echo "<input name='reports' type='radio' value='3' onclick='SelectReport(3);'/>";
		echo "Production Report(Costing)</label></span>"; 
echo"   <br><span class='style8'><label>";
        if ($reports=="4" )
           echo "<input name='reports' type='radio' value='4' checked onclick='SelectReport(3);'/>";
		else	
		   echo "<input name='reports' type='radio' value='4' onclick='SelectReport(3);'/>";
		echo "Production Variance Analysis</label></span>";

echo"   <br><span class='style8'><label>";
        if ($reports=="6" )
           echo "<input name='reports' type='radio' value='6' checked onclick='SelectReport(6);'/>";
		else	
		   echo "<input name='reports' type='radio' value='6' onclick='SelectReport(6);'/>";
		echo "Preproduction Report</label></span>";
		
echo"   <br><span class='style8'><label>";
        if ($reports=="7" )
           echo "<input name='reports' type='radio' value='7' checked onclick='SelectReport(7);'/>";
		else	
		   echo "<input name='reports' type='radio' value='7' onclick='SelectReport(7);'/>";
		echo "Production Factory Report</label></span>";

echo "</td>";
 
		
echo"   <td width='11%' valign='top'  rowspan='2' bgcolor='#F5F5F5'><span class='style8'><label>";
        if ($listby=="1" || $listby=="")
           echo "<input name='listby' type='radio' value='1' checked disabled  onclick='SelectListBy(1);'/>";
		else	
		   echo "<input name='listby' type='radio' value='1' disabled onclick='SelectListBy(1);' />";
		echo "Finished Goods</label></span>";   
		echo"   <br><span class='style8'><label>";
        if ($listby=="2" )
           echo "<input name='listby' type='radio' value='2' checked disabled onclick='SelectListBy(2);'/>";
		else	
		   echo "<input name='listby' type='radio' value='2' disabled onclick='SelectListBy(2);' />";
		echo "Raw Materials</label></span>";
		

echo"   <br><br><span class='style8' style='display: block; text-align: left;'>";
        echo "Order By";
		echo "</span>";	
echo"   <span class='style8'><label>";
        if ($orderBy=="1" || $orderBy=="")
           echo "<input name='orderBy' type='radio' value='1' checked disabled onclick='SelectOrder(1);'/>";
		else	
		   echo "<input name='orderBy' type='radio' value='1' disabled onclick='SelectOrder(1);'/>";
		echo "Date</label></span>";
echo"   <br><span class='style8'><label>";
        if ($orderBy=="2")
           echo "<input name='orderBy' type='radio' value='2' checked disabled onclick='SelectOrder(2);'/>";
		else	
		   echo "<input name='orderBy' type='radio' value='2' disabled onclick='SelectOrder(2);'/>";
		echo "Delivery Date</label></span>";
echo"   <br><span class='style8'><label>";
        if ($orderBy=="3")
           echo "<input name='orderBy' type='radio' value='3' checked disabled onclick='SelectOrder(3);'/>";
		else	
		   echo "<input name='orderBy' type='radio' value='3' disabled onclick='SelectOrder(3);'/>";
		echo "Reference</label></span>";
echo"   <br><span class='style8'><label>";
        if ($orderBy=="4")
           echo "<input name='orderBy' type='radio' value='4' checked disabled onclick='SelectOrder(4);'/>";
		else	
		   echo "<input name='orderBy' type='radio' value='4' disabled onclick='SelectOrder(4);'/>";
		echo "Item Code</label></span>";
echo"   <br><span class='style8'><label>";
        if ($orderBy=="5")
           echo "<input name='orderBy' type='radio' value='5' checked disabled onclick='SelectOrder(5);'/>";
		else	
		   echo "<input name='orderBy' type='radio' value='5' disabled onclick='SelectOrder(5);'/>";
		echo "Item Description</label></span></td>";		
		
echo"   <td width='15%' rowspan='2' bgcolor='#F5F5F5' valign='top'><span class='style8'><label>";
echo"      <input type='checkbox' name='showdetail' id='showdetail' value='1'  unchecked />Show Detail</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 type='checkbox' name='showcost' id='showcost' value='1'  $ShowCostCheck  $ShowCostMode onclick=\"showCosts('1');\" />Show Average Cost</label><br>";
echo"      <input type='checkbox' name='showpurprice' id='showpurprice' value='1' onclick=\"showCosts('2');\" />Show Last Purchase Price</label><br>";
echo"      <input type='checkbox' name='showidealqty' id='showidealqty' value='1'  unchecked disabled />Show Ideal Quantity</label><br>";
echo"      <input type='checkbox' name='showqtyexists' id='showqtyexists' value='1'  unchecked disabled />Show Qty Exists By WH</label>";
echo"      <br><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>";

echo"     <br><label> <input name='prtdtlWh' type='checkbox' id='prtdtlWh' value='0'  />";
echo"      Print Detailed Warehouses</label>";
if ($Module_DoubleUnit == 1) {
	echo"   <br><span class='style8'><label>";
	echo"      <input name='showunit2qty' type='checkbox' id='showunit2qty' value='1' unchecked disabled />Show Unit2 Qty</label>";
}
if($Module_Heatno == 1)	{
	echo"    <br><span class='style8'>&nbsp;<label><input type='checkbox' name='Htn' id='Htn' value='Htn' checked/>Show HeatNo</span></label>";
	
}

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

echo"   <td width='15%' rowspan='2' bgcolor='#F5F5F5' valign='top'><span class='style8'><label>";
        if ($status=="1" || $status=="")
           echo "<input name='status' type='radio' value='1' checked disabled onclick='SelectStatus(1);'/>";
		else	
		   echo "<input name='status' type='radio' value='1' disabled onclick='SelectStatus(1);'/>";
		echo "All Preproductions</label></span>";
echo"   <br><span class='style8'><label>";
        if ($status=="2" )
           echo "<input name='status' type='radio' value='2' checked disabled onclick='SelectStatus(2);'/>";
		else	
		   echo "<input name='status' type='radio' value='2' disabled onclick='SelectStatus(2);' />";
		echo "Pending Preproductions</label></span>";
echo"   <br><span class='style8'><label>";
        if ($status=="3" )
           echo "<input name='status' type='radio' value='3' checked disabled onclick='SelectStatus(3);'/>";
		else	
		   echo "<input name='status' type='radio' value='3' disabled onclick='SelectStatus(3);' />";
		echo "Produced Preproductions</label></span></td>";     		


echo" </tr>";

echo" <tr>";
echo"   <td width='5%' 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' 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>";
if($module_expiredate == 1){
echo"   <td width='15%' height='19' align='left' bgcolor='#F5F5F5' colspan='2'><span class='style8'>";
echo"     <label><input name='edatechk' id='edatechk' type='checkbox' > Expire Date </label> ";
echo"</span></td><td height='19' align='left' bgcolor='#F5F5F5' colspan='2'><span class='style8'> <label><input name='grpedate' id='grpedate' type='checkbox' > Group By Expire Date </label></span></td> ";
} else echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

if($module_expiredate == 1){
echo" <tr>";
	echo"   <td width='5%'  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='fromedate' value='$fromedate' maxlength='10' size='8'>";
	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" </tr>";
}

if($module_expiredate == 1){
echo" <tr>";
	echo"   <td width='5%' 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='toedate' value='$toedate'  maxlength='10' size='8'>";
	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 height='20px' ><td></td></tr>";
}
echo" </table>";

echo" <table>";
echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Finished Item Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Warehouse</span></td>";
echo" </tr>";

echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='51%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromitem' type='text' id='fromitem' size='15' value='".$fromitem."' />
        <input name='fromitemdesc' type='text' id='fromitemdesc' size='28' 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,'productionFG'); \"><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' colspan='2' ><span class='style8'><select name='fromwarehouse' id='fromwarehouse' style='width:350px'>";
		echo"<option></option>";
		while($wrhf=mysql_fetch_row($resultfromwarehouse)){
		echo"<option ";
			if ($fromwarehouse==$wrhf[0])
				echo " selected ";
		echo" value='$wrhf[0]'>$wrhf[0] / $wrhf[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";			 

echo" </tr>";
   
   

   
echo" <tr height='15px'>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='3' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toitem' type='text' id='toitem' size='15' value='".$toitem."' />
        <input name='toitemdesc' type='text' id='toitemdesc' size='28' 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,'productionFG'); \"><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";

echo"   <td width='50%' colspan='3' align='left' bgcolor='#F5F5F5' ><span class='style8'>Qty To Be Prod.</span><input type='text' name='qtyprod' id='qtyprod' size='10' value='".$qtyprod."' /></td>";			 
echo" </tr>";



if($Module_Heatno==1){
echo" <tr height='20'>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Finished HeatNo / Type";
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='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Raw Material Item Code / Description</span></td>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Raw Material HeatNo / Type</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='fromitemRM' type='text' id='fromitemRM' size='15' value='".$fromitemRM."' />
        <input name='fromitemdescRM' type='text' id='fromitemdescv' size='28' value='".$fromitemdescRM."' />
        <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 class='SelectrowMaterial' href='javascript:void(0);' NAME='My Window Name' title=' Select Item From ' 
             onClick=\"showlistitem(3,'productionRM'); \"><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";


			 

if($Module_Heatno==1){


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='fromheatno1' type='text' id='fromheatno1' size='15' value='".$fromheatno1."' />
        <input name='fromheatnotype1' type='text' id='fromheatnotype1' size='35' value='".$fromheatnotype1."' />
        <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(3); '><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='toitemRM' type='text' id='toitemRM' size='15' value='".$toitemRM."' />
        <input name='toitemdescRM' type='text' id='toitemdescRM' size='28' value='".$toitemdescRM."' />
        <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 class='SelectrowMaterial' href='javascript:void(0);' NAME='My Window Name' title=' Select Item To ' 
             onClick=\"showlistitem(4,'productionRM'); \"><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";


			 
if($Module_Heatno==1){			 
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='toheatno1' type='text' id='toheatno1' size='15' value='".$toheatno1."' />
        <input name='toheatnotype1' type='text' id='toheatnotype1' size='35' value='".$toheatnotype1."' />
        <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 class='SelectrowMaterial'  href='javascript:void(0);' NAME='My Window Name' title=' Select Item To ' 
             onClick='showlistheatno(4); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>      ";
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'>Project </span></td>";
echo"   <td colspan='3' 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'><select name='fromproject' id='fromproject' style='width:400px'>";
		echo"<option></option>";
		while($prj=mysql_fetch_row($resultfromproject)){
		echo"<option ";
		    if (($fromproject==$prj[0]) || ($defaultproject==$prj[0]))
				echo " selected ";
		echo" value='$prj[0]'>$prj[0] / $prj[1]</option>";
		}
		echo"</select>";
		echo"</span></td>";

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

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

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

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

//group - subgroup
echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Group </span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5'><span class='style8'>Subgroup</span></td>";
echo" </tr>";
echo" <tr>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
	    <td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='fromgroup_code' id='fromgroup_code' value='$fromgroup_code' readonly size='15' >
		<input type='text' name='fromgroup_name' id='fromgroup_name' value='$fromgroup_name' readonly size='28' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistgroups(7); '  /></span></label></td>".
	"   <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='fromsubgroup_code' id='fromsubgroup_code' value='$fromsubgroup_code' readonly size='15' >
		<input type='text' name='fromsubgroup_name' id='fromsubgroup_name' value='$fromsubgroup_name' readonly size='25' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistsubgroups(5); '  /></span></label></td>";
	
echo "</tr>";

echo" <tr>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
	    <td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='togroup_code' id='togroup_code' value='$togroup_code' readonly size='15' >
		<input type='text' name='togroup_name' id='togroup_name' value='$togroup_name' readonly size='28' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistgroups(8); '  /></span></label></td>".
	"  <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='tosubgroup_code' id='tosubgroup_code' value='$tosubgroup_code' readonly size='15' >
		<input type='text' name='tosubgroup_name' id='tosubgroup_name' value='$tosubgroup_name' readonly size='25' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistsubgroups(6); '  /></span></label></td>";
echo "</tr>";

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

//group - subgroup
echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Category </span></td> 
		<td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Batch No </span></td>";
echo" </tr>";
echo" <tr>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
	    <td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='fromcategory_code' id='fromcategory_code' value='$fromcategory_code' readonly size='15' >
		<input type='text' name='fromcategory_name' id='fromcategory_name' value='$fromcategory_name' readonly size='28' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistcategory(3); '  /></span></label></td>";
echo "<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:340px;' >
		<img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick=\"showListBatch('1');\"  /></span></label></td>";
	echo "</tr>";

echo" <tr>
	    <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>
	    <td width='45%' colspan='3' bgcolor='#F5F5F5'> <span class='style8'><input type='text' name='tocategory_code' id='tocategory_code' value='$tocategory_code' readonly size='15' >
		<input type='text' name='tocategory_name' id='tocategory_name' value='$tocategory_name' readonly size='28' ></span>
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick='showlistcategory(4); '  /></span></label></td>";
echo "<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:340px;' >
		<img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" 
		onClick=\"showListBatch('2');\"  /></span></td>";		
echo "</tr>";		
		
echo" <tr>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </tr>";
   /* <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"	<tr>
	  <td colspan='9' height='100'>&nbsp;</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");
}
	  
?>