var errors, hddnNpId, selNpUser, edtNpDate, edtNpDescription, edtNpAmount, selNpPaymentType;
var module = baseRootURL + "netcash_payment/";

function registerNetcashPayment(action)
{
	errors = false;
	validate_hddnNpId();
	validate_selNpUser();
	validate_edtNpDate();
	validate_edtNpDescription();
	validate_edtNpAmount();
	validate_selNpPaymentType();
	if (!errors)
	{
		var data = {};
		data.dummy = ""; //we seem to get errors from the first value, so always add a dummy value first.
		data.action = action;
		if (document.getElementById("hddnNpId") != null) data.hddnNpId = hddnNpId;
		data.selNpUser = selNpUser;
		data.edtNpDate = edtNpDate;
		data.edtNpDescription = edtNpDescription;
		data.edtNpAmount = edtNpAmount;
		data.selNpPaymentType = selNpPaymentType;
		callModule("netcash_payment/netcash_payment_val.php", data);
	}
}
function insertNetcashPayment(){registerNetcashPayment(0)}
function modifyNetcashPayment(){registerNetcashPayment(1)}

function validate_hddnNpId(){
	if (document.getElementById("hddnNpId") != null) hddnNpId=document.getElementById("hddnNpId").value;}
function validate_selNpUser(){selNpUser=validateRequiredSelection("selNpUser", "Please make a valid selection.");}
function validate_edtNpDate(){edtNpDate=validateRequiredText("edtNpDate", "This field is required.");}
function validate_edtNpDescription(){edtNpDescription=validateRequiredText("edtNpDescription", "This field is required.");}
function validate_edtNpAmount(){edtNpAmount=validateRequiredNumber("edtNpAmount", "Please enter a valid numeric value.");}
function validate_selNpPaymentType(){selNpPaymentType=validateRequiredSelection("selNpPaymentType", "Please make a valid selection.");}

function viewNetcashPayment(id)
{
	var data = {}
	data.dummy = "";
	data.hddnNpId = id;
	data.action = 2;
	callModule("netcash_payment/netcash_payment_val.php", data);
}

function editNetcashPayment(id)
{
	var data = {}
	data.dummy = "";
	data.hddnNpId = id;
	data.action = 3;
	callModule("netcash_payment/netcash_payment_val.php", data);
}

function deleteNetcashPayment(id, desc)
{
	if (confirm("Are you sure you want to delete "+desc+" and all associated records?"))
	{
		var data = {}
		data.dummy = "";
		data.hddnNpId = id;
		data.action = 4;
		callModule("netcash_payment/netcash_payment_val.php", data);
	}
}
