<?php

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


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


//Read From 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 ,Module_TransferRequestPrice 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);
}

$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
			From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


	if ($transferrequest_id!='')
	{		
$query="select Transferrequest_WarehouseTo from transferrequest where transferrequest_id = ".$transferrequest_id;
$result=mysql_query($query) or die(mysql_error());
$resultcheckwarehouse=mysql_fetch_array($result);
$previousWarehouse = $resultcheckwarehouse[0];
//fecho $previousWarehouse;
}	
	


$querylog="SELECT Fi_TransferRequest as loginaccess,ifNull(Login_negativeQty,0) As Login_negativeQty,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);
	}

if ($loginaccess=='' or $loginaccess==0 or ($TransType!='Tr' and $TransType!='Rm'))
	header("location:menu.php");
	


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

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


//FI_ProductionDel  FI_TransferMod FI_TransferApp
$querylog=" select ifNull(FI_TransferRequest,0) As FI_TransferRequest ,login_belongstogrp ,ifNull(Fi_Transferapp,0) As FI_TransferIns,ifNull(Fi_RmTransferapp,0) As FI_RmTransferIns, 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);
}

$TrInsMode = '';

if ($FI_TransferIns == 0 and $TransType=='Tr')
	$TrInsMode = ' disabled ';
else
if ($FI_RmTransferIns == 0 and $TransType=='Rm')
	$TrInsMode = ' disabled ';

	
$query="SELECT costcent_code,costcent_name FROM costcent order by costcent_code";
$costcenterresult=mysql_query($query,$connection) or die(mysql_error());



// default project
$query="select project_code from ".$_SESSION['dbLabel'].".loginstk 
where default_project = 1 
and user_account='".$_SESSION['useraccount']."'";
//echo $query;
$defaultproject=mysql_query($query,$connection) or die(mysql_error());
$rows = mysql_fetch_row($defaultproject);
				
							$defaultprojectcode = $rows[0];
							
							if ($fromproject=='' && $Module_Project == 1)
								$fromproject = $defaultprojectcode;

$sqlproject = "select project_code,project_name
									from project
									where project_code in 
			(select project_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."')
									";
							$resultdefaultproject=mysql_query($sqlproject,$connection) or die(mysql_error());
						//	echo $sqlproject;
$sqlproject1 = "select project_code,project_name
									from project
									where project_code in 
			(select project_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."')
									";
			
		if(mysql_num_rows($resultdefaultproject)=="0")
			{
				$sqlproject = "select project_code,project_name
									from project
									";							
				$sqlproject1 = "select project_code,project_name
									from project
									";	
			}									
			else
			if (($edit=='yes' or sref!='') and $fromprojectedit!='')
			{
				$sqlproject = "select '".$fromprojectedit."' , '".$fromprojectnameedit."' from dual union " . $sqlproject;
				$sqlproject1 = "select '".$toprojectedit."' , '".$toprojectnameedit."' from dual union " . $sqlproject1;
			
			}
			//echo $sqlproject;
			$sqlproject = $sqlproject . " order by project_code ";
			$sqlproject1 = $sqlproject1 . " order by project_code ";
$projectresultfrom=mysql_query($sqlproject,$connection) or die(mysql_error());
$projectresultto=mysql_query($sqlproject1,$connection) or die(mysql_error());





//warehouse
$query="select warehouse_code from ".$_SESSION['dbLabel'].".loginstk where default_warehouse = 1 
and user_account='".$_SESSION['useraccount']."'";
//echo $query; exit;
							$defaultwarehouse=mysql_query($query,$connection) or die(mysql_error());
							$rows = mysql_fetch_row($defaultwarehouse);
							$defaultwarehousecode = $rows[0];
							
							//echo $actionmode;
							if ($fromwarehouse=='' and $actionmode!='view')
							$fromwarehouse = $defaultwarehousecode;
			

			$sql = "select warehouse_code,warehouse_name
									from warehouse
									where warehouse_code in (select warehouse_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."')
									";
							$resultdefaultwarehouse=mysql_query($sql,$connection) or die(mysql_error());
							//echo $sql;
							
			$sql1 = "select warehouse_code,warehouse_name
									from warehouse
									where warehouse_code in (select warehouse_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."')
									";
							$resultdefaultwarehouse=mysql_query($sql,$connection) or die(mysql_error());
							
			if(mysql_num_rows($resultdefaultwarehouse)=="0")
			{
				$sql = "select warehouse_code,warehouse_name
									from warehouse";
				$sql1 = "select warehouse_code,warehouse_name
									from warehouse";
															
			}	
			else
			if (($edit=='yes' or sref!='') and $fromwarehouseedit!='')
			{
				$sql = "select '".$fromwarehouseedit."' , '".$fromwarehousenameedit."' from dual union " . $sql;
				$sql1 = "select '".$towarehouseedit."' , '".$towarehousenameedit."' from dual union " . $sql1;
			
			}
			//$resultdefaultwarehouse=mysql_query($sql,$connection) or die(mysql_error());
				//$fromwarehouseedit		
			//echo $sql."<br>";
			//echo $sql1;
			//exit;
			$sql = $sql . " order by warehouse_code ";
			$sql1 = $sql1 . " order by warehouse_code ";

$warehouseresultfrom=mysql_query($sql,$connection) or die(mysql_error());
$warehouseresultto=mysql_query($sql1,$connection) or die(mysql_error());
// end of warehouse

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

if (empty($mainaction))
	$mainaction = 'insert';

	
	if ($mainaction=='insert') 
		{
				$query = "select TransferRequest_WarehouseFrom,TransferRequest_WarehouseTo
							from temp_transferRequest
							where 
							transferRequest_id = '".$transferrequest_id."'";
				
				$result=mysql_query($query,$connection) or die(mysql_error());
				$row=mysql_fetch_array($result);
					if ($fromwarehouse=='')
						$fromwarehouse = $row[0];
					if ($towarehouse=='')
						$towarehouse = $row[1];
					
		
		}
	
	
$message = ereg_replace("'"," ",$message);


if (empty($transferrequest_date))	
	$transferrequest_date = displayToday();
	
	//$transfer_date = date();

	/*
	if ($actionmode=='' and $transfer_reference=='')
		$actionmode = 'insert';
	*/	

if ($actionmode == "post" && $transferrequest_id != '')	
	{
		$PreviewButtons = 'disabled';
	}
else
	{
		$PreviewButtons = 'enabled';
	}

if ((($actionmode == "submitrecord" || $actionmode == "edit" || $actionmode == "editdt" || $actionmode == "deletedt" || $actionmode == "post") && $transferrequest_id != '') 
or ($actionmode == "post" && $transferrequest_id != ''))
{
	// Read From Temp Tables For Selected Record				 

		$query = "select Transferrequest_Id,date_format(Transferrequest_Date,'%d/%m/%Y'),Transferrequest_Remark,Project_code1,Project_code2,Costcenter_Code
					,Driver_Name,Vehicle_No,Transferrequest_WarehouseFrom,Transferrequest_WarehouseTo,transferrequest_reference,ToCostcenter_Code,Document_RefNo
					from temp_transferrequest
					where 
					transferrequest_id = ".$transferrequest_id;
					
		if ($actionmode == "post" && $transferrequest_id != '')			
			{
					$query = "select Transferrequest_Id,date_format(Transferrequest_Date,'%d/%m/%Y'),Transferrequest_Remark,Project_code1,Project_code2,Costcenter_Code,
					Driver_Name,Vehicle_No,Transferrequest_WarehouseFrom,Transferrequest_WarehouseTo,transferrequest_reference,ToCostcenter_Code,Document_RefNo
					from transferrequest
					where 
					transferrequest_id = ".$transferrequest_id;
			}
			//echo $query;	exit;		
		$result=mysql_query($query,$connection) or die(mysql_error());
		$rows=mysql_fetch_array($result);
			$transferrequest_date = $rows[1];
			$fromproject = $rows[3];
			$toproject = $rows[4];
			$costcent = $rows[5];
			$tocostcent = $rows[11];
			$documentrefno = $rows[12];
			
			$fromwarehouse = $rows[8];
			$towarehouse = $rows[9];
			$driver_name = $rows[6];
			$vehicle_no = $rows[7];
			$transferrequest_remark = $rows[2];
			$transferrequest_reference = $rows[10];
		
		}

//Search/Cancel Mode	


if ($actionmode == "cancel" && $transferrequest_id != '') {
	
		
	
	$query = " DELETE FROM Temp_TransferrequestDt ".
			 " WHERE transferrequest_id = ".$transferrequest_id;
	if (!updateData($connection, $query, true))
      $message  = mysql_error(); 
	  
	
	  
	$query = " DELETE FROM Temp_transferrequest ".
			 " WHERE transferrequest_id = ".$transferrequest_id;
	if (!updateData($connection, $query, true))
      $message  = mysql_error();   

	$transferrequest_id = '';
}








$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,
			 save, cancel, clear_page, pending, search
	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);
		
	}











print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 


<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">



<script type="text/javascript" language="javascript">


function FillData(prjct,cst){

var x =  document.transferrequest;
if (document.getElementById(prjct).value == '')
	document.getElementById(prjct).value =  x.fromwarehouse.value;
	
if (document.getElementById(cst).value == '')	
	document.getElementById(cst).value = x.towarehouse.value;

}

function showsearchpage1(vtype,vtext1,vtext2,vtext3,vtext4,vtext5,vtext6,vwidth,vheight){

	
	
	
		var text2value = document.getElementById(vtext2).value;
		
		
	win = window.open('List_PurItems.php?PItem_Code=&PItem_Description='+text2value+'&item=6&vtype='+vtype+'&vtext1='+vtext1+'&vtext2='+vtext2+'&vtext3='+vtext3
						+'&vtext4='+vtext4+'&vtext5='+vtext5+'&vtext6='+vtext6
						+'&text1value=', 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	
	}
	
	
function setprojectcode(val,vfield1,btnname){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							document.getElementById(btnname).click();
						}
						

				}
		}
  }

