var reportId, edtStartDate, edtEndDate, selClientId, edtReportName, selPmId;

function doClientRefinement(obj)
{
	var data = {}
	data.dummy = "";
	data.field_id = 'selClientId';
	data.input_id = obj.value;
	callModule("lib/getClientsByNameNumber.php", data);
}

function setClientName()
{
	"use strict"; 
	var sel = document.getElementById('selClientId');
	var edt = document.getElementById('edtClientName');
	edt.value = sel.options[sel.selectedIndex].innerHTML;
}

function validate_edtStartDate(){edtStartDate=document.getElementById("edtStartDate").value;}
function validate_edtEndDate(){edtEndDate=document.getElementById("edtEndDate").value;}
function validate_selClientId(){selClientId=validateSelection("selClientId", "Please select a client.");}
function validate_selPmId(){selPmId=validateSelection("selPmId", "Please select a pay method.");}
function validate_edtReportName(){edtReportName = validateRequiredText("edtReportName", "Please specify the report name.");}

function runAgeingReport(callback)
{
	errors = false;
	validate_edtReportName();
	
	if (!errors)
	{
		var data = {};
		data.dummy 				= ""; //we seem to get errors from the first value, so always add a dummy value first.
		data.reportId 			= 2;
		data.selClientId 		= document.getElementById("selClientId").value;
		data.edtReportName 		= edtReportName;
		callModule("report/report_val.php", data, callback);
	}
}

function runClientReport(callback)
{
	errors = false;
	/**
	validate_selPmId();
	validate_selClientId();
	**/
	validate_edtEndDate();
	validate_edtStartDate();
	validate_edtReportName();
	
	if (!errors)
	{
		var data = {};
		data.dummy 				= ""; //we seem to get errors from the first value, so always add a dummy value first.
		data.reportId 			= 1;
		data.edtStartDate 		= edtStartDate;
		data.edtEndDate 		= edtEndDate;
		data.selClientId 		= document.getElementById("selClientId").value;
		data.edtReportName 		= edtReportName;
		data.selPmId 			= document.getElementById("selPmId").value;
		data.selTxnTypeId		= document.getElementById("selTxnTypeId").value;
		callModule("report/report_val.php", data, callback);
	}
}

function showTeamIncome()
{
	var data = {};
	data.booking_date = document.getElementById("edtBookingDate").value;
	callModule("lib/getIncomeByTeam.php", data);
}