<?php

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


include("config.inc.php");
include("Functions_Purchase.php");


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


	
//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2 from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

//Read From Module Table
$querymodule=" Select ifNull(Module_Pack,0) As Module_Pack, ifNull(Module_ExpireDate,0) As Module_ExpireDate, ".
			 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt ".
			 " From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

//Read From ProductionSetup Table
$queryProductionSetup="Select ifNull(DisableIdeal,0) As DisableIdeal From ProductionSetup";
$resultProductionSetup=mysql_query($queryProductionSetup,$connection) or die(mysql_error());
while($rowProductionSetup=mysql_fetch_array($resultProductionSetup)){
	extract($rowProductionSetup);
}



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


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


$querydflwh="select default_warehouse_code as defaultwarehouse from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['useraccount']."' and default_warehouse_code != '' ";
$resultdflwh=mysql_query($querydflwh,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflwh)){
  extract($rows);
}


print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="default.css" type="text/css" />
<script type="text/javascript" language="javascript">


function SubmitRecord(ItemExpire) {
	x = document.productiondt;
	
	var result = CheckFields(ItemExpire);
	var vPrdId    = x.PPrdId.value;
	var vPrdDtId  = x.txtPrdDtId.value;
	var vMainMode = x.mainaction.value;
	var vMode= x.actionmode.value;
	
	if (vPrdDtId == '')
		vMode = 'submitrecord';	
	else
		vMode = 'editdt';	
	   
	if (result == 1) {
		x.action="Form_Assemble_Actions.php?mode="+vMode+"&mainmode="+vMainMode+"&SPrdId="+vPrdId+"&SPrdDtId="+vPrdDtId;
		x.submit();
		
	}	
}

function ChangeLocation() {
	x = document.productiondt;
	var vMode = x.actionmode.value;
	
	if (vMode == 'submitrecord') {
		
		opener.document.production.actionmode.value = x.actionmode.value;
		opener.document.production.mainaction.value = x.mainaction.value;
		//opener.document.production.message.value = x.message.value;
		opener.document.production.txtPrdId.value = x.PPrdId.value;
		opener.document.production.submit();
		
	} 
	else if (vMode == 'submitrecord' || vMode == 'editdt') {
		opener.document.production.actionmode.value = x.actionmode.value;
		opener.document.production.mainaction.value = x.mainaction.value;
		opener.document.production.txtPrdId.value = x.PPrdId.value;
		opener.document.production.submit();
		
		self.close();
	
	}
	
	//x.txtItemCodeFG.focus();
}

function CheckFields(ItemExpire){
  
    x = document.productiondt;
	
	var PrdDtItem = x.txtItemCodeFG.value;
	var PrdDtWarehouse = x.lstWarehouse.value;
	var PrdDtQty = x.txtPrdDtQty.value;
	var PrdDtCostPrice = x.txtPrdDtCostPrice.value;
	var PrdDtRemQty = x.txtRemainQty.value;
	
	var PrdDtExpireDate = x.txtPrdDtExpireDate.value;
	var PrdDtBatchNo    = x.txtPrdDtBatchNo.value;
	
	PrdDtQty = parseFloat(PrdDtQty);
	PrdDtRemQty = parseInt(PrdDtRemQty);
	
	var vmode = x.actionmode.value;
	
	if (PrdDtCostPrice == '') PrdDtCostPrice = 0;
		
	if (PrdDtWarehouse=='')
	{
		alert("Warehouse Column is mandatory!");
		x.lstWarehouse.focus();
		return 0;
	}
	else if (PrdDtItem=='' )
	{
		alert("Item Column is mandatory!");
		x.txtItemCodeFG.focus();
		return 0;
	}
	else if ((PrdDtQty == '' || PrdDtQty*1 != PrdDtQty/1 || PrdDtQty < 0)) {
		alert('Quantity should be a NUMERIC and POSITIVE value ');
		x.txtPrdDtQty.focus();
		return 0;
	}
	else if ((PrdDtCostPrice*1 != PrdDtCostPrice/1 || PrdDtCostPrice < 0) ) {
		alert('Cost Price should be a NUMERIC and POSITIVE value');
		x.txtPrdDtCostPrice.focus();
		return 0;
	}
	else if (ItemExpire == 1 && PrdDtExpireDate == '' ) {
		alert('Item Expire Date is mandatory.');
		x.txtPrdDtExpireDate.focus();
		return 0;
	}
	else if (ItemExpire == 1 && PrdDtBatchNo == '' ) {
		alert('Item Batch No is mandatory.');
		x.txtPrdDtBatchNo.focus();
		return 0;
	}
		
	
	else
	return 1 ;	
}






