function delfa(postid, fa){
	var templateUrl = object_name.templateUrl;
	var siteUrl = object_name.siteUrl;

	divdata = document.getElementById("fasr"+postid).innerHTML;
	document.getElementById("fasr"+postid).innerHTML = "<img src="+ templateUrl +"/img/loader1.gif />";

	const xhr = new XMLHttpRequest ();

	xhr.onload = function () {
		const serverResponse = document.getElementById("fasr"+postid);
		response = this.responseText;

		serverResponse.innerHTML = response;
	};
	xhr.open("POST", templateUrl+"/do/fadel-do.php");
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.send("order_id="+postid+"&fa="+fa);
}


function fa(postid){
	var templateUrl = object_name.templateUrl;
	var siteUrl = object_name.siteUrl;
	divdata = document.getElementById("fasr"+postid).innerHTML;
	document.getElementById("fasr"+postid).innerHTML = "<img src="+ templateUrl +"/img/loader1.gif />";

	const xhr = new XMLHttpRequest ();

	xhr.onload = function () {
		const serverResponse = document.getElementById("fasr"+postid);
		response = this.responseText;
		res = response.split(",");
		if ( res[0] == "new" ){
			//alert("New Transaction added with ID "+res[1]);
					serverResponse.innerHTML =
					"<a title='View Sales Order' href="+siteUrl+"/fa/sales/view/view_sales_order.php?trans_no="+res[1]+"&trans_type=30 target=new>FA # "+res[1]+"</a><br />" +
					"<a title='View Sales Invocie' href="+siteUrl+"/fa/sales/view/view_invoice.php?trans_no="+res[1]+"&trans_type=10 target=new>Invocie</a> / " +
					"<a title='View Sales Invocie GL' href="+siteUrl+"/fa/gl/view/gl_trans_view.php?type_id=10&trans_no="+res[1]+" target=new>GL</a><br />" +
					"<a title='View Dispatch Note' href="+siteUrl+"/fa/sales/view/view_dispatch.php?trans_no="+res[1]+"&trans_type=13 target=new>Dispatch</a> / " +
					"<a title='View Dispatch Note GL' href="+siteUrl+"/fa/gl/view/gl_trans_view.php?type_id=13&trans_no="+res[1]+" target=new>GL</a><br />" +
					"<a title='Edit Sales Order Invoice' href="+siteUrl+"/fa/sales/customer_invoice.php?ModifyInvoice="+res[1]+" target=new>Edit Invoice</a>";
		} else if ( res[0] == "exits" ){
			alert( "Existing transaction found with Transaction ID "+res[1] );
			serverResponse.innerHTML =
			"<a title='View Sales Order' href="+siteUrl+"/fa/sales/view/view_sales_order.php?trans_no="+res[1]+"&trans_type=30 target=new>FA # "+res[1]+"</a><br />" +
			"<a title='View Sales Invocie' href="+siteUrl+"/fa/sales/view/view_invoice.php?trans_no="+res[1]+"&trans_type=10 target=new>Invocie</a> / " +
			"<a title='View Sales Invocie GL' href="+siteUrl+"/fa/gl/view/gl_trans_view.php?type_id=10&trans_no="+res[1]+" target=new>GL</a><br />" +
			"<a title='View Dispatch Note' href="+siteUrl+"/fa/sales/view/view_dispatch.php?trans_no="+res[1]+"&trans_type=13 target=new>Dispatch</a> / " +
			"<a title='View Dispatch Note GL' href="+siteUrl+"/fa/gl/view/gl_trans_view.php?type_id=13&trans_no="+res[1]+" target=new>GL</a><br />" +
			"<a title='Edit Sales Order Invoice' href="+siteUrl+"/fa/sales/customer_invoice.php?ModifyInvoice="+res[1]+" target=new>Edit Invoice</a>";
		} else if ( res[0] == "skuerror" ){
			alert( res[1] );
			serverResponse.innerHTML = divdata;
		}
	};
	xhr.open("POST", templateUrl+"/do/fa-do.php");
	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr.send("order_id="+postid);
}