xmlhttp.open("GET","Form_PurchaseRequest_Actions.php?vprojectcode="+val+"&actionmode=checkprojectcode",true);
xmlhttp.send();

}


function setitemcode(val,vfield1,vfield2,vfield3,vfield4,vfield5,vfield6,vgridname,btnname,btnname1,codedesc){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							if (codedesc==1)
								document.getElementById(btnname).click();
							else	
								document.getElementById(btnname1).click();
						}
						else
							{	
								if (codedesc==1)
									document.getElementById(vfield2).value = resp;
								else	
									document.getElementById(vfield1).value = resp;
							}	
						//showsearchpage('itemcode',vfield1,vfield2,vfield3,vfield4,vfield5,vfield6,800,500);

				}
		}
  }


  if (codedesc==1)
	xmlhttp.open("GET","Form_TransferRequest_Actions.php?vitemcode="+val+"&codedesc="+codedesc+"&actionmode=checkitemcode",true);
else	
  if (codedesc==2)
	xmlhttp.open("GET","Form_TransferRequest_Actions.php?vitemdesc="+val+"&codedesc="+codedesc+"&actionmode=checkitemcode",true);  
  
  
xmlhttp.send();

}


function calcTotal(vprice,vqty,indx){


var vprice = document.getElementById(vprice).value;


var vqty = document.getElementById(vqty).value;

var vamount = 'amount['+indx+']';

if (vprice=='')
	vprice = 0;
	
if (vqty=='')
	vqty = 0;
	
document.getElementById(vamount).value  = parseInt(vprice) * parseInt(vqty);


}

function showlistCostcenter(vtype,vtext1,vwidth,vheight,item){
  	var text1value = document.getElementById(vtext1).value;
	
	if (item=='')
		item = 2;
	win = window.open('List_Costcenter.php?PCostcent_Code='+text1value+'&item='+item+'&vtype='+vtype+'&vtext1='+vtext1
						+'&text1value='+text1value, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	

	
}




function setcostcentercode(val,vfield1,btnname){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							document.getElementById(btnname).click();
						}
						
						//showsearchpage('itemcode',vfield1,vfield2,vfield3,vfield4,vfield5,vfield6,800,500);

				}
		}
  }

xmlhttp.open("GET","Form_PurchaseRequest_Actions.php?vcostcentercode="+val+"&actionmode=checkcostcentercode",true);
xmlhttp.send();

}

function clearprequestdt(vrec,VPurchaseTTC,Module_DoubleUnit){


var p_item_code = 'p_item_code['+vrec+']';
var p_item_description = 'p_item_description['+vrec+']';
var p_item_quantity = 'p_item_quantity['+vrec+']';
var Item_Unit2Qty = 'Item_Unit2Qty['+vrec+']';
var p_item_sellingprice1 = 'p_item_sellingprice1['+vrec+']';
var fromwarehouse = 'fromwarehouse['+vrec+']';
var towarehouse = 'towarehouse['+vrec+']';
var p_transferdt_remark = 'p_transferdt_remark['+vrec+']';
var Item_UnitSalesDesc = 'Item_UnitSalesDesc['+vrec+']';
var Item_UnitPurchaseDesc = 'Item_UnitPurchaseDesc['+vrec+']';



document.getElementById(p_item_code).value='';
document.getElementById(p_item_description).value='';
document.getElementById(p_item_quantity).value='';
document.getElementById(Item_Unit2Qty).value='';
document.getElementById(p_item_sellingprice1).value='';
document.getElementById(fromwarehouse).value='';
document.getElementById(towarehouse).value='';
document.getElementById(p_transferdt_remark).value='';
document.getElementById(Item_UnitSalesDesc).value='';
document.getElementById(Item_UnitPurchaseDesc).value='';

}

