// Function Key Actions
function F1Action()
{
}
function F2Action(fParm)
{
// Receipt Print
	if (fParm == "receiptsummary")
	{
        var vldStr = "";
        var table = document.getElementById(dataTable);
        if (document.getElementById("txtTranType").value == "RBTD")
		{
			var customerId = "";
			for (var i = 1; i < table.rows.length; i++)
			{
				try
				{
					if (trnName[i] == "haulierReference")
					{
						if (document.getElementById(''+i).value != "")
						{
							id = i;
							customerId = i;
							var vldStr = document.getElementById(''+i).value;
							var url = ajaxPath+"reports/receiptsummary.php"+
							"?customerreference="+vldStr+
							"&host="+userSettings[0].dbhost+
							"&user="+userSettings[0].dbuser+
							"&pword="+userSettings[0].dbpwd+
							"&dbase="+userSettings[0].dbase+
							"&connection="+userSettings[0].path+
							"&table="+
							"&returnfields="+
							"&filter="+
							"&currentuser="+document.getElementById("txtUser").value+
							"&output=F";
                            document.getElementById("txtstoredvalue").value = "/vimsreports/receiptsummary";
//                            ajaxGet(url, printPdf);
                            get(url).then(function(response) 
                            {
                                printPdf(response);
                            }, 
                            function(error) 
                            {
                                console.error("Failed!", error);
                            })
						}
						else
						{
							getMessage("FAIL-Invalid Reference","");
							return false;
						}
                        if (customerId != "")
                        {
                            i = customerId;
                            var vldStr = "haulierreference="+document.getElementById(''+i).value;
                            var url = ajaxPath+"rdtphp/validaterdt.php"+
                                        "?function=completereceipt"+
                                        "&host="+userSettings[0].dbhost+
                                        "&user="+userSettings[0].dbuser+
                                        "&pword="+userSettings[0].dbpwd+
                                        "&dbase="+userSettings[0].dbase+
                                        "&connection="+userSettings[0].path+
                                        "&table="+
                                        "&returnfields="+
                                        "&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//                            ajaxGet(url, rowValidated);
//                            ajaxGet(url, nextScreen,'',document.getElementById("txtTranType").value);
                            get(url).then(function(response) 
                            {
                                rowValidated(response);
                            }, 
                            function(error) 
                            {
                                console.error("Failed!", error);
                            })
                        }
					}
                    if (trnName[i] == "customerReference")
					{
						if (document.getElementById(''+i).value != "")
						{
							id = i;
							customerId = i;
							var vldStr = document.getElementById(''+i).value;
							var url = ajaxPath+"reports/receiptsummary.php"+
							"?reference="+vldStr+
							"&host="+userSettings[0].dbhost+
							"&user="+userSettings[0].dbuser+
							"&pword="+userSettings[0].dbpwd+
							"&dbase="+userSettings[0].dbase+
							"&connection="+userSettings[0].path+
							"&table="+
							"&returnfields="+
							"&filter="+
							"&currentuser="+document.getElementById("txtUser").value+
							"&output=F";
                            document.getElementById("txtstoredvalue").value = "/vimsreports/receiptsummary";
//                            ajaxGet(url, printPdf);
                            get(url).then(function(response) 
                            {
                                printPdf(response);
                            }, 
                            function(error) 
                            {
                                console.error("Failed!", error);
                            })
						}
						else
						{
							getMessage("FAIL-Invalid Reference","");
							return false;
						}
                        if (customerId != "")
                        {
                            i = customerId;
                            var vldStr = "customerreference="+document.getElementById(''+i).value;
                            var url = ajaxPath+"rdtphp/validaterdt.php"+
                                        "?function=completereceipt"+
                                        "&host="+userSettings[0].dbhost+
                                        "&user="+userSettings[0].dbuser+
                                        "&pword="+userSettings[0].dbpwd+
                                        "&dbase="+userSettings[0].dbase+
                                        "&connection="+userSettings[0].path+
                                        "&table="+
                                        "&returnfields="+
                                        "&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//                            ajaxGet(url, rowValidated);
//                            ajaxGet(url, nextScreen,'',document.getElementById("txtTranType").value);
                            get(url).then(function(response) 
                            {
                                rowValidated(response);
                            }, 
                            function(error) 
                            {
                                console.error("Failed!", error);
                            })
                        }
					}
				}
				catch(e)
				{
				}
			}
/*
			if (customerId != "")
			{
				i = customerId;
				var vldStr = "haulierreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
							"?function=completereceipt"+
							"&host="+userSettings[0].dbhost+
							"&user="+userSettings[0].dbuser+
							"&pword="+userSettings[0].dbpwd+
							"&dbase="+userSettings[0].dbase+
							"&connection="+userSettings[0].path+
							"&table="+
							"&returnfields="+
							"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
				ajaxGet(url, rowValidated);
			}
*/
		}
		else if((document.getElementById("txtTranType").value == "RBTC") || (document.getElementById("txtTranType").value == "RBTC"))
		{
			var haulierId = "";
            var customerId = "";
			for (var i = 1; i < table.rows.length; i++)
			{
				try
				{
					if (trnName[i] == "haulierReference")
					{
						if (document.getElementById(''+i).value == "")
						{
							getMessage("FAIL-Invalid Reference");
							return false;
						}
						else
						{
							var haulierId = i; 
						}
					}
                    if (trnName[i] == "customerReference")
					{
						if (document.getElementById(''+i).value == "")
						{
							getMessage("FAIL-Invalid Reference");
							return false;
						}
						else
						{
							var customerId = i; 
						}
					}
				}
				catch(e)
				{
				}
			}
			i = customerId;
			id = i;
			var vldStr = document.getElementById(''+i).value;
			var url = ajaxPath+"reports/receiptsummary.php"+
					"?customerreference="+vldStr+
					"&host="+userSettings[0].dbhost+
					"&user="+userSettings[0].dbuser+
					"&pword="+userSettings[0].dbpwd+
					"&dbase="+userSettings[0].dbase+
					"&connection="+userSettings[0].path+
					"&table="+
					"&returnfields="+
					"&filter="+
					"&currentuser="+document.getElementById("txtUser").value+
					"&output=F";
//			ajaxGet(url, printPdf);
			if (haulierId != "")
			{
                i = haulierId;
                id = i;
				var vldStr = "haulierreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=completereceipt"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&connection="+userSettings[0].path+
						"&table="+
						"&returnfields="+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
//                ajaxGet(url, nextScreen,'',document.getElementById("txtTranType").value);
				get(url).then(function(response) 
				{
					nextScreen(response,'',document.getElementById("txtTranType").value);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
			}
            if (customerId != "")
			{
                i = customerId;
                id = i;
				var vldStr = "customerreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=completereceipt"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&connection="+userSettings[0].path+
						"&table="+
						"&returnfields="+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
//                ajaxGet(url, nextScreen,'',document.getElementById("txtTranType").value);
				get(url).then(function(response) 
				{
					rowValidated(response);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
					}
				}
		else if((document.getElementById("txtTranType").value == "RBTP") || (document.getElementById("txtTranType").value == "JRBTP"))
		{
			var haulierId = "";
            var customerId = "";
			for (var i = 1; i < table.rows.length; i++)
			{
				try
				{
					if (trnName[i] == "haulierReference")
					{
						if (document.getElementById(''+i).value == "")
						{
							getMessage("FAIL-Invalid Reference");
							return false;
						}
						else
						{
							var haulierId = i; 
						}
					}
                    if (trnName[i] == "customerReference")
					{
						if (document.getElementById(''+i).value == "")
						{
							getMessage("FAIL-Invalid Reference");
							return false;
						}
						else
						{
							var customerId = i; 
						}
					}
					if (trnName[i] == "boxCountQty")
					{
						if (document.getElementById(''+i).value == "")
						{
							getMessage("FAIL-Box Count not Complete","");
							return false;
						}
					}
				}
				catch(e)
				{
				}
			}
			i = customerId;
			id = i;
			var vldStr = document.getElementById(''+i).value;
			var url = ajaxPath+"reports/receiptsummary.php"+
					"?customerreference="+vldStr+
					"&host="+userSettings[0].dbhost+
					"&user="+userSettings[0].dbuser+
					"&pword="+userSettings[0].dbpwd+
					"&dbase="+userSettings[0].dbase+
					"&connection="+userSettings[0].path+
					"&table="+
					"&returnfields="+
					"&filter="+
					"&currentuser="+document.getElementById("txtUser").value+
					"&output=F";
//			ajaxGet(url, printPdf);
			if (haulierId != "")
			{
                i = haulierId;
                id = i;
				var vldStr = "haulierreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=checkscandata"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
				get(url).then(function(response) 
				{
					rowValidated(response);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
					
				var vldStr = "haulierreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=completereceipt"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&connection="+userSettings[0].path+
						"&table="+
						"&returnfields="+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
				get(url).then(function(response) 
				{
					rowValidated(response);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
			}
            if (customerId != "")
			{
                i = customerId;
                id = i;
				var vldStr = "customerreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=checkscandata"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
				get(url).then(function(response) 
				{
					rowValidated(response);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
					
				var vldStr = "customerreference="+document.getElementById(''+i).value;
				var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=completereceipt"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&connection="+userSettings[0].path+
						"&table="+
						"&returnfields="+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//				ajaxGet(url, rowValidated);
				get(url).then(function(response) 
				{
					rowValidated(response);
				}, 
				function(error) 
				{
					console.error("Failed!", error);
				})
			}
		}
		cs = 0;
		changeTran(document.getElementById('txtTranType').value);
		return false;
	}
// Skip / resequence Current Pick task
	if (fParm == "skippick")
	{
		var vldStr = "";
		var skipped = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "customerReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"reference="+trnValue[i];
				}
                if (trnName[i] == "documentReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"documentreference="+trnValue[i];
				}
				if (trnName[i] == "lineNo")
				{
					skipped = trnValue[i];
				}
				if (trnName[i] == "allocationId")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"pickdetailid="+trnValue[i];
				}
				if (trnName[i] == "aisleCode")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"aislecode="+trnValue[i];
				}
                if (trnName[i] == "taskType")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"tasktype="+trnValue[i];
				}
                if (trnName[i] == "train")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"train="+trnValue[i];
				}
				if (trnName[i] == "toPlt")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"toplt="+trnValue[i];
				}
				if ((trnName[i] == "serialReferencexxx") || (trnName[i] == "qtyAllocated"))
				{
					if (document.getElementById(''+i).value != "")
					{
						getMessage("FAIL-Cannot skip if fields are scanned");
						return false;
					}
				}
			}
			catch(e)
			{
			}
		}
		if (vldStr != "")
		{
			rdtEnd = now();
			vldStr = vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
            vldStr = vldStr+"|AND|transactionTypeId="+document.getElementById("txtTranType").value;
			vldStr = vldStr+"|AND|rdtstart="+rdtStart+"|AND|rdtend="+rdtEnd;
			var url = ajaxPath+"rdtphp/picking.php"+
			"?function=skippick"+
			"&host="+userSettings[0].dbhost+
            "&user="+userSettings[0].dbuser+
            "&pword="+userSettings[0].dbpwd+
            "&dbase="+userSettings[0].dbase+
            "&connection="+userSettings[0].path+
			"&filter="+vldStr;
//			ajaxGet(url, rowValidated);
			get(url).then(function(response) 
			{
				rowValidated(response);
			}, 
			function(error) 
			{
				console.error("Failed!", error);
			})
			clearMessage();
//					alert("Skipped Line: "+skipped);
			rdtStart = now();
			cellFail = true;
			return false;
		}
		return false;
	}
	if (fParm == "replenlocate")
	{
		var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "toPlt")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"toplt="+trnValue[i];
				}
			}
			catch(e)
			{
			}
		}
		if (vldStr != "")
		{
			changeTran("REPLOC?DATA:toLoc:"+vldStr+":skip2");
			return false;
		}
	}
