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

function DisplayMasterTableInfo_List_Management($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="List Management";

//$strSQL = "Select  idCL,  `Customer Name`,  Address,  City,  `State`,  Country,  `Postal Code`,  `Web address`,  Area,  Customer_Category,  `Breif About the Company`,  `Existing Setup`,  `Interaction Summary`,  `Commercial Summary`,  `Customer Status`,  Region,  `Last Updated on`,  MonthName(`Last Updated on`) AS `LU-Month`,  Year(`Last Updated on`) AS `LU-Year`,  `Created on`,  `Assigned Executive`,  `Assigned Date`  FROM customer_list  ORDER BY idCL DESC  ";

$sqlHead="Select idCL,  `Customer Name`,  Address,  City,  `State`,  Country,  `Postal Code`,  `Web address`,  Area,  Customer_Category,  `Breif About the Company`,  `Existing Setup`,  `Interaction Summary`,  `Commercial Summary`,  `Customer Status`,  Region,  `Last Updated on`,  MonthName(`Last Updated on`) AS `LU-Month`,  Year(`Last Updated on`) AS `LU-Year`,  `Created on`,  `Assigned Executive`,  `Assigned Date`";
$sqlFrom="FROM customer_list";
$sqlWhere="";
$sqlTail="";

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

if($detailtable=="Contact Details")
{
		$where.= GetFullFieldName("Customer Name")."=".make_db_value("Customer Name",$keys[1-1]);
	$showKeys .= " Customer Name: ".$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["idCL"]));
	


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

//	Customer Name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Customer Name", ""),"field=Customer+Name".$keylink);
			$xt->assign("Customer_Name_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);

//	Web address - Hyperlink
			$value="";
				$value = GetData($data,"Web address", "Hyperlink");
			$xt->assign("Web_address_mastervalue",$value);

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

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

//	Breif About the Company - HTML
			$value="";
				$value = GetData($data,"Breif About the Company", "HTML");
			$xt->assign("Breif_About_the_Company_mastervalue",$value);

//	Existing Setup - HTML
			$value="";
				$value = GetData($data,"Existing Setup", "HTML");
			$xt->assign("Existing_Setup_mastervalue",$value);

//	Interaction Summary - HTML
			$value="";
				$value = GetData($data,"Interaction Summary", "HTML");
			$xt->assign("Interaction_Summary_mastervalue",$value);

//	Commercial Summary - HTML
			$value="";
				$value = GetData($data,"Commercial Summary", "HTML");
			$xt->assign("Commercial_Summary_mastervalue",$value);

//	Customer Status - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Customer Status", ""),"field=Customer+Status".$keylink);
			$xt->assign("Customer_Status_mastervalue",$value);

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

//	Last Updated on - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"Last Updated on", "Short Date"),"field=Last+Updated+on".$keylink);
			$xt->assign("Last_Updated_on_mastervalue",$value);

//	LU-Month - 
			$value="";
				$value = ProcessLargeText(GetData($data,"LU-Month", ""),"field=LU%2DMonth".$keylink);
			$xt->assign("LU_Month_mastervalue",$value);

//	LU-Year - 
			$value="";
				$value = ProcessLargeText(GetData($data,"LU-Year", ""),"field=LU%2DYear".$keylink);
			$xt->assign("LU_Year_mastervalue",$value);

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

//	Assigned Executive - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Assigned Executive", ""),"field=Assigned+Executive".$keylink);
			$xt->assign("Assigned_Executive_mastervalue",$value);

//	Assigned Date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"Assigned Date", "Short Date"),"field=Assigned+Date".$keylink);
			$xt->assign("Assigned_Date_mastervalue",$value);
	$xt->display("List_Management_masterlist.htm");
	$strTableName=$oldTableName;
}

?>