function submitTransReqDt(TrqstDtId,TrqstId,vrec,vmode,VPurchaseTTC,FIPurchaseCategory,filepath){


var STrqstDtId = TrqstDtId;

	if (vmode=='i')
			{		 
				var vactionmode = 'submitprqstdt';
				var actionmoded = 'i';
			}	
	else {
				var vactionmode = 'editdt';	
				var actionmoded = 'e';
		}
						

var p_item_code = 'p_item_code['+vrec+']';
var p_item_quantity = 'p_item_quantity['+vrec+']';

var p_item_sellingprice1 = 'p_item_sellingprice1['+vrec+']';

var fromwarehouse = 'fromwarehouse['+vrec+']';
var towarehouse = 'towarehouse['+vrec+']';

var p_transferdt_remark = 'p_transferdt_remark['+vrec+']';
var Item_Unit2Qty = 'Item_Unit2Qty['+vrec+']';

var p_transferdt_batchno 	 = 'p_transferdt_batchno['+vrec+']'; 
var p_transferdt_packagingno = 'p_transferdt_packagingno['+vrec+']';
var p_transferdt_nbrunit  	 = 'p_transferdt_nbrunit['+vrec+']';
var p_transferdt_heatno  	 = 'p_transferdt_heatno['+vrec+']';

if (document.getElementById(p_item_sellingprice1).value=='')
	document.getElementById(p_item_sellingprice1).value = '0';
	
var value1 = encodeURIComponent(document.getElementById(p_item_code).value);
var value2 = document.getElementById(p_item_quantity).value;
var value3 = document.getElementById(p_item_sellingprice1).value;
var value4 = document.getElementById(fromwarehouse).value;
var value5 = document.getElementById(towarehouse).value;
var value6 = document.getElementById(p_transferdt_remark).value;
var value17 = document.getElementById(Item_Unit2Qty).value;;

var value19 = document.getElementById(p_transferdt_batchno).value;;
var value20 = document.getElementById(p_transferdt_packagingno).value;;
var value21 = document.getElementById(p_transferdt_nbrunit).value;;

if(document.getElementById(p_transferdt_heatno))
	var value22 = document.getElementById(p_transferdt_heatno).value;
else var value22 = '';

var x =  document.transferrequest;
var value7 = x.transferrequest_date.value;
var value8 = x.fromproject.value;
var value9 = x.costcent.value;
var value10 = x.documentrefno.value;
var value11 = x.toproject.value;
var value12 = x.tocostcent.value;
var value13 = x.fromwarehouse.value;
var value14 = x.towarehouse.value;
var value15 = x.driver_name.value;
var value16 = x.transferrequest_remark.value;
var value18 = x.vehicle_no.value;


		
		

if (value7=='')
{
			alert("Date is mandatory!");
			x.transferrequest_date.focus();
			return 0;
}
	
	
	
	
if (document.getElementById(p_item_code).value=='')
{
			alert("Item is mandatory!");
			document.getElementById(p_item_code).focus();
return 0;
}

if (document.getElementById(p_item_quantity).value=='')
{
			alert("Quantity is mandatory!");
			document.getElementById(p_item_quantity).focus();
return 0;
}
/*
if (document.getElementById(p_item_sellingprice1).value=='')
{
			alert("Price is mandatory!");
			document.getElementById(p_item_sellingprice1).focus();
return 0;
}
*/





var trqstsid = document.getElementById('transferrequest_id').value;
$("#Loader").addClass("ajaxsaving");

	var SubBtnID = 'imgSubmitPTransReqDt['+vrec+']';
	var SubBtnObj = document.getElementById(SubBtnID);
	$(SubBtnObj).unbind('click');
	$(SubBtnObj).removeAttr("onclick");	

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  

  
xmlhttp.onreadystatechange=function()
  {  
    
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 		  
					if (vmode=='i')
						{  
					
							var data = xmlhttp.responseText.split("[BRK]");
							
							document.getElementById('transferrequest_id').value = data[1];
							document.getElementById('testdatagrid').innerHTML = data[0];
							
							
					
						//document.transferrequest.mainaction.value='edit';
						document.transferrequest.actionmode.value='edit';
					
						if (trqstsid==''){				
								document.transferrequest.action='Form_TransferRequest.php';				
								document.transferrequest.submit();
								
										}
										else {
										
										ReloadGrid(filepath,'TRQ',trqstsid,'datagrid','','','ADD','','','','',0,'',function() {
											var focusedvrec = parseInt(vrec) + 1;
											var focused = 'p_item_code['+focusedvrec+']';
											document.getElementById(focused).focus();
										});
										$("#Loader").removeClass("ajaxloading");
										//ReloadGridDt(filepath,'TRQ-totals','totalsdatagrid','totalsdatagrid',trqstsid,-1);
										//$("#Loader").removeClass("ajaxsaving");
										
										}
					
						}	
					else {
					
							
						
							document.getElementById('testdatagrid').innerHTML =  xmlhttp.responseText;
							
							 
							ReloadGrid(filepath,'TRQ',trqstsid,'datagrid','','','ADD','','','','',0,'',function() {
											var focusedvrec = parseInt(vrec) + 1;
											var focused = 'p_item_code['+focusedvrec+']';
											document.getElementById(focused).focus();
										});
							//ReloadGridDt(filepath,'TRQ-totals','totalsdatagrid','totalsdatagrid',trqstsid,-1);
										$("#Loader").removeClass("ajaxloading");
						
						}						
					
					
									
					
					
									
				}
		}
  }


xmlhttp.open("GET","Form_TransferRequest_Actions.php?vmode="+vmode+"&value1="+value1+"&value2="+value2+"&value3="+value3
											+"&value4="+value4+"&value5="+value5+"&value6="+value6+"&value7="+value7+"&value8="+value8+"&value9="+value9
											+"&value10="+value10+"&value11="+value11+"&value12="+value12+"&value13="+value13
											+"&value14="+value14+"&value15="+value15+"&value16="+value16+"&value17="+value17+"&value18="+value18+"&TrqstId="+trqstsid
											+"&STrqstDtId="+STrqstDtId+"&transferrequestdt_id="+STrqstDtId+"&STrqstDtBatchno="+value19+"&STrqstDtPackagingno="+value20
											+"&STrqstDtNbrunit="+value21+"&STrqstDtHeatno="+value22
											+"&transferrequest_id="+trqstsid+"&actionmode="+vactionmode+"&actionmoded="+actionmoded,true);

xmlhttp.send();

    
 }

function deletetrequestsdt(trqstid,trqstdtid, ItemPackCode, ItemCode,filepath){


var x =  document.transferrequest;
		var value7 = x.transferrequest_date.value;
		var value8 = x.fromproject.value;
		var value9 = x.costcent.value;
		var value10 = x.documentrefno.value;
		var value11 = x.toproject.value;
		var value12 = x.tocostcent.value;
		var value13 = x.fromwarehouse.value;
		var value14 = x.towarehouse.value;
		var value15 = x.driver_name.value;
		var value16 = x.transferrequest_remark.value;
		var value18 = x.vehicle_no.value;
		
		
if (ItemPackCode != '')
	   vDelMsg = "Are you sure you want to Delete Pack Item "+ItemPackCode+" ?";
	else  
	   vDelMsg = "Are you sure you want to Delete Item "+ItemCode+" ?";
	   
	   
   
if (confirm ( vDelMsg ))
	{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 
							//document.getElementById('testdatagrid').innerHTML = xmlhttp.responseText;
							var data = xmlhttp.responseText.split('[BRK]');
							document.getElementById('testdatagrid').innerHTML = data[0];
								
							ReloadGrid(filepath,'TRQ',trqstid,'datagrid','','','ADD','','','','',0,'',function() {
								document.getElementById('SelectedRec').value='';		});
							$("#Loader").removeClass("ajaxloading");
														
				}
		}
  }

xmlhttp.open("GET","Form_TransferRequest_Actions.php?trqstid="+trqstid+"&actionmoded=d&transferrequestdt_id="+trqstdtid
				+"&value7="+value7+"&value8="+value8+"&value9="+value9
											+"&value10="+value10+"&value11="+value11
											+"&value12="+value12+"&value13="+value13
											+"&value14="+value14+"&value15="+value15
											+"&value16="+value16+"&value18="+value18
											+"&transferrequest_id="+trqstid
				,true);
xmlhttp.send();

}
}
	
	
function changeqty2(vnum,vitemunit,moduleunit1,indx){

itemunit = 'Item_Unit[' + indx + ']';
itemunit =document.getElementById(itemunit).value;
var itemunit2qty = 'Item_Unit2Qty[' + indx + ']';


var p_item_quantity = 'p_item_quantity[' + indx + ']';




if (vnum==1)
	{ 
	
if (document.getElementById(itemunit2qty).value!='')
return;
		
			if (moduleunit1==1 && itemunit !='')
					{
					var itemqty = document.getElementById(p_item_quantity).value;
					var xx = Number(itemqty) * Number(itemunit);

					document.getElementById(itemunit2qty).value = xx;
					}
			else {
				if (moduleunit1==0 && itemunit !='')
						{
							var itemqty = document.getElementById(p_item_quantity).value;
							var xx = Number(itemqty) / Number(itemunit);
							document.getElementById(itemunit2qty).value = xx;
						}
				}
	}
else {
if (document.getElementById(p_item_quantity).value!='')
return;
			if (moduleunit1==1 && itemunit !='')
					{
					var itemqty = document.getElementById(itemunit2qty).value;
					var xx = Number(itemqty) / Number(itemunit);

					document.getElementById(p_item_quantity).value = xx;
					}
			else {
				if (moduleunit1==0 && itemunit !='')
						{
							var itemqty = document.getElementById(itemunit2qty).value;
							var xx = Number(itemqty) * Number(itemunit);
							document.getElementById(p_item_quantity).value = xx;
						}
				}
	}

}