//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.productiondt;
	var vmode = x.actionmode.value;
	
	if (Option == 'D')
	{
		x.txtPrdDtId.value='';
		x.txtItemCodeFG.value='';
		x.txtItemDescFG.value='';
		x.lstWarehouse.value='';
		x.txtPrdDtRemark.value='';
		x.txtPrdDtQty.value='';
		x.txtPrdDtQtyIdeal.value='';
		x.txtPrdDtWasteCalc.value='';
		x.txtPrdDtWaste.value='';
		x.txtPrdDtCostPrice.value='';
		x.txtPrdDtTotal.value='';
		x.txtPrdDtTotalIdeal.value='';
		
		x.txtPrdDtExpireDate.value='';
		x.txtPrdDtBatchNo.value='';
		
		//x.message.value='';
		x.actionmode.value = '';
	
	}

}


function CalcPrdDtTotal(dec) {
	x = document.productiondt;
	var vmode = x.actionmode.value;
	var Qty = x.txtPrdDtQty.value;
	var CostPrice = x.txtPrdDtCostPrice.value;
	if (Qty == '') Qty = 0;
	if (CostPrice == '') CostPrice = 0;
	
	Qty = parseInt(Qty);
	CostPrice = parseFloat(CostPrice);
	
	if (Qty > 0 && CostPrice >= 0)
	   x.txtPrdDtTotal.value = Math.round((Qty*CostPrice)*Math.pow(10,dec))/Math.pow(10,dec);

}




