<?php

session_start();
if($_SESSION['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($_SESSION['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_DoubleUnit,0) As Module_DoubleUnit, ".
			 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt, ".
			 " ifNull(Module_Unit1Method,0) As Module_Unit1Method, ifNull(Module_ExpireDate,0) As Module_ExpireDate ".
			 " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


$mainaction = $_POST["mainaction"]; if ($mainaction == ""){$mainaction = $_GET["mainaction"];} 
$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];} 
$message 	= $_POST["message"]; if ($message == ""){$message = $_GET["message"];} 

$PPurId    			= $_GET["PPurId"]; if ($PPurId == ""){$PPurId = $_POST["PPurId"];} 
$PPurType    		= $_GET["PPurType"]; if ($PPurType == ""){$PPurType = $_POST["PPurType"];} 
$PPurDtId    		= $_GET["PPurDtId"]; if ($PPurDtId == ""){$PPurDtId = $_POST["PPurDtId"];} 
$PPurDate 			= $_GET["PPurDate"]; if ($PPurDate == ""){$PPurDate = $_POST["PPurDate"];} 
$PPurMaturityDate 	= $_GET["PPurMaturityDate"]; if ($PPurMaturityDate == ""){$PPurMaturityDate = $_POST["PPurMaturityDate"];} 
$PPurSupplier 	   	= $_GET["PPurSupplier"]; if ($PPurSupplier == ""){$PPurSupplier = $_POST["PPurSupplier"];} 
$PPurCurr   		= $_GET["PPurCurr"]; if ($PPurCurr == ""){$PPurCurr = $_POST["PPurCurr"];} 
$PPurProjectCode 	= $_GET["PPurProjectCode"]; if ($PPurProjectCode == ""){$PPurProjectCode = $_POST["PPurProjectCode"];} 
$PPurCostCentCode	= $_GET["PPurCostCentCode"]; if ($PPurCostCentCode == ""){$PPurCostCentCode = $_POST["PPurCostCentCode"];} 
$PPurCategory	 	= $_GET["PPurCategory"]; if ($PPurCategory == ""){$PPurCategory = $_POST["PPurCategory"];} 
$PPurRemark	 		= $_GET["PPurRemark"]; if ($PPurRemark == ""){$PPurRemark = $_POST["PPurRemark"];} 
$PPurInvoiceNo 		= $_GET["PPurInvoiceNo"]; if ($PPurInvoiceNo == ""){$PPurInvoiceNo = $_POST["PPurInvoiceNo"];} 
$PPurFormMNo 		= $_GET["PPurFormMNo"]; if ($PPurFormMNo == ""){$PPurFormMNo = $_POST["PPurFormMNo"];} 
$PPurPackRef 		= $_GET["PPurPackRef"]; if ($PPurPackRef == ""){$PPurPackRef = $_POST["PPurPackRef"];} 

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