function showsearchpage(vtype,vtext1,vtext2,vtext3,vtext4,vtext5,vtext6,vtext7,vwidth,vheight){

	var text1value = document.getElementById(vtext1).value;
	if(document.getElementById("fromwarehouse"))
		var fromwh = document.getElementById("fromwarehouse").value;
	else var fromwh = '';
	
	var transferrequest_date = document.transferrequest.transferrequest_date.value;
	
	if (document.getElementById(vtext2))
		var text2value = document.getElementById(vtext2).value;
else
		var text2value = '';
		
		
	win = window.open('List_PurItems.php?PItem_Code='+text1value+'&PItem_Description=&item=6&transferrequest_date='+transferrequest_date+'&vtype='+vtype+'&vtext1='+vtext1+'&vtext2='+vtext2+'&vtext3='+vtext3
						+'&vtext4='+vtext4+'&vtext5='+vtext5+'&vtext6='+vtext6+'&vtext7='+vtext7
						+'&text1value='+text1value+'&fromwh='+fromwh, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	
	}
	
	
function dokeytransferrequest(e,obj,rowindx,columnslist,vbutname){





	//if (e.ctrlKey == false)
	//return;
	var vindx = rowindx;
	if (!e) { var e = window.Events;}
    var intKey = (window.Events) ? e.which : e.keyCode;


	var columnsarray=new Array();
	columnsarray = columnslist.split(",");
	var firstcell = columnsarray[0];
	var lastcell  = columnsarray[columnsarray.length-1];
	var arrayname = obj.id.split("[");

	if (( ((intKey == 37) || (intKey == 39)) && e.ctrlKey )  ||  (intKey == 13))
	{
		var cindx = columnsarray.indexOf(arrayname[0]);
		
		if (intKey == 37) { //left key
			var nextindx = Number(cindx) - 1;
		}
		if (intKey == 13 || intKey == 39) { //right key
			var nextindx = Number(cindx) + 1;
		}


		var nextitem = columnsarray[nextindx] + '[' + rowindx + ']' ;

		
		if (document.getElementById(nextitem)) {
			var nextobj = document.getElementById(nextitem);
			nextobj.focus();
			if(nextobj.type!='select-one')
			nextobj.select();
		}
		else { 
			var nextrow  = rowindx + 1;
			var nextcell = firstcell + '[' +  nextrow + ']';
				
			var imgname = 'imgSubmit' + vbutname + '[' +  rowindx + ']';
			
			document.getElementById(imgname).click();
			
			if (document.getElementById(nextcell) ) {
				document.getElementById(nextcell).focus();
				if(document.getElementById(nextcell).type!='select-one')
				document.getElementById(nextcell).select();
			}	
					
		}	
	}
	else if ( ((intKey == 38) || (intKey == 40)) && e.ctrlKey) {
		
		if (intKey == 38) 
			rowindx = rowindx - 1;
		if (intKey == 40) 
			rowindx = rowindx + 1;
			
		var nextitem =  arrayname[0] + '[' + rowindx + ']';
		if (document.getElementById(nextitem)) {
			var nextobj = document.getElementById(nextitem);
			nextobj.focus();
			if(nextobj.type!='select-one')
			nextobj.select();
		}	
	}

}

function SearchForPending(TransType){
    ClearForm('All');

    win = window.open('Form_TransferRequestSearchPending.php?TransType='+TransType, 'Form_TransferRequestSearchPending', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1030,height=450,top=100');		
	
	win.creator = self;
	win.focus();		
			
}




function CancelRecord(){
	x = document.transferrequest;
	var vmode1 = x.actionmode.value;
	var TRId = x.transferrequest_id.value;
	
	if (confirm ( "Are you sure you want to Delete current pending transfer request permenantly?"))
	{
		ClearForm('All');
		x.transferrequest_id.value = TRId;
		x.actionmode.value='cancel';
		var TransType = x.TransType.value;
		x.action='Form_TransferRequest.php?TransType='+TransType;
		x.submit();
	
	Form_TransferRequestSearchPending.close();
	Form_TransferRequestSearch.close();
	Loading.close();
	Item.close();
	Serial.close();
	mywindow.close();
	Form_TransferRequestSearchPending.close();
	
	}
    
}



function SearchForRef(){
    
	ClearForm('All');
    x = document.transferrequest;
	var TransType = x.TransType.value;
    win = window.open('Form_TransferRequestSearch.php?TransType='+TransType, 'Form_TransferRequestSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=860,height=460,top=100');		
	win.creator = self;
	win.focus();		
			
}


function ClearForm(Option){
    x = document.transferrequest;
	var vmode = x.actionmode.value;
	
	if (Option == 'All') {
		
		x.transferrequest_date.value='';
		x.transferrequest_id.value='';
		x.transferrequest_reference.value='';
		x.fromproject.value='';
		x.toproject.value='';
		x.fromwarehouse.value='';
		x.towarehouse.value='';
		x.costcent.value='';
		x.tocostcent.value='';
		x.driver_name.value='';
		x.vehicle_no.value='';
		x.transferrequest_remark.value='';
		x.documentrefno.value='';
		
		
		
		x.message.value='';
		x.actionmode.value = '';
		} 
}





function ClearPage(){
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		x = document.transferrequest;
		x.actionmode.value='';
		var TransType = x.TransType.value;
		x.action='Form_TransferRequest.php?TransType='+TransType;
		x.submit();
	}	
}

function ClearPage1(){
	x = document.transferrequest;
	var msg = x.message.value;
	
	ClearForm('All');
	
	//x.actionmode.value='insert';
	var TransType = x.TransType.value;
	x.message.value=msg;
	x.action='Form_TransferRequest.php?TransType='+TransType;
	x.submit();
}

function PrintTransfer(TrId,TrRef) {
	var str = '';
	var Vdetail=0;
	var TransType = document.transferrequest.TransType.value;
	//alert(TransType);
	
	//if (confirm ( "Do you want to Print Transfer Request Ref "+TrRef+"?"))
	if (TransType!='Tr')
	if (confirm ( "Do you want to Print with detail?"))
	{
		Vdetail = 1;	
	}
	if (TransType=='Tr')
		Vdetail = 1;	
		str= 'Form_TransferRequestPreview.php?transferrequest_id='+TrId+'&TransType='+TransType+'&detail='+Vdetail;
		window.open(str);
	
//ClearPage1();	
}



function PostChanges(ModuleProject, ModuleCostCenter, Module_RestrictProjCost, Module_RestrictCost){
	var costcent= document.transferrequest.costcent.value;
	var tocostcent= document.transferrequest.tocostcent.value;
	var fromwarehouse= document.transferrequest.fromwarehouse.value;
	var towarehouse= document.transferrequest.towarehouse.value;
	var toproject = document.transferrequest.toproject.value;
	var fromproject = document.transferrequest.fromproject.value;
	var actionmode = document.transferrequest.actionmode.value;
	var transferrequest_id = document.transferrequest.transferrequest_id.value;
	var transferrequest_remark = document.transferrequest.transferrequest_remark.value;
	var transferrequest_date = document.transferrequest.transferrequest_date.value;
	var driver_name = document.transferrequest.driver_name.value;
	var vehicle_no = document.transferrequest.vehicle_no.value;
	var TransType = document.transferrequest.TransType.value;
	var documentrefno = document.transferrequest.documentrefno.value;
	var actionmoded = 'mi';
	var result = CheckFields(ModuleProject, ModuleCostCenter,Module_RestrictProjCost,Module_RestrictCost);
	fromwarehouse = fromwarehouse.replace('&','%26');
	towarehouse = towarehouse.replace('&','%26');
	

	if ( ((actionmode=='edit') ))
	   {
		if (result==1)
		if (confirm ( "Are you sure you want to Save current Transfer Request?"))
		{
		document.transferrequest.actionmode.value='post';
		document.transferrequest.action= 'Form_TransferRequest_Actions.php?fromproject='+fromproject+'&toproject='+toproject+'&fromwarehouse='+fromwarehouse+'&towarehouse='+towarehouse+'&actionmoded='+actionmoded+'&transferrequest_id='+transferrequest_id+'&transferrequest_remark='+transferrequest_remark+'&transferrequest_date='+transferrequest_date+'&drivername='+driver_name+'&documentrefno='+documentrefno+'&vehicle_no='+vehicle_no+'&costcent='+costcent+'&tocostcent='+tocostcent+'&TransType='+TransType;
		document.transferrequest.submit();
		}
	   }
		
}


function UpdateTrDt(item_withserial,transferdt_id,fromwarehouse,towarehouse){
	var costcent= document.transferrequest.costcent.value;
	var tocostcent= document.transferrequest.tocostcent.value;
	
	
	var toproject = document.transferrequest.toproject.value;
	var fromproject = document.transferrequest.fromproject.value;
	var actionmode = document.transferrequest.actionmode.value;
	var transferrequest_id = document.transferrequest.transferrequest_id.value;
	var transferrequest_remark = document.transferrequest.transferrequest_remark.value;
	var transferrequest_date = document.transferrequest.transferrequest_date.value;
	var driver_name = document.transferrequest.driver_name.value;
	var vehicle_no = document.transferrequest.vehicle_no.value;
	var transit = document.transferrequest.transit.value;
	var TransType = document.transferrequest.TransType.value;	
	var actionmoded = 'e';
	
	fromwarehouse = fromwarehouse.replace('&','%26');
	towarehouse = towarehouse.replace('&','%26');
	str1= 'Form_TransferItems.php?item=1&fromwarehouse='+fromwarehouse+'&towarehouse='+towarehouse+'&fromproject='+fromproject+'&toproject='+toproject+'&actionmode='+actionmode+'&transferrequest_id='+transferrequest_id+'&transferrequest_remark='+transferrequest_remark+'&transferrequest_date='+transferrequest_date+'&driver_name='+driver_name+'&vehicle_no='+vehicle_no+'&costcent='+costcent+'&transferrequestdt_id='+transferrequestdt_id+'&actionmoded='+actionmoded+'&item_withserial='+item_withserial+'&transit='+transit+'&tocostcent='+tocostcent+'&TransType='+TransType;
	
	width = screen.width - 250;
	height = screen.height - 350;
	
	window.open(str1,"Item", "width=" + width + ",height=" + height + ",screenX=0,left=150,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");


}
function DeleteTrDt(item_withserial,transferdt_id){
	var costcent= document.transferrequest.costcent.value;
	var tocostcent= document.transferrequest.tocostcent.value;
	var fromwarehouse= document.transferrequest.fromwarehouse.value;
	var towarehouse= document.transferrequest.towarehouse.value;
	var toproject = document.transferrequest.toproject.value;
	var fromproject = document.transferrequest.fromproject.value;
	var actionmode = document.transferrequest.actionmode.value;
	var transferrequest_id = document.transferrequest.transferrequest_id.value;
	var transferrequest_remark = document.transferrequest.transferrequest_remark.value;
	var transferrequest_date = document.transferrequest.transferrequest_date.value;
	var driver_name = document.transferrequest.driver_name.value;
	var vehicle_no = document.transferrequest.vehicle_no.value;
	var TransType = document.transferrequest.TransType.value;
	var documentrefno = document.transferrequest.documentrefno.value;
	var actionmoded = 'd';
	fromwarehouse = fromwarehouse.replace('&','%26');
	towarehouse = towarehouse.replace('&','%26');
	
	if (confirm ( "Are you sure you want to Delete current Item?"))
	{
	document.transferrequest.action= 'Form_Transferrequest_Actions.php?fromproject='+fromproject+'&toproject='+toproject+'&fromwarehouse='+fromwarehouse+'&towarehouse='+towarehouse+'&actionmode='+actionmode+'&transferrequest_id='+transferrequest_id+'&transferrequest_remark='+transferrequest_remark+'&transferrequest_date='+transferrequest_date+'&drivername='+driver_name+'&documentrefno='+documentrefno+'&vehicle_no='+vehicle_no+'&costcent='+costcent+'&actionmoded='+actionmoded+'&transferdt_id='+transferdt_id+'&item_withserial='+item_withserial+'&tocostcent='+tocostcent+'&TransType='+TransType;
	document.transferrequest.submit();
	}
}
function resubmit(){

document.transferrequest.submit();
}




function openitempage(TransType){
	var costcent= document.transferrequest.costcent.value;
	var tocostcent= document.transferrequest.tocostcent.value;
	var fromwarehouse= document.transferrequest.fromwarehouse.value;
	var towarehouse= document.transferrequest.towarehouse.value;
	var toproject = document.transferrequest.toproject.value;
	var fromproject = document.transferrequest.fromproject.value;
	var actionmode = document.transferrequest.actionmode.value;
	var transfer_id = document.transferrequest.transfer_id.value;
	var transfer_remark = document.transferrequest.transfer_remark.value;
	var transfer_date = document.transferrequest.transfer_date.value;
	var driver_name = document.transferrequest.driver_name.value;
	var vehicle_no = document.transferrequest.vehicle_no.value;
var documentrefno = document.transferrequest.documentrefno.value;
	fromwarehouse = fromwarehouse.replace('&','%26');
	towarehouse = towarehouse.replace('&','%26');
	
	
	  str1= 'Form_TransferItems.php?item=1&fromwarehouse='+fromwarehouse+'&towarehouse='+towarehouse+'&fromproject='+fromproject+'&toproject='+toproject+'&actionmode='+actionmode+'&transfer_id='+transfer_id+'&transfer_remark='+transfer_remark+'&transfer_date='+transferrequest_date+'&driver_name='+driver_name+'&documentrefno='+documentrefno+'&vehicle_no='+vehicle_no+'&costcent='+costcent+'&tocostcent='+tocostcent+'&TransType='+TransType;
	  width = screen.width - 100;
	  height = screen.height - 350;
	  window.open(str1,"Items", "width=" + width + ",height=" + height + ",screenX=0,left=250,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
	
}

  
  
function CheckFields(ModuleProject, ModuleCostCenter,Module_RestrictProjCost,Module_RestrictCost){
 x = document.transferrequest;

 var STransDate = x.transferrequest_date.value; 
 var SFromProject = x.fromproject.value;
 var SToProject = x.toproject.value;
 var SFromWarehouse = x.fromwarehouse.value;
 var SToWarehouse = x.towarehouse.value;
 
 var Scostcent = x.costcent.value;
 var SToCostCenter_code = x.tocostcent.value;
 var SModule_TransferWithOneWh = x.Module_TransferWithOneWh.value
 //alert(SModule_TransferWithOneWh);
 if (STransDate=='' )
	{
		alert("Date is mandatory!");
		x.transferrequest_date.focus();
		return 0;
	}
	else if (SFromProject=='' && ModuleProject==1 && Module_RestrictProjCost==1 )
	{
		alert("From Project is mandatory!");
		x.fromproject.focus();
		return 0;
	}
	else if (SToProject==''  && ModuleProject==1  && Module_RestrictProjCost==1 )
	{
		alert("To Project is mandatory!");
		x.toproject.focus();
		return 0;
	}
		else if (Scostcent=='' && ModuleCostCenter==1 && Module_RestrictCost==1)
	{
		alert("From CostCenter is mandatory!");
		x.costcent.focus();
		return 0;
	}
	else if (SToCostCenter_code==''  && ModuleCostCenter==1 && Module_RestrictCost==1)
	{
		alert("To CostCenter is mandatory!");
		x.tocostcent.focus();
		return 0;
	}
	else if (SFromWarehouse=='' && SModule_TransferWithOneWh==1)
	{
		alert("From Warehouse is mandatory!");
		x.fromwarehouse.focus();
		return 0;
	}
		else if (SToWarehouse==''  && SModule_TransferWithOneWh==1)
	{
		alert("To Warehouse is mandatory!");
		x.towarehouse.focus();
		return 0;
	}
	else return 1;
}
/*
function showlistProject(str,prj){
var TransType = document.transferrequest.TransType.value;
window.open('List_TrsProject.php?item='+str+'&Project='+prj+'&TransType='+TransType,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
*/
function showlistProject(vtype,vtext1,vwidth,vheight,item){
  	var text1value = document.getElementById(vtext1).value;
	if (item=='')
		item = 2;
	win = window.open('List_Project.php?PProject_Code='+text1value+'&item='+item+'&vtype='+vtype+'&vtext1='+vtext1
						+'&text1value='+text1value, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	

	
}

function setwarehousecode(val,vfield1,btnname){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							document.getElementById(btnname).click();
						}
						
						//showsearchpage('itemcode',vfield1,vfield2,vfield3,vfield4,vfield5,vfield6,800,500);

				}
		}
  }