// decant scan complete
	if (fParm == "decantdone")
	{
		id=1;				
		idx = 999;
		trnScreenOption[8] = "HHHIHHH";
		document.getElementById("txtPageNum").value = "4";
		document.getElementById("rdtmessage").innerHTML = "";
		document.getElementById("rdtmessage").style.display = "none";
		gotoHere();
		return false;
	}					   	
}
function F3Action(fParm)
{
    document.getElementById('txtstoredvalue').value="";
	var table = document.getElementById(dataTable);
	if (fParm == "clearpick")
	{
//				cs = 0;
		idx = 999;
		id = 0;
		clearMessage();
        vldStr = "currentUser="+document.getElementById("txtUser").value+"|AND|lock=OFF";
		var url = ajaxPath+"rdtphp/picking.php"+
		"?function=checklock"+
		"&filter="+vldStr+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase;
//		ajaxGet(url, rowValidated);
//        ajaxGet(url, nextScreen,'',document.getElementById("txtTranType").value);

        get(url).then(function(response) 
        {
            nextScreen(response,'',document.getElementById("txtTranType").value);
        }, 
        function(error) 
        {
            console.error("Failed!", error);
        })

/*
		if (((cs==6) || (cs==2)) && (document.getElementById("txtTranType").value=="PBTP$") && (toPlt != ""))
		{
			cs=0;
			var table = document.getElementById(dataTable);
			mData = "DATA:documentReference::,toPlt:"+toPlt+":PPPPPIP";
			refreshData(table,mData.substr(5));
			document.getElementById("txtPageNum").value = "1";
			gotoHere();
		}
		else if((document.getElementById("txtTranType").value=="PBTM") && (documentReference!="") && (aisleCode != "ALL"))
			changeTran("PBAISLE?DATA:customerReference:"+documentReference+"?5");
		else if((document.getElementById("txtTranType").value=="PBTP") && (documentReference!="") && (aisleCode != "ALL"))
			changeTran("PAISLE?DATA:customerReference:"+documentReference+"?5");
		else
			changeTran("MENUPICK");
*/
		return false;
	}
	if (fParm == "closepltrec")
	{
// test for box-count
		var table = document.getElementById(dataTable);
		var customerId = "";
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if ((trnName[i] == "customerReference") || (trnName[i] == "toLocationHashCode") || (trnName[i] == "toPlt"))
				{
					if (document.getElementById(''+i).value == "")
					{
						cs = 0;
						idx = 999;
						id = 0;
						changeTran("MENUREC");
						return false;
					}
					else
					{
					}
				}
				else if (trnName[i] == "boxCountQty")
				{
					if (document.getElementById(''+i).value == "")
					{
//								getMessage("box count","");
//								document.getElementById("rdtmessage").style.display = "none";
//								document.getElementById("alert").innerHTML="FAIL-Box Count not Complete";
//								document.getElementById("alert").style.display = "block";
//								alert("FAIL-Box Count not Complete");
						F8Action("boxcount");
						return false;
					}
					else
					{
						cs = 0;
						idx = 999;
						id = 0;
						changeTran("MENUREC");
						return false;
					}
				}
			}
			catch(e)
			{
			}
		}
	}
	if (fParm == "clearreplen")
	{
		var vldStr = document.getElementById("txtUser").value;
		vldStr = "currentUser="+document.getElementById("txtUser").value+"|AND|menu=MENURPL";
		var url = ajaxPath+"rdtphp/validaterdt.php"+
			"?function=clearreplen"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&filter="+vldStr;
//			ajaxGet(url, rowValidated);
			get(url).then(function(response) 
			{
				rowValidated(response);
			}, 
			function(error) 
			{
				console.error("Failed!", error);
			})
			changeTran("MENURPL");
		return false;
	}
	if (fParm == "replen")
	{
// get Replen Group
		var table = document.getElementById(dataTable);
		var replenGroup = "";
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "replenGroup")
				{
					replenGroup = document.getElementById(''+i).value;
					if (replenGroup == "")
						replenGroup = trnValue[i];
					changeTran("REPLEN?DATA:replenGroupinput:"+replenGroup);
					return false;
				}
			}
			catch(e)
			{
				changeTran("REPLEN");
			}
		}
	}
}
function F4Action(fParm)
{
//			alert("F4"+fParm);
//			return;
	if (fParm == "closedock")
	{
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "customerReference")
				{
					if (document.getElementById(''+i).value != "")
					{
						id = i;
						var vldStr = "customerReference="+document.getElementById(''+i).value;
						var url = ajaxPath+"rdtphp/validaterdt.php"+
						"?function=completeReceipt"+
						"&host="+userSettings[0].dbhost+
						"&user="+userSettings[0].dbuser+
						"&pword="+userSettings[0].dbpwd+
						"&dbase="+userSettings[0].dbase+
						"&connection="+userSettings[0].path+
						"&table="+
						"&returnfields="+
						"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//						ajaxGet(url, rowValidated);
						get(url).then(function(response) 
						{
							rowValidated(response);
						}, 
						function(error) 
						{
							console.error("Failed!", error);
						})
						cs = 0;
						changeTran(document.getElementById('txtTranType').value);
						return;
					}
					else
					{
						getMessage("FAIL-Invalid Reference");
						return false;
					}
				}
			}
			catch(e)
			{
			}
		}
	}
	else if (fParm == "closepallet")
	{
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "customerReference")
				{
					if (document.getElementById(''+i).value == "")
					{
						getMessage("FAIL-Invalid Reference","");
						return;
					}
					else
					{
						var customerId = i; 
					}
				}
				if (trnName[i] == "boxCountQty")
				{
					if (document.getElementById(''+i).value == "")
					{
						getMessage("FAIL-Wrong Box Count","");
						return false;
					}
				}
			}
			catch(e)
			{
			}
		}
		i = customerId;
		id = i;
		var vldStr = "customerReference="+document.getElementById(''+i).value;
		var url = ajaxPath+"rdtphp/validaterdt.php"+
					"?function=completeReceipt"+
					"&host="+userSettings[0].dbhost+
					"&user="+userSettings[0].dbuser+
					"&pword="+userSettings[0].dbpwd+
					"&dbase="+userSettings[0].dbase+
					"&connection="+userSettings[0].path+
					"&table="+
					"&returnfields="+
					"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		cs = 0;
		changeTran(document.getElementById('txtTranType').value);
		return false;
	}
