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

function DisplayMasterTableInfo_material_category($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="material category";

//$strSQL = "SELECT  `Material Category`,  Description  FROM `material category`  ";

$sqlHead="SELECT `Material Category`,  Description";
$sqlFrom="FROM `material category`";
$sqlWhere="";
$sqlTail="";

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

if($detailtable=="Materials_Master")
{
		$where.= GetFullFieldName("Material Category")."=".make_db_value("Material Category",$keys[1-1]);
	$showKeys .= " Material Category: ".$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["Material Category"]));
	


//	Material Category - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Material Category", ""),"field=Material+Category".$keylink);
			$xt->assign("Material_Category_mastervalue",$value);

//	Description - 
			$value="";
				$value = ProcessLargeText(GetData($data,"Description", ""),"field=Description".$keylink);
			$xt->assign("Description_mastervalue",$value);
	$xt->display("material_category_masterlist.htm");
	$strTableName=$oldTableName;
}

?>