xmlhttp.open("GET","Form_TransferRequest_Actions.php?vwarehousecode="+val+"&actionmode=checkwarehousecode",true);
xmlhttp.send();

}


function showlistWarehouse(str,wrh){
var TransType = document.transferrequest.TransType.value;
var text1value = document.getElementById(wrh).value;

  window.open('List_TrsWarehouseGrid.php?item='+str+'&Warehouse='+wrh+'&TransType='+TransType+'&PLedger_number='+text1value,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Transfer Request</title>


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


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

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





<script type="text/javascript" src="dropdown.js"></script>
<script type="text/javascript" language="javascript">
	
	
	$(document).ready(function() { 
		
	if (document.getElementById('p_item_code[1]'))
		document.getElementById('p_item_code[1]').focus();
		
	
		$(document).on('focusin', '.table-focus-g1', function() {
			AutoSaveRecordGrid(this.id,'SelectedRec','ModRec_G1','imgSubmitPTransReqDt');
			selRecordColor(this,'SelectedRec','SelectedRecColor');
		});
		
		//Set Scroll Positions on Page Load
		scrollToPage();
		
		$(window).scroll(function(){
			scrollPage();
		});
		
	
	});


function showlistBatchNo(str,PIndex) {
	x = document.transferrequest;
	
	XPos = (screen.availHeight - 400) / 2;
	YPos = (screen.availWidth - 580) / 2;
	
	vItemCode = encodeURIComponent(document.getElementById('p_item_code['+PIndex+']').value);
	if(x.fromwarehouse) vWarehouseCode = encodeURIComponent(document.getElementById('fromwarehouse').value);
	else if (document.getElementById('fromwarehousedt['+PIndex+']')) vWarehouseCode = encodeURIComponent(document.getElementById('fromwarehousedt['+PIndex+']').value);
	else vWarehouseCode='';
	window.open('List_BatchNo.php?frm=12&index='+PIndex+'&PItem_Code='+vItemCode+'&PWarehouseCode='+vWarehouseCode,'List_BatchNo','width=580,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+YPos+',top='+XPos);
}
	
function setQty(index){
	var pckge   = document.getElementById("p_transferdt_packagingno["+index+"]").value;
	var unitnbr = document.getElementById("p_transferdt_nbrunit["+index+"]").value;
	var qty 	= 0;
	
	if(pckge == '') pckge = 0;
	else pckge = parseFloat(pckge);
	
	if(unitnbr == '') unitnbr = 0;
	else unitnbr = parseFloat(unitnbr);
	
	qty = pckge*unitnbr;
	document.getElementById("p_item_quantity["+index+"]").value = qty;
	
}	


function showlistHeatNo(PIndex) {
	XPos = (screen.availHeight - 550) / 2;
	YPos = (screen.availWidth - 850) / 2;
	
	var vHeatNoCode = encodeURIComponent(document.getElementById('p_transferdt_heatno['+PIndex+']').value);
	
	window.open('List_HeatNo.php?frm=13&index='+PIndex+'&PHeatNoCode='+vHeatNoCode+'&PHeatNo_Type=','List_HeatNo','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,left='+YPos+',top='+XPos);
}
</script>


<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">

<style>



#table1:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	cursor:pointer;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;

}
#table2:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#table3:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#tabledt1:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#tabledt2:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;

}

#tabledt3:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#table5:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#table6:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#table7:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}
#table8:hover {
	background-color:#f2f2f2;
	border:1px solid #E2E2E2;
	-o-transition:.9s;
  -ms-transition:.9s;
  -moz-transition:.9s;
  -webkit-transition:.9s;
  /* ...and now for the proper property */
  transition:.9s;
cursor:pointer;
}