$txtPurDtId	  	  	= $_POST["txtPurDtId"]; if ($txtPurDtId == ""){$txtPurDtId = $_GET["txtPurDtId"];}  
$txtItemCode	  	= $_POST["txtItemCode"]; if ($txtItemCode == ""){$txtItemCode = $_GET["txtItemCode"];}  
$txtItemDesc	  	= $_POST["txtItemDesc"]; if ($txtItemDesc == ""){$txtItemDesc = $_GET["txtItemDesc"];}  
$txtPurDtRemark	  	= $_POST["txtPurDtRemark"]; if ($txtPurDtRemark == ""){$txtPurDtRemark = $_GET["txtPurDtRemark"];}  
$txtPurDtQty	  	= $_POST["txtPurDtQty"]; if ($txtPurDtQty == ""){$txtPurDtQty = $_GET["txtPurDtQty"];}  
$txtPurDtQty2	  	= $_POST["txtPurDtQty2"]; if ($txtPurDtQty2 == ""){$txtPurDtQty2 = $_GET["txtPurDtQty2"];}  
$txtRemainQty	  	= $_POST["txtRemainQty"]; if ($txtRemainQty == ""){$txtRemainQty = $_GET["txtRemainQty"];}  
$txtPurDtVolume	  	= $_POST["txtPurDtVolume"]; if ($txtPurDtVolume == ""){$txtPurDtVolume = $_GET["txtPurDtVolume"];}  
$txtPurDtVat	  	= $_POST["txtPurDtVat"]; if ($txtPurDtVat == ""){$txtPurDtVat = $_GET["txtPurDtVat"];}  
$txtPurDtExpireDate = $_POST["txtPurDtExpireDate"]; if ($txtPurDtExpireDate == ""){$txtPurDtExpireDate = $_GET["txtPurDtExpireDate"];}  
$txtPurDtBatchNo 	= $_POST["txtPurDtBatchNo"]; if ($txtPurDtBatchNo == ""){$txtPurDtBatchNo = $_GET["txtPurDtBatchNo"];}  
$txtProjectCodeDt 	= $_POST["txtProjectCodeDt"]; if ($txtProjectCodeDt == ""){$txtProjectCodeDt = $_GET["txtProjectCodeDt"];}  
$txtCostCentCodeDt	= $_POST["txtCostCentCodeDt"]; if ($txtCostCentCodeDt == ""){$txtCostCentCodeDt = $_GET["txtCostCentCodeDt"];}  



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.purchasedt;
	
	var result = CheckFields(ItemExpire);
	var PurId     = x.PPurId.value;
	var PurDtId   = x.txtPurDtId.value;
	var vMainMode = x.mainaction.value;
	var vMode     = x.actionmode.value;
	
	if (PurDtId == '')
		vMode = 'submitrecord';	
	else
		vMode = 'editdt';	
	   
	if (result == 1) {
		x.action="Form_RetGoodRecNote_Actions.php?mode="+vMode+"&mainmode="+vMainMode+"&SPurId="+PurId+"&SPurDtId="+PurDtId;
		x.submit();
		
	}	
}

function ChangeLocation() {
	x = document.purchasedt;
	var vMode = x.actionmode.value;
	
	if (vMode == 'submitrecord') {
		
		opener.document.purchase.actionmode.value = x.actionmode.value;
		opener.document.purchase.mainaction.value = x.mainaction.value;
		//opener.document.purchase.message.value = x.message.value;
		opener.document.purchase.txtPurId.value = x.PPurId.value;
		opener.document.purchase.submit();
		
	} 
	else if (vMode == 'submitrecord' || vMode == 'editdt') {
		opener.document.purchase.actionmode.value = x.actionmode.value;
		opener.document.purchase.mainaction.value = x.mainaction.value;
		opener.document.purchase.txtPurId.value = x.PPurId.value;
		opener.document.purchase.submit();
		
		self.close();
	
	}
	
	//x.txtItemCode.focus();
}

