<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);

if (!empty($_GET["action"])) {
	$dftorderby   = $_GET["dftorderby"];
	$action 	  = $_GET["action"];
	$orderby 	  = $_GET["orderby"];
	$morelines	  = $_GET["morelines"];
	$startrange   = $_GET["startrange"];
	$perpage 	  = $_GET["perpage"];
	$totalrows    = $_GET["totalrows"];
	$direction    = $_GET["direction"];
	$filepath     = $_GET["filepath"];
	$transid      = $_GET["transid"];
	$transdtid    = $_GET["transdtid"];
	$form      	  = $_GET["form"];
	
	
	
	include("config.inc.php");
	include("Functions_Sales.php");
	
	$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
	mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");
	
	
	if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
		mysql_query("SET NAMES 'utf8'"); 
		mysql_query('SET CHARACTER SET utf8'); 
		mysql_set_charset('utf8', $connection);
	}

	//echo $_SESSION['dbName']."<br>";
	
	if ($form == 'PReq') {
		$querylog=" select ifNull(FI_PurchaseRequestApp,0) As FI_PurchaseRequestApp, ifNull(FI_PRequestConfirmed,0) As FI_PRequestConfirmed, ".
			  " ifNull(FI_PurchaseCategory,0) As FI_PurchaseCategory, ifNull(Login_FastPrint,0) As Login_FastPrint ".
			  " 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);
	}
		
	//Read From Setup Table							
	$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
				 " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage 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_AdditionalTaxes,0) As Module_AdditionalTaxes, ifNull(Module_Pack,0) As Module_Pack, ".
				 " ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
				 " ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost, ".
				 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt, ".
				 " ifNull(Module_PRequestConfirm,0) As Module_PRequestConfirm, ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ifNull(Module_Unit1Method,0) As Module_Unit1Method ".
				 ", ifnull(Module_PurchaseRequestPrice,0) as Module_PurchaseRequestPrice, ifnull(Module_Heatno, 0) as Module_Heatno, ifnull(module_shipmentclosing,0) as module_shipmentclosing  ".
				 " From Module ";
	$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
	while($rowmodule=mysql_fetch_array($resultmodule)){
		extract($rowmodule);
	}

	//Read From PurchaseSetup Table
	$queryPurchaseSetup="Select PurchaseTTC From PurchaseSetup";
	$resultPurchaseSetup=mysql_query($queryPurchaseSetup,$connection) or die(mysql_error());
	while($rowPurchaseSetup=mysql_fetch_array($resultPurchaseSetup)){
		extract($rowPurchaseSetup);
	}

		ShowPRequestDtGrid($connection,$form,$transid,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$PriceLabel,$Module_Unit1Method,$PurchaseTTC,$FIPurchaseCategory,$Module_PurchaseRequestPrice,$Module_Pack, $Module_Heatno);
	}
	else if ($form == 'PReq-totals') {
		ShowPRequestDtTotalsGrid($connection,$form,$transid,$_SESSION["PurchaseTTC"],$_SESSION["VatApplied"],$_SESSION["Setup_VatPercentage"],$_SESSION["DecimalBase"]);
	}
	else if ($form == 'PurchasesJv-TOT') {
		ShowPurchasesJvTotals($connection,$transid,$_SESSION['PurJv_parameters'],$_SESSION['gJv_arrayaccess']);
	}	
	else if ($form == 'SalesJv-TOT') {
		ShowSalesJvTotals($connection,$transid,$_SESSION['SalesJv_parameters'],$_SESSION['gSalesJv_arrayaccess']);
	} else if ($form == 'PorderJv-TOT') {
		ShowPorderJvTotals($connection,$transid,$_SESSION['PurJv_parameters'],$_SESSION['gJv_arrayaccess']);
	}
else if ($form == 'TRQ') {
 
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
	//Read From Module Table
$querymodule="Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh, Module_TransferSorder,ifnull(Module_ZeroQuantity,0) as Module_ZeroQuantity 
			,ifnull(Module_Unit1Method,0) as Module_Unit1Method,ifnull(Module_DoubleUnit,0) as Module_DoubleUnit,ifnull(Module_TransferRequestPrice,0) as Module_TransferRequestPrice,
			ifnull(Module_Heatno,0) as Module_Heatno
			From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$querySalesSetup="Select ifNull(ShowCostCentLayout,0) As ShowCostCentLayout, ifnull(showBatch,0) showBatch From TransferSetup";
$resultSalesSetup=mysql_query($querySalesSetup,$connection) or die(mysql_error());
while($rowSalesSetup=mysql_fetch_array($resultSalesSetup)){
	extract($rowSalesSetup);
}
							
	ShowTransferRequestDtGrid($connection,'TRQ',$transid,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$PriceLabel,$Module_Unit1Method,$PurchaseTTC,$Module_TransferWithOneWh,$FIPurchaseCategory,$Module_TransferRequestPrice,$showBatch,$Module_Heatno);
}
else if ($form == 'TR') {
	
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
	//Read From Module Table
$querymodule="Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh 
			,Module_TransferSorder,ifnull(Module_ZeroQuantity,0) as Module_ZeroQuantity 
			,ifnull(Module_Unit1Method,0) as Module_Unit1Method
			,ifnull(Module_DoubleUnit,0) as Module_DoubleUnit
			,ifnull(Module_TransferRequestPrice,0) as Module_TransferRequestPrice
			From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit 
				,ifNull(Module_TransferPrice,0) As Module_TransferPrice 
				,ifNull(Module_Heatno,0) As Module_Heatno 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}
$querySalesSetup="Select ifNull(ShowCostCentLayout,0) As ShowCostCentLayout, ifnull(showBatch,0) showBatch From TransferSetup";
$resultSalesSetup=mysql_query($querySalesSetup,$connection) or die(mysql_error());
while($rowSalesSetup=mysql_fetch_array($resultSalesSetup)){
	extract($rowSalesSetup);
}

		ShowTransferDtGrid($connection,'TR',$transid,$orderby,$startrange,$perpage,$option,$direction,$_SESSION['gso_parameters']);
		
}
else if ($form == 'JS') {
	
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt , ifnull(module_shipmentclosing,0) as module_shipmentclosing 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
//Read From Login Table
$querylog=" select ifNull(Login_ModifyDiscount,0) As Login_ModifyDiscount, ifNull(Login_ModifySellingPrice,0) As Login_ModifySellingPrice ".
          " 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);
}
//echo $querylog;
	
//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

		
		ShowSalesJvDtGrid($connection,'JS',$transid,$_SESSION['salesjv_parameters'],$Login_ModifySellingPrice,$Login_ModifyDiscount,$DecimalBase,$Module_RestrictProjCost,$Module_RestrictCost,$FI_SalesCheckSalesman,$Module_ProjectDt,$Module_CostCenterDt,$salesjv_paymentmode,$module_shipmentclosing);
		
}
else if ($form == 'JP') {
	
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt  , ifnull(module_shipmentclosing,0) as module_shipmentclosing 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
//Read From Login Table
$querylog=" select ifNull(Login_ModifyDiscount,0) As Login_ModifyDiscount, ifNull(Login_ModifySellingPrice,0) As Login_ModifySellingPrice ".
          " 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);
}
//echo $querylog;
//echo $querylog;
	
//Read From Setup Table
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
		
		ShowPurchasesJvDtGrid($connection,'JP',$transid,$_SESSION['purjv_parameters']);
		
}
else if ($form == 'ADR') {

					//Read From Module Table
					$querymodule=" Select ifNull(Module_AdditionalTaxes,0) As Module_AdditionalTaxes, ifNull(Module_Pack,0) As Module_Pack, ".
								 " ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
								 " ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost, ".
								 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt, ".
								 " ifNull(Module_PRequestConfirm,0) As Module_PRequestConfirm, ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ifNull(Module_Unit1Method,0) As Module_Unit1Method ".
								 ", ifnull(Module_PurchaseRequestPrice,0) as Module_PurchaseRequestPrice ".
								 " From Module ";
					$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
					while($rowmodule=mysql_fetch_array($resultmodule)){
						extract($rowmodule);
					}

					
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit 
				From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
	//Read From Module Table
$querymodule="Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,Module_TransferSorder,ifnull(Module_ZeroQuantity,0) as Module_ZeroQuantity,ifnull(Module_Unit1Method,0) as Module_Unit1Method, 
			ifNull(Module_Heatno,0) As Module_Heatno,ifnull(Module_DoubleUnit,0) as Module_DoubleUnit,ifnull(Module_TransferRequestPrice,0) as Module_TransferRequestPrice, ifnull(Module_IsInvoice,0) as Module_IsInvoice
			From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
								 " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

	ShowAdjustmentRequestDtGrid($connection,'ADR',$transid,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$Module_Unit1Method,$Module_Pack, $Module_Heatno, $Module_IsInvoice);
		
	}
else if ($form == 'CH') {
	ShowChecksCollectedGrid($connection,'CH',$transid,$DecimalBase,'');
}

else if ($form == 'JPO') {
	
	//Read From Module Table
$querymodule=" Select ifNull(Module_TransferWithOneWh,0) As Module_TransferWithOneWh,ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter , ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost , module_serialno,ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity ,Module_TransferSorder  
				,ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, 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);
}

$ModuleProject=$Module_Project;
$ModuleCostCenter=$Module_CostCenter;
	
//Read From Login Table
$querylog=" select ifNull(Login_ModifyDiscount,0) As Login_ModifyDiscount, ifNull(Login_ModifySellingPrice,0) As Login_ModifySellingPrice ".
          " 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);
}
//echo $querylog;
//echo $querylog;
	
//Read From Setup Table
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
		
		ShowPorderJvDtGrid($connection,'JPO',$transid,$_SESSION['salesjv_parameters'],$Login_ModifySellingPrice,$Login_ModifyDiscount,$DecimalBase,$Module_RestrictProjCost,$Module_RestrictCost,$FI_SalesCheckSalesman,$Module_ProjectDt,$Module_CostCenterDt);
		
}

}

function showDataGridFooter($filepath,$form,$transid,$gridid,$dftorderby,$action,$orderby,$morelines,$startrange,$perpage,$totalrows,$direction ,$perpage_label,$page_label,$record_to_view) {
	
	echo"<div  style='background-color:C8C8C8;width:1100'>
			<table width='100%' border=0 >
			<tr>";
	
	$rangefrom = ($startrange + 1);
	if (($startrange + $perpage) >= $totalrows) $rangeto = $totalrows; else $rangeto = ($startrange + $perpage);
				
	if ($totalrows > 0)			
		echo"	<td align='left' style='width:350px; padding-left:10px;'><span class='toolbar_style'>View ".$rangefrom." - ".$rangeto." of ".$totalrows."</span></td>";
	else
		echo"	<td align='left' style='width:350px; padding-left:10px;'><span class='toolbar_style'>$record_to_view</span></td>";
	
	echo"		<td align='center' style='width:120px;'><span class='toolbar_style'>$perpage_label </span><span class='toolbar_style'><select name='perpage' id='perpage' value='$perpage' onchange=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'CP','".$orderby."','".$morelines."',0,this.value,'".$totalrows."','".$direction."');\">";
				  
				if ($perpage==10)		$s10 = 'selected';
				else if ($perpage==20)	$s20 = 'selected';
				else if ($perpage==30)	$s30 = 'selected';
				else if ($perpage==40)	$s40 = 'selected';
				else if ($perpage==50)	$s50 = 'selected';

								
				echo'<option '.$s10.' value="10">10</option>
					 <option '.$s20.' value="20">20</option>
					 <option '.$s30.' value="30">30</option>
					 <option '.$s40.' value="40">40</option>
					 <option '.$s50.' value="50">50</option>
					 </select></span>
				</td>';
				
	echo"		<td  style='width:100px;border-right:1px solid #000000;text-align:right;'>";
				
				if($startrange > 0)
					echo"<img src='img/firstpage.png' title='First Page' onMouseOver=\"style.cursor='pointer'\"    onclick=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'F','".$orderby."','".$morelines."','".$startrange."','".$perpage."','".$totalrows."','".$direction."');return false;\" >";

				$diff= $startrange - $perpage;
					
				if (($diff) >= 0 ){
					$prvstartrange = $startrange - $perpage;
					echo"&nbsp;&nbsp;<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='pointer'\"  onclick=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'P','".$orderby."','".$morelines."','".$prvstartrange."','".$perpage."','".$totalrows."','".$direction."');return false;\" >";
				}
				else
					echo "&nbsp;";
			
	echo"		</td><td  align='left' style='width:100px;'>";
			
			
				if ($startrange <= $totalrows){
					$startrange1 = $startrange + $perpage;
					if  ($startrange1 < $totalrows){ 
						echo"<img src='img/arrowright.png' title='Next' onclick=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'N','".$orderby."','".$morelines."','".$startrange1."','".$perpage."','".$totalrows."','".$direction."');return false;\" onmouseover=\"style.cursor='pointer'\" >";
						echo"&nbsp;&nbsp;<img src='img/lastpage.png' title='Last Page' onMouseOver=\"style.cursor='pointer'\" onclick=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'L','".$orderby."','".$morelines."','".$prvstartrange."','".$perpage."','".$totalrows."','".$direction."');return false;\" >";	
					}
				} else
					echo "&nbsp;";
			
				
				$currentpage = ($startrange / $perpage) + 1;
				$totalpages  = ceil($totalrows / $perpage);
				
	echo"		</td><td style='text-align:center; width:150px;'>&nbsp;<span class='toolbar_style'>$page_label $currentpage / $totalpages</span></td>";
	

	
	echo"		<td style='text-align:center; width:60px;'><img src='img/Refresh-icon.png'  onMouseOver=\"style.cursor='pointer'\"  width='20' height='20' onclick=\"ReloadGrid('".$filepath."', '".$form."', '".$transid."', '".$gridid."', 1, '".$dftorderby."', 'R','".$orderby."','".$morelines."','".$startrange."','".$perpage."','".$totalrows."','".$direction."');\" ></td>";
	echo"		<td align='right' style='width:210px; padding-right:10px;'>&nbsp;</td>";
	
	echo"	</tr>";
	echo"	</table></div>";

}

function ShowPRequestDtGrid($connection,$form,$txtPreqId,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$PriceLabel,$Module_Unit1Method,$PurchaseTTC,$FIPurchaseCategory,$Module_PurchaseRequestPrice,$Module_Pack,$Module_Heatno){
	
	//Read From PurchaseSetup Table
	$queryPurchaseSetup="Select ifNull(ShowCostCentLayout,0) As ShowCostCentLayout From PurchaseSetup ";
	$resultPurchaseSetup=mysql_query($queryPurchaseSetup,$connection) or die(mysql_error());
	while($rowPurchaseSetup=mysql_fetch_array($resultPurchaseSetup)){
		extract($rowPurchaseSetup);
	}

	$query="Select ifNull(Module_CancelledQty,0) As Module_CancelledQty From Module ";
	$result=mysql_query($query,$connection) or die(mysql_error());
	while($row=mysql_fetch_array($result)){
		extract($row);
	}

	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	
	
	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
		
			
	if ($Module_PurchaseRequestPrice==1) {
	if ($PurchaseTTC == 1) {
	$columnsarray = array("itemcode"						,"itemdescription"						,"prqstdtitemdescription"
						,"warehousecode"						,"prqstdtOquantity"						);
			
	if($Module_CancelledQty==1) {
		$columnsarray[] = "prqstdtCquantity";
		$columnsarray[] = "itemunit2qty";
		}
						
						
		$columnsarray[] = "prqstdtpricettc";
		$columnsarray[] = "prqstdtdiscount";
		$columnsarray[] = "prqstdttotalttc";
	if($Module_Heatno == 1)
			$columnsarray[] = "prqstdtheatno";
							
	if ($Module_ProjectDt==1)
		$columnsarray[] = "prqstdtprojectcode";						
		
	if ($Module_CostCenterDt==1 && $ShowCostCentLayout == 1)		
		$columnsarray[] = "prqstdtcostcentercode";
	
	$columnsarray[] = "prqstdt_RequiredDate";
	$columnsarray[] = "prqstdt_Remark";
		}				
	else {
	$columnsarray = array("itemcode"						,"itemdescription"						,"prqstdtitemdescription"			,"warehousecode"
					,"prqstdtOquantity"						,"prqstdtCquantity"						,"itemunit2qty"			,"prqstdtprice"		,"prqstdtdiscount"
					,"prqstdttotal"					);
	if($Module_Heatno == 1)
			$columnsarray[] = "prqstdtheatno";
		
	if ($Module_ProjectDt==1)
		$columnsarray[] = "prqstdtprojectcode";
	
	if ($Module_CostCenterDt==1 && $ShowCostCentLayout == 1)
		$columnsarray[] =  "prqstdtcostcentercode";
	$columnsarray[] = "prqstdt_RequiredDate";
	$columnsarray[] =  "prqstdt_Remark";
					
		}			
	}
	else if ($Module_PurchaseRequestPrice==0) {
	if ($PurchaseTTC == 1) {
	$columnsarray = array("itemcode"						,"itemdescription"						,"prqstdtitemdescription"
						,"warehousecode"						,"prqstdtOquantity");

		if($Module_CancelledQty==1)	 {
			$columnsarray[] = "prqstdtCquantity";
			$columnsarray[] = "itemunit2qty";
		}			
		if($Module_Heatno == 1)
			$columnsarray[] = "prqstdtheatno";
						
		if ($Module_ProjectDt==1)
			$columnsarray[] = "prqstdtprojectcode";
		
		if ($Module_CostCenterDt==1 && $ShowCostCentLayout == 1)
			$columnsarray[] =  "prqstdtcostcentercode";
		$columnsarray[] = "prqstdt_RequiredDate";	
		$columnsarray[] =  "prqstdt_Remark";
		}
		else {
		$columnsarray = array("itemcode"						,"itemdescription"		,"prqstdtitemdescription"		,"warehousecode"
						,"prqstdtOquantity"	);
						
						
		if($Module_CancelledQty==1)	 {
			$columnsarray[] = "prqstdtCquantity";
			$columnsarray[] = "itemunit2qty";
		}
		if($Module_Heatno == 1)
			$columnsarray[] = "prqstdtheatno";
		
		if ($Module_ProjectDt==1)
			$columnsarray[] = "prqstdtprojectcode";
		
		if ($Module_CostCenterDt==1 && $ShowCostCentLayout == 1)
			$columnsarray[] =  "prqstdtcostcentercode";
		$columnsarray[] = "prqstdt_RequiredDate";	
		$columnsarray[] =  "prqstdt_Remark";
						
					}	
	}
	
	
	$columnslist = implode(',', $columnsarray);

	
	
	
echo"<input type='hidden' name='headercurrency_code' id='headercurrency_code' value='$headercurrency_code'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
			$query = " Select PRequestDt.PRqstDt_id, PRequestDt.Item_CodePacked, PRequestDt.Item_code, Items.Item_Description, PRequestDt.Warehouse_Code, ".
					   " PRqstDt_Remark, PRqstDt_Quantity, Round(PRqstDt_Price, ".$DecimalBase."), Round(PRqstDt_PriceTTC, ".$DecimalBase."), ".
					   " Round(PRqstDt_Discount, ".$DecimalBase."), ".
					   " Round(((PRqstDt_Quantity*PRqstDt_Price)-((PRqstDt_Quantity*PRqstDt_Price*ifNull(PRqstDt_Discount,0))/100)), ".$DecimalBase.") As Total, ".
					   " Round(((PRqstDt_Quantity*PRqstDt_PriceTTC)-((PRqstDt_Quantity*PRqstDt_PriceTTC*ifNull(PRqstDt_Discount,0))/100)), ".$DecimalBase.") As TotalTTC, ".
					   " PRequestDt.Item_Unit2Qty, Item_UnitPurchaseDesc, Item_UnitSalesDesc, PRequestDt.Project_code, PRequestDt.CostCent_Code, PRequestDt.Item_description".
					   " ,PRequestDt.PRqstDt_OQuantity,PRequestDt.PRqstDt_CQuantity,prequestdt_unitsalesdesc, PRequestDt_heatno, date_format(PRequestDt_RequiredDate, '%d/%m/%Y') ".
					   " From Temp_PRequestDt As PRequestDt Left Join Items on PRequestDt.Item_code = Items.Item_code ".
					   " Where PRequestDt.PRqst_id = '".$txtPreqId."' ".
					   " Order By PRequestDt.PRqstDt_id Asc ";
//echo $query;	
$result=mysql_query($query,$connection)  or die(mysql_error());
$totalrows = mysql_num_rows($result);

$query = $query." limit ".$startrange.",".$perpage;
//echo $query;
$result=mysql_query($query,$connection);

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='prequestdtdiv' style='overflow:auto;width:1090px;height:200px;border:0px solid black;'>";

$widthTable = 1105;
if ($Module_Pack == 1) $widthTable += 120;
if ($Module_CancelledQty == 1) $widthTable += 145;
if ($Module_DoubleUnit == 1) $widthTable += 145;
if ($Module_PurchaseRequestPrice == 1) $widthTable += 240;
if ($Module_Heatno == 1) $widthTable += 120;
if ($Module_ProjectDt == 1) $widthTable += 120;
if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1) $widthTable += 120;

$widthTable = $widthTable."px";
	
echo"<table border='0' align='center'   class='grid_data'  width=$widthTable style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0;' cellpadding='0' cellspacing='1'>";

echo"	<col width=30>";

if ($Module_Pack == 1)
	echo" <col width=120>";
	
echo" 	<col width=150>
		<col width=200>
		<col width=140>
		<col width=100>
		<col width=80>";

echo"<col width=80>";

if($Module_CancelledQty==1) {
	echo" <col width=70>
		  <col width=75>";
}
if ($Module_DoubleUnit == 1)
	echo" <col width=70>
		  <col width=75>";
		  
if ($Module_PurchaseRequestPrice==1)		  
	echo"<col width=80>
		 <col width=80>
		 <col width=80>";
if($Module_Heatno == 1)	  echo "<col width=120>";

if ($Module_ProjectDt == 1)	echo" <col width=120>";

if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)	echo "<col width=120>";
	echo "<col width=100>";
	echo "<col width=200><col width=25>";

	

		  
		echo"<tr bgcolor='#D8D8D8' height='25'>";
		echo"  <th bgcolor='#D8D8D8' align='left'><span class='style27'>&nbsp;</th>";
		
		if ($Module_Pack == 1)
			echo"  <th bgcolor='#D8D8D8' align='left'><b>Item Code Packed</b></th>";
			
		echo"  <th bgcolor='#D8D8D8' align='left'><b>Item</b></th>";
		echo"  <th bgcolor='#D8D8D8' align='left'><b>Description</b></th>";
		echo"  <th bgcolor='#D8D8D8' align='left'><b>New Item</b></th>";
		echo"  <th bgcolor='#D8D8D8' align='center'><b>WH</b></th>";
		
		//if ($Module_DoubleUnit == 1)
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Unit1</b></th>";
			
		echo"  <th bgcolor='#D8D8D8' align='center'><b>Ordered Qty</b></th>";
		
		if($Module_CancelledQty==1) {
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Cancelled Qty</b></th>";
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Qty</b></th>";
		}
		
		if ($Module_DoubleUnit == 1) {
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Unit2</b></th>";
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Unit2 Qty</b></th>";
		}
		
		if ($Module_PurchaseRequestPrice==1)  {
		echo"  <th bgcolor='#D8D8D8' align='center'><b>$PriceLabel</b></th>";
		echo"  <th bgcolor='#D8D8D8' align='center'><b>Disc(%)</b></th>";
		echo"  <th bgcolor='#D8D8D8' align='center'><b>Total</b></th>";
		}
		if($Module_Heatno == 1)
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Heat No.</b></th>";
		if ($Module_ProjectDt == 1)	
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Project</b></th>";
		if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
			echo"  <th bgcolor='#D8D8D8' align='center'><b>CostCenter</b></th>";
			
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Required Date</b></th>";
			echo"  <th bgcolor='#D8D8D8' align='center'><b>Remark</b></th>";
			
			echo"  <th bgcolor='#D8D8D8' align='center'></span></th>";
			
        echo"</tr>";
			



	$i=0;
	$j=1;
	
	echo"
		
		 <input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>		 
		 <input type='hidden' name='Module_PurchaseRequestPrice' id='Module_PurchaseRequestPrice' value='$Module_PurchaseRequestPrice'>		 
		 ";

		 