table.sample {
	border-width: 0px;
	border-spacing: 3px;
	border-style: double;
	border-color: gray;
	border-collapse: collapse;
	background-color: white;
}
table.sample th {
	border-width: 1px;
	padding: 0px;
	border-style: solid;
	border-color: #DCDCDC;
	-moz-border-radius: ;
}
table.sample td {
	border-width: 1px;
	padding: 0px;
	border-style: solid;
	border-color: #E5E5E5;
	-moz-border-radius: ;
}


tablesalary.sample {
	border-width: 0px;
	border-spacing: 3px;
	border-style: double;
	border-color: gray;
	border-collapse: collapse;
	background-color: white;
}
tablesalary.sample th {
	border-width: 1px;
	padding: 0px;
	border-style: solid;
	border-color: #DCDCDC;
	-moz-border-radius: ;
}
tablesalary.sample td {
	border-width: 1px;
	padding: 0px;
	border-style: solid;
	border-color: #E5E5E5;
	-moz-border-radius: ;
}


</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

</head>
<body>
<form name='transferrequest' method='post'>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='transferrequest_id' id='transferrequest_id' value='$transferrequest_id'>
<input type='hidden' name='message' value='$message' size='200'>
<input type='hidden' name='login_belongstogrp' value='$login_belongstogrp' size='15'>
<input type='hidden' name='process' value='$process' size='15'>
<input type='hidden' name='previousWarehouse' value='$previousWarehouse' size='15'>
<input type='hidden' name='TransType' value='$TransType' size='15'>
HERE;

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


echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>";
			if ($TransType=='Tr')
				echo"Transfer Request";
			else
			if ($TransType=='Rm')
				echo"Material Issue-Factory Transfer";	
			echo"</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='30'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";
	echo" <button type='button' id='btnClear' name='btnClear' onclick='ClearPage();return false;' title='Clear Page'><span><span>$clear_page</span></span></button>";	
	
echo"<button type='button' id='btnCancel' name='btnCancel' ";
if ($actionmode=='cancel' or $PreviewButtons=='disabled')
					echo " disabled ";
			
echo" onclick='CancelRecord();return false;' title='Cancel Changes'><span><span>$cancel</span></span></button>";	
				
echo"<button type='button' id='btnPost' name='btnPost' ";
		if ((($actionmode=='' || $actionmode=='cancel') && $mainaction!='edit') or $PreviewButtons=='disabled')
					echo " disabled ";
	echo" onclick=\"PostChanges($ModuleProject, $ModuleCostCenter, $Module_RestrictProjCost,$Module_RestrictCost);\" title='Save Changes'><span><span>$save</span></span></button>";	
				