function CheckFields(ItemExpire){
  
    x = document.purchasedt;
	
	var PurDtItem 	   = x.txtItemCode.value;
	//var PurDtItemPacked = x.txtItemCodePacked.value;
	var PurDtWarehouse = x.lstWarehouse.value;
	var PurDtQty	   = x.txtPurDtQty.value;
	var PurDtQty2	   = x.txtPurDtQty2.value;
	var PurDtRemQty	   = x.txtRemainQty.value;
	
	var PurDtExpireDate = x.txtPurDtExpireDate.value;
	var PurDtBatchNo    = x.txtPurDtBatchNo.value;
	
	var vmode = x.actionmode.value;
	
	PurDtQty = parseInt(PurDtQty);
	PurDtRemQty = parseInt(PurDtRemQty);

	if (PurDtWarehouse=='')
	{
		alert("Warehouse Column is mandatory!");
		x.lstWarehouse.focus();
		return 0;
	}
	else if (PurDtItem=='' )
	{
		alert("Item Column is mandatory!");
		x.txtItemCode.focus();
		return 0;
	}
	else if (PurDtQty*1 != PurDtQty/1 || PurDtQty < 0) {
		alert('Quantity should be a NUMERIC and POSITIVE value ');
		x.txtPurDtQty.focus();
		return 0;
	}
	else if (PurDtRemQty != '' && PurDtQty > PurDtRemQty ) {
		alert('Quantity entered not allowed. Qty must be <= Remaining Purchased Qty ['+PurDtRemQty+'].');
		x.txtPurDtQty.focus();
		return 0;
	}
	else if ((PurDtQty2 != '' && PurDtQty2*1 != PurDtQty2/1) ) {
		alert('Item Qty2 should be a NUMERIC value.');
		x.txtPurDtQty2.focus();
		return 0;
	}	
	else if (ItemExpire == 1 && PurDtExpireDate == '' ) {
		alert('Item Expire Date is mandatory.');
		x.txtPurDtExpireDate.focus();
		return 0;
	}
	else if (ItemExpire == 1 && PurDtBatchNo == '' ) {
		alert('Item Batch No is mandatory.');
		x.txtPurDtBatchNo.focus();
		return 0;
	}
	
	else
	return 1 ;	
}






//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.purchasedt;
	var vmode = x.actionmode.value;
	
	if (Option == 'D')
	{
		x.txtPurDtId.value='';
		//x.txtItemCodePacked.value='';
		//x.txtItemDescPacked.value='';
		x.txtItemCode.value='';
		x.txtItemDesc.value='';
		x.lstWarehouse.value='';
		x.txtWarehouseName.value='';
		x.txtPurDtRemark.value='';
		x.txtPurDtQty.value='';
		x.txtPurDtQty2.value='';
		x.txtPurDtVolume.value='';
		x.txtPurDtVat.value='';
		x.txtPurDtExpireDate.value='';
		x.txtPurDtBatchNo.value='';
		
		//x.message.value='';
		x.actionmode.value = '';
	
	}

}


function CalcQty2(ModuleUnit1Method,UnitCoef,Option) {
	x = document.purchasedt;
	var Qty  = x.txtPurDtQty.value;
	var Qty2 = x.txtPurDtQty2.value;
	
	if (Qty == '')  Qty = 0;
	if (Qty2 == '') Qty2 = 0;
	
	if(ModuleUnit1Method == 1) {
		if (Qty > 0 && Option == 1 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty2.value = Qty*UnitCoef;
		}	
		else if (Qty == 0 && Option == 1 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty2.value = '';
		}
	}
	//Case Modify Qty and Qty2 Should Be Empty
	else if(ModuleUnit1Method == 0 && Option == 1 && Qty2 == 0) {
		if (Qty > 0 && UnitCoef != 0 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty2.value = Qty/UnitCoef;
		}	
		else if (Qty == 0 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty2.value = '';
		}
	}
	//Case Modify Qty2 Get Qty
	else if(ModuleUnit1Method == 0 && Option == 2) {
		if (Qty2 > 0 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty.value = Qty2*UnitCoef;
		}	
		else if (Qty2 == 0 && document.getElementById('txtPurDtQty2').type == 'text') {
			x.txtPurDtQty.value = '';
		}
	}
}

function SetItemVat() {
	x = document.purchasedt;
	var vmode = x.actionmode.value;
	
	if (x.txtPurDtVat.value == 1)
	   x.chkPurDtVat.checked = true;

}