while($row=mysql_fetch_row($result)){
		
		
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
		
		$KeyDown   = 'onkeydown="return dokeypurchaserequest(event,this,'.$i.',\''.$columnslist.'\',\'PReqstDt\')"';

			$txtPreqDTId[$i] = $row[0];
			$itemcodepacked[$i] = $row[1];
			$itemcode[$i] = $row[2];
			$itemdescription[$i] = $row[3];
			$warehousecode[$i] = $row[4];
			
			
			
			
			$prqstdtquantity[$i] = $row[6];
			$itemunitpurchasedesc[$i] = $row[13];
			$itemunit2qty[$i] = $row[12];
			$prqstdtpricettc[$i] = $row[8];
			$prqstdtprice[$i] = $row[7];
			$prqstdtdiscount[$i] = $row[9];
			$prqstdttotal[$i] = $row[10];
			$prqstdttotalttc[$i] = $row[11];
			$prqstdtprojectcode[$i] = $row[15];
			$prqstdtcostcentercode[$i] = $row[16];
			
			$prqstdt_Remark[$i] = $row[5];
			
			$prqstdtitemdescription[$i] = $row[17];
			
			$prequestdt_unitsalesdesc[$i] = $row[20];
			$prqstdtheatno[$i] = $row[21];			
			$prqstdt_RequiredDate[$i] = $row[22];	
			
			if($itemcode[$i]!='')
				$readonly='readonly';
				else
				$readonly='';
				
			if($itemcode[$i]=='')
				$itemunitsalesdesc[$i] = $prequestdt_unitsalesdesc[$i];
			else
				$itemunitsalesdesc[$i] = $row[14];			
			
			$prqstdtOquantity[$i] = $row[18];
			$prqstdtCquantity[$i] = $row[19];

			
			//echo"<tr height='20px' id='prqstdt$i' onclick=\"returncolor(this,'SelectedRec','SelectedRecColor','$row[0]')\" style='background-color:$bgcolor'>";
			echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";
		
						
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
			echo"<td  align=center onclick=\"deleteprequestsdt('$txtPreqId','$row[0]','".$itemcodepacked[$i]."','".$itemcode[$i]."','$filepath'); return false;\"><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' ></td>";
		
			if ($Module_Pack == 1)
				echo"<td ><span class='style4'><input type='text'   class='roundedtext_amortization_medium' readonly   $KeyDown  name='itemcodepacked[$i]' id='itemcodepacked[$i]' value='".$itemcodepacked[$i]."' style='width:115px'> </span></td>";
			else
				echo"<input type='hidden'  name='itemcodepacked[$i]' id='itemcodepacked[$i]' value='".$itemcodepacked[$i]."'>";
			
			
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   onchange=\"setitemcode(this.value,'itemcode[$i]','itemdescription[$i]','item_vat[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','prqstdtitemcodeimage1[$i]',1,7);SetModRecord('ModRec_G1','$i')\"    name='itemcode[$i]' id='itemcode[$i]' value='".$itemcode[$i]."' style='width:125px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='prqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('$i')\">
					</td>";
			
			echo"<td ><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'itemcode[$i]','itemdescription[$i]','item_vat[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','prqstdtitemcodeimage1[$i]',2,7);SetModRecord('ModRec_G1','$i')\"     name='itemdescription[$i]' id='itemdescription[$i]' value='".$itemdescription[$i]."' style='width:195px'> </span></td>";					
			echo"<td ><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown    name='prqstdtitemdescription[$i]' id='prqstdtitemdescription[$i]' value='".$prqstdtitemdescription[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');CheckItemCode(this,'$i')\" style='width:140px'> </span></td>";					

		
			
			
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='warehousecode[$i]' id='warehousecode[$i]' value='".$warehousecode[$i]."' onchange=\"setwarehousecode(this.value,'warehousecode[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('warehousecode','warehousecode[$i]','800','500') \" />
			</td>";

			
			//if ($Module_DoubleUnit == 1)
				echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$itemunitsalesdesc[$i]."' $readonly  onfocus='checkstatus($i)'  > </span></td>";
				//else
				//echo"<input type='hidden' class='roundedtext_amortization_medium'     name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$itemunitsalesdesc[$i]."' readonly style='width:60px'> ";
		
				
				echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtOquantity[$i]' id='prqstdtOquantity[$i]' value='".$prqstdtOquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i');\" > </span></td>";
				
				if($Module_CancelledQty==1) {
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:68px'  name='prqstdtCquantity[$i]' id='prqstdtCquantity[$i]' value='".$prqstdtCquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i');\"  > </span></td>";
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:68px'  name='prqstdtquantity[$i]' id='prqstdtquantity[$i]' value='".$prqstdtquantity[$i]."'  maxlength='20'  readonly onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i');\" > </span></td>";
				} else {
					$prqstdtCquantity[$i] = 0;
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'  name='prqstdtCquantity[$i]' id='prqstdtCquantity[$i]' value='".$prqstdtCquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i');\" > </span>";
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'  name='prqstdtquantity[$i]' id='prqstdtquantity[$i]' value='".$prqstdtquantity[$i]."'  maxlength='20'  readonly onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i');\" > </span>";
				}
		
		
				if ($Module_DoubleUnit == 1) { 
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitpurchasedesc[$i]' id='itemunitpurchasedesc[$i]' value='".$itemunitpurchasedesc[$i]."'  readonly  > </span></td>";
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunit2qty[$i]' id='itemunit2qty[$i]' value='".$itemunit2qty[$i]."'   maxlength='20' onchange=\"CalcQty2($i,$Module_Unit1Method,2);SetModRecord('ModRec_G1','$i');\"  > </span></td>";
				}
				else 
				{
					echo"<span class='style4'><input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitpurchasedesc[$i]' id='itemunitpurchasedesc[$i]' value='".$itemunitpurchasedesc[$i]."'  readonly  style='width:60px'> </span>";
					echo"<span class='style4'><input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='itemunit2qty[$i]' id='itemunit2qty[$i]' value='".$itemunit2qty[$i]."'   maxlength='20' onchange=\"CalcQty2($i,$Module_Unit1Method,2);SetModRecord('ModRec_G1','$i');\"  > </span>";
				}
				
				if ($Module_PurchaseRequestPrice==1) {
				if ($PurchaseTTC == 1) 
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtpricettc[$i]' id='prqstdtpricettc[$i]' value='".$prqstdtpricettc[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  > </span></td>";
				else
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtprice[$i]' id='prqstdtprice[$i]' value='".$prqstdtprice[$i]."'   maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i');\" onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  > </span></td>";


				echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtdiscount[$i]' id='prqstdtdiscount[$i]' value='".$prqstdtdiscount[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'   > </span></td>";					

				
				if ($PurchaseTTC == 1) 
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotalttc[$i]' id='prqstdttotalttc[$i]' value='".$prqstdttotalttc[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
				else
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotal[$i]' id='prqstdttotal[$i]' value='".$prqstdttotal[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
				
				}
				else {
				if ($PurchaseTTC == 1) 
					echo"<input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtpricettc[$i]' id='prqstdtpricettc[$i]' value='".$prqstdtpricettc[$i]."'   > ";
				else
					echo"<input type='hidden'    class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtprice[$i]' id='prqstdtprice[$i]' value='".$prqstdtprice[$i]."'   maxlength='20' >";


				echo"<input type='hidden'     class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtdiscount[$i]' id='prqstdtdiscount[$i]' value='".$prqstdtdiscount[$i]."' >";					

				
				if ($PurchaseTTC == 1) 
					echo"<input type='hidden'     class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotalttc[$i]' id='prqstdttotalttc[$i]' value='".$prqstdttotalttc[$i]."' >";
				else
					echo"<input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotal[$i]' id='prqstdttotal[$i]' value='".$prqstdttotal[$i]."' >";				
				}

								
				echo"<input type='hidden'   style='width:70px'  name='item_vat[$i]' id='item_vat[$i]' value='".$item_vat[$i]."'  > </span>";					
				echo"<input type='hidden'   style='width:70px'  name='i_unitcoef[$i]' id='i_unitcoef[$i]' value='".$i_unitcoef[$i]."'  > </span>";					
				
				if($Module_Heatno == 1)
					echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:85px'  name='prqstdtheatno[$i]' id='prqstdtheatno[$i]' value='".$prqstdtheatno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" >  </span>
					<label><span><img src='img/openlist.png' title='Select Heat No' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick=\"showlistHeatNo('$i'); \" style='vertical-align:bottom;'/></span></label></td>";
				else 
					echo"<input type='hidden'  name='prqstdtheatno[$i]' id='prqstdtheatno[$i]' value=''> </span>";					
				
				if ($Module_ProjectDt == 1)	
					echo"<td ><span class='style4'><input type='text'   $KeyDown  class='roundedtext_amortization_medium'    style='width:90px'  name='prqstdtprojectcode[$i]' id='prqstdtprojectcode[$i]' value='".$prqstdtprojectcode[$i]."'   onchange=\"setprojectcode(this.value,'prqstdtprojectcode[$i]','imgprojectbtn[$i]');SetModRecord('ModRec_G1','$i');\" > </span>
					<img src='img/scroll-down-1.png' title=' Select Project ' id='imgprojectbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistProject('project','prqstdtprojectcode[$i]','800','500',3) \" />			
					</td>";
				else echo"<input type='hidden' style='width:70px'  name='prqstdtprojectcode[$i]' id='prqstdtprojectcode[$i]' value='".$prqstdtprojectcode[$i]."'  style='width:60px'> </span>"; 
				
				if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
					echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:90px'  name='prqstdtcostcentercode[$i]' id='prqstdtcostcentercode[$i]' value='".$prqstdtcostcentercode[$i]."'    onchange=\"setcostcentercode(this.value,'prqstdtcostcentercode[$i]','imgcostcenterbtn[$i]');SetModRecord('ModRec_G1','$i')\" > 
					<img src='img/scroll-down-1.png' title=' Select Costcenter ' id='imgcostcenterbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistCostcenter('costcenter','prqstdtcostcentercode[$i]','800','500',3) \" />
					</span></td>";
				else	echo"<input type='hidden'    name='prqstdtcostcentercode[$i]' id='prqstdtcostcentercode[$i]' value='".$prqstdtcostcentercode[$i]."' > ";
			
			echo"<td align='center'><span class='style4'><input type='text' name='prqstdt_RequiredDate[$i]' id='prqstdt_RequiredDate[$i]' value='$prqstdt_RequiredDate[$i]' maxlength='10' onchange=\"SetModRecord('ModRec_G1','$i');\" class='roundedtext_amortization_medium date' style='font-size:12px; width:80px; height:20px;'  $KeyDown readonly ></span></td>";
			echo"<td ><span class='style4'><input type='text'    style='width:195px'  $KeyDown   class='roundedtext_amortization_medium'   name='prqstdt_Remark[$i]' id='prqstdt_Remark[$i]' value='".$prqstdt_Remark[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
					
			
			
			
			echo"<td><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPReqstDt[$i]' title='Save' onclick=\"submitPReqstDt('$txtPreqDTId[$i]','$txtPreqId','$i','e','$PurchaseTTC','$FIPurchaseCategory','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtPreqDTId[$i]' id='txtPreqDTId[$i]' value='".$txtPreqDTId[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
		}
		
		$prei = $i-1;
		if ($warehousecode[$prei] !='')
			$warehousecode[$i] = $warehousecode[$prei];
		else
		if (empty($warehousecode[$i])) { 
			if(!empty($_SESSION['prqstdefaultwarehouse'] ))
				$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			else if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeypurchaserequest(event,this,'.$i.',\''.$columnslist.'\',\'PReqstDt\');"';

			echo"<tr height='30' id='CurRec$i' class='$bgcolor table-focus-g1'>";
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearprequestdt('$i','$PurchaseTTC','$FIPurchaseCategory')\"></td>";
			
			if ($Module_Pack == 1)
				echo"<td align='center'><span class='style4'><input type='text'   class='roundedtext_amortization_medium'   readonly   $KeyDown  name='itemcodepacked[$i]' id='itemcodepacked[$i]' value='".$itemcodepacked[$i]."' style='width:115px'> </span></td>";
			else
				echo"<input type='hidden'  name='itemcodepacked[$i]' id='itemcodepacked[$i]' value='".$itemcodepacked[$i]."'>";
			
			
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   onchange=\"setitemcode(this.value,'itemcode[$i]','itemdescription[$i]','item_vat[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','prqstdtitemcodeimage1[$i]',1,7);SetModRecord('ModRec_G1','$i');\" onblur=\"FillDetail('prqstdtprojectcode[$i]','prqstdtcostcentercode[$i]')\"   name='itemcode[$i]' id='itemcode[$i]' value='".$itemcode[$i]."' style='width:125px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='prqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('$i');FillDetail('prqstdtprojectcode[$i]','prqstdtcostcentercode[$i]')\">
					</td>";
			
			echo"<td align='center'><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'itemcode[$i]','itemdescription[$i]','item_vat[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','prqstdtitemcodeimage1[$i]',2,7);SetModRecord('ModRec_G1','$i')\"     name='itemdescription[$i]' id='itemdescription[$i]' value='".$itemdescription[$i]."' style='width:195px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='prqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','itemcode[$i]','itemdescription[$i]','item_vat[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','800','500')\">
			</td>";					
			echo"<td align='center'><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown    name='prqstdtitemdescription[$i]' id='prqstdtitemdescription[$i]' value='".$prqstdtitemdescription[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');FillDetail('prqstdtprojectcode[$i]','prqstdtcostcentercode[$i]');CheckItemCode(this,'$i')\" style='width:135px'> </span></td>";					
		
			
			
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='warehousecode[$i]' id='warehousecode[$i]' value='".$warehousecode[$i]."'   onchange=\"setwarehousecode(this.value,'warehousecode[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i')\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('warehousecode','warehousecode[$i]','800','500') \" />
			</td>";
			
			//if ($Module_DoubleUnit == 1)
				echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$itemunitsalesdesc[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" readonly onfocus='checkstatus($i)' > </span></td>";
			//else
				//echo"<input type='hidden'   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$itemunitsalesdesc[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" readonly style='width:60px'> </span>";
				
				
				echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtOquantity[$i]' id='prqstdtOquantity[$i]' value='".$prqstdtOquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i')\"  > </span></td>";
				
				if($Module_CancelledQty==1) {
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:68px'  name='prqstdtCquantity[$i]' id='prqstdtCquantity[$i]' value='".$prqstdtCquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i')\"  > </span></td>";
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:68px'  name='prqstdtquantity[$i]' id='prqstdtquantity[$i]' value='".$prqstdtquantity[$i]."'  maxlength='20' readonly onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i')\"  > </span></td>";
				} else {
					$prqstdtCquantity[$i] = 0;
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'   name='prqstdtCquantity[$i]' id='prqstdtCquantity[$i]' value='".$prqstdtCquantity[$i]."'  maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i')\"   > </span>";
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'   name='prqstdtquantity[$i]' id='prqstdtquantity[$i]' value='".$prqstdtquantity[$i]."'  maxlength='20' readonly onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"CalcQty2($i,$Module_Unit1Method,1);SetModRecord('ModRec_G1','$i')\"   > </span>";
				
				}
		
		
				if ($Module_DoubleUnit == 1) { 
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitpurchasedesc[$i]' id='itemunitpurchasedesc[$i]' value='".$itemunitpurchasedesc[$i]."'  readonly  style='width:60px'> </span></td>";
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunit2qty[$i]' id='itemunit2qty[$i]' value='".$itemunit2qty[$i]."'   maxlength='20' onchange=\"CalcQty2($i,$Module_Unit1Method,2);SetModRecord('ModRec_G1','$i')\"  > </span></td>";
				}
				else {
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunitpurchasedesc[$i]' id='itemunitpurchasedesc[$i]' value='".$itemunitpurchasedesc[$i]."' > </span>";
					echo"<span class='style4'><input type='hidden'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='itemunit2qty[$i]' id='itemunit2qty[$i]' value='".$itemunit2qty[$i]."'   maxlength='20' onchange=\"CalcQty2($i,$Module_Unit1Method,2);SetModRecord('ModRec_G1','$i')\"  > </span>";
				}
				
				if ($Module_PurchaseRequestPrice==1) {
				if ($PurchaseTTC == 1) 
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtpricettc[$i]' id='prqstdtpricettc[$i]' value='".$prqstdtpricettc[$i]."'  onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:60px'> </span></td>";
				else
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtprice[$i]' id='prqstdtprice[$i]' value='".$prqstdtprice[$i]."'   maxlength='20' onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'  onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:60px'> </span></td>";


				echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtdiscount[$i]' id='prqstdtdiscount[$i]' value='".$prqstdtdiscount[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onBlur='CalcPorDtTotal($i,$DecimalBase,$PurchaseTTC);'   style='width:60px'> </span></td>";					

				
				if ($PurchaseTTC == 1) 
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotalttc[$i]' id='prqstdttotalttc[$i]' value='".$prqstdttotalttc[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:60px'> </span></td>";
				else
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotal[$i]' id='prqstdttotal[$i]' value='".$prqstdttotal[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:60px'> </span></td>";
				}
				else {
				if ($PurchaseTTC == 1) 
					echo"<input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtpricettc[$i]' id='prqstdtpricettc[$i]' value='".$prqstdtpricettc[$i]."' > ";
				else
					echo"<input type='hidden'    class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtprice[$i]' id='prqstdtprice[$i]' value='".$prqstdtprice[$i]."'   maxlength='20' >";


				echo"<input type='hidden'     class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdtdiscount[$i]' id='prqstdtdiscount[$i]' value='".$prqstdtdiscount[$i]."' >";					

				
				if ($PurchaseTTC == 1) 
					echo"<input type='hidden'     class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotalttc[$i]' id='prqstdttotalttc[$i]' value='".$prqstdttotalttc[$i]."' >";
				else
					echo"<input type='hidden'      class='roundedtext_amortization_medium'   style='width:70px'  name='prqstdttotal[$i]' id='prqstdttotal[$i]' value='".$prqstdttotal[$i]."' >";				
				}


				
			echo"<input type='hidden'   style='width:70px'  name='item_vat[$i]' id='item_vat[$i]' value='".$item_vat[$i]."' > </span>";					
			echo"<input type='hidden'   style='width:70px'  name='i_unitcoef[$i]' id='i_unitcoef[$i]' value='".$i_unitcoef[$i]."' > </span>";					
				
					$ii = $i-1;
					
					if ($prqstdtprojectcode[$ii]!='')
						$prqstdtprojectcode[$i] = $prqstdtprojectcode[$ii];
						
					if ($prqstdtcostcentercode[$ii]!='')
						$prqstdtcostcentercode[$i] = $prqstdtcostcentercode[$ii];
						
					
					
					if ($prqstdtprojectcode[$i]=='')
						$prqstdtprojectcode[$i] = $_SESSION['prqstdefaultproject'];

					if ($prqstdtcostcentercode[$i]=='')
						$prqstdtcostcentercode[$i] = $_SESSION['prqstdefaultcostcent'];
				
				if($Module_Heatno == 1)
					echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:85px'  name='prqstdtheatno[$i]' id='prqstdtheatno[$i]' value='".$prqstdtheatno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" >  </span>
					<label><span><img src='img/openlist.png' title='Select Heat No' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick=\"showlistHeatNo('$i'); \" style='vertical-align:bottom;'/></span></label></td>";
				else 
					echo"<input type='hidden'  name='prqstdtheatno[$i]' id='prqstdtheatno[$i]' value=''> </span>";			
				
				if ($Module_ProjectDt == 1)	
					echo"<td align='center'><span class='style4'><input type='text'   $KeyDown  class='roundedtext_amortization_medium'    style='width:90px'  name='prqstdtprojectcode[$i]' id='prqstdtprojectcode[$i]' value='".$prqstdtprojectcode[$i]."'   onchange=\"setprojectcode(this.value,'prqstdtprojectcode[$i]','imgprojectbtn[$i]');SetModRecord('ModRec_G1','$i')\" > </span>
					<img src='img/scroll-down-1.png' title=' Select Project ' id='imgprojectbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistProject('project','prqstdtprojectcode[$i]','800','500',3) \" />			
					</td>";

				if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
					echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:90px'  name='prqstdtcostcentercode[$i]' id='prqstdtcostcentercode[$i]' value='".$prqstdtcostcentercode[$i]."'    onchange=\"setcostcentercode(this.value,'prqstdtcostcentercode[$i]','imgcostcenterbtn[$i]');SetModRecord('ModRec_G1','$i')\"  > 
					<img src='img/scroll-down-1.png' title=' Select Costcenter ' id='imgcostcenterbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistCostcenter('costcenter','prqstdtcostcentercode[$i]','800','500',3) \" />
					</span></td>";
			
			
				echo"<td align='center'><span class='style4'><input type='text' name='prqstdt_RequiredDate[$i]' id='prqstdt_RequiredDate[$i]' value='$prqstdt_RequiredDate[$i]' maxlength='10' onchange=\"SetModRecord('ModRec_G1','$i');\" class='roundedtext_amortization_medium date' style='font-size:12px; width:80px; height:20px;'  $KeyDown readonly >
			 </span></td>";
			
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium' style='width:190px'   name='prqstdt_Remark[$i]' id='prqstdt_Remark[$i]' value='".$prqstdt_Remark[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\"> </span></td>";
					
			echo"<td><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPReqstDt[$i]' title='Save' onclick=\"return submitPReqstDt('$txtPreqDTId[$i]','$txtPreqId','$i','i','$PurchaseTTC','$FIPurchaseCategory','$filepath');\"></td>";
			echo"<input type='hidden'  name='txtPreqDTId[$i]' id='txtPreqDTId[$i]' value='".$txtPreqDTId[$i]."' >";
			echo"</tr>";
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div>";
	

	

}

function ShowSalesJvTotals($connection,$txtSalesJVId,$arrayparams,$arrayaccess){


	$DecimalBase  = $arrayparams['DecimalBase'];
	$DecimalBase1 = $arrayparams['DecimalBase1'];
	$DecimalBase2 = $arrayparams['DecimalBase2'];
	$Base1 = $arrayparams['Base1'];
	$Base2 = $arrayparams['Base2'];
	
	$txtClientCode = $arrayparams['txtClientCode'];
	
	
	$Setup_VatPercentage = $arrayparams['Setup_VatPercentage'];
	$VatApplied = $arrayparams['VatApplied'];
	$AllowModifyVAT = $arrayparams['AllowModifyVAT'];
	$FA_SalesJvVAT = $arrayparams['FA_SalesJvVAT'];
	$costcent_applyvat   = $arrayparams['costcent_applyvat'];
	if($FA_SalesJvVAT==0) $AllowModifyVAT= ' disabled ';
	
	if($txtSalesJVId!='') {
	$query = " Select SalesJV_ID, SalesJV_Reference, Date_Format(SalesJV_Date,'%d/%m/%Y') As SalesJV_Date, ".
	         " Date_Format(JournalDt_ValueDate,'%d/%m/%Y') As MaturityDate, ".
			 " SalesJV.Client_Code As ClientCode, Clients.Ledger_name As ClientName, Client_VAT,   ".
			 " SalesJV.Salesman_Code As SalesmanCode, Salesmen.Ledger_name As SalesmanName, ".
			 " SalesJV.Currency_Code, Sales_Remark, SalesJV.Project_Code, SalesJV.Costcenter_Code,  ".
			 " Round(ifNull(SalesJV_Taxable,0), ".$DecimalBase."), Round(ifNull(SalesJV_NoneTaxable,0), ".$DecimalBase."), ".
			 " Round(ifNull(SalesJV_Total,0), ".$DecimalBase.") As GrossTotal, ".
			 " Round(ifNull(SalesJV_DiscountPer,0), ".$DecimalBase."), Round(ifNull(SalesJV_DiscountAmount,0), ".$DecimalBase."),  ".
			 " Round(ifNull(SalesJV_VAT,0), ".$DecimalBase.") As SalesJV_VAT, ".
			 " Round((ifNull(SalesJV_Total,0) + IfNull(SalesJV_VAT,0) - IfNull(SalesJV_DiscountAmount,0)), ".$DecimalBase.") As SalesJV_NetTotal,  ".
			 " ifNull(SalesJV_VatCheck,0) As SalesJV_VatCheck, Journal.Journal_folio, Journal.Journal_refgovernment, SalesJV.SalesJv_ManualNo ".
			 " From Temp_SalesJV As SalesJV ".
			 " Left Join Clients on SalesJV.Client_Code = Clients.Ledger_Number ".
			 " Left Join Salesmen on SalesJV.Salesman_Code = Salesmen.Ledger_Number ".
			 " Left Join Journal on SalesJV.Journal_ID = Journal.Journal_ID ".
	         " Where SalesJV_ID = ".$txtSalesJVId;
			 //" And Logged_Code = '".$_SESSION['useraccount']."' ";
			 
			 
			 
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);
	
	$txtClientVat    = $rows[6];

	$txtTaxable      = $rows[13];
	$txtNoneTaxable  = $rows[14];
	$txtGrossTotal   = $rows[15];
	$txtDiscountPer  = $rows[16];
	$txtDiscountAmt  = $rows[17];
	$txtVatAmt       = $rows[18];
	$txtNetTotal     = $rows[19];
	$txtVatChk       = $rows[20];
	}else {
		$sub_query = " Select ifNull(Client_VAT,0) From Clients Where Ledger_Number = '".$txtClientCode."'";			 
		
		$sub_result = selectData($connection, $sub_query);
		$txtVatChk = $sub_result[0];
		if($costcent_applyvat==0) $txtVatChk=0;
	}
	
	
	
echo"<table border='0' style='table-layout:fixed' cellspacing=0 cellpadding=0>";


echo"<tr>
		<td id='total-top' style='width:240px;height:12px;'></td>
		</tr>
		<tr><td id='total-content' style='width:240px;height:12px;'>";
				
		echo"	<table border='0' cellspacing=0 width=100% >
		<col width=100>
		<col width=110>
			
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Taxable</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtTaxable' value='$txtTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='25'>
			<td valign='center' align='right' ><span class='style10'>None Taxable</span>&nbsp;</td> 
 			<td align='left'><input type='text' name='txtNoneTaxable' value='$txtNoneTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Gross Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtGrossTotal' value='$txtGrossTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Discount</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtDiscountPer' value='$txtDiscountPer' maxlength='5'  style='text-align:right; width:40px; height=18px;' onKeyup='CalcDiscount(1, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ><span class='style10'>%</span>
			                 <input type='text' name='txtDiscountAmt' value='$txtDiscountAmt' maxlength='20' style='text-align:right; width:44px; height=18px;' onKeyup='CalcDiscount(2, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ></td>
		</tr>";
		  


echo "  <tr  height='20'>
			<td valign='center' align='right' >
				<input type='hidden' name='txtVatChk' id='txtVatChk' value='$txtVatChk' size='1'/>
				<input name='chkVat' type='checkbox' id='chkVat' value='1' onClick='SetVat($DecimalBase,$VatApplied,$Setup_VatPercentage);'   "; 
			  if ($txtVatChk==1 ) echo " checked $AllowModifyVAT />";  else echo " $AllowModifyVAT />";   
	          
echo "   	<span class='style10'>VAT $Setup_VatPercentage%</span></td> 
			<td align='left'>
				<input type='text' name='txtVatAmt' value='$txtVatAmt' maxlength='20' style='text-align:right; width:100px; height=18px;' readonly >
			</td>
		</tr>";

	
echo"   <tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Net Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtNetTotal' value='$txtNetTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;";
		if($txtNetTotal<0) echo " color:#FF0000;";	
			
			echo"'></td>
		</tr>";
		  

echo "	</table></td>
				</tr><tr>
					<td id='total-bottom' style='width:240px;height:12px;'></td>
				</tr>";	
		echo"</table>";
}


function ShowPurchasesJvTotals($connection,$txtPurchasesJVId,$arrayparams,$arrayaccess){


	$DecimalBase  = $arrayparams['DecimalBase'];
	$DecimalBase1 = $arrayparams['DecimalBase1'];
	$DecimalBase2 = $arrayparams['DecimalBase2'];
	$Base1 = $arrayparams['Base1'];
	$Base2 = $arrayparams['Base2'];
	
	
	$Setup_VatPercentage = $arrayparams['Setup_VatPercentage'];
	$VatApplied = $arrayparams['VatApplied'];
	$AllowModifyVAT = $arrayparams['AllowModifyVAT'];
	$txtSupplierCode = $arrayparams['txtSupplierCode'];
	$costcent_applyvat   = $arrayparams['costcent_applyvat'];
	$FA_PurchaseJVVAT   = $arrayparams['FA_PurchaseJVVAT'];
	if($FA_PurchaseJVVAT==0) $AllowModifyVAT= ' disabled ';
	
	if($txtPurchasesJVId!=''){
		$query = " Select PurchaseJV_ID, PurchaseJV_Reference, Date_Format(PurchaseJV_Date,'%d/%m/%Y') As PurchaseJV_Date, ".
	         " Date_Format(JournalDt_ValueDate,'%d/%m/%Y') As MaturityDate, ".
			 " PurchasesJV.Supplier_Code As SupplierCode, Suppliers.Ledger_name As SupplierName, Supplier_VAT,   ".
			 " PurchasesJV.Currency_Code, PurchaseJV_InvoiceNo, Purchase_Remark, PurchasesJV.Project_Code, PurchasesJV.Costcenter_Code,  ".
			 " Round(ifNull(PurchaseJV_Taxable,0), ".$DecimalBase."), Round(ifNull(PurchaseJV_NoneTaxable,0), ".$DecimalBase."), ".
			 " Round(ifNull(PurchaseJV_Total,0), ".$DecimalBase.") As GrossTotal, ".
			 " Round(ifNull(PurchaseJV_DiscountPer,0), ".$DecimalBase."), Round(ifNull(PurchaseJV_DiscAmount,0), ".$DecimalBase."),  ".
			 " Round(ifNull(PurchaseJV_VAT,0), ".$DecimalBase.") As PurchaseJV_VAT, ".
			 " Round((ifNull(PurchaseJV_Total,0) + IfNull(PurchaseJV_VAT,0) - IfNull(PurchaseJV_DiscAmount,0)), ".$DecimalBase.") As PurchaseJV_NetTotal,  ".
			 " ifNull(PurchaseJV_VatCheck,0) As PurchaseJV_VatCheck, Journal.Journal_folio, Journal.Journal_refgovernment, ".
			 " PurchaseJV_WHTChk, PurchaseJV_WHTAccount, Round(ifNull(PurchaseJV_WHTPer,0), ".$DecimalBase."), Round(ifNull(PurchaseJV_WHTAmt,0), ".$DecimalBase."), ".
			 " PurchasesJV.PurchaseJv_ManualNo ".
			 " From Temp_PurchasesJV As PurchasesJV ".
			 " Left Join Suppliers on PurchasesJV.Supplier_Code = Suppliers.Ledger_Number ".
			 " Left Join Journal on PurchasesJV.Journal_ID = Journal.Journal_ID ".
	         " Where PurchaseJV_ID = ".$txtPurchasesJVId;
	
	
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);

	
	$txtTaxable      = $rows[12];
	$txtNoneTaxable  = $rows[13];
	$txtGrossTotal   = $rows[14];
	$txtDiscountPer  = $rows[15];
	$txtDiscountAmt  = $rows[16];
	$txtVatAmt       = $rows[17];
	$txtNetTotal     = $rows[18];
	$txtVatChk       = $rows[19];
	
	$txtJvFolio	     = $rows[20];
	$txtJvRef 	     = $rows[21];
	
	$txtWHTChk 	     = $rows[22];
	$txtWHTAcc 	     = $rows[23];
	$txtWHTPer 	     = $rows[24];
	$txtWHTAmt 	     = $rows[25];
	} else {
		$sub_query = " Select ifNull(Supplier_VAT,0) From Suppliers Where Ledger_Number = '".$txtSupplierCode."'";			 
		$sub_result = selectData($connection, $sub_query);
		$txtPorVatChk = $sub_result[0];
	}
echo"<table border='0' style='table-layout:fixed' cellspacing=0 cellpadding=0>";
echo"<tr>
		<td id='total-top' style='width:240px;height:12px;'></td>
		</tr>
		<tr><td id='total-content' style='width:240px;height:12px;'>";
				
		echo"	<table border='0' cellspacing=0 width=100% >
		<col width=100>
		<col width=110>
			
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Taxable</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtTaxable' value='$txtTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='25'>
			<td valign='center' align='right' ><span class='style10'>None Taxable</span>&nbsp;</td> 
 			<td align='left'><input type='text' name='txtNoneTaxable' value='$txtNoneTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Gross Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtGrossTotal' value='$txtGrossTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Discount</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtDiscountPer' value='$txtDiscountPer' maxlength='5'  style='text-align:right; width:40px; height=18px;' onKeyup='CalcDiscount(1, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ><span class='style10'>%</span>
			                 <input type='text' name='txtDiscountAmt' value='$txtDiscountAmt' maxlength='20' style='text-align:right; width:44px; height=18px;' onKeyup='CalcDiscount(2, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ></td>
		</tr>";
		  


echo "  <tr  height='20'>
			<td valign='center' align='right' >
				<input type='hidden' name='txtVatChk' id='txtVatChk' value='$txtVatChk' size='1'/>
				<input name='chkVat' type='checkbox' id='chkVat' value='1' onClick='SetVat($DecimalBase,$VatApplied,$Setup_VatPercentage);'   "; 
			  if ($txtVatChk==1 ) echo " checked $AllowModifyVAT />";  else echo " $AllowModifyVAT />";   
	          
echo "   	<span class='style10'>VAT $Setup_VatPercentage%</span></td> 
			<td align='left'>
				<input type='text' name='txtVatAmt' value='$txtVatAmt' maxlength='20' style='text-align:right; width:100px; height=18px;' readonly >
			</td>
		</tr>";

	
echo"   <tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Net Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtNetTotal' value='$txtNetTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;";
			if($txtNetTotal<0) echo " color:#FF0000;";
			echo"'></td>
		</tr>
		  
		</table></td></tr><tr>
					<td id='total-bottom' style='width:240px;height:12px;'></td>
				</tr>";	
		echo"</table>";

}