echo"<button type='button' id='btnSearch' name='btnSearch' ";
	if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit') 
		    echo " disabled ";
	echo" onclick='SearchForRef();return false;' title='Search By Reference'><span><span>$search</span></span></button>";

echo"<button type='button' id='btnPending' name='btnPending' ";	

        if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit')
		    echo " disabled ";
	echo" onclick='SearchForPending(\"$TransType\");return false;' title='Pending Transfer Request'><span><span>$pending</span></span></button>";	


if ($actionmode == "post" && $transferrequest_id != '') 
{
	$qry="select transferrequest_reference from transferrequest where transferrequest_id = $transferrequest_id";
	
	$result=mysql_query($qry,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($result)){
				extract($rows);
												}	
		echo" <button type='button' id='btnPrint' name='btnPrint' onclick=PrintTransfer('".$transferrequest_id."','".$transferrequest_reference."');return false; title='Printing Transfer Request'><span><span>Print</span></span></button>";												
				
}

//if ($Module_TransferSorder==1)
//	$type='button';
//	else
//	$type='hidden';

//echo" <button type='button' id='btnSearchSorder' name='btnSearchSorder' onclick='SearchConfirmedSorder($Module_RestrictProjCost, $Module_RestrictCost , $ModuleProject,$ModuleCostCenter,\"$TransType\");' title='Search Confirmed Preparation Order'><span><span>Load Preparation Order</span></span></button>";			
//echo"  &nbsp; <input name='btnSearchSorder' type='$type' id='btnSearchSorder' value='Load Preparation Order' onclick='SearchConfirmedSorder($Module_RestrictProjCost, $Module_RestrictCost , $ModuleProject,$ModuleCostCenter,\"$TransType\");' $style style='width: 180px;' title='Search Confirmed Preparation Order'  ";

                //if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit' )
				 //   echo " disabled ";
				//else
				//			    echo " enabled ";
		//echo " />";	
		
echo"	</td></tr></table>";
echo"</td></tr>";				

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

print <<<HERE
	
		
		<table border="0" style='table-layout:fixed'>	
		 <tr bgcolor="#F7F7F7" height='30'>
          <td width="9%" valign="center" align='left' bgcolor="#F7F7F7">
		  <span class="style1">$Reference&nbsp;<span class="style16">*</span></span></td>
		  <td><font face='Verdana' size='2'><b>&nbsp;$transferrequest_reference</b></font><input type="hidden" name="transferrequest_reference" value="$transferrequest_reference" readonly><input type="hidden" name="journal_id" value="$journal_id" ></td>
		  <td></td>
		  
HERE;
 

 if ($Module_Project == 1) 
		  echo"<td><span class='style1'>$Project&nbsp;</span><span class='style16'>*</span></td>";
 
 if ($Module_CostCenter == 1 && $ShowCostCentLayout == 1)  
	echo"<td><span class='style1'>Costcenter&nbsp;</span><span class='style16'>*</span></td>";
	 if ($Module_TransferWithOneWh==1)
		echo " <td> <span class='style1'>$Warehouse&nbsp;</span><span class='style16'>*</span></td>"; 
print <<<HERE
		  
		</tr>
		<tr  height='30' bgcolor="#F7F7F7"><td width="8%" align="left"><span class="style1">$date_label&nbsp;<span class="style16">*</span></span></td>
		  <td><input type='text'  size='17' name='transferrequest_date'  value='$transferrequest_date' $PreviewButtons maxlength=10>
          <A HREF="#" onClick="displayCalendar(document.transferrequest.transferrequest_date,'dd/mm/yyyy',this); return false;" NAME="anchor1" ID="anchor1" >
HERE;
		  if ($PreviewButtons=='enabled')
		  echo"<image src='./img/cal.gif' border=0 align=center ></image></A>";
echo"		  </td>";

			
		 echo"<td align='left' ><span class='style1'>$from_date</span></span></td>";
		 
		 if ($Module_Project == 1) 
		 echo"<td align='left' > <span class='style1'>
		    <input type='text' name='fromproject'  $PreviewButtons  id='fromproject' value='".htmlentities($fromproject)."'   onchange=setprojectcode(this.value,'fromproject','transfromprojectimg')  size='17' maxlength='20' /></span>
		    <label><span class='style1'><img src='img/scroll-down-1.png' title=' Select Project '  id='transfromprojectimg' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onclick=\"showlistProject('project','fromproject','800','500',3)\"  $PreviewButtons/></span></label></td>";
		else
			echo"<input type='hidden' name='fromproject' readonly $PreviewButtons  id='fromproject' value='".htmlentities($fromproject)."' size='17' maxlength='20' />";
		
		if ($Module_CostCenter == 1 && $ShowCostCentLayout == 1)
			echo"<td><span class='style1'>
		    <input type='text' $PreviewButtons name='costcent'  id='costcent' value='".htmlentities($costcent)."' size='17' maxlength='20' onchange=setcostcentercode(this.value,'costcent','imgcostcenterbtnheader') /></span>
		    <label><span class='style1'><image src='img/scroll-down-1.png' title=' Select Costcenter ' id='imgcostcenterbtnheader' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  
 onclick=\"showlistCostcenter('costcenter','costcent','800','500',3) \"  $PreviewButtons/></span></label></td>		";
		else
			echo"<input type='hidden' name='costcent' id='costcent' readonly $PreviewButtons value='".htmlentities($costcent)."' size='17' maxlength='20' />";
		
		
		if ($Module_TransferWithOneWh == 0){
			echo "<input type='hidden' $PreviewButtons name='fromwarehouse' id='fromwarehouse'  value='".htmlentities($fromwarehouse)."'  >";
			
		} else if ($Module_TransferWithOneWh==1) {
		echo"<td><label><input type='text' $PreviewButtons name='fromwarehouse' id='fromwarehouse'  onchange=\"setwarehousecode(this.value,'fromwarehouse','fromwarehouseimgheader');\" value='".htmlentities($fromwarehouse)."'  >
		<span class='style1'>"; 		
		echo"&nbsp;<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='fromwarehouseimgheader' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"   onclick=\"showlistWarehouse('fromwarehouse','fromwarehouse','800','500') \" 	";

		if ($transferrequest_id!='') 
			echo " disabled ";		
		echo"/></span></label>";
		
		echo"</span></td>";
		  }
		  
		  echo'</tr>
		  <tr  height="30" bgcolor="#F7F7F7"><td width="8%" align="left" ><span class="style1">';
		  if ($TransType=='Rm')
			echo "Doc. Ref No";
		  echo'</span></td>  