function showlistItems(str){
  var vdate, vid;
  x = document.productiondt;
  
  vdate = x.PPrdDate.value;
  vid   = x.PPrdId.value;
  vItemType  = x.lstItemType.value;
  vItemGroup = x.lstGroup.value;
  vItemSort  = 'ItemCode';
  vItemWh    = x.lstWarehouse.value;
  vItemCode  = x.txtItemCodeFG.value;
  
  vItemGroup = vItemGroup.replace('&','%26');
  vItemWh = vItemWh.replace('&','%26');
  
  
  window.open('List_SorItems.php?frm=4&PItem_Code='+vItemCode+'&ItemType='+vItemType+'&ItemSort='+vItemSort+'&ItemGroup='+vItemGroup+'&ItemWh='+vItemWh+'&TransDate='+vdate,'mywindow','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistBatchNo(str) {
	x = document.productiondt;
	vItemCode  = x.txtItemCodeFG.value;
	
	window.open('List_BatchNo.php?frm=7&PItem_Code='+vItemCode,'List_BatchNo','width=580,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function showlistProject(str){

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

function showlistCostcenter(str){

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

function kd(e)
{
	x=document.productiondt;
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13) { //enter key
        //x.btnSubmitRecord.click();
		return false;
    }
    return true;
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Assemble Detail - Add Items</title>


<script type="text/javascript" src="dropdown.js"></script>
<link rel="stylesheet" href="default.css" type="text/css" />
<link rel="stylesheet" href="short.css" type="text/css" />
<link rel="stylesheet" href="dropdown.css" type="text/css" />
<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style11 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

</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 onLoad='ChangeLocation();' onkeydown='return kd(event)'>
<form name='productiondt' method='post'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='PPrdDate' value='$PPrdDate'>
<input type='hidden' name='PPrdId' value='$PPrdId'>
<input type='hidden' name='PPrdDtId' value='$PPrdDtId'>

<input type='hidden' name='PPrdExpireDate' value='$PPrdExpireDate'>
<input type='hidden' name='PPrdBatchNo' value='$PPrdBatchNo'>
<input type='hidden' name='PPrdWhCode' value='$PPrdWhCode'>
<input type='hidden' name='PPrdItemCode' value='$PPrdItemCode'>
<input type='hidden' name='PPrdCurr' value='$PPrdCurr'>
<input type='hidden' name='PPrdProjectCode' value='$PPrdProjectCode'>
<input type='hidden' name='PPrdCostCentCode' value='$PPrdCostCentCode'>
<input type='hidden' name='PPrdQty' value='$PPrdQty'>
<input type='hidden' name='PPrdQtyIdeal' value='$PPrdQtyIdeal'>
<input type='hidden' name='PPrdWaste' value='$PPrdWaste'>

HERE;

echo "<input type='hidden' name='PPrdRemark' value='".htmlspecialchars($PPrdRemark, ENT_QUOTES)."'>";
	
		                  
						  
//Pack Item Module
$ModePackItem = '';
if ($Module_Pack == 0)
	$ModePackItem = ' disabled ';


$lstWarehouse = $_POST["lstWarehouse"]; if ($lstWarehouse == ""){$lstWarehouse = $_GET["lstWarehouse"];}   
$lstItemType = $_POST['lstItemType']; if ($lstItemType == ""){$lstItemType = $_GET["lstItemType"];} if ($lstItemType == ""){$lstItemType = "All";}

if (empty($lstWarehouse)) {
	if(!empty($defaultwarehouse))
		$lstWarehouse = $defaultwarehouse;
	else	
		$lstWarehouse = $SetupDftWareHouse;
}	

if ($Module_ProjectDt == 1 && empty($txtProjectCodeDt))     $txtProjectCodeDt  = $PPrdProjectCode; 
if ($Module_CostCenterDt == 1 && empty($txtCostCentCodeDt)) $txtCostCentCodeDt = $PPrdCostCentCode; 


//Edit Production Detail Mode
if($PPrdDtId != ''){
	$querydt = " Select ProductionDt_ID, ProductionDt.Item_CodePacked, ProductionDt.Item_code, Item_Description, ProductionDt.Warehouse_Code, ".
	           " ProductionDt_Remark, ProductionDt_Quantity, ProductionDt_IdealQty, Round(ProductionDt_Cost, ".$DecimalBase."), ProductionDt_CostBase1, ".
			   " ProductionDt_CostBase2, ifNull(ProductionDt_IdealQty,0) - ifNull(ProductionDt_Quantity,0) As ProductionDtWasteCalc, ProductionDt_Waste, ".
			   " Round((ProductionDt_Quantity*ProductionDt_Cost), ".$DecimalBase.") As TotalActual, ".
			   " Round((ProductionDt_IdealQty*ProductionDt_Cost), ".$DecimalBase.") As TotalIdeal, ".
			   " Date_Format(ProductionDt.ProductionDt_ExpireDate,'%d/%m/%Y') As ProductionDt_ExpireDate, ProductionDt.ProductionDt_BatchNo, ".
			   " ProductionDt.Project_code, ProductionDt.CostCenter_Code ".
			   " From Temp_ProductionDt As ProductionDt Left Join Items on ProductionDt.Item_code = Items.Item_code ".
	           " Where ProductionDt.ProductionDt_ID = ".$PPrdDtId;
			   //" And Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";			   
	//echo $querydt;
	$resultdt=mysql_query($querydt,$connection) or die(mysql_error());
    $rowsdt=mysql_fetch_array($resultdt);
 	
	$txtPrdDtId         = $rowsdt[0];
	$txtItemCodeFG      = $rowsdt[2];
	$txtItemDescFG      = $rowsdt[3];
	$lstWarehouse       = $rowsdt[4];
	$txtPrdDtRemark     = $rowsdt[5];
	$txtPrdDtQty        = $rowsdt[6];
	$txtPrdDtQtyIdeal   = $rowsdt[7];
	$txtPrdDtWasteCalc  = $rowsdt[11];
	$txtPrdDtWaste 	    = $rowsdt[12];
	$txtPrdDtCostPrice 	= $rowsdt[8];
	$txtPrdDtTotal 	    = $rowsdt[13];
	$txtPrdDtTotalIdeal = $rowsdt[14];
	$txtPrdDtExpireDate = $rowsdt[15];
	$txtPrdDtBatchNo    = $rowsdt[16];
	$txtProjectCodeDt	= $rowsdt[17]; 
	$txtCostCentCodeDt	= $rowsdt[18];
	
}

$i_expire   = 0;

if($txtItemCodeFG != ''){
	$sub_query = " SELECT Item_Vat, Currency_Code, ifNull(Item_CostMethod,0), ifNull(Item_NonStock,0), ifNull(Item_Expire,1) ".
				 " FROM Items WHERE Item_Code = '".$txtItemCodeFG."'";
	$sub_result = selectData($connection, $sub_query);
	$ItemVat 	     = $sub_result[0];
	$ItemCurr		 = $sub_result[1];
	$ItemCostMethod  = $sub_result[2];
	$ItemNonStock    = $sub_result[3];
	$i_expire	 	 = $sub_result[4];
			
	if ($PPrdDtId == '')		
		$txtPrdDtCostPrice = Round(Get_CostPrice($txtItemCodeFG, $ItemCurr, $ItemCostMethod, $PPrdDate, $PPrdCurr, $base1, $base2, $connection), $DecimalBase);		

}

$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

	  
echo"   <tr><td valign='top'>
        <table border='0' style='table-layout:fixed' align='center' valign='top'>
          <col width=90>";
		  
if ($DisableIdeal == 0) {	  
	echo" <col width=90>
		  <col width=80>
		  <col width=80>
		  <col width=100>
		  <col width=100>
		  <col width=100>";
} else {
	echo" <col width=100>
		  <col width=100>
		  <col width=100>
		  <col width=90>
		  <col width=80>
		  <col width=80> ";
}
		  
echo"	   <tr bgcolor='#F7F7F7' height='25'>
		     <th colspan='7'><span class='style3'>Add Items </span></th></tr>
		   <tr bgcolor='#F7F7F7' height='25'>	
			 <td colspan='7' align='center'><font size='1' color='#FF0000' face='Verdana'><b>".$message."</b></font></td></tr>			 
			 
		   <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Warehouse&nbsp;<span class='style26'>*</span></span></td>";
		     
		if ($PPrdDtId == '') {	 	 
			echo" <td colspan='6'><select name='lstWarehouse' id='lstWarehouse' style='font-size:11px; width:200px; height:20px;' >";
			echo"<option></option>";
			while($wrhf=mysql_fetch_row($resultwarehouse)){
			echo"<option ";
				if (($lstWarehouse==$wrhf[0]) || ($DftWareHouse==$wrhf[0]))
					echo " selected ";
			echo" value='$wrhf[0]'>$wrhf[0] / $wrhf[1]</option>";
			}
			echo"</select></td>";
			
		} else 	{
			echo"<td colspan='6'><b>$lstWarehouse</b><input type='hidden' name='lstWarehouse' id='lstWarehouse' value='$lstWarehouse'></td>";
		
		}
			
	echo"</tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Item Type</span></td>
		     <td colspan='6'>
			 <input type='hidden' name='txtPrdDtId' value='$txtPrdDtId' >
			 <input type='hidden' name='txtRemainQty' value='$txtRemainQty' >
			 <select name='lstItemType' style='font-size:11px; width:200px; height:20px;'>";
			
			if ($lstItemType == "All"){
				echo "<option selected value='All'>All Items</option>";
			}else {
				echo "<option value='All'>All Items</option>";
			}
			if ($lstItemType == "Packed" && $Module_Pack == 1){
				echo "<option selected value='Packed'>Packed</option>";
			}else if ($Module_Pack == 1){
				echo "<option value='Packed'>Packed</option>";
			}
			if ($lstItemType == "PromoPacked" && $Module_Pack == 1){
				echo "<option selected value='PromoPacked'>Promo Packed</option>";
			}else{
				echo "<option value='PromoPacked'>Promo Packed</option>";
			}
			if ($lstItemType == "Trading"){
				echo "<option selected value='Trading'>Trading</option>";
			}else{
				echo "<option value='Trading'>Trading</option>";
			}
			if ($lstItemType == "PromoTrading"){
				echo "<option selected value='PromoTrading'>Promo Trading</option>";
			}else{
				echo "<option value='PromoTrading'>Promo Trading</option>";
			}
			if ($lstItemType == "Production"){
				echo "<option selected value='Production'>Production</option>";
			}else{
				echo "<option value='Production'>Production</option>";
			}
			if ($lstItemType == "NonStock"){
				echo "<option selected value='NonStock'>Non-Stock</option>";
			}else{
				echo "<option value='NonStock'>Non-Stock</option>";
			}
			echo "</select></td>";
			 
			
echo"     </tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Group</span></td>
		     <td colspan='6'><select name='lstGroup' id='lstGroup' style='font-size:11px; width:383px; height:20px;' >";
			echo"<option></option>";
			while($groupf=mysql_fetch_row($resultgroup)){
			echo"<option ";
				if ($lstGroup==$groupf[0] )
					echo " selected ";
			echo" value='$groupf[0]'>$groupf[0] - $groupf[1]</option>";
			}
			
echo"        </select></td>			 
		  </tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Item&nbsp;<span class='style26'>*</span></span></td>";
			 
			 if ($PPrdDtId == '') {
				echo " <td colspan='6'><input type='text' name='txtItemCodeFG' value='$txtItemCodeFG'  maxlength='20' style='font-size:12px; width:110px; height:20px;'>
					   <input type='text' name='txtItemDescFG' id='txtItemDescFG' value='$txtItemDescFG' style='font-size:12px; width:270px; height:20px;' />
					   <label><span class='style12'><img src='img/btnopen.jpg' title=' Select Item '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistItems(1); ' /></span></label></td>";
			 } else {
				echo " <td colspan='6'><input type='hidden' name='txtItemCodeFG' value='$txtItemCodeFG' /><input type='hidden' name='txtItemDescFG' id='txtItemDescFG' value='$txtItemDescFG' />
					   <b>$txtItemCodeFG &nbsp;&nbsp; $txtItemDescFG</b></td>";
			 }	
			 
echo"     </tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Remark</span></td>
			 <td  colspan='6'><input type='text' name='txtPrdDtRemark' value='".htmlspecialchars($txtPrdDtRemark, ENT_QUOTES)."'  maxlength='51' style='font-size:12px; width:385px; height:20px;'></td>
		  </tr>";

if ($Module_ProjectDt == 1 || $Module_CostCenterDt == 1) {
	echo"   <tr bgcolor='#F7F7F7'>";

	if ($Module_ProjectDt == 1) {
		echo" <td align='left'><span class='style12'>Project&nbsp;<span class='style12'>*</span></span></td>
			  <td colspan='2' align='left'> <span class='style12'>
				<input type='text' name='txtProjectCodeDt' id='txtProjectCodeDt' value='$txtProjectCodeDt' style='width:120px;' maxlength='15' readonly /></span>
				<label><span class='style12'><img src='img/btnopen.jpg' title=' Select Project ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(1); '  /></span></label></td>";
	} else {
		echo" <td align='left'>&nbsp;</td>
			  <td colspan='2' align='left'><input type='hidden' name='txtProjectCodeDt' id='txtProjectCodeDt' value='' /></td>";
	}

	if ($Module_CostCenterDt == 1) {		  
		echo" <td align='left'><span class='style12'>Costcenter&nbsp;<span class='style12'>*</span></span></td>
			  <td colspan='3' align='left'><span class='style12'>
				<input type='text' name='txtCostCentCodeDt' id='txtCostCentCodeDt' value='$txtCostCentCodeDt' style='width:130px;' maxlength='15' readonly /></span>
				<label><span class='style12'><img src='img/btnopen.jpg' title=' Select Costcenter ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick='showlistCostcenter(1); ' /></span></label></td>";
	} else {
		echo" <td align='left'>&nbsp;</td>
			  <td colspan='3' align='left'><input type='hidden' name='txtCostCentCodeDt' id='txtCostCentCodeDt' value='' /></td>";

	}
	echo"   </tr>";
}

if ($Module_ExpireDate == 1) {
	echo" <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Batch No</span></td>
			 <td colspan='2'><input type='text' name='txtPrdDtBatchNo' value='".htmlspecialchars($txtPrdDtBatchNo, ENT_QUOTES)."'  maxlength='40' style='font-size:12px; width:120px; height:20px;' readonly >
				<label><span class='style12'><img src='img/btnopen.jpg' title='Select Batch No'  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistBatchNo(1); ' /></span></label></td>
			  <td valign='center' align='left' ><span class='style12'>Expire Date</span></td>
			  <td colspan='3'><input type='text' name='txtPrdDtExpireDate' value='$txtPrdDtExpireDate' maxlength='10' style='font-size:12px; width:90px; height:20px;'>
					<a HREF='#' onClick=\"displayCalendar(document.productiondt.txtPrdDtExpireDate,'dd/mm/yyyy',this); return false;\" NAME='anchor1' ID='anchor1'><img src='./img/cal.gif' border=0 align=center></a>
			 </td>
		  </tr>	"; 	 
} else {
	echo" <input type='hidden' name='txtPrdDtExpireDate' value='$txtPrdDtExpireDate'>";
	echo" <input type='hidden' name='txtPrdDtBatchNo' value='$txtPrdDtBatchNo'>";
}
		  
echo"	  <tr bgcolor='#F7F7F7' height='25'>";

	if ($DisableIdeal == 0) {		  
		echo"<td valign='center' align='center' ><span class='style12'>Actual Qty&nbsp;<span class='style26'>*</span></span></td> 
			 <td valign='center' align='center' ><span class='style12'>Ideal Qty</span></td> 
			 <td valign='center' align='center' ><span class='style12'>Waste</span></td> 
			 <td valign='center' align='center' ><span class='style12'>Actual Waste</span></td> 
			 <td valign='center' align='center' ><span class='style12'>Cost Price&nbsp;<span class='style26'>*</span></span></td> 
			 <td valign='center' align='center' ><span class='style12'>Actual Total</span></td> 
			 <td valign='center' align='center' ><span class='style12'>Ideal Total</span></td> ";
	} else {
		echo"<td valign='center' align='center' ><span class='style12'>Actual Qty&nbsp;<span class='style26'>*</span></span></td> 
			 <td valign='center' align='center' ><span class='style12'>Cost Price&nbsp;<span class='style26'>*</span></span></td> 
			 <td valign='center' align='center' ><span class='style12'>Actual Total</span></td> 
			 <td valign='center' align='center' colspan='4'>&nbsp;</td> ";
	}
	
echo"	  </tr>
		  <tr bgcolor='#F7F7F7' height='25'>
		     <td align='center'><input type='text' name='txtPrdDtQty' value='$txtPrdDtQty' maxlength='20' onBlur='CalcPrdDtTotal($DecimalBase);'  style='font-size:12px; width:80px; height:20px;' ></td>";
			 
	if ($DisableIdeal == 0) {		 
		echo"<td align='center'><input type='text' name='txtPrdDtQtyIdeal' value='$txtPrdDtQtyIdeal' maxlength='20' style='font-size:12px; width:80px; height:20px;' readonly></td>
			 <td align='center'><input type='text' name='txtPrdDtWasteCalc' value='$txtPrdDtWasteCalc' maxlength='20'  style='text-align:right; font-size:12px; width:70px; height:20px;' readonly></td>
			 <td align='center'><input type='text' name='txtPrdDtWaste' value='$txtPrdDtWaste' maxlength='20' style='text-align:right; font-size:12px; width:70px; height:20px;' ></td>
			 <td align='center'><input type='text' name='txtPrdDtCostPrice' value='$txtPrdDtCostPrice' maxlength='20' onBlur='CalcPrdDtTotal($DecimalBase);' style='text-align:right; font-size:12px; width:90px; height:20px;' ></td>
			 <td align='center'><input type='text' name='txtPrdDtTotal' value='$txtPrdDtTotal' maxlength='20' style='text-align:right; font-size:12px; width:90px; height:20px;' ></td>
			 <td align='center'><input type='text' name='txtPrdDtTotalIdeal' value='$txtPrdDtTotalIdeal' maxlength='20' style='text-align:right; font-size:12px; width:90px; height:20px;'></td>";
	} else {
		echo"<td align='center'><input type='text' name='txtPrdDtCostPrice' value='$txtPrdDtCostPrice' maxlength='20' onBlur='CalcPrdDtTotal($DecimalBase);' style='text-align:right; font-size:12px; width:90px; height:20px;' ></td>
			 <td align='center'><input type='text' name='txtPrdDtTotal' value='$txtPrdDtTotal' maxlength='20' style='text-align:right; font-size:12px; width:90px; height:20px;' ></td>
			 <td align='center' colspan='4'>
				<input type='hidden' name='txtPrdDtQtyIdeal' value='$txtPrdDtQtyIdeal' >
				<input type='hidden' name='txtPrdDtWasteCalc' value='$txtPrdDtWasteCalc' >
				<input type='hidden' name='txtPrdDtWaste' value='$txtPrdDtWaste' >
				<input type='hidden' name='txtPrdDtTotalIdeal' value='$txtPrdDtTotalIdeal' >
			 </td>";
	}
	
echo"	  </tr>
		  <tr bgcolor='#F7F7F7' height='35'>
		     <td colspan='7' align='center' bgcolor=#D8D8D8>
			    <input type='button' id='btnSubmitRecord' name='btnSubmitRecord'  value='Submit Record'  onclick='SubmitRecord($i_expire)' $style title='Submit Record'></td>
			 
		  </tr>
        </table>";

	

print <<<HERE
</form>
</body>

HERE;

?>