function ShowPorderJvTotals($connection,$txtPorderJVId,$arrayparams,$arrayaccess){

	$DecimalBase  = $arrayparams['DecimalBase'];
	$DecimalBase1 = $arrayparams['DecimalBase1'];
	$DecimalBase2 = $arrayparams['DecimalBase2'];
	$Base1 = $arrayparams['Base1'];
	$Base2 = $arrayparams['Base2'];
	
	
	$Setup_VatPercentage = $arrayparams['Setup_VatPercentage'];
	$VatApplied = $arrayparams['VatApplied'];
	$AllowModifyVAT = $arrayparams['AllowModifyVAT'];
	$txtSupplierCode = $arrayparams['txtSupplierCode'];
	$costcent_applyvat   = $arrayparams['costcent_applyvat'];
	$FA_PurchaseJVVAT   = $arrayparams['FA_PurchaseJVVAT'];
	if($FA_PurchaseJVVAT==0) $AllowModifyVAT= ' disabled ';
	
	if($txtPorderJVId!=''){
		$query = " Select PorderJV_ID, PorderJV_Reference, Date_Format(PorderJV_Date,'%d/%m/%Y') As PorderJV_Date, ".
	         " Date_Format(JournalDt_ValueDate,'%d/%m/%Y') As MaturityDate, ".
			 " PorderJV.Supplier_Code As SupplierCode, Suppliers.Ledger_name As SupplierName, Supplier_VAT,   ".
			 " PorderJV.Currency_Code, PorderJV_InvoiceNo, Purchase_Remark, PorderJV.Project_Code, PorderJV.Costcenter_Code,  ".
			 " Round(ifNull(PorderJV_Taxable,0), ".$DecimalBase."), Round(ifNull(PorderJV_NoneTaxable,0), ".$DecimalBase."), ".
			 " Round(ifNull(PorderJV_Total,0), ".$DecimalBase.") As GrossTotal, ".
			 " Round(ifNull(PorderJV_DiscountPer,0), ".$DecimalBase."), Round(ifNull(PorderJV_DiscAmount,0), ".$DecimalBase."),  ".
			 " Round(ifNull(PorderJV_VAT,0), ".$DecimalBase.") As PorderJV_VAT, ".
			 " Round((ifNull(PorderJV_Total,0) + IfNull(PorderJV_VAT,0) - IfNull(PorderJV_DiscAmount,0)), ".$DecimalBase.") As PorderJV_NetTotal,  ".
			 " ifNull(PorderJV_VatCheck,0) As PorderJV_VatCheck, Journal.Journal_folio, Journal.Journal_refgovernment, ".
			 " PorderJV_WHTChk, PorderJV_WHTAccount, Round(ifNull(PorderJV_WHTPer,0), ".$DecimalBase."), Round(ifNull(PorderJV_WHTAmt,0), ".$DecimalBase."), ".
			 " PorderJV.PorderJv_ManualNo ".
			 " From Temp_PorderJV As PorderJV ".
			 " Left Join Suppliers on PorderJV.Supplier_Code = Suppliers.Ledger_Number ".
			 " Left Join Journal on PorderJV.Journal_ID = Journal.Journal_ID ".
	         " Where PorderJV_ID = ".$txtPorderJVId;
	
	
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);

	
	$txtTaxable      = $rows[12];
	$txtNoneTaxable  = $rows[13];
	$txtGrossTotal   = $rows[14];
	$txtDiscountPer  = $rows[15];
	$txtDiscountAmt  = $rows[16];
	$txtVatAmt       = $rows[17];
	$txtNetTotal     = $rows[18];
	$txtVatChk       = $rows[19];
	
	$txtJvFolio	     = $rows[20];
	$txtJvRef 	     = $rows[21];
	
	$txtWHTChk 	     = $rows[22];
	$txtWHTAcc 	     = $rows[23];
	$txtWHTPer 	     = $rows[24];
	$txtWHTAmt 	     = $rows[25];
	} else {
		$sub_query = " Select ifNull(Supplier_VAT,0) From Suppliers Where Ledger_Number = '".$txtSupplierCode."'";			 
		$sub_result = selectData($connection, $sub_query);
		$txtPorVatChk = $sub_result[0];
	}
echo"<table border='0' style='table-layout:fixed' cellspacing=0 cellpadding=0>";
echo"<tr>
		<td id='total-top' style='width:240px;height:12px;'></td>
		</tr>
		<tr><td id='total-content' style='width:240px;height:12px;'>";
				
		echo"	<table border='0' cellspacing=0 width=100% >
		<col width=100>
		<col width=110>
			
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Taxable</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtTaxable' value='$txtTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='25'>
			<td valign='center' align='right' ><span class='style10'>None Taxable</span>&nbsp;</td> 
 			<td align='left'><input type='text' name='txtNoneTaxable' value='$txtNoneTaxable' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Gross Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtGrossTotal' value='$txtGrossTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		</tr>
		<tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Discount</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtDiscountPer' value='$txtDiscountPer' maxlength='5'  style='text-align:right; width:40px; height=18px;' onKeyup='CalcDiscount(1, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ><span class='style10'>%</span>
			                 <input type='text' name='txtDiscountAmt' value='$txtDiscountAmt' maxlength='20' style='text-align:right; width:44px; height=18px;' onKeyup='CalcDiscount(2, $DecimalBase,$VatApplied,$Setup_VatPercentage);' $DiscountMode ></td>
		</tr>";
		  


echo "  <tr  height='20'>
			<td valign='center' align='right' >
				<input type='hidden' name='txtVatChk' id='txtVatChk' value='$txtVatChk' size='1'/>
				<input name='chkVat' type='checkbox' id='chkVat' value='1' onClick='SetVat($DecimalBase,$VatApplied,$Setup_VatPercentage);'   "; 
			  if ($txtVatChk==1 ) echo " checked $AllowModifyVAT />";  else echo " $AllowModifyVAT />";   
	          
echo "   	<span class='style10'>VAT $Setup_VatPercentage%</span></td> 
			<td align='left'>
				<input type='text' name='txtVatAmt' value='$txtVatAmt' maxlength='20' style='text-align:right; width:100px; height=18px;' readonly >
			</td>
		</tr>";

	
echo"   <tr  height='20'>
			<td valign='center' align='right' ><span class='style10'>Net Total</span>&nbsp;</td> 
			<td align='left'><input type='text' name='txtNetTotal' value='$txtNetTotal' maxlength='20' readonly style='text-align:right; width:100px; height=18px;";
			if($txtNetTotal<0) echo " color:#FF0000;";
			echo"'></td>
		</tr>
		  
		</table></td></tr><tr>
					<td id='total-bottom' style='width:240px;height:12px;'></td>
				</tr>";	
		echo"</table>";


}
function ShowPRequestDtTotalsGrid($connection,$form,$txtPreqId,$PurchaseTTC,$VatApplied,$Setup_VatPercentage,$DecimalBase){


	$query = " Select PRqst_id, PRqst_reference, Date_Format(PRqst_date,'%d/%m/%Y') As PrequestDate, ".
	         " Date_Format(PRqst_RequestDate,'%d/%m/%Y') As RequestDate, PRqst_RequestBy, Prequest.Currency_code, ".
			 " Null, Null, Null, ".
			 " Null, Null, PRqst_remark, Prequest.Project_Code, Prequest.Costcent_code,  ".
			 " null , ifNull(Prqst_Import,0), ifNull(PRqst_Status,'A'), ".
			 " Status_Remark, PRqst_DeliveryPlace, PRqst_DeliveryContact,  ".
			 " Round(PRqst_Taxable, ".$DecimalBase."), Round(PRqst_NoneTaxable, ".$DecimalBase."), ".
			 " Round(PRqst_Total, ".$DecimalBase.") As GrossTotal, ".
			 " Round(PRqst_DiscountPer, ".$DecimalBase."), Round(PRqst_DiscountAmount, ".$DecimalBase."),  ".
			 " ifNull(PRqst_VATChckbx,0) As PRqst_VATChckbx, Round(PRqst_Vat, ".$DecimalBase.") As PRqst_Vat, ".
			 " Round((IfNull(PRqst_Total,0) + IfNull(PRqst_Vat,0) - IfNull(PRqst_DiscountAmount,0) + (ifNull(Prqst_Tax1,0) + ifNull(Prqst_Tax2,0) + ifNull(Prqst_Tax3,0) + ifNull(Prqst_Tax4,0) + ifNull(Prqst_Tax5,0))), ".$DecimalBase.") As Prequest_NetTotal,  ".
			 " Round((ifNull(Prqst_Tax1,0) + ifNull(Prqst_Tax2,0) + ifNull(Prqst_Tax3,0) + ifNull(Prqst_Tax4,0) + ifNull(Prqst_Tax5,0)), ".$DecimalBase.") As TotalTaxes  ".
			 " From Temp_PRequest As Prequest ".
	         " Where PRqst_id = '".$txtPreqId."'";
			 
			 
			 
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);
	
	$txtPreqId       = $rows[0];
	$txtRef         = $rows[1];
	$txtDate        = $rows[2];
	$txtRequestDate = $rows[3];
	$txtRequestBy   = $rows[4];
	$txtCurr        = $rows[5];
	
	
	$txtRemark          = $rows[11];
	$txtProjectCode     = $rows[12];
	$txtCostCentCode    = $rows[13];
	
	$txtReqCategory     = $rows[15];
	$txtReqStatus       = $rows[16];
	$txtStatusRemark    = $rows[17];
	$txtDeliveryPlace   = $rows[18];
	$txtDeliveryContact = $rows[19];
	
	$txtReqTaxable     = $rows[20];
	$txtReqNoneTaxable = $rows[21];
	$txtReqGrossTotal  = $rows[22];
	$txtReqDiscount    = $rows[23];
	$txtReqDiscountAmt = $rows[24];
	$ChkReqVat         = $rows[25];
	$txtReqVat         = $rows[26];
	$txtReqNetTotal    = $rows[27];
	$txtReqTotalTaxes  = $rows[28];
	
	
	
print <<<HERE
<table border='0' style='table-layout:fixed;width:100px' cellspacing=0>
<tr>
		<td id='total-top' style='width:240px;height:12px;'></td>
		</tr>
		<tr><td id='total-content' style='width:240px;height:12px;'>
<table border='0' style='table-layout:fixed;' cellspacing=0 >
			<col width=90>
			<col width=140>
			
			<tr  height='20'>
			 <td valign='center' align='right' ><span class='style10'>Taxable</span>&nbsp;</td> 
			 <td align='left'><input type='text' name='txtReqTaxable' value='$txtReqTaxable' maxlength='20' readonly  style='text-align:right; width:120px; height=20px;background:#C6D4E5;'></td>
		  </tr>
		  <tr   height='25'>
			 <td valign='center' align='right' ><span class='style10'>None Taxable</span>&nbsp;</td> 
 			 <td align='left'><input type='text' name='txtReqNoneTaxable' value='$txtReqNoneTaxable' maxlength='20' readonly  style='text-align:right; width:120px; height=20px;background:#C6D4E5;'></td>

		  </tr>
		  <tr   height='20'>
			 <td valign='center' align='right' ><span class='style10'>Gross Total</span>&nbsp;</td> 
			 <td align='left'><input type='text' name='txtReqGrossTotal' value='$txtReqGrossTotal' maxlength='20' readonly  style='text-align:right; width:120px; height=20px;background:#C6D4E5;'></td>
		  </tr>
		  <tr  height='20'>
			 <td valign='center' align='right' ><span class='style10'>Discount</span>&nbsp;</td> 
			 <td align='left'><input type='text' name='txtReqDiscount' value='$txtReqDiscount' maxlength='5'  style='text-align:right; width:40px; height=18px;' onKeyup='CalcPorDiscount(1, $DecimalBase,$VatApplied,$Setup_VatPercentage);' ><span class='style10'>%</span>
			                  <input type='text' name='txtReqDiscountAmt' value='$txtReqDiscountAmt' maxlength='20' style='text-align:right; width:64px; height=18px;' onKeyup='CalcPorDiscount(2, $DecimalBase,$VatApplied,$Setup_VatPercentage);' ></td>
		  </tr>

HERE;

echo "    <tr   height='20'>
			 <td valign='center' align='right' ><input type='checkbox' name='ChkReqVat' id='ChkReqVat' value='1' onClick='SetPorVat($DecimalBase,$VatApplied,$Setup_VatPercentage,$PurchaseTTC);'   "; 
	          if($ChkReqVat==1) echo "checked />"; else echo " />";   
echo "   	 <span class='style10'>VAT $Setup_VatPercentage%</span>&nbsp;</td> 
			 <td align='left'>
			   <input type='text' name='txtReqVat' value='$txtReqVat' maxlength='20'  maxlength='20' style='text-align:right; width:120px; height=20px;background:#C6D4E5;' >
			 </td>";
echo "  </tr>";
		  
	if ($Module_AdditionalTaxes == 1) {
		echo"<tr  height='20'>
			   <td valign='center' align='right' ><span class='style10'>Taxes</span>&nbsp;</td> 
			   <td align='left'><input type='text' name='txtReqTotalTaxes' value='$txtReqTotalTaxes' maxlength='20' readonly  maxlength='20' style='text-align:right; width:120px; height=20px;background:#C6D4E5;'></td>
		     </tr>";
	} else {
		echo "<input type='hidden' name='txtReqTotalTaxes' value='$txtReqTotalTaxes'>";
	}

echo"     <tr   height='25'>
			 <td valign='center' align='right' ><span class='style10'>Net Total</span>&nbsp;</td> 
			 <td align='left'><input type='text' name='txtReqNetTotal' value='$txtReqNetTotal' maxlength='20' readonly  maxlength='20' style='text-align:right; width:120px; height=20px;background:#C6D4E5;";
			 
			if($txtReqNetTotal<0) echo " color:#FF0000;";
			 
			 
			 echo"'></td>
		  </tr>
		  
		  </table></td>
				</tr><tr>
					<td id='total-bottom' style='width:240px;height:12px;'></td>
				</tr></table></td></tr>";


}

	    	