function showlistBatchNo(str) {
	x = document.purchasedt;
	vItemCode  = x.txtItemCode.value;
	
	window.open('List_BatchNo.php?frm=9&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=19&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=19&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Goods Receive Note 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();' >
<form name='purchasedt' method='post'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='PPurType' value='$PPurType'>
<input type='hidden' name='PPurDate' value='$PPurDate'>
<input type='hidden' name='PPurId' value='$PPurId'>
<input type='hidden' name='PPurDtId' value='$PPurDtId'>

HERE;

if ($Module_ProjectDt == 1 && empty($txtProjectCodeDt))     $txtProjectCodeDt  = $PPurProjectCode; 
if ($Module_CostCenterDt == 1 && empty($txtCostCentCodeDt)) $txtCostCentCodeDt = $PPurCostCentCode; 
	
//Edit Purchase Detail Mode
if($PPurDtId != ''){
	$querydt = " Select PurchaseDt_ID, GrnPurchasesDt.Item_CodePacked, GrnPurchasesDt.Item_code, Items.Item_Description, GrnPurchasesDt.Warehouse_Code, ".
	           " Warehouse.Warehouse_Name, Purchasedt_Remark, PurchaseDt_Quantity, PurchaseDt_Volume, if(ifNull(Items.Item_Vat,0) != '', 1, 0) As ItemVat, ".
			   " GrnPurchasesDt.Item_Unit2Qty, Date_Format(PurchaseDt_ExpireDate,'%d/%m/%Y') As PurchaseDt_ExpireDate, PurchaseDt_BatchNo, ".
			   " GrnPurchasesDt.Project_code, GrnPurchasesDt.CostCent_Code ".
			   " From Temp_GrnPurchasesDt As GrnPurchasesDt Left Join Items on GrnPurchasesDt.Item_code = Items.Item_code ".
			   " Left Join Warehouse on GrnPurchasesDt.Warehouse_Code = Warehouse.Warehouse_Code ".
	           " Where GrnPurchasesDt.PurchaseDt_ID = '".$PPurDtId."'";
			   //" And Logged_Code = '".$_SESSION['useraccount']."' ";			   
	//echo $querydt;
	$resultdt=mysql_query($querydt,$connection) or die(mysql_error());
    $rowsdt=mysql_fetch_array($resultdt);
	
	$txtPurDtId        = $rowsdt[0];
	//$txtItemCodePacked = $rowsdt[1];
	$txtItemCode       = $rowsdt[2];
	$txtItemDesc       = $rowsdt[3];
	$lstWarehouse      = $rowsdt[4];
	$txtWarehouseName  = $rowsdt[5];
	$txtPurDtRemark    = $rowsdt[6];
	$txtPurDtQty       = $rowsdt[7];
	$txtPurDtQty2      = $rowsdt[10];
	$txtPurDtVolume    = $rowsdt[8];
	$txtPurDtVat       = $rowsdt[9];
	$txtPurDtExpireDate = $rowsdt[11];
	$txtPurDtBatchNo    = $rowsdt[12];
	$txtProjectCodeDt	= $rowsdt[13]; 
	$txtCostCentCodeDt	= $rowsdt[14];
	
}

$i_unitcoef = 1;
$i_expire   = 0;

if($txtItemCode != ''){
	$query = " SELECT Item_UnitSalesDesc, Item_UnitPurchaseDesc, ifNull(Item_Unit,1), ifNull(Item_Expire,1) ".
			 " FROM items WHERE Item_Code = '".$txtItemCode."'";
		
	//echo "<br><br>".$query;
	$result = selectData($connection, $query);
	$i_unit1  	  = $result[0];
	$i_unit2 	  = $result[1]; 
	$i_unitcoef	  = $result[2];
	$i_expire	  = $result[3];
	
	$txtItemUnit1 = $i_unit1;
	$txtItemUnit2 = $i_unit2;
	
}


$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>
		  <col width=170>
		  <col width=80>
		  <col width=320>
		   <tr bgcolor='#F7F7F7' height='25'>
		     <th colspan='4'><span class='style3'>Add Items </span></th></tr>
		   <tr bgcolor='#F7F7F7' height='20'>	
			 <td colspan='4' align='center'><font size='1' color='#FF0000' face='Verdana'><b>".$message."<br>".$WarningMsg."</b></font></td></tr>			 
			 
		   <tr bgcolor='#F7F7F7' height='25'>
			<input type='hidden' name='txtPurDtId' value='$txtPurDtId' >
			<input type='hidden' name='txtRemainQty' value='$txtRemainQty' >
			<input type='hidden' name='txtItemCode' value='$txtItemCode' />
			<input type='hidden' name='txtItemDesc' id='txtItemDesc' value='$txtItemDesc' />
			<input type='hidden' name='lstWarehouse' id='lstWarehouse' value='$lstWarehouse'>
			<input type='hidden' name='txtWarehouseName' id='txtWarehouseName' value='$txtWarehouseName'>
            <td valign='center' align='left' ><span class='style12'>Warehouse&nbsp;<span class='style26'>*</span></span></td>";
		     
	echo"	<td colspan='3'><b>$lstWarehouse - $txtWarehouseName</b></td>";
	echo" </tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Item&nbsp;<span class='style26'>*</span></span></td>";
			 
	echo " 	<td colspan='3'><b>$txtItemCode &nbsp;&nbsp; $txtItemDesc</b></td>";
			 
	echo" </tr>	 
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Remark</span></td>
			 <td colspan='3'><input type='text' name='txtPurDtRemark' value='".htmlspecialchars($txtPurDtRemark, 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 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 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 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 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><input type='text' name='txtPurDtBatchNo' value='".htmlspecialchars($txtPurDtBatchNo, 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><input type='text' name='txtPurDtExpireDate' value='$txtPurDtExpireDate' maxlength='10' style='font-size:12px; width:90px; height:20px;'>
					<a HREF='#' onClick=\"displayCalendar(document.purchasedt.txtPurDtExpireDate,'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='txtPurDtExpireDate' value='$txtPurDtExpireDate'>";
	echo" <input type='hidden' name='txtPurDtBatchNo' value='$txtPurDtBatchNo'>";
}
		  
echo"	  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Quantity&nbsp;<span class='style26'>*</span></span></td>
			 <td><input type='text' name='txtPurDtQty' value='$txtPurDtQty' onchange='CalcQty2($Module_Unit1Method,$i_unitcoef,1);' maxlength='20' style='font-size:12px; width:80px; height:20px;' >&nbsp;<b>$txtItemUnit1</b></td>";
			 
if ($Module_DoubleUnit == 1){
	echo"<td valign='center' align='left' ><span class='style12'>Unit2 Qty</span></td>";
	echo"<td align='left'><input type='text' name='txtPurDtQty2' id='txtPurDtQty2' value='$txtPurDtQty2' onchange='CalcQty2($Module_Unit1Method,$i_unitcoef,2);' maxlength='20' style='text-align:left; font-size:12px; width:90px; height:20px;' ><b>&nbsp;$txtItemUnit2</b></td>";
		 
} else {
	echo "<td colspan='2'><input type='hidden' name='txtPurDtQty2' id='txtPurDtQty2' value='$txtPurDtQty2'></td>";
}
			 
	echo" </tr>	
		  <tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style12'>Volume</span></td>
			 <td colspan='3'><input type='text' name='txtPurDtVolume' value='$txtPurDtVolume' maxlength='20' style='font-size:12px; width:80px; height:20px;'></td>
		  </tr>	 
		  <tr bgcolor='#F7F7F7' height='20'>
             <td valign='center' align='left' ><span class='style12'>VAT</span></td>
			 <td colspan='3'><input type='hidden' name='txtPurDtVat' value='$txtPurDtVat'><input name='chkPurDtVat' type='checkbox' id='chkPurDtVat' value='1' disabled "; 
	          if($txtPurDtVat==1) echo "checked /></td>"; else echo " /></td>";   
echo"	  </tr>	";
echo"	  <tr bgcolor='#F7F7F7' height='30'>
		     <td colspan='4' 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;

?>