// Change Serial to Status 'lost'
	else if (fParm == "lostserial")
	{
		var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "customerReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"reference="+trnValue[i];
				}
				if (trnName[i] == "sequencingRequestId")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"invid="+trnValue[i];
				}
				if (trnName[i] == "aisleCode")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"aislecode="+trnValue[i];
				}
				if (trnName[i] == "toPlt")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"toplt="+trnValue[i];
				}
				if (trnName[i] == "fromLocationHashCode")
				{
					document.getElementById(''+i).value = "";
				}
				if (trnName[i] == "serialReference")
				{
					document.getElementById(''+i).value = "";
				}
			}
			catch(e)
			{
			}
		}
		if (vldStr != "")
		{				
			vldStr = vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
			var url = ajaxPath+"rdtphp/validaterdt.php"+
			"?function=lostserial"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//			ajaxGet(url, rowValidated);	
			get(url).then(function(response) 
			{
				rowValidated(response);
			}, 
			function(error) 
			{
				console.error("Failed!", error);
			})
			return false;
		}
	}
	else if (fParm == "closepi")
	{
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if ((trnName[i] == "toLocationHashCode") || (trnName[i] == "locationHashCode"))
				{
					if (document.getElementById(''+i).value == "")
					{
						getMessage("FAIL-Invalid Location","");
						return;
					}
					else
					{
						var id = i;
					}
				}
			}
			catch(e)
			{
			}
		}
		var vldStr = "closehashcode="+document.getElementById(''+id).value;
		var url = ajaxPath+"rdtphp/validaterdt.php"+
					"?function=piloccount"+
					"&host="+userSettings[0].dbhost+
					"&user="+userSettings[0].dbuser+
					"&pword="+userSettings[0].dbpwd+
					"&dbase="+userSettings[0].dbase+
					"&connection="+userSettings[0].path+
					"&currentUser="+document.getElementById("txtUser").value+
					"&table="+
					"&returnfields="+
					"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		cs = 0;
		changeTran(document.getElementById('txtTranType').value);
		return false;				
	}
