<?php
include(getabspath("include/My_Home_settings.php"));

function DisplayMasterTableInfo_My_Home($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="My Home";

//$strSQL = "SELECT  idemplist,  `Full Name`,  `Job Title`,  Address,  City,  `State`,  Country,  `Postal Code`,  `Business Phone`,  `Home Phone`,  `Mobile Phone`,  `E-Mail Address`,  Department,  Region,  `Birth Date`,  DOJ,  `Reporting Manager`,  `Father / Husband Name`,  username  FROM employee_list  ";

$sqlHead="SELECT idemplist,  `Full Name`,  `Job Title`,  Address,  City,  `State`,  Country,  `Postal Code`,  `Business Phone`,  `Home Phone`,  `Mobile Phone`,  `E-Mail Address`,  Department,  Region,  `Birth Date`,  DOJ,  `Reporting Manager`,  `Father / Husband Name`,  username";
$sqlFrom="FROM employee_list";
$sqlWhere="";
$sqlTail="";

$where="";
$mKeys = array();
$showKeys = "";

if($detailtable=="My Planned Visits")
{
		$where.= GetFullFieldName("username")."=".make_db_value("username",$keys[1-1]);
	$showKeys .= " Username: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
if($detailtable=="My Leads")
{
		$where.= GetFullFieldName("username")."=".make_db_value("username",$keys[1-1]);
	$showKeys .= " Username: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
if($detailtable=="My Calls Summary")
{
		$where.= GetFullFieldName("username")."=".make_db_value("username",$keys[1-1]);
	$showKeys .= " Username: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
if($detailtable=="My Visit Summary")
{
		$where.= GetFullFieldName("username")."=".make_db_value("username",$keys[1-1]);
	$showKeys .= " Username: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
if($detailtable=="RO-Customer List Summary")
{
		$where.= GetFullFieldName("Region")."=".make_db_value("Region",$keys[1-1]);
	$showKeys .= " Region: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName=$oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.=" and ".$str;

	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["username"]));
	


//	idemplist - 
			$value="";
				$value = ProcessLargeText(GetData($data,"idemplist", ""),"field=idemplist".$keylink);
			$xt->assign("idemplist_mastervalue",$value);

//	Full Name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Full Name", ""),"field=Full+Name".$keylink);
			$xt->assign("Full_Name_mastervalue",$value);

//	Job Title - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Job Title", ""),"field=Job+Title".$keylink);
			$xt->assign("Job_Title_mastervalue",$value);

//	Address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Address", ""),"field=Address".$keylink);
			$xt->assign("Address_mastervalue",$value);

//	City - 
			$value="";
				$value = ProcessLargeText(GetData($data,"City", ""),"field=City".$keylink);
			$xt->assign("City_mastervalue",$value);

//	State - 
			$value="";
				$value = ProcessLargeText(GetData($data,"State", ""),"field=State".$keylink);
			$xt->assign("State_mastervalue",$value);

//	Country - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Country", ""),"field=Country".$keylink);
			$xt->assign("Country_mastervalue",$value);

//	Postal Code - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Postal Code", ""),"field=Postal+Code".$keylink);
			$xt->assign("Postal_Code_mastervalue",$value);

//	Business Phone - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Business Phone", ""),"field=Business+Phone".$keylink);
			$xt->assign("Business_Phone_mastervalue",$value);

//	Home Phone - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Home Phone", ""),"field=Home+Phone".$keylink);
			$xt->assign("Home_Phone_mastervalue",$value);

//	Mobile Phone - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Mobile Phone", ""),"field=Mobile+Phone".$keylink);
			$xt->assign("Mobile_Phone_mastervalue",$value);

//	E-Mail Address - Email Hyperlink
			$value="";
				$value = GetData($data,"E-Mail Address", "Email Hyperlink");
			$xt->assign("E_Mail_Address_mastervalue",$value);

//	Department - 
			$value="";
				$value=DisplayLookupWizard("Department",$data["Department"],$data,$keylink,MODE_LIST);
			$xt->assign("Department_mastervalue",$value);

//	Region - 
			$value="";
				$value=DisplayLookupWizard("Region",$data["Region"],$data,$keylink,MODE_LIST);
			$xt->assign("Region_mastervalue",$value);

//	Birth Date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"Birth Date", "Short Date"),"field=Birth+Date".$keylink);
			$xt->assign("Birth_Date_mastervalue",$value);

//	DOJ - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"DOJ", "Short Date"),"field=DOJ".$keylink);
			$xt->assign("DOJ_mastervalue",$value);

//	Reporting Manager - 
			$value="";
				$value=DisplayLookupWizard("Reporting Manager",$data["Reporting Manager"],$data,$keylink,MODE_LIST);
			$xt->assign("Reporting_Manager_mastervalue",$value);

//	Father / Husband Name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Father / Husband Name", ""),"field=Father+%2F+Husband+Name".$keylink);
			$xt->assign("Father___Husband_Name_mastervalue",$value);
	$xt->display("My_Home_masterlist.htm");
	$strTableName=$oldTableName;
}

?>