';
		  
		  echo"     <td align='left' >";
		  if ($TransType=='Rm')
			echo"<input type='text' name='documentrefno' id='documentrefno' $PreviewButtons value='$documentrefno'>";
			else
			echo"<input type='hidden' name='documentrefno' id='documentrefno' $PreviewButtons value='$documentrefno'>";
		  echo"</td>";
			

		
		echo"<td><span class='style1'>$to_date</span></td>";
		if ($Module_Project == 1) 
		{
			echo"<td><span class='style1'><input type='text' name='toproject'   id='toproject' $PreviewButtons value='".htmlentities($toproject)."' size='17' maxlength='20'   onchange=setprojectcode(this.value,'toproject','transtoprojectimg2')  /></span>";
			echo"</span>&nbsp;<label><span class='style1'><img src='img/scroll-down-1.png' id='transtoprojectimg2' title=' Select Project ' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onclick=\"showlistProject('project','toproject','800','500',3)\"   $PreviewButtons/></span></label></td>";
		}
		else
			echo"<input type='hidden' name='toproject' id='toproject' readonly $PreviewButtons value='".htmlentities($toproject)."' size='17' maxlength='20' />";
		
		
			if ($Module_CostCenter == 1 && $ShowCostCentLayout == 1)
				echo"<td><span class='style1'>
					<input type='text' $PreviewButtons name='tocostcent'  id='tocostcent' value='".htmlentities($tocostcent)."' size='17' maxlength='20'  onchange=setcostcentercode(this.value,'tocostcent','imgcostcenterbtnheader2') /></span>
						<label><span class='style1'><image src='img/scroll-down-1.png' id='imgcostcenterbtnheader2' title=' Select Costcenter ' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"   onclick=\"showlistCostcenter('costcenter','tocostcent','800','500',3) \"  $PreviewButtons/></span></label></td>		";
			else
			echo"<input type='hidden' name='tocostcent' readonly id='tocostcent' $PreviewButtons value='".htmlentities($tocostcent)."' size='17' maxlength='20' />";
		
		if ($Module_TransferWithOneWh == 0){
			echo "<input $PreviewButtons type='hidden' name='towarehouse' id='towarehouse' value='".htmlentities($towarehouse)."'>";
		} else if ($Module_TransferWithOneWh==1){
		echo"<td> <span class='style1'>";
		echo"<label><input $PreviewButtons type='text' name='towarehouse' id='towarehouse'  onchange=\"setwarehousecode(this.value,'towarehouse','towarehouseimgheader');\" value='".htmlentities($towarehouse)."'>
			<span class='style1'>&nbsp;";
		echo"<img src='img/scroll-down-1.png' title=' Select Warehouse ' id='towarehouseimgheader' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"   onclick=\"showlistWarehouse('towarehouse','towarehouse','800','500') \"   $PreviewButtons/></span></label>";
		echo"</td>";
		}
		echo'</tr>';
		
	
		
				
		
		echo"<tr bgcolor='#F7F7F7'><td><span class='style1'>$driver_label</td><td>
		<input type='text' name='driver_name'  $PreviewButtons value='$driver_name'></td>
		<td></td><td colspan=2></td><td></td></tr>";
		echo"<tr bgcolor='#F7F7F7'><td><span class='style1'>$vehicle_label</td><td><input type='text' $PreviewButtons name='vehicle_no' value='$vehicle_no' ></td>
		<td colspan=3 class='style1'></td>
		<td></td>";
		//echo"<td bgcolor=#D8D8D8><span class='style1'>Total Amount</span></td>
		//echo"<td bgcolor=#D8D8D8><input type='text' name='totalamount' id='totalamount' value='$totalamount' readonly></td>
		echo"</tr>";
			
		echo"<tr bgcolor='#F7F7F7'  height='30'>
		<td  align='left' ><span class='style1'>$Remark</span></td><td colspan='8'><span class='style1'>
		<input type='text' name='transferrequest_remark'  $PreviewButtons size='130' value='".htmlspecialchars($transferrequest_remark, ENT_QUOTES)."'  ></td></tr>";	
		echo"</td></tr>";
echo"   </table></td></tr>";

echo"<tr bgcolor='#F7F7F7'  ><td >&nbsp;</td></tr>";


if ($fromwarehouse!='')
	{
		$get_ware = "select warehouse_transit as transit from warehouse where warehouse_code = '".$fromwarehouse."'";
		$result=mysql_query($get_ware,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($result)){
				extract($rows);
												}	
	}	

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

if ($PreviewButtons=='enabled')
{
if ($transit=='' or $transit==0)
	{
	$loadstatus='disabled';
	$unloadstatus='enabled';
	}
else
	{
	$loadstatus='enabled';
	$unloadstatus='disabled';
	}
}
else
{
	$loadstatus='disabled';
	$unloadstatus='disabled';
}
					
/////////////// buttttttonssssssssssssss ////////////
/*echo"   <tr bgcolor='#D8D8D8' height='30'><td  align='center'>";

echo"           <input type='button' id='btnClear' name='BtnClear' value='Clear Page'   onclick='ClearPage();' $style title='Clear Page'>";
				
echo"           <input type='button' name='btnCancel' id='btnCancel' value='Cancel' ";//cancel
				if ($actionmode=='cancel' or $PreviewButtons=='disabled')
					echo " disabled ";
				echo" onclick='CancelRecord();' $style title='Cancel Changes'>";
				
echo"           <input type='button' name='btnPost' id='btnPost' value='Save' ";//post
				if ((($actionmode=='' || $actionmode=='cancel') && $mainaction!='edit') or $PreviewButtons=='disabled')
					echo " disabled ";
				echo" onclick='PostChanges($ModuleProject, $ModuleCostCenter, $Module_RestrictProjCost,$Module_RestrictCost);' $style	title='Save Changes' />";

echo"           <input name='btnSearch' type='button' id='btnSearch' value='Search' onclick='SearchForRef();' $style title='Search By Reference' ";
                if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit') 
				    echo " disabled ";
		        echo " />";
				
echo"           <input name='btnPending' type='button' id='btnPending' value='Pending' onclick='SearchForPending(\"$TransType\");' $style title='Pending Transfer Request' ";
                if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit')
				    echo " disabled ";
		        echo " />";				
				



if ($actionmode == "post" && $transferrequest_id != '') 
{
	$qry="select transferrequest_reference from transferrequest where transferrequest_id = $transferrequest_id";
	
	$result=mysql_query($qry,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($result)){
				extract($rows);
												}	
	echo"<input name='btnPrint' type='button' id='btnPrint' value='Print' onclick=PrintTransfer('".$transferrequest_id."','".$transferrequest_reference."')  $style title='Printing Transfer Request' />";				
}

if ($Module_TransferSorder==1)
	$type='button';
	else
	$type='hidden';

	
echo"  &nbsp; <input name='btnSearchSorder' type='$type' id='btnSearchSorder' value='Load Preparation Order' onclick='SearchConfirmedSorder($Module_RestrictProjCost, $Module_RestrictCost , $ModuleProject,$ModuleCostCenter,\"$TransType\");' $style style='width: 180px;' title='Search Confirmed Preparation Order'  ";

                //if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit' )
				 //   echo " disabled ";
				//else
				//			    echo " enabled ";
		echo " />";	

echo"   </td>";


echo"</tr>";*/	



echo"   <tr bgcolor='#ffffff'><td colspan='10' valign='top' align='left'>";

echo"	<div id='datagrid' class='' style='width:1200px;text-align:left;' >";

//Show Items Grid

				
ShowTransferRequestDtGrid($connection,'TRQ',$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);

echo"	  </div>"; 
echo"   </td></tr>"; 
		
	echo"   <tr><td colspan='9' valign='top'>";

echo"	<div id='testdatagrid' class='' style='width:1090px;' >";


echo"	  </div>"; 

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

echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>";  
echo" </table>  ";//end of last table menu
print <<<HERE
</form>
</body>

HERE;



if ($actionmode == "post" && $transferrequest_id != '' && $Login_FastPrint ==1 ) 
{
	$qry="select transferrequest_reference from transferrequest where transferrequest_id = $transferrequest_id";
	
	$result=mysql_query($qry,$connection) or die(mysql_error());
		while($rows=mysql_fetch_array($result)){
				extract($rows);
												}	
	
	echo '<script type="text/javascript" language="javascript">';
    echo ' PrintTransfer(\''.$transferrequest_id.'\',\''.$transferrequest_reference.'\'); ';
	echo ' ClearPage1(); ';
	echo '</script>';

}




function displayToday(){
	return strftime("%d")."/".strftime("%m")."/".strftime("%Y");
}

function selectData($conn, $query){
		$result = mysql_query($query, $conn);
		$cur = mysql_fetch_row($result);		
		return $cur;
	}
//Method to Insert/ Update/ Delete Record in Database
function updateData($conn, $query, $commit){
	if (mysql_query($query, $conn)){				
		return true;
	}else{
		return false;
	}
}

?>