// Generic Processing
	else
	{
		i = 0;
		var 	parmArr = fParm.split(",")
		for (i=0;i<parmArr.length;i++)
		{
			fParm = parmArr[i];
			if(fParm.substr(0,11) == "validaterdt")
			{
				var s = fParm.indexOf("?");
				if (s > 0)
				{
					var func = fParm.substring(12,s);
					s = s+1;
					var e = fParm.indexOf(")");
					if (e < s)
						e = fParm.indexOf(",");
					if (e < s)
						e = fParm.length;
					var l = e-s;
					var vldStr = fParm.substring(s,e);
					var url = ajaxPath+"rdtphp/validaterdt.php"+
							"?function="+func+
							"&host="+userSettings[0].dbhost+
							"&user="+userSettings[0].dbuser+
							"&pword="+userSettings[0].dbpwd+
							"&dbase="+userSettings[0].dbase+
							"&connection="+userSettings[0].path+
							"&currentUser="+document.getElementById("txtUser").value+
							"&table="+
							"&returnfields="+
							"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//					ajaxGet(url, rowValidated);
					get(url).then(function(response) 
					{
						rowValidated(response);
					}, 
					function(error) 
					{
						console.error("Failed!", error);
					})
				}
				else
				{
					s = 12;
					var e = fParm.indexOf(")");
					if (e < s)
						e = fParm.indexOf(",");
					if (e < s)
						e = fParm.length;
					var l = e-s;
					var func = fParm.substring(s,e);
					var table = document.getElementById(dataTable);
					var vldStr = getScreenData(table);
					var url = ajaxPath+"rdtphp/validaterdt.php"+
							"?function="+func+
							"&host="+userSettings[0].dbhost+
							"&user="+userSettings[0].dbuser+
							"&pword="+userSettings[0].dbpwd+
							"&dbase="+userSettings[0].dbase+
							"&connection="+userSettings[0].path+
							"&currentUser="+document.getElementById("txtUser").value+
							"&table="+
							"&returnfields="+
							"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//					ajaxGet(url, rowValidated);
					get(url).then(function(response) 
					{
						rowValidated(response);
					}, 
					function(error) 
					{
						console.error("Failed!", error);
					})
				}
			}
			if(fParm.substr(0,10) == "changetran")
			{
				s = 11;
				var e = fParm.indexOf(")");
				if (e < s)
					e = fParm.indexOf(",");
				if (e < s)
					e = fParm.length;
				var l = e-s;
				var func = fParm.substring(s,e);
				var func = validationFormat(func);
				try
				{
					changeTran(func);
				}
				catch(e)
				{
					changeTran(document.getElementById('txtTranType').value);
				}
			}
		}
	}
}
function F5Action(fParm)
{
//			alert('F5');
    if (fParm == "receiptsummary")
	{
        var vldStr = "";
        var table = document.getElementById(dataTable);
        if (document.getElementById("txtTranType").value == "RBTD")
		{
			var customerId = "";
			for (var i = 1; i < table.rows.length; i++)
			{
                if (trnName[i] == "customerReference")
                {
                    if (document.getElementById(''+i).value != "")
                    {
                        id = i;
                        customerId = i;
                        var vldStr = document.getElementById(''+i).value;
                        var url = ajaxPath+"reports/receiptsummary.php"+
                        "?reference="+vldStr+
                        "&host="+userSettings[0].dbhost+
                        "&user="+userSettings[0].dbuser+
                        "&pword="+userSettings[0].dbpwd+
                        "&dbase="+userSettings[0].dbase+
                        "&connection="+userSettings[0].path+
                        "&table="+
                        "&returnfields="+
                        "&filter="+
                        "&currentuser="+document.getElementById("txtUser").value+
                        "&output=F";
                        document.getElementById("txtstoredvalue").value = "/vimsreports/receiptsummary"+document.getElementById("txtUser").value+".pdf";
//                            ajaxGet(url, printPdf);
                        get(url).then(function(response) 
                        {
                            printPdf(response);
                        }, 
                        function(error) 
                        {
                            console.error("Failed!", error);
                        })
                    }
                    else
                    {
                        getMessage("FAIL-Invalid Reference","");
                        return false;
                    }                        
				}
			}
		}
		cs = 0;
		changeTran(document.getElementById('txtTranType').value);
		return false;
	}
	if (fParm == "decantlabelpdf")
	{
		id=1;
		vldStr = "printer=decant";
		var url = ajaxPath+"rdtphp/report.php"+
		"?function=getprinter"+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase+
		"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//		ajaxGet(url, rowValidated);	
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		idx = 999;
//				document.getElementById("txtPageNum").value = "1";
		trnScreenOption[9] = "HHHIHHH";
		document.getElementById("txtPageNum").value = "4";
		gotoHere();
		return false;
	}
    if (fParm == "assemblylabelpdf")
	{
        id=0;
        var inventoryId = "";
        var table = document.getElementById(dataTable);
        for (var i = 1; i < table.rows.length; i++)
		{
			if (trnName[i] == "allocationId")
			{
				inventoryId=trnValue[i];
			}
		}
		vldStr = "printer=assembly|AND|inventoryid="+inventoryId+"|AND|partnumber=|AND|serialreference=|AND|snp=";
		var url = ajaxPath+"rdtphp/report.php"+
		"?function=assemblylabelpdf"+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase+
		"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//		ajaxGet(url, rowValidated);	
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		idx = 999;
		return false;
	}
}
function F6Action(fParm)
{
//			alert('F6');
	
	if (fParm == "missingreplenserial")
	{
		idx=999;
		var table = document.getElementById(dataTable);
		var vldStr = getScreenData(table);
		var url = ajaxPath+"rdtphp/validaterdt.php"+
			"?function=missingreplenserial"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&connection="+userSettings[0].path+
			"&currentUser="+document.getElementById("txtUser").value+
			"&table="+
			"&returnfields="+
			"&filter="+vldStr;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
//				return false;
	}
    else if (fParm == "rtslabel")
	{
		idx=999;
		var table = document.getElementById(dataTable);
		var vldStr = "label=rtslabel|AND|screenoption=HHHHHHI";
		var url = ajaxPath+"rdtphp/report.php"+
			"?function=getuserprinter"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&connection="+userSettings[0].path+
			"&currentUser="+document.getElementById("txtUser").value+
			"&table="+
			"&returnfields="+
			"&filter="+vldStr;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})	
	}
    else if (fParm == "picklabel")
	{
        id=0;
        var printer = "";
        var table = document.getElementById(dataTable);
        for (var i = 1; i < table.rows.length; i++)
		{
			if (trnName[i] == "allocationId")
			{
				id=trnValue[i];
			}
            if (trnName[i] == "printer")
			{
				printer=trnValue[i];
			}
		}
		vldStr = "pickdetailid="+id+"|AND|printer="+printer;
            var url = "/KUK/action/printLabels.php";
//            var url = "/KUKtest/action/printLabels.php";
        url +=
		"?function=picklabelzebra"+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase+
		"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		idx = 999;
		return false;
	}
}
function F7Action(fParm)
{
//	alert('F7');
    if (fParm == "closecase")
	{
		var customerReference="";
		var toCase="";
		var id=0;
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			if (trnName[i] == "customerReference")
			{
				customerReference=trnValue[i];
			}
			if (trnName[i] == "toCase")
			{
				toCase=trnValue[i];
				id = i;
			}
			if ((trnName[i] == "serialReference") && ((trnValue[i] != "") || (document.getElementById(''+i).value != "")))
			{
				getMessage("FAIL-serial is not blank","");
				return false;
			}
			if ((trnName[i] == "quantity") && ((trnValue[i] != "") || (document.getElementById(''+i).value != "")))
			{
				getMessage("FAIL-quantity is not blank","");
				return false;
			}
			if ((trnName[i] == "partNumber") && ((trnValue[i] != "") || (document.getElementById(''+i).value != "")))
			{
				getMessage("FAIL-part is not blank","");
				return false;
			}
		}
		if (customerReference == "")
		{
			getMessage("FAIL-Invalid Customer","");
			return;
		}
		if (toCase == "")
		{
			getMessage("FAIL-Invalid Case","");
			return;
		}
		vldStr = "confirm=Y|AND|customerreference="+customerReference+"|AND|tocase="+toCase;
		var url = ajaxPath+"rdtphp/receiving.php"+
		"?function=completecase"+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase+
		"&connection="+userSettings[0].path+
		"&filter="+vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
//        ajaxGet(url, nextScreen,id,document.getElementById("txtTranType").value);
		get(url).then(function(response) 
		{
			nextScreen(response,'',document.getElementById("txtTranType").value);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		return false;
	}
}
function F8Action(fParm)
{
	var table = document.getElementById(dataTable);
//			alert('F8');
	if (fParm == "boxcount")
	{
		var count = "y";
		var table = document.getElementById(dataTable);
		trys = 3;
		var boxIdx = 0;
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (((trnName[i] == "toPlt") || (trnName[i] == "plt")) && (document.getElementById(''+i).value == "") && (trnValue[i] == ""))
				{
					getMessage("FAIL-Invalid Pallet","");
					return;
				}
				if (trnName[i] == "boxCountQty")
				{
					boxIdx = i;
					
					count = document.getElementById(''+i).value;
					if (count != "n")
						document.getElementById(''+i).value = "";
					else
						break;
				}
				if (trnName[i] == "comment")
				{
					document.getElementById(''+i).value = 3;
					trys = parseInt(document.getElementById(''+i).value);
				}
			}
			catch(e)
			{
			}
		}
		if (document.getElementById("txtTranType").value == "PBTP")
		{
			document.getElementById("txtPageNum").value = "7";
			trnScreenOption[boxIdx] = "HHHHHHI";			
			idx = 999;
			gotoHere();
		}
        else if (document.getElementById("txtTranType").value == "RBTP")
		{
			document.getElementById("txtPageNum").value = "7";
			trnScreenOption[boxIdx] = "HHHHHHI";			
			idx = 999;
			gotoHere();
		}
		else if (document.getElementById("txtTranType").value == "PTM")
		{
			document.getElementById("txtPageNum").value = "3";
			trnScreenOption[boxIdx] = "HHI";
			document.getElementById("rdtmessage").innerHTML = trys+" Attempts";
//					getMessage("box count "+trys+" Attempts");
			getMessage("box count");
			idx = 999;
			gotoHere();
		}
		else
		{
			document.getElementById("txtPageNum").value = "6";
			trnScreenOption[boxIdx] = "HHHHHI";
			document.getElementById("rdtmessage").innerHTML = trys+" Attempts";
			getMessage("box count");
			idx = 999;
			gotoHere();
		}
	}
	else if (fParm == "ctslocfull")
	{
		var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "serialReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"serialReference:"+trnValue[i];
				}
			}
			catch(e)
			{
			}
		}
		if (document.getElementById("txtTranType").value == "CTS")
			changeTran("ctslocfull?DATA:"+vldStr);
		if (document.getElementById("txtTranType").value == "RCTS")
			changeTran("rctslocfull?DATA:"+vldStr);
		if (document.getElementById("txtTranType").value == "FQA")
			changeTran("fqalocfull?DATA:"+vldStr);
		if (document.getElementById("txtTranType").value == "CTL")
			changeTran("ctllocfull?DATA:"+vldStr);
	}
