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

function DisplayMasterTableInfo_Active_Customers($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="Active Customers";

//$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`,  `Assigned Executive`,  `Assigned Date`,  `Last Updated on`,  Region  FROM customer_list  WHERE (`Customer Status` = \"Active\")  ";

$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`,  `Assigned Executive`,  `Assigned Date`,  `Last Updated on`,  Region";
$sqlFrom="FROM customer_list";
$sqlWhere="(`Customer Status` = \"Active\")";
$sqlTail="";

$where="";

if($detailtable=="Contact Details")
{
		$where.= GetFullFieldName("Customer Name")."=".make_db_value("Customer Name",$keys[1-1]);
}
if($detailtable=="Call-Details")
{
		$where.= GetFullFieldName("Customer Name")."=".make_db_value("Customer Name",$keys[1-1]);
}
if($detailtable=="Visit-Details")
{
		$where.= GetFullFieldName("Customer Name")."=".make_db_value("Customer Name",$keys[1-1]);
}
if($detailtable=="Lead Details")
{
		$where.= GetFullFieldName("Customer Name")."=".make_db_value("Customer Name",$keys[1-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	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,"",MODE_PRINT);
			$xt->assign("idCL_mastervalue",$value);

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

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

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

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

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

//	Postal Code - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Postal Code", ""),"field=Postal+Code".$keylink,"",MODE_PRINT);
			$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_PRINT);
			$xt->assign("Area_mastervalue",$value);

//	Customer_Category - 
			$value="";
				$value=DisplayLookupWizard("Customer_Category",$data["Customer_Category"],$data,$keylink,MODE_PRINT);
			$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,"",MODE_PRINT);
			$xt->assign("Customer_Status_mastervalue",$value);

//	Assigned Executive - 
			$value="";
				$value=DisplayLookupWizard("Assigned Executive",$data["Assigned Executive"],$data,$keylink,MODE_PRINT);
			$xt->assign("Assigned_Executive_mastervalue",$value);

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

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

//	Region - 
			$value="";
				$value=DisplayLookupWizard("Region",$data["Region"],$data,$keylink,MODE_PRINT);
			$xt->assign("Region_mastervalue",$value);
	$xt->display("Active_Customers_masterprint.htm");
	$strTableName=$oldTableName;

}

?>