function ShowTransferRequestDtGrid($connection,$form,$transferrequest_id,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$PriceLabel,$Module_Unit1Method,$PurchaseTTC,$Module_TransferWithOneWh,$FIPurchaseCategory,$Module_TransferRequestPrice,$showBatch, $Module_Heatno){

	
	$querylog=" select language".
          " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

	$querylang="select language, Reference, Project, Warehouse, Date as date_label, from_date, to_date, 
			Driver_Name as driver_label, Vehicle_No as vehicle_label, Remark,
			 Item, Description, Packaging_Nbr, nb_of_unit, qty, Unit, qtyexist, batchnb, heatnb,
			 From_warehouse, to_warehouse, Price, totalamount
	from ".$_SESSION['dbLabel'].".transferrequest_label where 
			language='$language'";

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


	
	
	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
		
	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
		
	$columnsarray = array("p_item_code","p_item_description");
	
	if($showBatch == 1){
		$columnsarray[] = 'p_transferdt_packagingno';
		$columnsarray[] = 'p_transferdt_nbrunit';
	}
	$columnsarray[] = 'p_item_quantity';
	if ($Module_DoubleUnit==1) {
		$columnsarray[] = 'Item_Unit2Qty';
	}
			
	if ($Module_TransferRequestPrice==1)
		$columnsarray[] = 'p_item_sellingprice1';
			
	if ($Module_TransferWithOneWh!=1) {
		$columnsarray[] = 'fromwarehouse';
		$columnsarray[] = 'towarehouse';
	}
		
	if($showBatch == 1){
		$columnsarray[] = 'p_transferdt_batchno';
	}	
	if($Module_Heatno == 1){
		$columnsarray[] = 'p_transferdt_heatno';
	}
			
		$columnsarray[] = "p_transferdt_remark";
						
	
	$columnslist = implode(',', $columnsarray);
	
	
	
echo"<input type='hidden' name='headercurrency_code' id='headercurrency_code' value='$headercurrency_code'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
			$query = " Select a.TransferrequestDt_id,a.Transferrequest_Id,a.Transferrequest_Date,a.Item_code,a.TransferrequestDt_WarehouseFrom,
						a.TransferrequestDt_WarehouseTo,a.TransferrequestDt_Quantity,a.TransferrequestDt_Price,a.Project_Code1,a.Project_Code2
						,a.Transferrequestdt_remark,items.item_description,items.item_withserialno
						,Logged_Code ,null,Items.Item_UnitSalesDesc ,Items.Item_UnitPurchaseDesc,Item_Unit2Qty,
						TransferrequestDt_BatchNo,TransferrequestDt_packagingNo,TransferrequestDt_nbrUnit, transferrequestdt_heatno
						from temp_transferrequestdt as a,items
						where transferrequest_id = '".$transferrequest_id."'
						and a.item_code=items.item_code
						order by transferrequestdt_id asc
						";
						
						
//echo $query;	
$result=mysql_query($query,$connection)  or die(mysql_error());
$totalrows = mysql_num_rows($result);

$query = $query." limit ".$startrange.",".$perpage;
//echo $query;
$result=mysql_query($query,$connection);

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"	<div id='main' >";
echo"	<div id='Loader' class=''><div></div></div>";
echo"<div id='prequestdtdiv' style='overflow:auto;width:1100px;height:200px;border:0px solid #000000;'>";
$widthTable = 970;
if ($showBatch == 1)   $widthTable += 150;
if ($Module_DoubleUnit==1) $widthTable += 270;
if ($Module_TransferWithOneWh!=1) $widthTable += 220;
if ($showBatch == 1) $widthTable += 120;
if ($Module_Heatno == 1) $widthTable += 115;

$widthTable .='px';
echo"<table border='1' align='left'   class='grid_data'  width='$widthTable' style='table-layout:fixed;font-size:10px;border-spacing:0;' cellpadding='0' cellspacing='1'>";

    echo"  <col width=30><col width=170><col width=220>";
	if ($showBatch == 1)   echo"<col width=75><col width=75>";
	echo "<col width=90><col width=90><col width=90>";
	if ($Module_DoubleUnit==1)	 echo"<col width=100> <col width=170>"; 
	if ($Module_TransferWithOneWh!=1)   echo"<col width=120><col width=120>";

	if ($showBatch == 1)   echo"<col width=120>";
	if ($Module_Heatno == 1)   echo"<col width=115>";
	 echo"<col width=250><col width=30>";

	

		  
		echo"<tr height='25px'>";
		  echo"  <th bgcolor='#F7F7F7' align='left'>&nbsp;</td>";
          echo"  <th bgcolor='#F7F7F7' align='left'>$Item</td>";  
		  echo"  <th bgcolor='#F7F7F7' align='left'>$Description</td>";
		   if($showBatch == 1){
			  echo"  <th bgcolor='#F7F7F7' align='center'>$Packaging_Nbr .</td>";			  
			  echo"  <th bgcolor='#F7F7F7' align='center'>$nb_of_unit</td>";
		  }
		  echo"  <th bgcolor='#F7F7F7' align='left'>$qty</td>";
		  echo"  <th bgcolor='#F7F7F7' align='left'>$Unit</td>"; 
		  echo"  <th bgcolor='#F7F7F7' align='left'>$qtyexist</td>";
		  
		  //echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>Real Qty</td>";
		  
	if ($Module_DoubleUnit==1) {
		echo"  <th bgcolor='#F7F7F7' align='left'>$qty 2</td>";
		echo"  <th bgcolor='#F7F7F7' align='left'>$Unit 2</td>";
	}
		  
	if ($Module_TransferRequestPrice==1)
		echo"  <th bgcolor='#F7F7F7' align='center'>$Price</td>";
		  
	if ($Module_TransferRequestPrice==1)
		echo"  <th bgcolor='#F7F7F7' align='left'>$totalamount</td>";	  
	if ($Module_TransferWithOneWh!=1) {
		echo"  <th bgcolor='#F7F7F7' align='center'>$From_warehouse</td>";
		echo"  <th bgcolor='#F7F7F7' align='center'>$to_warehouse</td>";
	}
	if($showBatch == 1){
		echo"  <th bgcolor='#F7F7F7' align='center'>$batchnb</td>";
	}
	if ($Module_Heatno == 1) 	
	echo"  <th bgcolor='#F7F7F7' align='center'>$heatnb</td>";
	echo"  <th bgcolor='#F7F7F7' align='left'>$Remark</td>";	  
	echo"  <th bgcolor='#F7F7F7' align='left'>&nbsp;</td>";	  

	echo"</tr>";



	$i=0;
	$j=1;
	
	echo"
		
		 <input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>		 
		 ";

		 
while($row=mysql_fetch_row($result)){
		
		
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
		
		$KeyDown   = 'onkeydown="return dokeytransferrequest(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\')"';


						
						
			$transferrequestdt_id[$i] = $row[0];
			$transferrequestid[$i] = $row[1];
			
			$transferrequest_date[$i] = $row[2];
			$p_item_code[$i] = $row[3];
			$p_item_description[$i] = $row[11];
			$p_item_quantity[$i] = $row[6];
			$Item_Unit2Qty[$i] = $row[17];
			$p_item_sellingprice1[$i] = $row[7];
			$fromwarehouse[$i] = $row[4];
			$towarehouse[$i] = $row[5];
			$p_transferdt_remark[$i] = $row[10];
			$Item_UnitSalesDesc[$i] = $row[15];
			$Item_UnitPurchaseDesc[$i] = $row[16];
			
			$p_transferdt_batchno[$i] = $row[18];
			$p_transferdt_packagingno[$i] = $row[19];
			$p_transferdt_nbrunit[$i] = $row[20];
			$p_transferdt_heatno[$i] = $row[21];
			
			
			//echo"<tr height='20px' id='prqstdt$i' onclick=\"returncolor(this,'SelectedRec','SelectedRecColor','$row[0]')\" style='background-color:$bgcolor'>";
			echo"<tr height='30px'  id='CurRec$i' class='$bgcolor table-focus-g1'>";
		
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
			echo"<td  align=center onclick=\"deletetrequestsdt('".$transferrequestid[$i]."','$row[0]','".$itemcodepacked[$i]."','".$itemcode[$i]."','$filepath'); return false;\"><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' ></td>";
		
				
			echo"<td align='center'><span class='style4'><input type='text'   name='p_item_code[$i]' id='p_item_code[$i]' value='".$p_item_code[$i]."'   $KeyDown   class='roundedtext_amortization_small'   onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1);SetModRecord('ModRec_G1','$i')\"  style='width:140px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','','','txtAvailableQty[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType')\">
					</td>";

			echo"<td align='center'><span class='style4'><input type='text'      name='p_item_description[$i]' id='p_item_description[$i]' value='".$p_item_description[$i]."'  class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2);SetModRecord('ModRec_G1','$i')\" style='width:200px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType')\">	
			";
			
			echo"</td>";
	
		{
				$data = substr($transferrequest_date[$i], 6, 4) . substr($transferrequest_date[$i], 3, 2) . substr($transferrequest_date[$i], 0, 2);
				
				$transfer_date1[$i] = substr($transferrequest_date[$i], 0, 10)." ".strftime("%H").":".strftime("%M").":".strftime("%S");
				//echo $transfer_date[$i]."<br>";

			$qry="select item_pack from items where item_code = '".$p_item_code[$i]."'";
			$resultlog=mysql_query($qry,$connection) or die(mysql_error());
				while($rows=mysql_fetch_array($resultlog)){
					extract($rows);
				}
	
			$min_sorder_qty[$i] = 0;
			$min_available_qty[$i] = 9999999999;
			$min_exists_qty[$i] = 9999999999;
			$available_qty[$i] = 0;
			$exist_qty[$i] = 0;
			
			if (empty($transferrequestdt_id)) $transferrequestdt_id = 0;
				$Qry_QtyAvailable[$i] = " Select QtyExists('".$p_item_code[$i]."', '".$fromwarehouse[$i]."', '".$transferrequest_date[$i]."', 0, 'TR', '', '') QtyExists From Dual ";
						//fady		
				$resultq = selectData($connection, $Qry_QtyAvailable[$i]);
				$min_available_qty[$i] = $resultq[0];
			//echo  $min_available_qty[$i] . "-".$resultTemp[0];
			$txtAvailableQty[$i] = $min_available_qty[$i]  - $resultTemp[0];
		
			$errorquantity=0;
			$PostNotAllowed='False';
			if  (($Module_NegativeQuantity==0) or ($Login_negativeQty==0)) 
				{
					$PostNotAllowed='True';
				$errorquantity=1;
				}
	}
	 if($showBatch == 1){
			 echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_packagingno[$i]' id='p_transferdt_packagingno[$i]' value='".$p_transferdt_packagingno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\" style='width:70px;'> </span></td>";
			 echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_nbrunit[$i]' id='p_transferdt_nbrunit[$i]' value='".$p_transferdt_nbrunit[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\" style='width:70px;'> </span></td>";
		 } else {
			 echo "<input type='hidden'  name='p_transferdt_packagingno[$i]' id='p_transferdt_packagingno[$i]' value=''>";
			 echo "<input type='hidden'  name='p_transferdt_nbrunit[$i]' id='p_transferdt_nbrunit[$i]' value=''>";
		 }
		echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='p_item_quantity[$i]' id='p_item_quantity[$i]' value='".$p_item_quantity[$i]."' style='width:80px'  onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\" > </span></td>";
	

	echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$Item_UnitSalesDesc[$i]."' style='width:80px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	echo"<td align='center'><input type='text' name='txtAvailableQty[$i]' readonly id='txtAvailableQty[$i]' value='".$txtAvailableQty[$i]."' readonly style='border-width:0px' size=4></td>";

	
		if ($Module_DoubleUnit==1) {
		echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_Unit2Qty[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\"   style='width:68px'  id='Item_Unit2Qty[$i]'  value='".$Item_Unit2Qty[$i]."'  size=4> </td>";
		echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_UnitPurchaseDesc[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:68px'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> </td>";
		}
		else {
		echo"<input type='hidden' name='Item_Unit2Qty[$i]'  id='Item_Unit2Qty[$i]'  onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$Item_Unit2Qty[$i]."'  size=4>";
		
		}

		echo"	  <input type='hidden' name='p_item_quantity1[$i]'  id='p_item_quantity1[$i]' value='".$p_item_quantity1[$i]."'  size=4>";
		echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";
				
				$amount = '';
				$amount = $row[6] * $row[7];
				

				//$totalamount = $totalamount + $amount;
				
			if($Module_TransferRequestPrice==1)
				echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_item_sellingprice1[$i]'    onchange=calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)   style='width:80px'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4> </td>";
			else
				echo"<input type='hidden'  name='p_item_sellingprice1[$i]'    onchange=calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)   style='width:80px'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4>";
			
			
			if($Module_TransferRequestPrice==1)
				echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='amount[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:80px'  id='amount[$i]'  value='".$amount."'  size=4> </td>";
			else
				echo"<input type='hidden' name='amount[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:80px'  id='amount[$i]'  value='".$amount."'  size=4>";
				
			if ($Module_TransferWithOneWh==1)
				echo"<input type='hidden' name='fromwarehouse[$i]' id='fromwarehouse[$i]' value='".$fromwarehouse[$i]."' ;\"  > ";
			else{
				echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='fromwarehouse[$i]' id='fromwarehouse[$i]' value='".$fromwarehouse[$i]."' onchange=\"setwarehousecode(this.value,'fromwarehouse[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
				
				echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('fromwarehouse','fromwarehouse[$i]','800','500') \" />
				</td>";
			}
			if ($Module_TransferWithOneWh==1)
			echo"<input type='hidden' name='towarehouse[$i]' id='towarehouse[$i]' value='".$towarehouse[$i]."' ;\"  > ";
			else{
			echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='towarehouse[$i]' id='towarehouse[$i]' value='".$towarehouse[$i]."' onchange=\"setwarehousecode(this.value,'towarehouse[$i]','imgwarehousebtn1[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn1[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('towarehouse','towarehouse[$i]','800','500') \" />
			</td>";
			}
			 if($showBatch == 1){
				 echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_batchno[$i]' id='p_transferdt_batchno[$i]' value='".$p_transferdt_batchno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:95px;' > </span>
					<label><span><img src='img/openlist.png' title='Select Batch No' id='lstBatchNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistBatchNo(2,$i); ' style='vertical-align:bottom;'/></span></label></td>";
			} else {
				 echo "<input type='hidden'  name='p_transferdt_batchno[$i]' id='p_transferdt_batchno[$i]' value=''>";
			 }
			if ($Module_Heatno == 1) {
				 echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_heatno[$i]' id='p_transferdt_heatno[$i]' value='".$p_transferdt_heatno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:85px;' > </span>
					<label><span><img src='img/openlist.png' title='Select Heat No' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick=\"showlistHeatNo('$i'); \" style='vertical-align:bottom;'/></span></label></td>";
			 } else {
				 echo "<input type='hidden'  name='p_transferdt_heatno[$i]' id='p_transferdt_heatno[$i]' value=''>";
			 } 
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   name='p_transferdt_remark[$i]' id='p_transferdt_remark[$i]' value='".$p_transferdt_remark[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:245px;' > </span></td>";
			
			echo"<td align='center'><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"submitTransReqDt('$transferrequestdt_id[$i]','$transferrequestid[$i]','$i','e','$PurchaseTTC','$FIPurchaseCategory','$filepath')\"></td>";
			echo"<input type='hidden'  name='transferrequestdt_id[$i]' id='transferrequestdt_id[$i]' value='".$transferrequestdt_id[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
		}
		
		if (empty($warehousecode[$i])) { 
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeytransferrequest(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\');"';

			echo"<tr height='30px' id='CurRec$i' class='$bgcolor table-focus-g1'>";
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearprequestdt('$i','$PurchaseTTC','$Module_DoubleUnit')\"></td>";
			
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1);SetModRecord('ModRec_G1','$i')\"  onblur=\"FillData('fromwarehouse[$i]','towarehouse[$i]')\"  name='p_item_code[$i]' id='p_item_code[$i]' value='".$p_item_code[$i]."' style='width:140px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','','','txtAvailableQty[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType');FillData('fromwarehouse[$i]','towarehouse[$i]')\">
					</td>";

			echo"<td align='center'><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2);SetModRecord('ModRec_G1','$i')\"     name='p_item_description[$i]' id='p_item_description[$i]' value='".$p_item_description[$i]."' style='width:200px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','itemunitsalesdesc[$i]','itemunitpurchasedesc[$i]','i_unitcoef[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType')\">	";
				
		
			echo"</td>";
		 if($showBatch == 1){
				 echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_packagingno[$i]' id='p_transferdt_packagingno[$i]' value='".$p_transferdt_packagingno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\" style='width:70px;'> </span></td>";
				 echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_nbrunit[$i]' id='p_transferdt_nbrunit[$i]' value='".$p_transferdt_nbrunit[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\" style='width:70px;'> </span></td>";
		} else {
				 echo "<input type='hidden'  name='p_transferdt_packagingno[$i]' id='p_transferdt_packagingno[$i]' value=''>";
				 echo "<input type='hidden'  name='p_transferdt_nbrunit[$i]' id='p_transferdt_nbrunit[$i]' value=''>";
		 }			
		echo"<td  align='center' ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='p_item_quantity[$i]' id='p_item_quantity[$i]' value='".$p_item_quantity[$i]."' style='width:80px'  onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\" > </span></td>";
	

echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='itemunitsalesdesc[$i]' id='itemunitsalesdesc[$i]' value='".$Item_UnitSalesDesc[$i]."' style='width:80px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	echo"<td  align='center'><input type='text' name='txtAvailableQty[$i]' readonly id='txtAvailableQty[$i]' value='".$txtAvailableQty[$i]."'  size=4></td>";
	
		if ($Module_DoubleUnit==1) {
		echo"<td  align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_Unit2Qty[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i);\"   style='width:68px'  id='Item_Unit2Qty[$i]'  value='".$Item_Unit2Qty[$i]."'  size=4> </td>";
		echo"<td  align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_UnitPurchaseDesc[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:68px'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> </td>";
		}
		else {
		echo"<input type='hidden' name='Item_Unit2Qty[$i]'  id='Item_Unit2Qty[$i]'  onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$Item_Unit2Qty[$i]."'  size=4>";
		}

		echo"	  <input type='hidden' name='p_item_quantity1[$i]'  id='p_item_quantity1[$i]' value='".$p_item_quantity1[$i]."'  size=4>";
		echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";

				if ($rowsdt[6]=='')		$rowsdt[6] = 0;
				if ($rowsdt[7]=='') 	$rowsdt[7] = 0;
				
					
				$amount[$i] = $rowsdt[6] * $rowsdt[7];
				//$totalamount = $totalamount + $amount;
				
			if($Module_TransferRequestPrice==1)
				echo"<td  align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_item_sellingprice1[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\"   style='width:80px'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4> </td>";
			else
				echo"<input type='hidden' name='p_item_sellingprice1[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\"   style='width:80px'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4>";

			if($Module_TransferRequestPrice==1)	
				echo"<td  align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='amount[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:80px'  id='amount[$i]'  value='".$amount[$i]."'  size=4> </td>";
				else
				echo"<input type='hidden' name='amount[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:80px'  id='amount[$i]'  value='".$amount[$i]."'  size=4>";
			
			
				
			if ($Module_TransferWithOneWh==1)
				echo"<input type='hidden' name='fromwarehouse[$i]' id='fromwarehouse[$i]' value='".$fromwarehouse[$i]."' ;\"  > ";
			else{
				echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='fromwarehouse[$i]' id='fromwarehouse[$i]' value='".$fromwarehouse[$i]."' onchange=\"setwarehousecode(this.value,'fromwarehouse[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
				echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('fromwarehouse','fromwarehouse[$i]','800','500') \" />
				</td>";
			}
			
			if ($Module_TransferWithOneWh==1)
			echo"<input type='hidden' name='towarehouse[$i]' id='towarehouse[$i]' value='".$towarehouse[$i]."' ;\"  > ";
			else {
			echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='towarehouse[$i]' id='towarehouse[$i]' value='".$towarehouse[$i]."' onchange=\"setwarehousecode(this.value,'towarehouse[$i]','imgwarehousebtn1[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn1[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('towarehouse','towarehouse[$i]','800','500') \" />
			</td>";
			}
			 if($showBatch == 1){
				 echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_batchno[$i]' id='p_transferdt_batchno[$i]' value='".$p_transferdt_batchno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:95px;' > </span>
					<label><span><img src='img/openlist.png' title='Select Batch No' id='lstBatchNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistBatchNo(2,$i); ' style='vertical-align:bottom;'/></span></label></td>";
			 } else {
				 echo "<input type='hidden'  name='p_transferdt_batchno[$i]' id='p_transferdt_batchno[$i]' value=''>";
			 }
			if ($Module_Heatno == 1) {
				 echo"<td align='center' ><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_heatno[$i]' id='p_transferdt_heatno[$i]' value='".$p_transferdt_heatno[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:85px;' > </span>
					<label><span><img src='img/openlist.png' title='Select Heat No' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick=\"showlistHeatNo('$i'); \" style='vertical-align:bottom;'/></span></label></td>";
			 } else {
				 echo "<input type='hidden'  name='p_transferdt_heatno[$i]' id='p_transferdt_heatno[$i]' value=''>";
			 }	
			echo"<td  align='center'><span class='style4'><input type='text'   $KeyDown     name='p_transferdt_remark[$i]' id='p_transferdt_remark[$i]' value='".$p_transferdt_remark[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\"  style='width:245px;'> </span></td>";
				
			echo"<td  align='center'><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"return submitTransReqDt('$transferrequestdt_id[$i]','$transferrequestid[$i]','$i','i','$PurchaseTTC','$FIPurchaseCategory','$filepath');\"></td>";
			echo"<input type='hidden'  name='txtPreqDTId[$i]' id='txtPreqDTId[$i]' value='".$txtPreqDTId[$i]."' >";
			echo"</tr>";
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div></div>";
	

	

}

	
function ShowTransferDtGrid($connection,$form,$transfer_id,$orderby,$startrange,$perpage,$option,$direction,$arrayparams){

$querylog=" select language".
          " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}
//echo $querylog;
	$querylang="select language, Reference, Project, Warehouse, Date as date_label, from_date, to_date, 
			Driver_Name as driver_label, Vehicle_No as vehicle_label, Remark,
			 Item, Description, Packaging_Nbr, nb_of_unit, qty, Unit, qtyexist, batchnb, heatnb,
			 From_warehouse, to_warehouse, Price, totalamount as totalamount_label,page as page_label, perpage as perpage_label, record_to_view
			from ".$_SESSION['dbLabel'].".transfer_label where 
			language='$language'";
//echo $querylang;
$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
		extract($rows);
		
	}

	$base1 							= $arrayparams['base1'];
	$base2 							= $arrayparams['base2']; 						
	$DecimalBase 					= $arrayparams['DecimalBase']; 					
	$Module_DoubleUnit 				= $arrayparams['Module_DoubleUnit'];			
	$Module_ProjectDt 				= $arrayparams['Module_ProjectDt']; 			
	$Module_CostCenterDt 			= $arrayparams['Module_CostCenterDt']; 			
	$PriceLabel 					= $arrayparams['PriceLabel']; 					
	$Module_Unit1Method 			= $arrayparams['Module_Unit1Method']; 			
	$Module_TransferWithOneWh 		= $arrayparams['Module_TransferWithOneWh']; 	
	$Module_TransferRequestPrice 	= $arrayparams['Module_TransferRequestPrice']; 	
	$actionmode 					= $arrayparams['actionmode']; 					
	$module_serialno 				= $arrayparams['module_serialno']; 				
	$Module_ZeroQuantity 			= $arrayparams['Module_ZeroQuantity']; 			
	$ModuleProject	 				= $arrayparams['ModuleProject']; 				
	$ModuleCostCenter 				= $arrayparams['ModuleCostCenter']; 			
	$Module_RestrictProjCost 		= $arrayparams['Module_RestrictProjCost']; 		
	$Module_RestrictCost 			= $arrayparams['Module_RestrictCost']; 			
	$Module_TransferPrice 			= $arrayparams['Module_TransferPrice']; 		
	$Module_Heatno 					= $arrayparams['Module_Heatno']; 			
	$showbatch 						= $arrayparams['showbatch']; 					
	$module_chargesInTransfer 		= $arrayparams['module_chargesInTransfer']; 	
	
	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';


	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
		if ($Module_TransferWithOneWh!=1) {
				$columnsarray[] = 'fromwarehouse';
				$columnsarray[] = 'towarehouse';
		}
		
	$columnsarray[] = "p_item_code";
	$columnsarray[] = "p_item_description";
	
	if($Module_Heatno==1)
		$columnsarray[] =  "HeatNo";
	
	
	if($showBatch == 1){			
	$columnsarray[] = "p_transferdt_packagingno";
	$columnsarray[] = "p_transferdt_nbrunit";
}
	$columnsarray[] = "p_item_quantity";
						

	if ($Module_DoubleUnit==1) {
				$columnsarray[] = 'Item_Unit2Qty';
	}
			
if ($Module_TransferPrice==1)
	$columnsarray[] = 'p_item_sellingprice1';

if ($module_chargesInTransfer == 1){
	$columnsarray[] = 'p_costamount';
	$columnsarray[] = 'p_chargeamount';
}
if($showBatch == 1){			
	$columnsarray[] = "p_transferdt_batchno";
}
	$columnsarray[] = "p_transferdt_remark";
						
	
	
	$columnslist = implode(',', $columnsarray);
	
	
	
echo"<input type='hidden' name='headercurrency_code' id='headercurrency_code' value='$headercurrency_code'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
	  if ($transfer_id != '' )
		{

			$querydt = " Select a.TransferDt_id,a.Transfer_Id,a.Transfer_Date,a.Item_code,a.TransferDt_WarehouseFrom,
						a.TransferDt_WarehouseTo,a.TransferDt_Quantity,a.TransferDt_Price,a.Project_Code1,a.Project_Code2
						,a.Transferdt_remark,items.item_description,items.item_withserialno
						,a.Logged_Code  
						,(		SELECT count(*) FROM temp_purchasesserialno
						where purchasedt_id=a.transferdt_id
						and temp_purchasesserialno.item_code = if(a.item_code='',temp_purchasesserialno.item_code,a.item_code)
						) as purchasesserialno_qty ,  Items.Item_UnitSalesDesc ,Items.Item_UnitPurchaseDesc,Item_Unit2Qty,Transferdt_HeatNo,
						TransferDt_BatchNo, TransferDt_packagingNo,TransferDt_nbrUnit, items.Item_Unit, if (curencycode = '$base1', transferdt_costbase1, transferdt_costbase2),
						if (curencycode = '$base1', transferdt_chargebase1, transferdt_chargebase2)
						from temp_transferdt as a
						left join items on  a.item_code=items.item_code
						inner join temp_transfer on temp_transfer.transfer_id = a.transfer_id
						where a.transfer_id = ".$transfer_id."
						order by transferdt_id asc
						";
			if ($actionmode == "post" && $transfer_id != '') 
					{
			$querydt = " Select a.TransferDt_id,a.Transfer_Id,a.Transfer_Date,a.Item_code,a.TransferDt_WarehouseFrom,
						a.TransferDt_WarehouseTo,a.TransferDt_Quantity,a.TransferDt_Price,a.Project_Code1,a.Project_Code2
						,a.Transferdt_remark,items.item_description,items.item_withserialno
						,Null  
						,(		SELECT count(*) FROM temp_purchasesserialno
						where purchasedt_id=a.transferdt_id
						and temp_purchasesserialno.item_code = if(a.item_code='',temp_purchasesserialno.item_code,a.item_code)
						) as purchasesserialno_qty,  Items.Item_UnitSalesDesc ,Items.Item_UnitPurchaseDesc,Item_Unit2Qty,Transferdt_HeatNo,
						TransferDt_BatchNo, TransferDt_packagingNo,TransferDt_nbrUnit, items.Item_Unit, if (curencycode = '$base1', transferdt_costbase1, transferdt_costbase2),
						if (curencycode = '$base1', transferdt_chargebase1, transferdt_chargebase2)
						from transferdt as a
						left join items on  a.item_code=items.item_code
						inner join temp_transfer on temp_transfer.transfer_id = a.transfer_id
						where a.transfer_id = ".$transfer_id."
						order by transferdt_id asc ";
					}
				//echo $querydt;		
			$result=mysql_query($querydt,$connection)  or die(mysql_error());
			$totalrows = mysql_num_rows($result);

			$querydt = $querydt." limit ".$startrange.",".$perpage;

			$result=mysql_query($querydt,$connection);			
		}				



$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='container' style='position: relative;z-index:1;' >";
echo"	<div id='Loader' class=''></div>";
echo"<div id='prequestdtdiv' style='overflow:auto;width:1100px;height:200px;border:0px solid #000000;'>";

//$widthTable = ;
echo"<table border='0' align='left'   class='grid_data'  style='font-size:10px;border:0px solid black;border-spacing:0;width:1260px;' cellpadding='0' cellspacing='1'>
	 <col width=25><col width=25>";
if ($Module_TransferWithOneWh != 1) echo "<col width=140><col width=140>";
echo"<col width=150><col width=250>";
	
if($Module_Heatno==1) 	echo"<col width=120>";
	
if($showBatch == 1) echo"<col width=75><col width=75>";

	echo"<col width=80><col width=80><col width=80>";
		  
if ($Module_DoubleUnit==1)
	echo"<col width=70><col width=70>";
			

if ($Module_TransferPrice==1){
	  echo"<col width=90><col width=90> ";
	}
if ($module_chargesInTransfer == 1)
	echo"<col width=90><col width=90> ";

if($showBatch == 1) echo"<col width=120>";
echo"<col width=200><col width=25>";

	echo"<tr height='25px'>";
	echo"  <th bgcolor='#F7F7F7' align='left'> &nbsp;</th>";
	echo"  <th bgcolor='#F7F7F7' align='left'>&nbsp;</th>";
if ($Module_TransferWithOneWh!=1){
	echo"  <th bgcolor='#F7F7F7' align='center'><b>$From_warehouse.</b></th>";
	echo"  <th bgcolor='#F7F7F7' align='center'><b>$to_warehouse .</b></th>";
}
    echo"  <th bgcolor='#F7F7F7' align='left'>$Item</b></th>";  
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$Description</b></th>";
		 
if($Module_Heatno==1)
	 echo"  <th bgcolor='#F7F7F7' width='210px;'  align='left'><b>$heatnb</b></th>";
if($showBatch == 1){
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$Packaging_Nbr .</b></th>";	
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$nb_of_unit</b></th>";	
}  
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$qty</b></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$Unit</b></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$qtyexist</b></th>";
		  
if ($Module_DoubleUnit==1) {
	echo"  <th bgcolor='#F7F7F7' align='left'><b>Qty2</b></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'><b>Unit2</b></th>";
}
				
if ($Module_TransferPrice==1)	{				
	echo"  <th bgcolor='#F7F7F7' align='center'><b>$Price</b></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$totalamount_label</b></th>";	  
}
if ($module_chargesInTransfer == 1){
	echo"  <th bgcolor='#F7F7F7' align='center'><b>Cost</b></th>";	
	echo"  <th bgcolor='#F7F7F7' align='center'><b>Charge</b></th>";
}
if($showBatch == 1){
	echo"  <th bgcolor='#F7F7F7' align='left'><b>Batch No</b></th>";	
}
	echo"  <th bgcolor='#F7F7F7' align='left'><b>$Remark</b></th>";	  
	echo"  <th bgcolor='#F7F7F7' align='left'></th>";	  

	echo"</tr>";
	

		  
		


	$i=0;
	$j=1;
	
	echo"<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>";

$i=0;		 
while($rowsdt=mysql_fetch_row($result)){
			
			$transferdt_id[$i]				= $rowsdt[0];
			$transferid[$i]					= $rowsdt[1];
		
			$transfer_date[$i] 				= $rowsdt[2];
			$p_item_code[$i] 				= $rowsdt[3];
			$p_item_description[$i] 		= $rowsdt[11];
			$p_item_quantity[$i] 			= $rowsdt[6];
			$Item_UnitSalesDesc[$i] 		= $rowsdt[15];
			//$txtAvailableQty;
			$Item_Unit2Qty[$i] 				= $rowsdt[17];
			$Item_UnitPurchaseDesc[$i] 		= $rowsdt[16];
			$transferdt_heatno[$i] 			= $rowsdt[18];
			
			$amount 						= $rowsdt[6] * $rowsdt[7];
			$totalamount 					= $totalamount + $amount;
			$p_item_sellingprice1[$i] 		= $rowsdt[7];
			$fromwarehousedt[$i] 			= $rowsdt[4];
			$towarehousedt[$i] 				= $rowsdt[5];
			$p_transferdt_remark[$i] 		= $rowsdt[10];
			
			$p_transferdt_batchno[$i] 		= $rowsdt[19];
			$p_transferdt_packagingno[$i] 	= $rowsdt[20];
			$p_transferdt_nbrunit[$i] 		= $rowsdt[21];
			$Item_Unit[$i]					= $rowsdt[22];
			$p_costamount 					= $rowsdt[23];
			$p_chargeamount 				= $rowsdt[24];
			
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
		
		$KeyDown   = 'onkeydown="return dokeytransfer(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\')"';

			$p_item_code[$i]=$rowsdt[3];
			
			
			//if ($rowsdt[12]!=0) 
			{
				$data = substr($transfer_date[$i], 6, 4) . substr($transfer_date[$i], 3, 2) . substr($transfer_date[$i], 0, 2);
				
				$transfer_date1[$i] = substr($transfer_date[$i], 0, 10)." ".strftime("%H").":".strftime("%M").":".strftime("%S");
				//echo $transfer_date[$i]."<br>";

	$qry="select item_pack from items where item_code = '".$p_item_code[$i]."'";
	$resultlog=mysql_query($qry,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($resultlog)){
			extract($rows);
		}
	
	$min_sorder_qty[$i] = 0;
	$min_available_qty[$i] = 9999999999;
	$min_exists_qty[$i] = 9999999999;
	$available_qty[$i] = 0;
	$exist_qty[$i] = 0;
	
	if (empty($transfer_id)) $transfer_id = 0;
		$Qry_QtyAvailable[$i] = " Select QtyExists('".$p_item_code[$i]."', '".$fromwarehousedt[$i]."', '".$transfer_date[$i]."', ".$rowsdt[0].", 'TR', '', '') QtyExists From Dual ";
		//$Qry_QtyAvailable[$i] = " Select QtyExistsWSorder_Temp('".$p_item_code[$i]."', '".$fromwarehousedt[$i]."', '".$transfer_date[$i]."', 0, 'TR', '', '', 0) QtyExists From Dual ";
		
		//echo $Qry_QtyAvailable[$i]."<br>";
		
		$resultq = selectData($connection, $Qry_QtyAvailable[$i]);
		$min_available_qty[$i] = $resultq[0];

	
$querymodule=" Select ifNull(Module_NegativeQuantity,0) As Module_NegativeQuantity From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}		

$querylog="SELECT ifNull(Login_negativeQty,0) As Login_negativeQty 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);
	}
	//echo  $min_available_qty[$i] . - "".$resultTemp[0];

	$txtAvailableQty[$i] = $min_available_qty[$i]  - $resultTemp[0];
	
		$errorquantity=0;
		$PostNotAllowed='False';
		
		/*echo "<br>". $txtAvailableQty[$i];
		echo "<br>". $rowsdt[6];
		echo  "<br>".$Module_NegativeQuantity;
		echo  "<br>".$Login_negativeQty;*/
		if (($txtAvailableQty[$i]	< $rowsdt[6] ) and (($Module_NegativeQuantity==0) or ($Login_negativeQty==0)) )
			{
				$PostNotAllowed='True';
				$errorquantity=1;
			}
				
	}
	

	$data = substr($transfer_date[$i], 6, 4) . substr($transfer_date[$i], 3, 2) . substr($transfer_date[$i], 0, 2);
    //echo $data;
	$transfer_date1 = substr($data, 0, 4) ."-". substr($data, 4, 2) ."-".substr($data, 6, 2)." ".strftime("%H").":".strftime("%M").":".strftime("%S");
	
//echo $transfer_date1;
	$qry="select item_pack from items where item_code = '".$p_item_code[$i]."'";
	$resultlog=mysql_query($qry,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($resultlog)){
			extract($rows);
		}
	


			//echo"<tr height='20px' id='prqstdt$i' onclick=\"returncolor(this,'SelectedRec','SelectedRecColor','$row[0]')\" style='background-color:$bgcolor'>";
			echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";
		
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
			
		
			
			
			echo "	<td align='center' valign='center'>";
			if ($rowsdt[12]!=0)
					if ($module_serialno==1)
						echo"<span class='style15'><img  src='img/button_addserial.png' onMouseOver=\"style.cursor='hand'\" onclick=\"AddSerialNo(".htmlentities($rowsdt[0]).",'".htmlentities($rowsdt[3])."','".htmlentities($rowsdt[4])."','".htmlentities($rowsdt[5])."')\" title='Add Serial Nos' $PreviewButtons ></span></td>";
					else
						echo"</td>";
					
							
						
						
			echo"<td  align=center onclick=\"deletetrdt('".$transferid[$i]."','$rowsdt[0]','".$itemcodepacked[$i]."','".$itemcode[$i]."','$filepath'); return false;\"><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' ></td>";
		
				
			if ($Module_TransferWithOneWh==1)
				echo"<input type='hidden' class='roundedtext_amortization_medium'   style='width:115px'  name='fromwarehousedt[$i]' id='fromwarehousedt[$i]' value='".$fromwarehousedt[$i]."' readonly >";
			else {
				echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:115px'  name='fromwarehousedt[$i]' id='fromwarehousedt[$i]' value='".$fromwarehousedt[$i]."' onchange=\"setwarehousecode(this.value,'fromwarehousedt[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
				echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('fromwarehouse','fromwarehousedt[$i]','800','500') \" />
				</td>";
				}
		
			if ($Module_TransferWithOneWh==1)
			echo"<input type='hidden' class='roundedtext_amortization_medium'   style='width:115px'  name='towarehousedt[$i]' id='towarehousedt[$i]' value='".$towarehousedt[$i]."' readonly  >";
			else
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:115px'  name='towarehousedt[$i]' id='towarehousedt[$i]' value='".$towarehousedt[$i]."' onchange=\"setwarehousecode(this.value,'towarehousedt[$i]','imgwarehousebtn1[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn1[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('towarehouse','towarehousedt[$i]','800','500') \" />
			</td>";
			
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   name='p_item_code[$i]' id='p_item_code[$i]' value='".$p_item_code[$i]."'   $KeyDown   class='roundedtext_amortization_small'   onkeyup=\"AutoCompleteData(event,this.id,'p_item_code[$i]','p_item_description[$i]','items');\" onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1);SetModRecord('ModRec_G1','$i');";
			if ($module_chargesInTransfer == 1)
				echo "getCostCharges('$i');";
			echo "\"  style='width:120px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','','800','500','".htmlentities($fromwarehouse[$i])."','$TransType','$i')\">
					</td>";

		
			echo"<td align='center' valign='center'><span class='style4'><input type='text'      name='p_item_description[$i]' id='p_item_description[$i]' value='".$p_item_description[$i]."'  class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2);SetModRecord('ModRec_G1','$i')\" style='width:240px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType','$i')\">	
			";
			
			echo"</td>";
	if($Module_Heatno==1)		
		echo"  	<td align='center' valign='center'>
					<input type='text' name='transferdt_heatno[$i]' id='transferdt_heatno[$i]' value='".$transferdt_heatno[$i]."'  maxlength='20' class='".$ClassE."' style='font-size:12px; width:95px; height:20px;' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','warehouse','warehouse_code',this.value,'lstWarehouseCode[$i]');\" onkeyup=\"AutoCompleteData(event,this.id,'warehousecode[$i]','warehousename[$i]','warehouse');\" ".$KeyDown."   />
					<label><span><img src='img/openlist.png' title='Select HeatNo' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistHeatNo($i);' style='vertical-align:bottom;'/></span></label>
				</td>";
		else 	echo"<input type='hidden' name='transferdt_heatno[$i]'  id='transferdt_heatno[$i]'  value='' >";
	 if($showBatch == 1){
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_packagingno[$i]'  id='p_transferdt_packagingno[$i]'  value='".$p_transferdt_packagingno[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"  onkeyup=\"setQty('$i');\"  style='width:70px;background-image:transparent;text-align:right'  > </td>";
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_nbrunit[$i]'  id='p_transferdt_nbrunit[$i]'  value='".$p_transferdt_nbrunit[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"  onkeyup=\"setQty('$i');\"  style='width:70px;background-image:transparent;text-align:right'  > </td>";
	 } else {
		echo"<input type='hidden' name='p_transferdt_packagingno[$i]'  id='p_transferdt_packagingno[$i]'  value='' >";
		echo"<input type='hidden' name='p_transferdt_nbrunit[$i]'  id='p_transferdt_nbrunit[$i]'  value='' >";
	}		
						
		echo"<td align='center' valign='center' ";
		if ($PostNotAllowed=='True') 
				echo " bgcolor='red' ";
				echo "><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='p_item_quantity[$i]' id='p_item_quantity[$i]' value='".$p_item_quantity[$i]."' style='width:75px'  onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\" > </span></td>";
	

echo"<td align='center' valign='center' ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='Item_UnitSalesDesc[$i]' id='Item_UnitSalesDesc[$i]' value='".$Item_UnitSalesDesc[$i]."' style='width:75px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	
	echo"<td align='center' valign='center'><input type='text' name='txtAvailableQty[$i]' readonly id='txtAvailableQty[$i]' value='".$txtAvailableQty[$i]."' readonly style='border-width:0px' size=4></td>";

	if ($Module_DoubleUnit==1) {
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_Unit2Qty[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\"   onkeyup=\"changeQty2(this.value,'$i');\" style='width:68px'  id='Item_Unit2Qty[$i]'  value='".$Item_Unit2Qty[$i]."'  size=4> </td>";
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_UnitPurchaseDesc[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:68px'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> </td>";
		}
		else {
		echo"<input type='hidden' id='Item_Unit2Qty[$i]'  name='Item_Unit2Qty[$i]'  onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$Item_Unit2Qty[$i]."'  size=4>";
		echo"<input type='hidden' name='Item_UnitPurchaseDesc[$i]'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> ";
		}

		echo"	  <input type='hidden' name='p_item_quantity1[$i]'  id='p_item_quantity1[$i]' value='".$p_item_quantity1[$i]."'  size=4>";
		echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";
				
				$amount = '';
				$amount = $rowsdt[6] * $rowsdt[7];
				

				$totalamountdt = $totalamountdt + $amount;
				
				echo '<script type="text/javascript" language="javascript">';
				echo ' document.transfer.totalamount.value =  '.$totalamountdt.'';
				echo '</script>';
				

			if ($Module_TransferPrice==1)	{
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_item_sellingprice1[$i]'    onchange=\"calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i);SetModRecord('ModRec_G1','$i');\"   style='width:70px;background-image:transparent;text-align:right'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4> </td>";
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='amount[$i]'  readonly  onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)    style='width:70px;background-image:transparent;text-align:right'  id='amount[$i]'  value='".$amount."'  size=4> </td>";
			}
		else {
				echo"<input type='hidden' name='p_item_sellingprice1[$i]'    id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4>";
				echo"<input type='hidden' name='amount[$i]'  id='amount[$i]'  value='".$amount."'  size=4>";
			}
			if ($module_chargesInTransfer == 1){
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_costamount[$i]' id='p_costamount[$i]'  value='".$p_costamount."' style='width:90px;text-align:right'   > </td>";	
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_chargeamount[$i]' id='p_chargeamount[$i]'  value='".$p_chargeamount."'  style='width:90px;background-image:transparent;text-align:right'  readonly > </td>";

			} else echo "<input type='hidden' name='p_costamount[$i]' id='p_costamount[$i]'  value='".$p_costamount."'>
					<input type='hidden' name='p_chargeamount[$i]' id='p_chargeamount[$i]'  value='".$p_chargeamount."'>";	
			 if($showBatch == 1){
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_batchno[$i]'  id='p_transferdt_batchno[$i]'  value='".$p_transferdt_batchno[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"   style='width:80px;background-image:transparent;text-align:right'   size=4> 
					<label><span><img src='img/openlist.png' title='Select Batch No' id='lstBatchNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistBatchNo(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";
			 } else {
				echo"<input type='hidden' name='p_transferdt_batchno[$i]'  id='p_transferdt_batchno[$i]'  value='' >";
				}
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   name='p_transferdt_remark[$i]' id='p_transferdt_remark[$i]' value='".$p_transferdt_remark[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:190px'> </span></td>";
			
			echo"<td align='center' valign='center'><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"submitTransDt('$transferdt_id[$i]','$transferid[$i]','$i','e','$PurchaseTTC','$Module_ZeroQuantity','$filepath',$ModuleProject, $ModuleCostCenter,$Module_RestrictProjCost,$Module_RestrictCost)\"></td>";
			echo"<input type='hidden'  name='transferdt_id[$i]' id='transferdt_id[$i]' value='".$transferdt_id[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
}
	
		//$errorquantity=0;
		
			echo"<input type='hidden' name='errorquantity' value='$errorquantity'>";
			echo"<input type='hidden' name='totalamountdt' id='totalamountdt' value='$totalamountdt'>";	
			
			
			
			
			

			
		if (empty($warehousecode[$i])) { //echo $_SESSION['prqstdefaultwarehouse'];
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeytransfer(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\');"';

			echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";
			echo"<td></td>";
			echo"<td align='center' valign='center'><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearprequestdt('$i','$PurchaseTTC','$Module_DoubleUnit')\"></td>";
						
		
			if ($Module_TransferWithOneWh==1)
				echo"<input type='hidden'  class='roundedtext_amortization_medium'   style='width:115px'  name='fromwarehousedt[$i]' id='fromwarehousedt[$i]' value='".$fromwarehousedt[$i]."' readonly >";
			else {
				echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:115px'  name='fromwarehousedt[$i]' id='fromwarehousedt[$i]' value='".$fromwarehousedt[$i]."' onchange=\"setwarehousecode(this.value,'fromwarehouse[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
				echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('fromwarehouse','fromwarehousedt[$i]','800','500') \" />
				</td>";
				}
		
			if ($Module_TransferWithOneWh==1)
			echo"<input type='hidden'  class='roundedtext_amortization_medium'   style='width:115px'  name='towarehousedt[$i]' id='towarehousedt[$i]' value='".$towarehousedt[$i]."' readonly  >";
			else
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:115px'  name='towarehousedt[$i]' id='towarehousedt[$i]' value='".$towarehousedt[$i]."' onchange=\"setwarehousecode(this.value,'towarehousedt[$i]','imgwarehousebtn1[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn1[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('towarehouse','towarehousedt[$i]','800','500') \" />
			</td>";
	
	
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   name='p_item_code[$i]' id='p_item_code[$i]' value='".$p_item_code[$i]."'   $KeyDown   class='roundedtext_amortization_small'    
				onkeyup=\"AutoCompleteData(event,this.id,'p_item_code[$i]','p_item_description[$i]','items');\" onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1);SetModRecord('ModRec_G1','$i');";
			if ($module_chargesInTransfer == 1)
				echo "getCostCharges('$i');";
			echo "\"   onblur=\"FillData('fromwarehousedt[$i]','towarehousedt[$i]')\"   style='width:120px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','','800','500','".htmlentities($fromwarehouse[$i])."','$TransType','$i');FillData('fromwarehousedt[$i]','towarehousedt[$i]')\">
				</td>";

			echo"<td align='center' valign='center'><span class='style4'><input type='text'      name='p_item_description[$i]' id='p_item_description[$i]' value='".$p_item_description[$i]."'  class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2);SetModRecord('ModRec_G1','$i')\" style='width:240px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','p_item_code[$i]','p_item_description[$i]','Item_Unit[$i]','Item_UnitSalesDesc[$i]','Item_UnitPurchaseDesc[$i]','i_unitcoef[$i]','800','500','".htmlentities($fromwarehouse[$i])."','$TransType','$i')\">	
			";
	echo"</td>";

if($Module_Heatno==1)		
	echo"  	<td align='center' valign='center'>
				<input type='text' name='transferdt_heatno[$i]' id='transferdt_heatno[$i]' value='".$transferdt_heatno[$i]."'  maxlength='20' class='".$ClassE."' style='font-size:12px; width:95px; height:20px;' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','warehouse','warehouse_code',this.value,'lstWarehouseCode[$i]');\" onkeyup=\"AutoCompleteData(event,this.id,'warehousecode[$i]','warehousename[$i]','warehouse');\" ".$KeyDown."   />
				<label><span><img src='img/openlist.png' title='Select HeatNo' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistHeatNo($i);' style='vertical-align:bottom;'/></span></label>
			</td>";
else 	echo"<input type='hidden' name='transferdt_heatno[$i]'  id='transferdt_heatno[$i]'  value='' >";
		
	if($showBatch == 1){
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_packagingno[$i]'  id='p_transferdt_packagingno[$i]'  value='".$p_transfer_packagingno[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\"   style='width:70px;background-image:transparent;text-align:right'   size=4> </td>";
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_nbrunit[$i]'  id='p_transferdt_nbrunit[$i]'  value='".$p_transfer_nbrunit[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\" onkeyup=\"setQty('$i');\"   style='width:70px;background-image:transparent;text-align:right'   size=4> </td>";
		
	 } else {
		echo"<input type='hidden' name='p_transferdt_packagingno[$i]'  id='p_transferdt_packagingno[$i]'  value='' >";
		echo"<input type='hidden' name='p_transferdt_nbrunit[$i]'  id='p_transferdt_nbrunit[$i]'  value='' >";
	}				
		echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='p_item_quantity[$i]' id='p_item_quantity[$i]' value='".$p_item_quantity[$i]."' style='width:75px'  onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\" > </span></td>";
	

echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='Item_UnitSalesDesc[$i]' id='Item_UnitSalesDesc[$i]' value='".$Item_UnitSalesDesc[$i]."' style='width:75px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	
	echo"<td align='center' valign='center'><input type='text' name='txtAvailableQty[$i]' readonly id='txtAvailableQty[$i]' value='".$txtAvailableQty[$i]."'  size=4></td>";

	if ($Module_DoubleUnit==1) {
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_Unit2Qty[$i]'    onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)\"   onkeyup=\"changeQty2(this.value,'$i');\" style='width:68px'  id='Item_Unit2Qty[$i]'  value='".$Item_Unit2Qty[$i]."'  size=4> </td>";
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='Item_UnitPurchaseDesc[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:68px'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> </td>";
		}
		else {
		echo"<input type='hidden' id='Item_Unit2Qty[$i]'  name='Item_Unit2Qty[$i]'  onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$Item_Unit2Qty[$i]."'  size=4>";
		echo"<input type='hidden' name='Item_UnitPurchaseDesc[$i]'  id='Item_UnitPurchaseDesc[$i]'  value='".$Item_UnitPurchaseDesc[$i]."'  size=4> ";
		
		}

		echo"	  <input type='hidden' name='p_item_quantity1[$i]'  id='p_item_quantity1[$i]' value='".$p_item_quantity1[$i]."'  size=4>";
		echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";
				
				$amount = '';
				$amount = $rowsdt[6] * $rowsdt[7];
				

				//$totalamount = $totalamount + $amount;
				
			if ($Module_TransferPrice==1)	{			
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_item_sellingprice1[$i]'    onchange=calcTotal('p_item_sellingprice1[$i]','p_item_quantity[$i]',$i)   style='width:70px;text-align:right'  id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'  size=4> </td>";	
				echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='amount[$i]'   readonly    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)    style='width:70px;background-image:transparent;text-align:right' id='amount[$i]'  value='".$amount."'  size=4> </td>";
			}
			else {
				echo"<input type='hidden' name='p_item_sellingprice1[$i]'    id='p_item_sellingprice1[$i]'  value='".$p_item_sellingprice1[$i]."'>";
				echo"<input type='hidden' name='amount[$i]'  id='amount[$i]'  value='".$amount."'>";
			}
	if ($module_chargesInTransfer == 1){
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_costamount[$i]' id='p_costamount[$i]'  value='' style='width:90px;text-align:right'   > </td>";	
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_chargeamount[$i]' id='p_chargeamount[$i]'  value=''  style='width:90px;background-image:transparent;text-align:right'  readonly > </td>";

	} else echo "<input type='hidden' name='p_costamount[$i]' id='p_costamount[$i]'  value=''>
			<input type='hidden' name='p_chargeamount[$i]' id='p_chargeamount[$i]'  value=''>";	
			
	if($showBatch == 1){
		echo"<td align='center' valign='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='p_transferdt_batchno[$i]'  id='p_transferdt_batchno[$i]'  value='".$p_transfer_batchno[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"   style='width:80px;background-image:transparent;text-align:right'   size=4>
			<label><span><img src='img/openlist.png' title='Select Batch No' id='lstBatchNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistBatchNo(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";
	} else {
		echo"<input type='hidden' name='p_transferdt_batchno[$i]'  id='p_transferdt_batchno[$i]'  value='' >";
	}
			
			echo"<td align='center' valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   name='p_transferdt_remark[$i]' id='p_transferdt_remark[$i]' value='".$p_transferdt_remark[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:190px;'> </span></td>";
			
			echo"<td align='center' valign='center'><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"submitTransDt('$transferdt_id[$i]','$transferid[$i]','$i','i','$PurchaseTTC','$FIPurchaseCategory','$filepath',$ModuleProject, $ModuleCostCenter,$Module_RestrictProjCost,$Module_RestrictCost)\"></td>";
			echo"<input type='hidden'  name='transferdt_id[$i]' id='transferdt_id[$i]' value='".$transferdt_id[$i]."' >";
			echo"</tr>";
			
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div>";
	
	showDataGridFooter($filepath,$form,$transfer_id,'datagrid',$dftorderby,$action,$orderby,$morelines,$startrange,$perpage,$totalrows,$direction,$perpage_label,$page_label,$record_to_view);
	
	echo"</div>";

}



function ShowAdjustmentRequestDtGrid($connection,$form,$txtAdjId,$orderby,$startrange,$perpage,$option,$direction,$base1,$base2,$DecimalBase,$Module_DoubleUnit,$Module_ProjectDt,$Module_CostCenterDt,$Module_Unit1Method,$Module_Pack, $Module_Heatno, $Module_IsInvoice){

	//Read From AdjustmentSetup Table
	$queryAdjustSetup="Select ifNull(ShowCostCentLayout,0) As ShowCostCentLayout From AdjustmentSetup ";
	$resultAdjustSetup=mysql_query($queryAdjustSetup,$connection) or die(mysql_error());
	while($rowAdjustSetup=mysql_fetch_array($resultAdjustSetup)){
		extract($rowAdjustSetup);
	}
	
	$queryCostSetup="Select ifNull(FI_ShowCostPrice,0) As FI_ShowCostPrice From ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."') ";
	$resultCostSetup=mysql_query($queryCostSetup,$connection) or die(mysql_error());
	while($rowCostSetup=mysql_fetch_array($resultCostSetup)){
		extract($rowCostSetup);
	} 
	
	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	

	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
		
			
								
	$columnsarray = array("txtItemCodePacked"
						,"txtItemCode"
						,"txtItemDesc"
						,"lstWarehouse"
						,"txtAdjDtQty"
						);

	if ($Module_DoubleUnit==1) {
				$columnsarray[] = 'txtItemUnit1';
				$columnsarray[] = 'txtAdjDtQty2';
				$columnsarray[] = 'txtItemUnit2';
	}
	if($FI_ShowCostPrice == 1)				
		$columnsarray[] = "txtcostpriceDt";
	if($Module_Heatno == 1) $columnsarray[] = 'txtAdjDtHeatNo';		
	if ($Module_ProjectDt == 1)	$columnsarray[] = "txtProjectCodeDt";
	
	if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
		$columnsarray[] = "txtCostCentCodeDt";
			
		$columnsarray[] = "txtAdjDtExpireDate";
	
	if($Module_IsInvoice == 1) $columnsarray[] = "InvDEBITaccount";
	$columnslist = implode(',', $columnsarray);
	
	

	
echo"<input type='hidden' name='headercurrency_code' id='headercurrency_code' value='$headercurrency_code'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
		$query = " Select AdjustmentRequestDt.AdjustmentRequestDt_ID, AdjustmentRequestDt.Item_CodePacked, AdjustmentRequestDt.Item_code, Item_Description, AdjustmentRequestDt.Project_code, AdjustmentRequestDt.CostCent_Code, AdjustmentRequestDt.Warehouse_Code, ".
				 " AdjustmentRequestDt_Quantity ,AdjustmentRequestDt.Item_Unit2Qty, Item_UnitPurchaseDesc, Item_UnitSalesDesc ".
				 " ,Date_Format(AdjustmentRequestDt.AdjustmentRequestDt_ExpireDate,'%d/%m/%Y') As ExpireDate , AdjustmentRequestDt.AdjustmentRequestDt_BatchNo ".
				 ", Round(AdjustmentRequestDt_Price, ".$DecimalBase."), AdjustmentRequestDt_PriceBase1, AdjustmentRequestDt_PriceBase2, ".
				 " Round((ifNull(AdjustmentRequestDt_Quantity,0)*ifNull(AdjustmentRequestDt_Price,0)), ".$DecimalBase.") As TotalAmount, AdjustmentRequestDt_heatno, InvDEBITaccount ".
				 " From Temp_AdjustmentRequestDt As AdjustmentRequestDt Left Join Items on AdjustmentRequestDt.Item_code = Items.Item_code ".
				 " Where AdjustmentRequestDt.AdjustmentRequest_ID = '".$txtAdjId."'".
				 " Group By  AdjustmentRequestDt.AdjustmentRequestDt_ID ".
				 " Order By AdjustmentRequestDt.AdjustmentRequestDt_ID Asc ";
						
						
//echo $query;	
$result=mysql_query($query,$connection)  or die(mysql_error());
$totalrows = mysql_num_rows($result);

$query = $query." limit ".$startrange.",".$perpage;
//echo $query;
$result=mysql_query($query,$connection);

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='prequestdtdiv' style='width:1200px;height:300px'>";
echo"<table border='0' align='left'   class='grid_data'  style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0;width:1200px;' cellpadding='0' cellspacing='1'>";
echo"	<col width=30>";
if ($Module_Pack == 1)
	echo" <col width=120>";

    echo" <col width=150>  
		  <col width=200>	
		  <col width=110>
		  <col width=80>	
		  <col width=80> ";
  
if ($Module_DoubleUnit==1)	{		  
	echo"<col width=80><col width=85>";
}

if($FI_ShowCostPrice == 1){
    echo"<col width=80><col width=85>";
}
if($Module_Heatno == 1) echo"<col width=120>";				  
if ($Module_ProjectDt == 1)	 echo"<col width=120>";
if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1) echo"<col width=120>";
	echo"<col width=75>";
if($Module_IsInvoice == 1)	  echo"<col width=120>";		
	echo "<col width=30>";
		  

	echo"<tr height='25px'>";
	echo"  <th bgcolor='#F7F7F7' align='left'>&nbsp;</span></th>";
if ($Module_Pack == 1)
	echo"  <th bgcolor='#F7F7F7' align='left'>Item Packed</span></th>";  
	echo"  <th bgcolor='#F7F7F7' align='left'>Item </span></th>";  
	echo"  <th bgcolor='#F7F7F7' align='left'>Description</span></th>";
	echo"  <th bgcolor='#F7F7F7' align='center'>WH.</span></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'>Qty</span></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'>Unit1</span></th>";
	//echo"  <td bgcolor='#F7F7F7' align='left'>Real Qty</span></td>";
if ($FI_ShowCostPrice == 1) {  
	echo"  <th width='85px;' align='center'><span>Cost Price</span></th>";
	echo"  <th width='105px;' align='center'><span>Total</span></th>";
}

if ($Module_DoubleUnit==1) {
	echo"  <th bgcolor='#F7F7F7' align='left'>Qty2</span></th>";
	echo"  <th bgcolor='#F7F7F7' align='left'>Unit2</span></th>";
}

if($Module_Heatno == 1) echo"  <th bgcolor='#F7F7F7' align='left'>Heat No.</span></th>";

if ($Module_ProjectDt == 1)	
	echo"  <th bgcolor='#F7F7F7' align='center'>Project</span></th>";

if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
	echo"  <th bgcolor='#F7F7F7' align='center'>Costcenter</span></th>";

	echo"  <th bgcolor='#F7F7F7' align='left'>Expire Date</span></th>";	  
if ($Module_IsInvoice == 1)	
	echo"  <th bgcolor='#F7F7F7' align='left'>Ledger Number</span></th>";	  
	echo"  <th bgcolor='#F7F7F7' align='left'></th>";	  

	echo"</tr>";



	$i=0;
	$j=1;
	
	echo"
		
		 <input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>		 
		 ";

		 
while($row=mysql_fetch_row($result)){
		
		
	if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
		
		$KeyDown   = 'onkeydown="return dokeytransferrequest(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\')"';



		
			   
	$txtAdjDtId[$i] = $row[0];
	$lstItemType[$i] = 'All';
	$txtItemCodePacked[$i] = $row[1];
	$txtItemCode[$i] = $row[2];
	$txtItemDesc[$i] = $row[3];
	$txtProjectCodeDt[$i] = $row[4];
	$txtCostCentCodeDt[$i] = $row[5];
	$lstWarehouse[$i] = $row[6];
	$txtAdjDtQty[$i] = $row[7];
	$txtAdjDtQty2[$i] = $row[8];
	$txtItemUnit1[$i] = $row[9];
	$txtItemUnit2[$i] = $row[10];
	
	$txtAdjDtExpireDate[$i] = $row[11];
	$txtAdjDtBatchNo[$i] = $row[12];

	$txtcostpriceDt[$i] = $row[13];
	$txtAdjDtHeatNo[$i] = $row[17];
	$txtAdjDtTotal[$i] = $txtcostpriceDt[$i] * $txtAdjDtQty[$i];
	$txtAdjDtInvDebitAcc[$i] = $row[18];
	//echo"<tr height='20px' id='prqstdt$i' onclick=\"returncolor(this,'SelectedRec','SelectedRecColor','$row[0]')\" style='background-color:$bgcolor'>";
	echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";

		
	$recno = $i+1;
	$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
	
	echo"<td  align=center onclick=\"deletetrequestsdt('".$txtAdjId."','".$txtAdjDtId[0]."','".$txtItemCodePacked[$i]."','".$txtItemCode[$i]."','$filepath'); return false;\"><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' ></td>";

   //if ($Module_Pack == 1)
//		echo"<td ><span class='style4'><input type='text'   class='roundedtext_amortization_medium' readonly   $KeyDown  name='txtItemCodePacked[$i]' id='txtItemCodePacked[$i]' value='".$txtItemCodePacked[$i]."' style='width:100px'> </span></td>";
//	else
//		echo"<input type='hidden'  name='txtItemCodePacked[$i]' id='txtItemCodePacked[$i]' value='".$txtItemCodePacked[$i]."'>";
	
   if ($Module_Pack == 1)
   echo"<td ><span class='style4'><input type='text'   name='txtItemCodePacked[$i]' id='txtItemCodePacked[$i]' value='".$txtItemCodePacked[$i]."'   $KeyDown   class='roundedtext_amortization_small'   readonly  style='width:100px'></span></td>";

	echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'     name='txtItemCode[$i]' id='txtItemCode[$i]' value='".$txtItemCode[$i]."' onchange=\"setitemcode(this.value,'txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1,'$i');SetModRecord('ModRec_G1','$i')\"  onblur=\"FillData('txtProjectCodeDt[$i]','txtCostCentCodeDt[$i]')\" style='width:120px'></span>
		<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','','','800','500','".htmlentities($txtProjectCodeDt[$i])."','$TransType');FillData('txtProjectCodeDt[$i]','txtCostCentCodeDt[$i]')\">
			</td>";

	echo"<td align=center><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2, '$i');SetModRecord('ModRec_G1','$i')\"     name='txtItemDesc[$i]' id='txtItemDesc[$i]' value='".$txtItemDesc[$i]."' style='width:190px'> </span>
	<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','800','500','".htmlentities($txtProjectCodeDt[$i])."','$TransType')\">	";
		
	echo"</td>";
			
	
	echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='lstWarehouse[$i]' id='lstWarehouse[$i]' value='".$lstWarehouse[$i]."' onchange=\"setwarehousecode(this.value,'lstWarehouse[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
		echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('lstWarehouse','lstWarehouse[$i]','800','500') \" />
		</td>";					
			
	echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='txtAdjDtQty[$i]' id='txtAdjDtQty[$i]' value='".$txtAdjDtQty[$i]."' style='width:70px'  ";
	if($FI_ShowCostPrice == 1) echo " onKeyup=\"CalcAdjDtTotal(1,$DecimalBase,$i);\" ";
	echo " onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');\" > </span></td>";


	echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='txtItemUnit1[$i]' id='txtItemUnit1[$i]' value='".$txtItemUnit1[$i]."' style='width:70px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	if ($FI_ShowCostPrice == 1) {  
		echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtcostpriceDt[$i]' onKeyup=\"CalcAdjDtTotal(1,$DecimalBase,$i);\"      style='width:70px'  id='txtcostpriceDt[$i]'  value='".$txtcostpriceDt[$i]."'  size=4> </td>";
		echo"<td align=center> <input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtTotal[$i]'      style='width:70px'  id='txtAdjDtTotal[$i]'  value='".$txtAdjDtTotal[$i]."'  size=4 readonly> </td>";
	}	
		
		
	if ($Module_DoubleUnit==1) {
	echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtQty2[$i]'    ";
	
	echo " onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);\"   style='width:70px'  id='txtAdjDtQty2[$i]'  value='".$txtAdjDtQty2[$i]."'  size=4> </td>";
	echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtItemUnit2[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:70px'  id='txtItemUnit2[$i]'  value='".$txtItemUnit2[$i]."'  size=4> </td>";
	}
	else {
	echo"<input type='hidden' name='txtAdjDtQty2[$i]'  "; 
	
	echo " onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$txtAdjDtQty2[$i]."'  size=4>";
	}

	echo"	  <input type='hidden' name='lstItemType[$i]'  id='lstItemType[$i]' value='".$lstItemType[$i]."'  size=4>";
	echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";

			if ($rowsdt[6]=='')		$rowsdt[6] = 0;
			if ($rowsdt[7]=='') 	$rowsdt[7] = 0;
			
				
			$amount[$i] = $rowsdt[6] * $rowsdt[7];
			//$totalamount = $totalamount + $amount;
				
			

			
	echo"<input type='hidden' name='txtAdjDtBatchNo[$i]'   style='width:70px'  id='txtAdjDtBatchNo[$i]'  value='".$txtAdjDtBatchNo[$i]."'  size=4>";
			
	if($Module_Heatno == 1)	
		echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtHeatNo[$i]'  style='width:90px'  id='txtAdjDtHeatNo[$i]'  value='".$txtAdjDtHeatNo[$i]."'  > 
			<label><span><img src='img/openlist.png' title='Select HeatNo' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistHeatNo($i);' style='vertical-align:bottom;'/></span></label></td>";
	else 
		echo"<input type='hidden'   name='txtAdjDtHeatNo[$i]' id='txtAdjDtHeatNo[$i]' value='".$txtAdjDtHeatNo[$i]."'>";
	
	if ($Module_ProjectDt == 1)	
		echo"<td align=center><span class='style4'><input type='text'   $KeyDown  class='roundedtext_amortization_medium'    style='width:90px'  name='txtProjectCodeDt[$i]' id='txtProjectCodeDt[$i]' value='".$txtProjectCodeDt[$i]."'   onchange=\"setprojectcode(this.value,'txtProjectCodeDt[$i]','imgprojectbtn[$i]');SetModRecord('ModRec_G1','$i');\" > </span>
		<img src='img/scroll-down-1.png' title=' Select Project ' id='imgprojectbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"SetModRecord('ModRec_G1','$i');showlistProject('project','txtProjectCodeDt[$i]','800','500',3); \" />			
		</td>";
	else
		echo"<span class='style4'><input type='hidden'   name='txtProjectCodeDt[$i]' id='txtProjectCodeDt[$i]' value='".$txtProjectCodeDt[$i]."'> ";
	
	if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
		echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:90px'  name='txtCostCentCodeDt[$i]' id='txtCostCentCodeDt[$i]' value='".$txtCostCentCodeDt[$i]."'    onchange=\"setcostcentercode(this.value,'txtCostCentCodeDt[$i]','imgcostcenterbtn[$i]');SetModRecord('ModRec_G1','$i');\"  > 
			<img src='img/scroll-down-1.png' title=' Select Costcenter ' id='imgcostcenterbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"SetModRecord('ModRec_G1','$i');showlistCostcenter('costcenter','txtCostCentCodeDt[$i]','800','500',3) \" />
			</span></td>";
	else
		echo"<input type='hidden'  name='txtCostCentCodeDt[$i]' id='txtCostCentCodeDt[$i]' value='".$txtCostCentCodeDt[$i]."'>"; 				
	
	
	echo"<td align=center><span class='style4'><input type='text'   $KeyDown      class='".$ClassI." date'  style='width:65px;border-width:0px' name='txtAdjDtExpireDate[$i]' id='txtAdjDtExpireDate[$i]' value='".$txtAdjDtExpireDate[$i]."' onclick=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	
	if ($Module_IsInvoice == 1)	
		echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   maxlength='10'  style='width:90px'  name='txtAdjDtInvDebitAcc[$i]' id='InvDEBITaccount[$i]' value='".$txtAdjDtInvDebitAcc[$i]."'    onchange=\"SetModRecord('ModRec_G1','$i');\" > 
			<label><img src='img/btnopen.jpg' title=' Select Ledger ' id='lstLedgerCodeC' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistLedgers('3','$i'); \" /></label></td>";		
	else 
		echo" <input type='hidden' name='txtAdjDtInvDebitAcc[$i]' id='InvDEBITaccount[$i]' value=''>";		
	echo"<td align=center><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"submitAdjustReqDt('$txtAdjDtId[$i]','$txtAdjId','$i','e','$PurchaseTTC','$FIPurchaseCategory','$filepath')\"></td>";
	echo"<input type='hidden'  name='txtAdjDtId[$i]' id='txtAdjDtId[$i]' value='".$txtAdjDtId[$i]."' >";
	echo"</tr>";
			
			
			$i+=1;
		}
		
		if (empty($warehousecode[$i])) { //echo $_SESSION['prqstdefaultwarehouse'];
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeytransferrequest(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\');"';
		
			echo"<tr height='30px' id='CurRec$i' class='$bgcolor table-focus-g1'>";
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearprequestdt('$i','$PurchaseTTC','$Module_DoubleUnit')\"></td>";
			if ($Module_Pack == 1)
			echo"<td ><span class='style4'><input type='text'   name='txtItemCodePacked[$i]' id='txtItemCodePacked[$i]' value='".$txtItemCodePacked[$i]."'   $KeyDown   class='roundedtext_amortization_small'   readonly  style='width:100px'></span></td>";
		
			echo"<td align=center valign='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'     name='txtItemCode[$i]' id='txtItemCode[$i]' value='".$txtItemCode[$i]."' onchange=\"setitemcode(this.value,'txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','','trqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',1, '$i');SetModRecord('ModRec_G1','$i')\"  onblur=\"FillData('txtProjectCodeDt[$i]','txtCostCentCodeDt[$i]')\" style='width:120px'></span>
				<img src='img/scroll-down-1.png' width='20' height='20' id='trqstdtitemcodeimage[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage('itemcode','txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','','','800','500','".htmlentities($txtProjectCodeDt[$i])."','$TransType');FillData('txtProjectCodeDt[$i]','txtCostCentCodeDt[$i]')\">
					</td>";

			echo"<td align=center><span class='style4'><input type='text'   class='roundedtext_amortization_mediumlarge'    $KeyDown     onchange=\"setitemcode(this.value,'txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','','prqstdtitemcodeimage[$i]','trqstdtitemcodeimage1[$i]',2,'$i');SetModRecord('ModRec_G1','$i')\"     name='txtItemDesc[$i]' id='txtItemDesc[$i]' value='".$txtItemDesc[$i]."' style='width:190px'> </span>
			<img src='img/scroll-down-1.png' width='20' hidden height='20' id='trqstdtitemcodeimage1[$i]' onmouseover=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('itemcode','txtItemCode[$i]','txtItemDesc[$i]','Item_Unit[$i]','txtItemUnit1[$i]','txtItemUnit2[$i]','i_unitcoef[$i]','800','500','".htmlentities($txtProjectCodeDt[$i])."','$TransType')\">	";
				
			echo"</td>";
					
			$prei = $i-1;
		if ($lstWarehouse[$prei] !='')
			$lstWarehouse[$i] = $lstWarehouse[$prei];
		else
		if (empty($lstWarehouse[$i])) { 
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$lstWarehouse[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$lstWarehouse[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
			
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='lstWarehouse[$i]' id='lstWarehouse[$i]' value='".$lstWarehouse[$i]."' onchange=\"setwarehousecode(this.value,'lstWarehouse[$i]','imgwarehousebtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>";
				echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='imgwarehousebtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistWarehouse('lstWarehouse','lstWarehouse[$i]','800','500') \" />
				</td>";					
					
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='txtAdjDtQty[$i]' id='txtAdjDtQty[$i]' value='".$txtAdjDtQty[$i]."' style='width:70px'  ";
			if($FI_ShowCostPrice == 1) echo " onKeyup=\"CalcAdjDtTotal(1,$DecimalBase,$i);\" ";
			echo " onchange=\"changeqty2(1,'$Item_Unit','$Module_Unit1Method',$i);SetModRecord('ModRec_G1','$i');\" > </span></td>";
	

			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_small'   name='txtItemUnit1[$i]' id='txtItemUnit1[$i]' value='".$txtItemUnit1[$i]."' style='width:70px'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	
		if($FI_ShowCostPrice == 1){
			echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtcostpriceDt[$i]'    onKeyup=\"CalcAdjDtTotal(1,$DecimalBase,$i);\"     style='width:70px'  id='txtcostpriceDt[$i]'  value='".$txtcostpriceDt[$i]."'  size=4> </td>";
			echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtTotal[$i]'       style='width:70px'  id='txtAdjDtTotal[$i]'  value='".$txtAdjDtTotal[$i]."'  size=4 readonly> </td>";
		
		}else {
					echo" <input type='hidden' name='txtcostpriceDt' id='txtcostpriceDt[$i]' value='' >
						  <input type='hidden' name='txtAdjDtTotal' id='txtAdjDtTotal[$i]' value='' >";
				}
				
		if ($Module_DoubleUnit==1) {
		echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtQty2[$i]'   ";
				
		echo " onchange=\"changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i);\"   style='width:70px'  id='txtAdjDtQty2[$i]'  value='".$txtAdjDtQty2[$i]."'  size=4> </td>";
		echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtItemUnit2[$i]'    onchange=changeqty2(2,'$Item_Unit',$Module_Unit1Method,$i)   style='width:70px'  id='txtItemUnit2[$i]'  value='".$txtItemUnit2[$i]."'  size=4> </td>";
		}
		else {
		echo"<input type='hidden' name='txtAdjDtQty2[$i]'  ";
		
		echo " onchange=changeqty2(2,'$Item_Unit[$i]',$Module_Unit1Method,$i)  value='".$txtAdjDtQty2[$i]."'  size=4>";
		}
		
		echo"	  <input type='hidden' name='lstItemType[$i]'  id='lstItemType[$i]' value='".$lstItemType[$i]."'  size=4>";
		echo"	  <input type='hidden' name='Item_Unit[$i]' id='Item_Unit[$i]' value='".$Item_Unit[$i]."'  size=4>";

				if ($rowsdt[6]=='')		$rowsdt[6] = 0;
				if ($rowsdt[7]=='') 	$rowsdt[7] = 0;
				
					
				$amount[$i] = $rowsdt[6] * $rowsdt[7];
				//$totalamount = $totalamount + $amount;
				
			

			
				echo"<input type='hidden' name='txtAdjDtBatchNo[$i]'   style='width:70px'  id='txtAdjDtBatchNo[$i]'  value='".$txtAdjDtBatchNo[$i]."'  size=4>";
			
			
				
			
	if($Module_Heatno == 1)	
		echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAdjDtHeatNo[$i]'  style='width:90px'  id='txtAdjDtHeatNo[$i]'  value='".$txtAdjDtHeatNo[$i]."'  > 
			<label><span><img src='img/openlist.png' title='Select HeatNo' id='lstHeatNo[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistHeatNo($i);' style='vertical-align:bottom;'/></span></label></td>";
	else 
		echo"<input type='hidden'   name='txtAdjDtHeatNo[$i]' id='txtAdjDtHeatNo[$i]' value='".$txtAdjDtHeatNo[$i]."'>";
	
	if ($Module_ProjectDt == 1)	
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown  class='roundedtext_amortization_medium'    style='width:90px'  name='txtProjectCodeDt[$i]' id='txtProjectCodeDt[$i]' value='".$txtProjectCodeDt[$i]."'   onchange=\"setprojectcode(this.value,'txtProjectCodeDt[$i]','imgprojectbtn[$i]');SetModRecord('ModRec_G1','$i');\"  > </span>
			<img src='img/scroll-down-1.png' title=' Select Project ' id='imgprojectbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"SetModRecord('ModRec_G1','$i');showlistProject('project','txtProjectCodeDt[$i]','800','500',3); \" />			
			</td>";
	else
	echo"<input type='hidden'   name='txtProjectCodeDt[$i]' id='txtProjectCodeDt[$i]' value='".$txtProjectCodeDt[$i]."'> ";

		if ($Module_CostCenterDt == 1 && $ShowCostCentLayout == 1)
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:90px'  name='txtCostCentCodeDt[$i]' id='txtCostCentCodeDt[$i]' value='".$txtCostCentCodeDt[$i]."'    onchange=\"setcostcentercode(this.value,'txtCostCentCodeDt[$i]','imgcostcenterbtn[$i]');SetModRecord('ModRec_G1','$i');\" > 
			<img src='img/scroll-down-1.png' title=' Select Costcenter ' id='imgcostcenterbtn[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"SetModRecord('ModRec_G1','$i');showlistCostcenter('costcenter','txtCostCentCodeDt[$i]','800','500',3) \" />
			</span></td>";
		else
		echo"<input type='hidden' name='txtCostCentCodeDt[$i]' id='txtCostCentCodeDt[$i]' value='".$txtCostCentCodeDt[$i]."'>"; 				

	echo"<td align=center><span class='style4'><input type='text'   $KeyDown      class='".$ClassI." date'  style='width:65px;border-width:0px' name='txtAdjDtExpireDate[$i]' id='txtAdjDtExpireDate[$i]' value='".$txtAdjDtExpireDate[$i]."' onchange=\"SetModRecord('ModRec_G1','$i');\" > </span></td>";
	
	if ($Module_IsInvoice == 1)	
		echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   maxlength='10'  style='width:90px'  name='txtAdjDtInvDebitAcc[$i]' id='InvDEBITaccount[$i]' value='".$txtAdjDtInvDebitAcc[$i]."'    onchange=\"SetModRecord('ModRec_G1','$i');\" > 
			<label><img src='img/btnopen.jpg' title=' Select Ledger ' id='lstLedgerCodeC' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick=\"showlistLedgers('3','$i'); \" /></label></td>";		
	else 
		echo" <input type='hidden' name='txtAdjDtInvDebitAcc[$i]' id='InvDEBITaccount[$i]' value=''>";		
	echo"<td align=center><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPTransReqDt[$i]' title='Save' onclick=\"return submitAdjustReqDt('$txtAdjDtId[$i]','$txtAdjId','$i','i','$PurchaseTTC','$FIPurchaseCategory','$filepath');\"></td>";
	echo"<input type='hidden'  name='txtAdjDtId[$i]' id='txtAdjDtId[$i]' value='".$txtAdjDtId[$i]."' >";
	echo"</tr>";
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div>";
	

	


}

function ShowSalesJvDtGrid($connection,$form,$salesjv,$txtClientCode,$Login_ModifySellingPrice,$Login_ModifyDiscount,$DecimalBase,$Module_RestrictProjCost,$Module_RestrictCost,$FI_SalesCheckSalesman,$Module_ProjectDt,$Module_CostCenterDt, $salesjv_paymentmode,$module_shipmentclosing){

	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	
	$txtSalesJVId = $salesjv;
	
	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
	// User Has No Access To Modify The Price / Discount	
	$ModeModifySellPrice = '';
	$DiscountMode = '';
	
	if ($Login_ModifySellingPrice == 0) $ModeModifySellPrice = ' readonly ';
	if ($Login_ModifyDiscount == 0)	$DiscountMode = ' readonly ';


	if (empty($txtDtManualNo)) $txtDtManualNo = $PManualNo;

	if (empty($txtDtCurr))
	{
		if ($sub_result[0] != '')	$txtDtCurr = $sub_result[0];
		else		$txtDtCurr = $base1;
	}	

	if ($PClientCode != '') {
		$sub_query1 = " Select ifNull(Client_VAT,0) From Clients ".
					  " Where Ledger_Number = '".$PClientCode."' ";
		$sub_result1 = selectData($connection, $sub_query1);	
		$txtDtVat = $sub_result1[0];
		$chkDtVat = $sub_result1[0];
	}	


	
	$columnsarray = array("txtLedgerNo"
						,"txtLedgerName"
						,"txtDescription1"
						);

	$columnsarray[] = 'txtDescription2';
			
	$columnsarray[] = 'txtDtManualNo';
			
	$columnsarray[] = 'txtDtQty';
	$columnsarray[] = 'txtDtPrice';
	if ($salesjv_paymentmode==1)
    $columnsarray[] = 'txtDtCost';

	$columnsarray[] = 'txtDtDiscPer';
	$columnsarray[] = 'txtDtTotal';
	$columnsarray[] = 'chkDtVat';
	
	if ($Module_ProjectDt == 1) $columnsarray[] = 'projectcodedt'; 
	if ($Module_CostCenterDt == 1) $columnsarray[] = 'costcentcodedt'; 

		
	$columnslist = implode(',', $columnsarray);
	
	
	
echo"<input type='hidden' name='txtDtCurr' id='txtDtCurr' value='$txtDtCurr'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
	if ($txtSalesJVId != '' )
	{
		$querydt = " Select SalesJVDt.SalesJVDt_ID, SalesJVDt.Ledger_Number, Ledger.Ledger_Name, SalesJVDt_Description, SalesJvDt_Description2, SalesJVDt.Currency_Code, ".
	           " ifNull(SalesJVDt_Quantity,0), Round(ifNull(SalesJVDt_Price,0), ".$DecimalBase."), SalesJVDt_PriceBase1, SalesJVDt_PriceBase2, ".
			   " Round(ifNull(SalesJVDt_DiscountPer,0), ".$DecimalBase."), Round(ifNull(SalesJVDTCalcTotal,0), ".$DecimalBase.") As Total, ".
			   " ifNull(SalesJVDt.SalesJVDt_VAT, 0) As SalesJVDtVAT, SalesJvDt_ManualNo, SalesJVDt.Project_Code, SalesJVDt.Costcenter_Code, SalesJVDt.cost ,
			   ledger_numbercredit ,ledger_numberdebit ,expencesamt ".
			   " From Temp_SalesJVDt As SalesJVDt  Left Join Ledger on SalesJVDt.Ledger_Number = Ledger.Ledger_Number ".
			   " Where SalesJVDt.SalesJV_ID = ".$txtSalesJVId.
			   " Order By SalesJVDt.SalesJVDt_Id Asc ";
			   
			   //echo $querydt;
			   
		$result=mysql_query($querydt,$connection)  or die(mysql_error());
		$totalrows = mysql_num_rows($result);

		$querydt = $querydt." limit ".$startrange.",".$perpage;
		$result=mysql_query($querydt,$connection);	
	}
						
					
					

$TableWidth = 1295;
if ($Module_ProjectDt == 1)    $TableWidth += 160;
if ($Module_CostCenterDt == 1) $TableWidth += 160;

$TableWidthStyle = 'width:'.$TableWidth.'px;';

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='container' style='position: relative;z-index:1;' >";
echo"	<div id='Loader' class=''></div>";
echo"<div id='prequestdtdiv' style='overflow:scroll;width:1100px;height:200px'>";
echo"<table border='0' align='center'   class='grid_data'  style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0; $TableWidthStyle' cellpadding='0' cellspacing='1'>
		  
		  <col width=25>
		  <col width=130>  
		  <col width=170>	
		  <col width=200>	
		  <col width=200>";
		  if($module_shipmentclosing==1){
			echo "<col width=100><col width=100><col width=85>";
		  }
		  
echo"		  <col width=100>	
		  <col width=60>
		  <col width=85>	  
		  <col width=85>	  
		  <col width=85>";
if ($salesjv_paymentmode==1)		  
echo "	  <col width=85>	";
echo "	   <col width=85>
		  <col width=35>";
		  
	if ($Module_ProjectDt == 1) {
		echo" <col width=160>";
	}
	if ($Module_CostCenterDt == 1) {
		echo" <col width=160>";
	}		  
		  
	echo" <col width=35> ";	  

				
		echo"<tr height='25px'>";
		echo"  <th  align='left'><span class='style27'>&nbsp;</th>";
		echo"  <th  align='left'>Ledger Number</th>";
		echo"  <th  align='left'>Ledger Name</th>";
		echo"  <th  align='left'>Description</th>";
		echo"  <th  align='left'>Description 2</th>";
		if($module_shipmentclosing==1){
			
		echo"  <th  align='center'>Ledger No Credit</th>";
		echo"  <th  align='center'>Ledger No Debit </th>";
		echo"  <th  align='center'>Expences amount </th>";
		}
		echo"  <th  align='center'>Manual No</th>";
		echo"  <th  align='center'>Currency</th>";
		echo"  <th  align='center'>Quantity</th>";
		echo"  <th  align='center'>Price</th>";
		 if ($salesjv_paymentmode==1)
			 echo"  <th  align='center'>Cost</th>";
		echo"  <th  align='center'>Disc(%)</th>";
		echo"  <th  align='center'>Total</th>";
		echo"  <th  align='center'>Vat</th>";	

		if ($Module_ProjectDt == 1) {
			echo"  <th align='center'>Project</th>";	
		}
		if ($Module_CostCenterDt == 1) {
			echo"  <th align='center'>Costcenter</th>";	
		}	
		
		echo"  <th  align='center'></th>";		
        echo"</tr>";

	$i=0;
	$j=1;
	
	echo"<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>";

$i=0;		 
while($rowsdt=mysql_fetch_row($result)){
			   
	$txtDtId[$i]           = $rowsdt[0];
	$txtLedgerNo[$i]       = $rowsdt[1];
	$txtLedgerName[$i]	   = $rowsdt[2];
	$txtDescription1[$i]   = $rowsdt[3];
	$txtDescription2[$i]   = $rowsdt[4];
	$txtDtCurr[$i]		   = $rowsdt[5];
	$txtDtQty[$i]          = $rowsdt[6];
	$txtDtPrice[$i] 	   = $rowsdt[7];
	$txtDtCost[$i] 	       = $rowsdt[16];
	$txtDtDiscPer[$i]  	   = $rowsdt[10];
	$txtDtTotal[$i]        = $rowsdt[11];
	$chkDtVat[$i]          = $rowsdt[12];
	$txtDtVat[$i]          = $rowsdt[12];
	$txtDtManualNo[$i]     = $rowsdt[13];
	$txtProjectCodeDt[$i]  = $rowsdt[14];
	$txtCostCentCodeDt[$i] = $rowsdt[15];
	$txtledgernocl[$i] = $rowsdt[17];
	$txtledgernoexp[$i] = $rowsdt[18];
	$txtexpamt[$i] = $rowsdt[19];
	
			
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
			
			$KeyDown   = 'onkeydown="return dokeysalesjvdt(event,this,'.$i.',\''.$columnslist.'\',\'SalesJvDt\')"';

			echo "<input type='hidden' name='txtDtId' value='$txtDtId' >";

			echo"<tr id='CurRec$i' bgcolor='$bgcolor' class='$bgcolor table-focus-g1'>";
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
							
			echo "	<td align='center' $bgcolorvalign='center'><span class='style15'><img src='img/delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteDetail('".$rowsdt[0]."')\" title='Delete Record'  ></span></td>";
			
			
			echo"<td><input type='text'  class='roundedtext_amortization_medium'   name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10' size='8'  onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',1) style='font-size:11px; width:90px; height:22px;' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','800','500')\"   /></span></label>";
			echo"</td>";
			echo"<td >
			<input type='text'  class='roundedtext_amortization_medium'   $KeyDown   name='txtLedgerName[$i]'  id='txtLedgerName[$i]' onkeyup=\"searchLedger(event)\"  onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."'>
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
					
					
			echo"<td ><span class='style4'><input type='text' $KeyDown   class='roundedtext_amortization_mediumlarge'   name='txtDescription1[$i]' id='txtDescription1[$i]' onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."'></span></td>";
	
			echo"<td><input type='text' class='roundedtext_amortization_mediumlarge'  name='txtDescription2[$i]'   $KeyDown   id='txtDescription2[$i]'  class='roundedtext_amortization_m'  onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription2[$i], ENT_QUOTES)."'></td>";
			if($module_shipmentclosing==1){

			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtledgernocl[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtledgernocl[$i]'  value='".$txtledgernocl[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select ledger No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger1(30,$i); '   /></label>
			</td>";
			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtledgernoexp[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtledgernoexp[$i]'  value='".$txtledgernoexp[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select ledger No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger1(31,$i); '   /></label>
			</td>";
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='txtexpamt[$i]' id='txtexpamt[$i]' value='".number_format($txtexpamt[$i],$DecimalBase)."'   onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";

			}
			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
				<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '   /></label>
				</td>";
		
			echo"<td><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
				$txtDtCurr[$i] </td>";
			
			
			
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]'   id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'  onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			if ($salesjv_paymentmode==1)
			 {echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtCost[$i]'   id='txtDtCost[$i]' value='$txtDtCost[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'  onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";}
			else echo "<input type='hidden'  name='txtDtCost[$i]'   id='txtDtCost[$i]' value='$txtDtCost[$i]' >";	
			echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'   name='txtDtDiscPer[$i]'  id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'  onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown      class='roundedtext_amortization_medium'   name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'  onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(2,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			
			
			
			echo"<td ><span class='style4'><input type='hidden' name='txtDtVat[$i]' id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);SetModRecord(\"ModRec_G1\",\"$i\")'  $KeyDown ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}
			
			echo"<td><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitSalesJvDt[$i]' title='Save' onclick=\"submitSalesJvDt('$txtDtId[$i]','$txtSalesJVId[$i]','$i','e','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
}
	
		
	if (empty($warehousecode[$i])) { //echo $_SESSION['prqstdefaultwarehouse'];
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeysalesjvdt(event,this,'.$i.',\''.$columnslist.'\',\'SalesJvDt\');"';

			echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";
			
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearsalesjvdt('$i')\"></td>";
						
						
			echo"<td><input type='text'   class='roundedtext_amortization_medium'  name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10' size='8'   onchange=\"setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]','1'); SetRecordGridDefaults('$i');\"  style='font-size:11px; width:90px; height:22px;' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','800','500')\"  /></span></label>";
			echo"</td>";
			echo"<td ><input type='text'   class='roundedtext_amortization_medium'   $KeyDown   name='txtLedgerName[$i]'   id='txtLedgerName[$i]'    onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."' >
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
					
					
				echo"<td ><span class='style4'><input type='text'     $KeyDown   class='roundedtext_amortization_mediumlarge'   name='txtDescription1[$i]' id='txtDescription1[$i]'  onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."'></span></td>";
	
				echo"<td><input type='text'  name='txtDescription2[$i]'   $KeyDown   id='txtDescription2[$i]'  class='roundedtext_amortization_mediumlarge'    onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."'></td>";

	
				if($module_shipmentclosing==1){

			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtledgernocl[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtledgernocl[$i]'  value='".$txtledgernocl[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select ledger No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger1(30,$i); '   /></label>
			</td>";
			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtledgernoexp[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtledgernoexp[$i]'  value='".$txtledgernoexp[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select ledger No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger1(31,$i); '   /></label>
			</td>";
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:80px'  name='txtexpamt[$i]' id='txtexpamt[$i]' value='".$txtexpamt[$i]."'   onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";

				}
				echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
				<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '  /></label>
				</td>";
		
				echo"<td><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
				$txtDtCurr[$i] </td>";
			
			
			
			echo"<td ><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'   onchange=\"SetModRecord('ModRec_G1','$i');\"  > </span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]' id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
		if ($salesjv_paymentmode==1)
			 {echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtCost[$i]' id='txtDtCost[$i]' value='$txtDtCost[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
						}
			else echo "<input type='hidden'  name='txtDtCost[$i]'   id='txtDtCost[$i]' value='$txtDtCost[$i]' >";	
			echo"<td ><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'    name='txtDtDiscPer[$i]'   id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'     name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'  onchange=\"SetModRecord('ModRec_G1','$i');\"  onKeyup='CalcDtTotal(2,$DecimalBase,$i);'></span></td>";
			
			
			
			echo"<td ><span class='style4'><input type='hidden' name='txtDtVat[$i]'  id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);' ".$KeyDown." ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}
			
			echo"<td><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitSalesJvDt[$i]' title='Save' onclick=\"submitSalesJvDt('$txtDtId[$i]','$txtSalesJVId[$i]','$i','i','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div></div>";
	

	

}


Function ShowPorderJvDtGrid($connection,$form,$porderjv,$txtSupplierCode,$Login_ModifySellingPrice,$Login_ModifyDiscount,$DecimalBase,$Module_RestrictProjCost,$Module_RestrictCost,$FI_SalesCheckSalesman,$Module_ProjectDt,$Module_CostCenterDt){
	
	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	
	$txtPorderJVId = $porderjv;
	
	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
	// User Has No Access To Modify The Price / Discount	
	$ModeModifySellPrice = '';
	$DiscountMode = '';
	
	if ($Login_ModifySellingPrice == 0) $ModeModifySellPrice = ' readonly ';
	if ($Login_ModifyDiscount == 0)	$DiscountMode = ' readonly ';


	if (empty($txtDtManualNo)) $txtDtManualNo = $PManualNo;

	if (empty($txtDtCurr))
	{
		if ($sub_result[0] != '')	$txtDtCurr = $sub_result[0];
		else		$txtDtCurr = $base1;
	}	

	if ($PClientCode != '') {
		$sub_query1 = " Select ifNull(Client_VAT,0) From Clients ".
					  " Where Ledger_Number = '".$PClientCode."' ";
		$sub_result1 = selectData($connection, $sub_query1);	
		$txtDtVat = $sub_result1[0];
		$chkDtVat = $sub_result1[0];
	}	


	
	$columnsarray = array("txtLedgerNo"
						,"txtLedgerName"
						,"txtDescription1"
						);

	$columnsarray[] = 'txtDescription2';
			
	$columnsarray[] = 'txtDtManualNo';
			
	$columnsarray[] = 'txtDtQty';
	$columnsarray[] = 'txtDtPrice';
	$columnsarray[] = 'txtDtDiscPer';
	$columnsarray[] = 'txtDtTotal';
	$columnsarray[] = 'chkDtVat';
	
	if ($Module_ProjectDt == 1) $columnsarray[] = 'projectcodedt'; 
	if ($Module_CostCenterDt == 1) $columnsarray[] = 'costcentcodedt'; 
	$columnsarray[] = 'imgSubmitPorderJvDt';
		
		
	$columnslist = implode(',', $columnsarray);
	
	
	
echo"<input type='hidden' name='txtDtCurr' id='txtDtCurr' value='$txtDtCurr'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
	  if ($txtPorderJVId != '' )
			{
				$querydt = " Select PorderJVDt.PorderJVDt_Id, PorderJVDt.Ledger_Number, Ledger.Ledger_Name, PorderJVDt_Description, PorderJVDt_Description2
				, PorderJVDt.Currency_Code, ".
	           " ifNull(PorderJVDt_Quantity,0), Round(ifNull(porderjvdt_price,0), ".$DecimalBase."), PorderJVDt_PriceBase1, PorderJVDt_PriceBase2, ".
			   " Round(ifNull(porderjvdt_discper,0), ".$DecimalBase."), Round(ifNull(PorderJVDTCalcTotal,0), ".$DecimalBase.") As Total, ".
			   " ifNull(PorderJVDt.PorderJvDt_VAT, 0) As PorderJVDtVAT, PorderJvDt_ManualNo, PorderJVDt.Project_Code, PorderJVDt.Costcenter_Code ".
			   " From Temp_Porderjvdt As PorderJVDt  Left Join Ledger on PorderJVDt.Ledger_Number = Ledger.Ledger_Number ".
			   " Where PorderJVDt.PorderJV_Id = ".$txtPorderJVId.
			   " Order By PorderJVDt.PorderJVDt_Id Asc ";
			   
			  // echo $querydt;
			   
			   $result=mysql_query($querydt,$connection)  or die(mysql_error());
				$totalrows = mysql_num_rows($result);

				$querydt = $querydt." limit ".$startrange.",".$perpage;

				$result=mysql_query($querydt,$connection);	
			}
						
					
					

$TableWidth = 1295;
if ($Module_ProjectDt == 1)    $TableWidth += 160;
if ($Module_CostCenterDt == 1) $TableWidth += 160;

$TableWidthStyle = 'width:'.$TableWidth.'px;';

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='container' style='position: relative;z-index:1;' >";
echo"	<div id='Loader' class=''></div>";
echo"<div id='prequestdtdiv' style='overflow:scroll;width:1100px;height:200px'>";
echo"<table border='0' align='center'   bgcolor='#ffffff' id='grid_datatable' class='grid_data'  style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0; $TableWidthStyle' cellpadding='0' cellspacing='1' >
		  <col width=25>
		  <col width=130>  
		  <col width=170>	
		  <col width=200>	
		  <col width=200>
		  <col width=100>	
		  <col width=60>
		  <col width=85>	  
		  <col width=85>	  
		  <col width=85>	  
		  <col width=85>
		  <col width=35>";
	if ($Module_ProjectDt == 1) {
		echo" <col width=160>";
	}
	if ($Module_CostCenterDt == 1) {
		echo" <col width=160>";
	}		  
		  
	echo" <col width=35> ";

				
		echo"<tr height='25px'>";
		echo"  <th  align='left'>&nbsp;</span></th>";
		echo"  <th  align='left'>Ledger Number</th>";
		echo"  <th  align='left'>Ledger Name</th>";
		echo"  <th  align='left'>Description</th>";
		echo"  <th  align='left'>Description 2</th>";
		echo"  <th  align='center'>Manual No</th>";
		echo"  <th  align='center'>Currency</th>";
		echo"  <th  align='center'>Quantity</th>";
		echo"  <th  align='center'>Price</th>";
		echo"  <th  align='center'>Disc(%)</th>";
		echo"  <th  align='center'>Total</th>";
		echo"  <th  align='center'>Vat</th>";	

		if ($Module_ProjectDt == 1) {
			echo"  <th align='center'>Project</th>";	
		}
		if ($Module_CostCenterDt == 1) {
			echo"  <th align='center'>Costcenter</th>";	
		}	
		
		echo"  <th  align='center'></th>";		
        echo"</tr>";

	$i=0;
	$j=1;
	
	echo"<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>";

$i=0;		 
while($rowsdt=mysql_fetch_row($result)){
			   
	$txtDtId[$i]           = $rowsdt[0];
	$txtLedgerNo[$i]       = $rowsdt[1];
	$txtLedgerName[$i]	   = $rowsdt[2];
	$txtDescription1[$i]   = $rowsdt[3];
	$txtDescription2[$i]   = $rowsdt[4];
	$txtDtCurr[$i]		   = $rowsdt[5];
	$txtDtQty[$i]          = $rowsdt[6];
	$txtDtPrice[$i] 	   = $rowsdt[7];
	$txtDtDiscPer[$i]  	   = $rowsdt[10];
	$txtDtTotal[$i]        = $rowsdt[11];
	$chkDtVat[$i]          = $rowsdt[12];
	$txtDtVat[$i]          = $rowsdt[12];
	$txtDtManualNo[$i]     = $rowsdt[13];
	$txtProjectCodeDt[$i]  = $rowsdt[14];
	$txtCostCentCodeDt[$i] = $rowsdt[15];
	
			
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
			
			$KeyDown   = 'onkeydown="return dokeyporderjvdt(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\')"';

			echo "<input type='hidden' name='txtDtId' value='$txtDtId' >";

			echo"<tr id='CurRec$i' bgcolor='$bgcolor' class='$bgcolor table-focus-g1'>";
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
							
			echo "	<td align='center' $bgcolorvalign='center'><span class='style15'><img src='img/delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteDetail('".$rowsdt[0]."')\" title='Delete Record'  ></span></td>";
			
			
			echo"<td align='center'><input type='text'   class='roundedtext_amortization_medium'  name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10' size='8'   onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]',1) onkeyup=\"AutoCompleteData(event,this.id,'ledgernumber[$i]','txtLedgerName[$i]','ledgers');\"   style='font-size:11px; width:108px; height:22px;' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','800','500')\"  /></span></label>";
			echo"</td>";
			echo"<td align='center'><input type='text'   class='roundedtext_amortization_medium' style='font-size:11px; width:165px; '  $KeyDown   name='txtLedgerName[$i]'   id='txtLedgerName[$i]'    onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."' >
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
			
					
					
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown   class='roundedtext_amortization_mediumlarge'   style='font-size:11px; width:190px;'  name='txtDescription1[$i]' id='txtDescription1[$i]' value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" ></span></td>";
			echo"<td align='center'><input type='text'  class='roundedtext_amortization_mediumlarge'  name='txtDescription2[$i]'   style='font-size:11px; width:190px;'  $KeyDown   id='txtDescription2[$i]'  onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription2[$i], ENT_QUOTES)."' ></td>";

	
				
			echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' readonly  name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
				<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '   /></label>
				</td>";
		
			echo"<td align='center'><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
				$txtDtCurr[$i] </td>";
			
			
			
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:75px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]'   id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:80px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'   name='txtDtDiscPer[$i]'  id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:75px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td align='center' ><span class='style4'><input type='text'  $KeyDown      class='roundedtext_amortization_medium'   name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:75px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(2,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			
			
			
			echo"<td align='center'><span class='style4'><input type='hidden' name='txtDtVat[$i]' id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);SetModRecord(\"ModRec_G1\",\"$i\")' ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}
						
			echo"<td align='center'><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPorderJvDt[$i]' title='Save' onclick=\"submitPorderJvDt('$txtDtId[$i]','$txtPorderJVId[$i]','$i','e','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
}
	
		
	if (empty($warehousecode[$i])) { //echo $_SESSION['prqstdefaultwarehouse'];
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeyporderjvdt(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\');"';

			echo"<tr height='25px' id='CurRec$i' class='$bgcolor table-focus-g1'>";
			
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearporderjvdt('$i')\"></td>";
						
						
			echo"<td align='center' ><input type='text'   class='roundedtext_amortization_medium'  name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10' size='8'   onchange=\"setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]',1); SetRecordGridDefaults($i);\"   onkeyup=\"AutoCompleteData(event,this.id,'ledgernumber[$i]','txtLedgerName[$i]','ledgers');\"  style='font-size:11px; width:108px; ' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','800','500')\"  /></span></label>";
			echo"</td>";
			echo"<td align='center' ><input type='text'   class='roundedtext_amortization_medium'   $KeyDown   name='txtLedgerName[$i]'   id='txtLedgerName[$i]'    onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."' style='font-size:11px; width:165px; ' >
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
						
					
			echo"<td align='center'><span class='style4'><input type='text'    $KeyDown   class='roundedtext_amortization_mediumlarge'   name='txtDescription1[$i]' id='txtDescription1[$i]'  value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='font-size:11px; width:190px; ' ></span></td>";

			echo"<td align='center'><input type='text'    class='roundedtext_amortization_mediumlarge'  name='txtDescription2[$i]'   $KeyDown   id='txtDescription2[$i]'  value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='font-size:11px; width:190px; ' ></td>";

			echo"<td align='center'><input type='text' $KeyDown   class='roundedtext_amortization_medium' readonly name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '  /></label>
			</td>";
		
			echo"<td align='center'><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
			$txtDtCurr[$i] </td>";
			
			echo"<td align='center'><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:75px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]' id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:80px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'    name='txtDtDiscPer[$i]'   id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:75px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td align='center'><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'     name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:75px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(2,$DecimalBase,$i);'></span></td>";
			
			
			
			echo"<td align='center'><span class='style4'><input type='hidden' name='txtDtVat[$i]'  id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);' ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}

			echo"<td align='center'><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPorderJvDt[$i]' title='Save' onclick=\"submitPorderJvDt('$txtDtId[$i]','$txtPorderJVId[$i]','$i','i','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div></div>";
	

	

}

Function ShowPurchasesJvDtGrid($connection,$form,$purchasesjv,$arrayparams){

	$txtSupplierCode 			= $arrayparams['txtSupplierCode'];
	$Login_ModifySellingPrice 	= $arrayparams['Login_ModifySellingPrice'];
	$Login_ModifyDiscount		= $arrayparams['Login_ModifyDiscount'];
	$DecimalBase				= $arrayparams['DecimalBase'];
	$Module_RestrictProjCost	= $arrayparams['Module_RestrictProjCost'];
	$Module_RestrictCost		= $arrayparams['Module_RestrictCost'];
	$FI_SalesCheckSalesman		= $arrayparams['FI_SalesCheckSalesman'];
	$Module_ProjectDt			= $arrayparams['Module_ProjectDt'];
	$Module_CostCenterDt		= $arrayparams['Module_CostCenterDt'];
	
	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	
	$txtPurchasesJVId = $purchasesjv;
	
	$PriceLabel = 'Price';	
	if ($PurchaseTTC == 1)  $PriceLabel = 'Price TTC';	
	
	
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
	// User Has No Access To Modify The Price / Discount	
	$ModeModifySellPrice = '';
	$DiscountMode = '';
	
	if ($Login_ModifySellingPrice == 0) $ModeModifySellPrice = ' readonly ';
	if ($Login_ModifyDiscount == 0)	$DiscountMode = ' readonly ';


	if (empty($txtDtManualNo)) $txtDtManualNo = $PManualNo;

	if (empty($txtDtCurr))
	{
		if ($sub_result[0] != '')	$txtDtCurr = $sub_result[0];
		else		$txtDtCurr = $base1;
	}	

	if ($PClientCode != '') {
		$sub_query1 = " Select ifNull(Client_VAT,0) From Clients ".
					  " Where Ledger_Number = '".$PClientCode."' ";
		$sub_result1 = selectData($connection, $sub_query1);	
		$txtDtVat = $sub_result1[0];
		$chkDtVat = $sub_result1[0];
	}	


	
	$columnsarray = array("txtLedgerNo"
						,"txtLedgerName"
						,"txtDescription1"
						);

	$columnsarray[] = 'txtDescription2';
	$columnsarray[] = 'txtAssetPer';		
	$columnsarray[] = 'txtDtManualNo';
			
	$columnsarray[] = 'txtDtQty';
	$columnsarray[] = 'txtDtPrice';
	$columnsarray[] = 'txtDtDiscPer';
	$columnsarray[] = 'txtDtTotal';
	$columnsarray[] = 'chkDtVat';
	
	if ($Module_ProjectDt == 1) $columnsarray[] = 'projectcodedt'; 
	if ($Module_CostCenterDt == 1) $columnsarray[] = 'costcentcodedt'; 

		
		
	$columnslist = implode(',', $columnsarray);
	
	
	
echo"<input type='hidden' name='txtDtCurr' id='txtDtCurr' value='$txtDtCurr'>";


if ($orderby=='')
	$orderby = 'prqstdt_id';
	
	
	  
	  if ($txtPurchasesJVId != '' )
			{
				$querydt = " Select PurchasesJVDt.PurchaseJVDt_Id, PurchasesJVDt.Ledger_Number, Ledger.Ledger_Name, PurchaseJVDt_Description, PurchaseJVDt_Description2, PurchasesJVDt.Currency_Code, ".
	           " ifNull(PurchaseJVDt_Quantity,0), Round(ifNull(purchasejvdt_price,0), ".$DecimalBase."), PurchaseJVDt_PriceBase1, PurchaseJVDt_PriceBase2, ".
			   " Round(ifNull(purchasejvdt_discper,0), ".$DecimalBase."), Round(ifNull(PurchaseJVDTCalcTotal,0), ".$DecimalBase.") As Total, ".
			   " ifNull(PurchasesJVDt.PurchaseJvDt_VAT, 0) As PurchasesJVDtVAT, PurchaseJvDt_ManualNo, PurchasesJVDt.Project_Code, PurchasesJVDt.Costcenter_Code, purchasejvdt_assetPer ".
			   " From Temp_Purchasesjvdt As PurchasesJVDt  Left Join Ledger on PurchasesJVDt.Ledger_Number = Ledger.Ledger_Number ".
			   " Where PurchasesJVDt.PurchaseJV_Id = ".$txtPurchasesJVId.
			   " Order By PurchasesJVDt.PurchaseJVDt_Id Asc ";
			   
			  // echo $querydt;
			   
			   $result=mysql_query($querydt,$connection)  or die(mysql_error());
				$totalrows = mysql_num_rows($result);

				$querydt = $querydt." limit ".$startrange.",".$perpage;

				$result=mysql_query($querydt,$connection);	
			}
						
					
					

$TableWidth = 1295;
if ($Module_ProjectDt == 1)    $TableWidth += 160;
if ($Module_CostCenterDt == 1) $TableWidth += 160;

$TableWidthStyle = 'width:'.$TableWidth.'px;';

$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='container' style='position: relative;z-index:1;' >";
echo"	<div id='Loader' class=''></div>";
echo"<div id='prequestdtdiv' style='overflow:scroll;width:1100px;height:200px'>";
echo"<table border='0' align='center'   bgcolor='#ffffff' id='grid_datatable' class='grid_data'  style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0; $TableWidthStyle' cellpadding='0' cellspacing='1' >
		  <col width=25>
		  <col width=130>  
		  <col width=170>	
		  <col width=200>	
		  <col width=200>
		  <col width=100>
		  <col width=100>	
		  <col width=60>
		  <col width=85>	  
		  <col width=85>	  
		  <col width=85>	  
		  <col width=85>
		  <col width=35>";
	if ($Module_ProjectDt == 1) {
		echo" <col width=160>";
	}
	if ($Module_CostCenterDt == 1) {
		echo" <col width=160>";
	}		  
		  
	echo" <col width=35> ";

				
		echo"<tr height='25px'>";
		echo"  <th  align='left'>&nbsp;</span></th>";
		echo"  <th  align='left'>Ledger Number</th>";
		echo"  <th  align='left'>Ledger Name</th>";
		echo"  <th  align='left'>Description</th>";
		echo"  <th  align='left'>Description 2</th>";
		echo"  <th  align='left'>Asset %</th>";
		echo"  <th  align='center'>Manual No</th>";
		echo"  <th  align='center'>Currency</th>";
		echo"  <th  align='center'>Quantity</th>";
		echo"  <th  align='center'>Price</th>";
		echo"  <th  align='center'>Disc(%)</th>";
		echo"  <th  align='center'>Total</th>";
		echo"  <th  align='center'>Vat</th>";	

		if ($Module_ProjectDt == 1) {
			echo"  <th align='center'>Project</th>";	
		}
		if ($Module_CostCenterDt == 1) {
			echo"  <th align='center'>Costcenter</th>";	
		}	
		
		echo"  <th  align='center'></th>";		
        echo"</tr>";

	$i=0;
	$j=1;
	
	echo"<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>";

$i=0;		 
while($rowsdt=mysql_fetch_row($result)){
			   
	$txtDtId[$i]           = $rowsdt[0];
	$txtLedgerNo[$i]       = $rowsdt[1];
	$txtLedgerName[$i]	   = $rowsdt[2];
	$txtDescription1[$i]   = $rowsdt[3];
	$txtDescription2[$i]   = $rowsdt[4];
	$txtDtCurr[$i]		   = $rowsdt[5];
	$txtDtQty[$i]          = $rowsdt[6];
	$txtDtPrice[$i] 	   = $rowsdt[7];
	$txtDtDiscPer[$i]  	   = $rowsdt[10];
	$txtDtTotal[$i]        = $rowsdt[11];
	$chkDtVat[$i]          = $rowsdt[12];
	$txtDtVat[$i]          = $rowsdt[12];
	$txtDtManualNo[$i]     = $rowsdt[13];
	$txtProjectCodeDt[$i]  = $rowsdt[14];
	$txtCostCentCodeDt[$i] = $rowsdt[15];
	$txtAssetPer[$i]	   = $rowsdt[16];
			
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
			
			$KeyDown   = 'onkeydown="return dokeypurchasesjvdt(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\')"';

			echo "<input type='hidden' name='txtDtId' value='$txtDtId' >";

			echo"<tr id='CurRec$i' bgcolor='$bgcolor' class='$bgcolor table-focus-g1'>";
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
							
			echo "	<td align='center' $bgcolorvalign='center'><span class='style15'><img src='img/delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteDetail('".$rowsdt[0]."')\" title='Delete Record'  ></span></td>";
			
			
			echo"<td align=center><input type='text'   class='roundedtext_amortization_medium'  name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10' onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]',1) onkeyup=\"AutoCompleteData(event,this.id,'ledgernumber[$i]','txtLedgerName[$i]','ledgers');\"   style='font-size:11px; width:105px; height:22px;' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','txtAssetPer[$i]','800','500')\"  /></span></label>";
			echo"</td>";
			echo"<td align=center><input type='text'   class='roundedtext_amortization_medium'   $KeyDown   name='txtLedgerName[$i]'   id='txtLedgerName[$i]'    onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."' style='width:160px;' >
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
			
					
					
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown   class='roundedtext_amortization_mediumlarge'   name='txtDescription1[$i]' id='txtDescription1[$i]' value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" ></span></td>";
			echo"<td align=center><input type='text'  class='roundedtext_amortization_mediumlarge'  name='txtDescription2[$i]'   $KeyDown   id='txtDescription2[$i]'  onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($txtDescription2[$i], ENT_QUOTES)."' ></td>";

			echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAssetPer[$i]'  style='width:90px;background-image:transparent;text-align:right'  id='txtAssetPer[$i]'  value='".$txtAssetPer[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </td>";
				
			echo"<td><input type='text' $KeyDown   class='roundedtext_amortization_medium' readonly  name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
				<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '   /></label>
				</td>";
		
			echo"<td><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
				$txtDtCurr[$i] </td>";
			
			
			
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]'   id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'   name='txtDtDiscPer[$i]'  id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown      class='roundedtext_amortization_medium'   name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(2,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			
			
			
			echo"<td align=center><span class='style4'><input type='hidden' name='txtDtVat[$i]' id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);SetModRecord(\"ModRec_G1\",\"$i\")' ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}
						
			echo"<td><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPurchasesJvDt[$i]' title='Save' onclick=\"submitPurchasesJvDt('$txtDtId[$i]','$txtPurchasesJVId[$i]','$i','e','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
			
			$i+=1;
}
	
		
	if (empty($warehousecode[$i])) { //echo $_SESSION['prqstdefaultwarehouse'];
				if(!empty($_SESSION['prqstsetupdefaultWareHouse'] ))
					$warehousecode[$i] = $_SESSION['prqstsetupdefaultWareHouse'] ;
				else	
					$warehousecode[$i] = $_SESSION['prqstdefaultwarehouse'];
			}
			
	$k=1;
		$morelines = 1;
		//echo $morelines;
		while ($k <= $morelines) {
			$recno = $i+1;
			if ($k==$morelines)
				$mode = 'i';
			else
				$mode = 'e';			
			
			$KeyDown   = 'onkeydown="return dokeypurchasesjvdt(event,this,'.$i.',\''.$columnslist.'\',\'PTransReqDt\');"';

			echo"<tr id='CurRec$i' class='$bgcolor table-focus-g1'>";
			
			echo"<td align=center><img src='img/undo-1.png' width=20 height=20 onmouseover=\"style.cursor='pointer'\" name='' title='Clear' onclick=\"clearpurchasejvdt('$i')\"></td>";
						
						
			echo"<td align=center><input type='text'   class='roundedtext_amortization_medium'  name='txtLedgerNo[$i]' id='txtLedgerNo[$i]' $KeyDown value='$txtLedgerNo[$i]' maxlength='10'  onchange=\"setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]',1); SetRecordGridDefaults($i);\"   onkeyup=\"AutoCompleteData(event,this.id,'ledgernumber[$i]','txtLedgerName[$i]','ledgers');\"  style='font-size:11px; width:105px; height:22px;' >";
			echo"&nbsp;<label><span class='style11'><img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg[$i]' width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','projectcodedt[$i]','costcentcodedt[$i]','txtAssetPer[$i]','800','500')\"  /></span></label>";
			echo"</td>";
			echo"<td align=center><input type='text'   class='roundedtext_amortization_medium'   $KeyDown   name='txtLedgerName[$i]'   id='txtLedgerName[$i]'    onchange=setaccountno(this.value,'txtLedgerNo[$i]','txtLedgerName[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($txtLedgerName[$i], ENT_QUOTES)."' style='width: 165px;'>
			<img src='img/btnopen.jpg' title=' Select Ledger ' id='salesjvdtimg1[$i]' hidden width='15' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage1('txtLedgerNo','txtLedgerNo[$i]','txtLedgerName[$i]','800','500')\"   />
			</td>";
						
					
			echo"<td align=center><span class='style4'><input type='text'    $KeyDown   class='roundedtext_amortization_mediumlarge'   name='txtDescription1[$i]' id='txtDescription1[$i]'  value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" ></span></td>";

			echo"<td align=center><input type='text'    class='roundedtext_amortization_mediumlarge'  name='txtDescription2[$i]'   $KeyDown   id='txtDescription2[$i]'  value='".htmlspecialchars($txtDescription1[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" ></td>";

			echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' name='txtAssetPer[$i]'  style='width:90px;background-image:transparent;text-align:right'  id='txtAssetPer[$i]'  value='".$txtAssetPer[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" > </td>";
			
			echo"<td align=center><input type='text' $KeyDown   class='roundedtext_amortization_medium' readonly name='txtDtManualNo[$i]'  style='width:70px;background-image:transparent;text-align:right'  id='txtDtManualNo[$i]'  value='".$txtDtManualNo[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" size=4> 
			<label><img src='img/btnopen.jpg' title='Select Manual No' width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistManualNo(6,$i); '  /></label>
			</td>";
	
			echo"<td align=center><input type='hidden' name='txtDtCurr[$i]' id='txtDtCurr[$i]' value='$txtDtCurr[$i]'><span class='style13'>
			$txtDtCurr[$i] </td>";
			
			
			
			echo"<td align=center><span class='style4'><input type='text'   $KeyDown   class='roundedtext_amortization_medium'   style='width:70px'  name='txtDtQty[$i]' id='txtDtQty[$i]' value='".$txtDtQty[$i]."'  onKeyup='CalcDtTotal(1,$DecimalBase,$i);'  > </span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_medium'    name='txtDtPrice[$i]' id='txtDtPrice[$i]' value='$txtDtPrice[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $ModeModifySellPrice></span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'    name='txtDtDiscPer[$i]'   id='txtDtDiscPer[$i]' value='$txtDtDiscPer[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(1,$DecimalBase,$i);' $DiscountMode></span></td>";
			echo"<td align=center><span class='style4'><input type='text'  $KeyDown    class='roundedtext_amortization_medium'     name='txtDtTotal[$i]'   id='txtDtTotal[$i]' value='$txtDtTotal[$i]' style='text-align:right; font-size:12px; width:70px; height=18px;'   onchange=\"SetModRecord('ModRec_G1','$i');\" onKeyup='CalcDtTotal(2,$DecimalBase,$i);'></span></td>";
			
			
			
			echo"<td align=center><span class='style4'><input type='hidden' name='txtDtVat[$i]'  id='txtDtVat[$i]' value='$txtDtVat[$i]'><input name='chkDtVat[$i]' type='checkbox' id='chkDtVat[$i]' value='1' onclick='SetVatDt($i);' ";	
			if($chkDtVat[$i]==1 || $txtDtVat[$i] == 1) echo "checked"; echo " /> </span></td></span></td>";
		
			if ($Module_ProjectDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='".$txtProjectCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:120px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','project','project_code',this.value,'lstProjectCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Project' id='lstProjectCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick='showlistProjectDt(1,$i); ' style='vertical-align:bottom;'/></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtProjectCodeDt[$i]' id='projectcodedt[$i]' value='' >";
			}
			if ($Module_CostCenterDt == 1) {
				echo"<td width='160px;' align='center'><input type='text' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='".$txtCostCentCodeDt[$i]."' class='roundedtext_amortization_medium' style='width:130px;' maxlength='20' onchange=\"SetModRecord('ModRec_G1','$i'); CheckLookup('chkcodeexists','costcent','costcent_code',this.value,'lstCostCentCode[$i]');\" ".$KeyDown." /></span>
						<label><span><img src='img/openlist.png' title='Select Costcenter' id='lstCostCentCode[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onClick='showlistCostcenterDt(1,$i); ' style='vertical-align:bottom;' /></span></label></td>";	
			} else {
				echo"  <input type='hidden' name='txtCostCentCodeDt[$i]' id='costcentcodedt[$i]' value='' >";
			}

			echo"<td><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitPurchasesJvDt[$i]' title='Save' onclick=\"submitPurchasesJvDt('$txtDtId[$i]','$txtPurchasesJVId[$i]','$i','i','$Module_RestrictProjCost','$Module_RestrictCost','$FI_SalesCheckSalesman','$filepath')\"></td>";
			echo"<input type='hidden'  name='txtDtId[$i]' id='txtDtId[$i]' value='".$txtDtId[$i]."' >";
			echo"</tr>";
			
		$i+=1;
		$k+=1;
		}	
	
	echo"</table></div></div>";
	

	

}



Function ShowChecksCollectedGrid($connection,$form,$purchasesjv,$DecimalBase,$chkstatus,$vcolumnname,$searchedvalue){

	$ClassI = 'grid_roundedtext2';
	$filepath = 'Forms_DataGrid1.php';
	
			
	if ($startrange=='')	$startrange = 0;
		
	if ($direction == 'asc')
		$direction = 'desc';
	else if ($direction == 'desc')
		$direction = 'asc';
	else $direction = 'asc';

	if ($perpage=='')
		$perpage = 20;
	
if (!empty($fromdate))
	   $fromdate = explodeword($fromdate);
	   
	if (!empty($todate))
	   $todate = explodeword($todate);  

	if (empty($fromdate))   
	   $fromdate = 'null';
	else
	   $fromdate = "'".$fromdate."'"; 

   if (empty($todate))   
	   $todate = 'null';
	else
	   $todate = "'".$todate."'"; 

if($vcolumnname=='chk_valuedate' && $searchedvalue1==''){
	$searchedvalue1 = explode('/',$searchedvalue);
	$searchedvalue1 = "$searchedvalue1[2]"."-"."$searchedvalue1[1]"."-"."$searchedvalue1[0]";
	}
	
	$columnsarray = array("chk_valuedate"
						,"ledger_number"
						,"ledger_name"
						);
	$columnsarray[] = 'manual_no';
	$columnsarray[] = 'journaldt_desc';
	$columnsarray[] = 'chk_bank';	
	$columnsarray[] = 'chk_amount';
	$columnsarray[] = 'currency_code';
	$columnsarray[] = 'chk_number';
	$columnsarray[] = 'chk_bankdeposit';
	$columnsarray[] = 'chk_bankdepositname';
	$columnsarray[] = 'chk_depositvaluedate';
	$columnsarray[] = 'chk_date';
	$columnsarray[] = 'chk_status';
	$columnsarray[] = 'chk_commissioncur';
	$columnsarray[] = 'chk_commission';
	$columnsarray[] = 'chk_commissionacc';


	$columnslist = implode(',', $columnsarray);
	
	
if ($orderby=='')
	$orderby = ' order by chk_commissioncur,autoinc';
	
	
	  
	 // if ($txtPurchasesJVId != '' )
			{
				$querydt = " select autoinc, date_format(chk_valuedate,'%d/%m/%Y'), checkscollected.ledger_number,ledger.ledger_name,ledgerbank.ledger_name as chk_bankdepositname
				, chk_bank, chk_amount, checkscollected.currency_code, chk_number, journaldt_id2
				, chk_bankdeposit, chk_status, date_format(chk_depositvaluedate,'%d/%m/%Y'), journaldt_id1, chk_commission, chk_commissioncur, chk_commissionacc
				, checkcollected_posted, check_visible, manual_no, journaldt_desc, trans_id, date_format(chk_date,'%d/%m/%Y'),debit_ledgernumber
				from checkscollected
				left join ledger on ledger.ledger_number = checkscollected.ledger_number
				left join ledger as ledgerbank on ledgerbank.ledger_number = checkscollected.chk_bankdeposit
				where 1=1 ";
				if($searchedvalue != '' ){
				$querydt = $querydt ."
				and if('".$vcolumnname."'='ledger_number', ifnull(checkscollected.ledger_number,-1) like if('$searchedvalue'='',ifnull(checkscollected.ledger_number,-1),'%$searchedvalue%'),1=1)
				and if('".$vcolumnname."'='ledger_name', ifnull(ledger.ledger_name,-1) like if('$searchedvalue'='',ifnull(ledger.ledger_name,-1),'%$searchedvalue%'),1=1)
				and if('".$vcolumnname."'='manual_no', ifnull(checkscollected.manual_no,-1) like if('$searchedvalue'='',ifnull(checkscollected.manual_no,-1),'%$searchedvalue%'),1=1)
				and if('".$vcolumnname."'='journaldt_desc', ifnull(checkscollected.journaldt_desc,-1) like if('$searchedvalue'='',ifnull(checkscollected.journaldt_desc,-1),'%$searchedvalue%'),1=1)
				and if('".$vcolumnname."'='chk_bank', ifnull(checkscollected.chk_bank,-1) like if('$searchedvalue'='',ifnull(checkscollected.chk_bank,-1),'%$searchedvalue%'),1=1)
				and if('".$vcolumnname."'='chk_valuedate', date_format(chk_valuedate,'%Y-%m-%d') = '".$searchedvalue1."',1=1)
				and if('".$vcolumnname."'='chk_number', ifnull(checkscollected.chk_number,-1) like if('$searchedvalue'='',ifnull(checkscollected.chk_number,-1),'%$searchedvalue%'),1=1)
				
				";
				}
				$querydt = $querydt."
				and ifnull(chk_status,-1) = if('$chkstatus'='',ifnull(chk_status,-1),'$chkstatus')
				$orderby ";
			   
			   //echo $querydt;
			   //exit;
			   $result=mysql_query($querydt,$connection)  or die(mysql_error());
				$totalrows = mysql_num_rows($result);

				//$querydt = $querydt." limit ".$startrange.",".$perpage;

				$result=mysql_query($querydt,$connection);	
			}
						
$i=0;
//echo"<input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='strt' id='strt' value='$strt'><input type='hidden' name='end' id='end'  value='$end'>";
echo"<div id='container' style='position: relative;z-index:1;' >";
echo"	<div id='Loader' class=''></div>";
echo"<div id='prequestdtdiv' style='overflow:scroll;width:1100px;height:350px'>";
echo"<table border='0' align='center'   class='grid_data'  style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0;width:980px;' cellpadding='0' cellspacing='1'>
		  <col width=25>
		  <col width=100>  
		  <col width=100>  
		  <col width=200>	
		  <col width=80>	
		  <col width=200>
		  <col width=120>	
		  <col width=90>
		  <col width=60>	  
		  <col width=90>	  
		  <col width=120>	  
		  <col width=150>
		  <col width=95>
		  <col width=95>
		  <col width=55>
		  <col width=55>
		  <col width=80>
		  <col width=125>
		  <col width=125>
		  <col width=35>";
			
		echo"<tr height=25>";
		echo"  <th bgcolor='#F7F7F7' align='left'><span class='style27'>
		<img src='img/search1.png' style='width:25px' onmouseover=\"style.cursor='pointer'\" onclick=javascript:animatedcollapse.toggle('jason')> ";
		
		echo"  <th bgcolor='#F7F7F7' align='left'>Due Date</span></th>";
		echo"  <th bgcolor='#F7F7F7' align='left'>Ledger Number</th>";
		echo"  <th bgcolor='#F7F7F7' align='left'>Ledger Name</th>";
		echo"  <th bgcolor='#F7F7F7' align='left'>Manual No</th>";
		echo"  <th bgcolor='#F7F7F7' align='left'>JV Description</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Bank</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Amount</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Cur.</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Check No.</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Bank Deposit</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Bank Deposit Name</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Deposit Due Date</th>";
		echo"  <th bgcolor='#F7F7F7' align='center'>Bank Value Date</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'>Status</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'>Comm. Cur</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'>Commission</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'>Comm Account</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'>Debit Ledger(For Return)</th>";		
		echo"  <th bgcolor='#F7F7F7' align='center'></th>";		
        echo"</tr>";

	$i=0;
	$j=1;
	
	echo"<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
		 <input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
		 <input type='hidden' name='ModRec_G1' id='ModRec_G1' value='$ModRec_G1'>";

$i=0;	

if($i==0) {
				$j = 99999999;
				$KeyDown   = 'onkeydown="return dokeychecksdt(event,this,'.$j.',\''.$columnslist.'\',\'ChecksCollection\')"';
				echo"<tr><td colspan=20>";
				if($vcolumnname!='')
					echo"<div id='jason' style='width:100%;height:25px;'> ";
				else 	
					echo"<div id='jason' style='width:100%;height:25px;  display:none;'> ";
					 
					 echo"<table   style='table-layout:fixed;font-size:10px;border:0px solid black;border-spacing:0;width:980px;'  cellpadding='0' cellspacing='0'> 
					 <col width=25>		  <col width=100>  		  <col width=100>  		  <col width=200>			  <col width=80>			  <col width=200>		  <col width=120>	
					 <col width=90>		  <col width=60>	  		  <col width=90>	  		  <col width=120>	  		  <col width=150>		  <col width=95>
						<col width=95>		  <col width=55>		  <col width=55>		  <col width=80>		  <col width=125>		  <col width=125>
						<col width=35>		 ";

				echo"<tr id='CurRec$j' bgcolor='$bgcolor' height=15 class='$bgcolor table-focus-g1'>";
				
				if($vcolumnname=='chk_valuedate')
						$chk_valuedate[$j] = $searchedvalue;		
				echo"<td>&nbsp;</td><td><input type='text'   class='roundedtext_amortization_small'  name='chk_valuedate[$j]'  onkeydown=\"return searchgrid(event,'chk_valuedate',this)\"  id='chk_valuedate[$j]' $KeyDown value='$chk_valuedate[$j]' maxlength='10' style='width:90px;' >";
			
				if($vcolumnname=='ledger_number')
						$ledger_number[$j] = $searchedvalue;
				echo"<td><input type='text'     class='roundedtext_amortization_small'  name='ledger_number[$j]' id='ledger_number[$j]' onkeydown=\"return searchgrid(event,'ledger_number',this)\" value='$ledger_number[$j]'  maxlength='10'  style='width:90px;' >";
				echo"</td>";
				
				if($vcolumnname=='ledger_name')
						$ledger_name[$j] = $searchedvalue;
				echo"<td ><input type='text'   class='roundedtext_amortization_mediumlarge'    onkeydown=\"return searchgrid(event,'ledger_name',this)\"  name='ledger_name[$j]' onkeydown=\"return searchgrid(event,'ledger_name',this)\"   id='ledger_name[$j]' value='".htmlspecialchars($ledger_name[$j], ENT_QUOTES)."' style='width:190px;'></td>";
				
				if($vcolumnname=='manual_no')
						$manual_no[$j] = $searchedvalue;
				echo"<td ><input type='text'   class='roundedtext_amortization_mediumlarge'     name='manual_no[$j]'  onkeydown=\"return searchgrid(event,'manual_no',this)\"  id='manual_no[$j]' value='".htmlspecialchars($manual_no[$j], ENT_QUOTES)."' style='width:70px;'></td>";
				
				if($vcolumnname=='journaldt_desc')
						$journaldt_desc[$j] = $searchedvalue;				
				echo"<td ><span class='style4'><input type='text'  class='roundedtext_amortization_mediumlarge'   name='journaldt_desc[$j]' onkeydown=\"return searchgrid(event,'journaldt_desc',this)\"  id='journaldt_desc[$j]' value='".htmlspecialchars($journaldt_desc[$j], ENT_QUOTES)."'  style='width:190px;'></span></td>";
				
				if($vcolumnname=='chk_bank')
						$chk_bank[$j] = $searchedvalue;			
				echo"<td ><span class='style4'><input type='text'  class='roundedtext_amortization_small'   name='chk_bank[$j]' onkeydown=\"return searchgrid(event,'chk_bank',this)\"  id='chk_bank[$j]'  value='".htmlspecialchars($chk_bank[$j], ENT_QUOTES)."'   style='width:109px;'></span></td>";
				
				echo"<td></td>";
				echo"<td></td>";				
				
				if($vcolumnname=='chk_number')
					$chk_number[$j] = $searchedvalue;			
				echo"<td ><span class='style4'><input type='text'  class='roundedtext_amortization_small'   name='chk_number[$j]' onkeydown=\"return searchgrid(event,'chk_number',this)\"  id='chk_number[$j]'  value='".htmlspecialchars($chk_number[$j], ENT_QUOTES)."'   style='width:80px;'></span></td>";

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

			
while($rowsdt=mysql_fetch_row($result)){
			   
	$autoinc[$i]     = $rowsdt[0];
	$chk_valuedate[$i]     = $rowsdt[1];
	$ledger_number[$i]     = $rowsdt[2];
	$ledger_name[$i]     = $rowsdt[3];
	$chk_bankdepositname[$i]     = $rowsdt[4];
	$chk_bank[$i]     = $rowsdt[5];
	$chk_amount[$i]     = number_format($rowsdt[6], $DecimalBase);
	$currency_code[$i]     = $rowsdt[7];
	$chk_number[$i]     = $rowsdt[8];
	$journaldt_id2[$i]     = $rowsdt[9];
	$chk_bankdeposit[$i]     = $rowsdt[10];
	$chk_status[$i]     = $rowsdt[11];
	$chk_depositvaluedate[$i]     = $rowsdt[12];
	$journaldt_id1[$i]     = $rowsdt[13];
	$chk_commission[$i]     = $rowsdt[14];
	$chk_commissioncur[$i]     = $rowsdt[15];
	$chk_commissionacc[$i]     = $rowsdt[16];
	$checkcollected_posted[$i]     = $rowsdt[17];
	$check_visible[$i]     = $rowsdt[18];
	$manual_no[$i]     = $rowsdt[19];
	$journaldt_desc[$i]     = $rowsdt[20];
	$trans_id[$i]     = $rowsdt[21];
	$chk_date[$i]     = $rowsdt[22];
	$debit_ledgernumber[$i]     = $rowsdt[23];
				
		if ($i%2==0)
		$bgcolor='#F5FAFF';
	else	
		$bgcolor='#FFFFFF';
			
			
			
			
			
			$KeyDown   = 'onkeydown="return dokeychecksdt(event,this,'.$i.',\''.$columnslist.'\',\'ChecksCollection\')"';

			echo "<input type='hidden' name='txtDtId' value='$txtDtId' >";

			echo"<tr id='CurRec$i' bgcolor='$bgcolor' height=15 class='$bgcolor table-focus-g1'>";
				
			$recno = $i+1;
			$recno = $perpage * (($startrange / $perpage)) + 1 + $i;
			
							
			//echo "	<td align='center' $bgcolorvalign='center'><span class='style15'><img src='img/delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteDetail('".$rowsdt[0]."')\" title='Delete Record'  ></span></td>";
			$j = $i+1;
			echo "	<td align='center' $bgcolorvalign='center'>$j</td>";
			
			echo"<td><input type='text' readonly  class='roundedtext_amortization_small'  name='chk_valuedate[$i]' id='chk_valuedate[$i]' $KeyDown value='$chk_valuedate[$i]' maxlength='10' style='width:90px;' >";
			echo"<td><input type='text'  readonly   class='roundedtext_amortization_small'  name='ledger_number[$i]' id='ledger_number[$i]' $KeyDown value='$ledger_number[$i]' maxlength='10'  onchange=setaccountno(this.value,'ledger_number[$i]','ledger_name[$i]','','salesjvdtimg[$i]','salesjvdtimg1[$i]',1)  style='width:90px;' >";
			
			echo"</td>";
			echo"<td ><input type='text'   class='roundedtext_amortization_mediumlarge'   $KeyDown   name='ledger_name[$i]'   id='ledger_name[$i]'    onchange=setaccountno(this.value,'ledger_number[$i]','ledger_name[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',2)   value='".htmlspecialchars($ledger_name[$i], ENT_QUOTES)."' style='width:190px;'>
			</td>";
			
					
					
			echo"<td ><span class='style4'><input type='text'  $KeyDown   class='roundedtext_amortization_small'   name='manual_no[$i]' id='manual_no[$i]' value='".htmlspecialchars($manual_no[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:70px;'></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown   class='roundedtext_amortization_mediumlarge'   name='journaldt_desc[$i]' id='journaldt_desc[$i]' value='".htmlspecialchars($journaldt_desc[$i], ENT_QUOTES)."' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:190px;'></span></td>";
			echo"<td><input type='text' readonly class='roundedtext_amortization_medium'  name='chk_bank[$i]'   $KeyDown   id='chk_bank[$i]'  onchange=\"SetModRecord('ModRec_G1','$i');\" value='".htmlspecialchars($chk_bank[$i], ENT_QUOTES)."' style='width:110px;'></td>";

	
				
			echo"<td>
			<input type='text' $KeyDown  readonly    class='roundedtext_amortization_medium' readonly  name='chk_amount[$i]'  style='width:80px;background-image:transparent;text-align:right'  id='chk_amount[$i]'  value='".$chk_amount[$i]."'  onchange=\"SetModRecord('ModRec_G1','$i');\" > 
				
				</td>";
		
			echo"<input type='hidden' name='journaldt_id1[$i]'  id='journaldt_id1[$i]'  value='".$journaldt_id1[$i]."'   >";
			echo"<input type='hidden' name='autoinc[$i]'  id='autoinc[$i]'  value='".$autoinc[$i]."'   >";
			
			echo"<td ><span class='style4'><input type='text'  readonly     $KeyDown   class='roundedtext_amortization_small'   style='width:50px'  name='currency_code[$i]' id='currency_code[$i]' value='".$currency_code[$i]."' > </span></td>";
			echo"<td ><span class='style4'><input type='text'  readonly    $KeyDown     class='roundedtext_amortization_medium'    name='chk_number[$i]'   id='chk_number[$i]' value='$chk_number[$i]'  style='width:80px;'></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown     class='roundedtext_amortization_small'   name='chk_bankdeposit[$i]'  id='chk_bankdeposit[$i]' value='$chk_bankdeposit[$i]'   onchange=setaccountno(this.value,'chk_bankdeposit[$i]','chk_bankdepositname[$i]','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',1)   onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:85px;'></span>";
			echo"&nbsp;<label><span class='style11'><img src='img/openlist.png' title=' Select Ledger ' id='salesjvdtimg[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('chk_bankdeposit','chk_bankdeposit[$i]','chk_bankdepositname[$i]','800','500')\"   /></span></label>";
			echo"</td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown    readonly  class='roundedtext_amortization_medium'   name='chk_bankdepositname[$i]'   id='chk_bankdepositname[$i]' value='$chk_bankdepositname[$i]'   onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:140px;'></span></td>";
			
			echo"<td ><span class='style4'><input type='text'  $KeyDown        class='".$ClassI." date'   style='width:80px;border-width:0px;background-color:$bgcolor'     name='chk_depositvaluedate[$i]'   id='chk_depositvaluedate[$i]' value='$chk_depositvaluedate[$i]'    onchange=\"SetModRecord('ModRec_G1','$i');\" ></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown        class='".$ClassI." date'   style='width:80px;border-width:0px;background-color:$bgcolor'  name='chk_date[$i]'   id='chk_date[$i]' value='$chk_date[$i]'   onchange=\"SetModRecord('ModRec_G1','$i');\" ></span></td>";
			
			$chk1='';
			$chk2='';
			
			if (strtoupper($chk_status[$i])=='C')
				 $chk1 = ' selected ';
			else 	
			if (strtoupper($chk_status[$i])=='R')
				 $chk2 = ' selected ';
				
			echo"<td ><span class='style4'>
			<select  $KeyDown    name='chk_status[$i]'   id='chk_status[$i]' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:50px;'>
			<option value='c' $chk1>C</option>
			<option value='r' $chk2>R</option>
			</select>
			</span></td>";
	
	
			$querycurrency="select Currency_code from currency order by currency_code";
			$resultcurrency=mysql_query($querycurrency,$connection) or die(mysql_error());

			echo" <td ><span class='style11'><select  $KeyDown    name='chk_commissioncur[$i]' id='chk_commissioncur[$i]'   style='width:50px' onchange=\"SetModRecord('ModRec_G1','$i');\" >";
				echo"<option></option>";
				while($curf=mysql_fetch_row($resultcurrency)){
				echo"<option ";
					if ($chk_commissioncur[$i]==$curf[0])
						echo " selected ";
					echo" value='$curf[0]'>$curf[0] </option>";
					}
				echo"</select></span></td>";	
			
			echo"<td ><span class='style4'><input type='text'  $KeyDown      class='roundedtext_amortization_medium'   name='chk_commission[$i]'   id='chk_commission[$i]' value='$chk_commission[$i]' onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:70px;'></span></td>";
			echo"<td ><span class='style4'><input type='text'  $KeyDown      class='roundedtext_amortization_small'   name='chk_commissionacc[$i]'   id='chk_commissionacc[$i]' value='$chk_commissionacc[$i]'     onchange=setaccountno(this.value,'chk_commissionacc[$i]','','salesjv','salesjvdtimg[$i]','salesjvdtimg1[$i]',1)  onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:90px;'></span>";
			
			echo"&nbsp;<label><span class='style11'><img src='img/openlist.png' title=' Select Ledger ' id='salesjvdtimg[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('chk_commissionacc','chk_commissionacc[$i]','','800','500')\"   /></span></label>";
			echo"</td>";
			
		if ($debit_ledgernumber[$i]!='')
			$stat = 'readonly';
		else	
			$stat = '';
			
			echo"<td ><span class='style4'><input type='text'  $KeyDown    $stat  class='roundedtext_amortization_small'   name='debit_ledgernumber[$i]'   id='debit_ledgernumber[$i]' value='$debit_ledgernumber[$i]'    onchange=setaccountno(this.value,'debit_ledgernumber[$i]','','salesjv','dbeditledgerimg[$i]','dbeditledgerimg1[$i]',1)   onchange=\"SetModRecord('ModRec_G1','$i');\" style='width:90px;'></span>";
			echo"&nbsp;<label><span class='style11'><img src='img/openlist.png' title=' Select Ledger ' id='dbeditledgerimg[$i]' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('debit_ledgernumber','debit_ledgernumber[$i]','','800','500')\"   /></span></label>";
			echo"</td>";
			
			echo"<td><img src='img/confirm-1.png' onmouseover=\"style.cursor='pointer'\" name='' id='imgSubmitChecksCollection[$i]' title='Save' onclick=\"submitChecks('$autoinc[$i]','$i','e','$filepath')\"></td>";
			echo"</tr>";
			
			
			$i+=1;
}
	
		
	
	echo"</table></div></div>";
	

	

}





?>