// Transfer Replen Task
	else if (fParm == "transferreplen")
	{
// test if serial has been picked
		var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if (trnName[i] == "serialReference")
				{
					if (document.getElementById(''+i).value != "")
					{
						getMessage("FAIL-F8 is Not Allowed Now","");
						return;
					}
				}
			}
			catch(e)
			{
			}
		}

		clearScreen(dataTable,"7",currentRow);	
		clearScreen(dataTable,"6",currentRow);
		clearScreen(dataTable,"5",currentRow);
		clearScreen(dataTable,"4",currentRow);
		clearScreen(dataTable,"3",currentRow);
		cs = 2;
		refreshScreen(dataTable,cs);
		var table = document.getElementById(dataTable);
		var vldStr = getScreenData(table);
		var url = ajaxPath+"rdtphp/validaterdt.php"+
			"?function=transferreplen"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&connection="+userSettings[0].path+
			"&currentUser="+document.getElementById("txtUser").value+
			"&table="+
			"&returnfields="+
			"&filter="+vldStr;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
	}
    else if (fParm == "missingpickserial")
	{
        var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			if (trnName[i] == "fromLocationHashCode")
			{
				count = document.getElementById(''+i).value;
				if (count == "")
				{
					getMessage("FAIL-Invalid Location","");
					return;
				}
			}
            try
			{
				if (trnName[i] == "customerReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"reference="+trnValue[i];
				}
                if (trnName[i] == "documentReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"documentreference="+trnValue[i];
				}
				if (trnName[i] == "lineNo")
				{
					skipped = trnValue[i];
				}
				if (trnName[i] == "allocationId")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"pickdetailid="+trnValue[i];
				}
				if (trnName[i] == "aisleCode")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"aislecode="+trnValue[i];
				}
                if (trnName[i] == "taskType")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"tasktype="+trnValue[i];
				}
                if (trnName[i] == "train")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"train="+trnValue[i];
				}
				if (trnName[i] == "toPlt")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"toplt="+trnValue[i];
				}
            }
            catch(e)
            {
                changeTran(document.getElementById('txtTranType').value);
            }
		}
		if (vldStr != "")
		{
			rdtEnd = now();
			vldStr = vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
            vldStr = vldStr+"|AND|transactionTypeId="+document.getElementById("txtTranType").value;
			vldStr = vldStr+"|AND|rdtstart="+rdtStart+"|AND|rdtend="+rdtEnd;
			var url = ajaxPath+"rdtphp/picking.php"+
			"?function=missingpickserial"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&connection="+userSettings[0].path+
			"&currentUser="+document.getElementById("txtUser").value+
			"&table="+
			"&returnfields="+
			"&filter="+vldStr;
//            ajaxGet(url, rowValidated);
			get(url).then(function(response) 
			{
				rowValidated(response);
			}, 
			function(error) 
			{
				console.error("Failed!", error);
			})
        }
        gotoField("fromLocationHashCode");
        cellFail=true;
        idx=999;
        return false;
	}
    else if (fParm == "missingrelocserial")
	{
        var vldStr = "";
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			if (trnName[i] == "fromLocationCode")
			{
				count = document.getElementById(''+i).value;
				if (count == "")
				{
					getMessage("FAIL-Invalid Location","");
					return;
				}
			}
            try
			{
				if (trnName[i] == "customerReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"reference="+trnValue[i];
				}
                if (trnName[i] == "serialReference")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"serialreference="+trnValue[i];
				}
                if (trnName[i] == "partNumber")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"partnumber="+trnValue[i];
				}
				if (trnName[i] == "allocationId")
				{
					if (vldStr != "")
						vldStr = vldStr+"|AND|";
					vldStr = vldStr+"relocbodyid="+trnValue[i];
				}
            }
            catch(e)
            {
                changeTran(document.getElementById('txtTranType').value);
            }
		}
		if (vldStr != "")
		{
			rdtEnd = now();
			vldStr = vldStr+"|AND|currentUser="+document.getElementById("txtUser").value;
            vldStr = vldStr+"|AND|transactionTypeId="+document.getElementById("txtTranType").value;
			vldStr = vldStr+"|AND|rdtstart="+rdtStart+"|AND|rdtend="+rdtEnd;
			var url = ajaxPath+"rdtphp/reloc.php"+
			"?function=missingrelocserial"+
			"&host="+userSettings[0].dbhost+
			"&user="+userSettings[0].dbuser+
			"&pword="+userSettings[0].dbpwd+
			"&dbase="+userSettings[0].dbase+
			"&connection="+userSettings[0].path+
			"&currentUser="+document.getElementById("txtUser").value+
			"&table="+
			"&returnfields="+
			"&filter="+vldStr;
//            ajaxGet(url, rowValidated);
            get(url).then(function(response) 
            {
                rowValidated(response);
            }, 
            function(error) 
            {
                console.error("Failed!", error);
            })
        }
        changeTran('RELOCTASK');
        cellFail=true;
        return false;
	}
}
function F9Action(fParm)
{
	if (fParm == "getplt")
	{
		var table = document.getElementById(dataTable);
		for (var i = 1; i < table.rows.length; i++)
		{
			try
			{
				if ((trnName[i] == "customerReference") || (trnName[i] == "toLocation"))
				{
					if (document.getElementById(''+i).value == "")
					{
						return false;
					}
				}
				if (trnName[i] == "toPlt")
				{
					if (document.getElementById(''+i).value != "")
					{
						return false;
					}
					else
					{
						var pltId = i;
					}
				}
			}
			catch(e)
			{
				return false;
			}
		}
		i = pltId;
		id = i;
		vldStr = "plt=|AND|transactionType="+document.getElementById("txtTranType").value+"|AND|currentUser="+document.getElementById("txtUser").value;
		var url = ajaxPath+"rdtphp/validaterdt.php"+
		"?function=getplt"+
		"&host="+userSettings[0].dbhost+
		"&user="+userSettings[0].dbuser+
		"&pword="+userSettings[0].dbpwd+
		"&dbase="+userSettings[0].dbase+
		"&connection="+userSettings[0].path+
		"&table="+
		"&returnfields="+
		"&filter="+vldStr;
//		ajaxGet(url, rowValidated);
		get(url).then(function(response) 
		{
			rowValidated(response);
		}, 
		function(error) 
		{
			console.error("Failed!", error);
		})
		return;
	}
}
function F10Action(fParm)
{
	alert('F10');
}
function F11Action(fParm)
{
	alert('F11');
}
function F12Action(fParm)
{
//			alert('F12');
}