<?
function show_related_ecm($relation,$relationid,$record,$module)
{
$z="select ecmdocument_id from ".$relation." where ".$relationid."='".$record."' and deleted=0";
if($module=="Contacts")$wh="first_name,last_name";
else $wh="name";
$rr=mysql_fetch_array(mysql_query("select ".$wh." from ".str_replace("ecmdocuments_","",$relation)." where id='".$record."'"));
$name=$rr['name'];
if($relation=="ecmdocuments_emails" && !$name)$name="&lt;NO SUBJECT&gt;";
if($module=="Contacts")$name=$rr['first_name']." ".$rr['last_name'];
   $w=mysql_query($z);
   while($r=mysql_fetch_array($w))$idp[]=$r['ecmdocument_id'];
   $linked_path="";
   if(mysql_num_rows($w)>0)
   {
   foreach($idp as $ids)
   {
   		$bl=explode("||",$ids."||".check_block($ids,""));
   		for($i=count($bl)-1;$i>=0;$i--)
   		{
   			$z="select name,id,no from ecmdocuments where id='".$bl[$i]."'";
			$w=mysql_query($z);
			$r=mysql_fetch_array($w);
			if($r['name'])$linked_path.='<a class=utilsLink href=index.php?module=EcmDocuments&action=DetailView&record='.$r['id'].'>'.$r['no'].'.'.$r['name'].'</a> / ';
   		}
		$linked_path.="<br>";
	}
	}
$name=str_replace("\n","",$name);
$name=str_replace("\l","",$name);
$name=str_replace("\r","",$name);
$name=str_replace("'","&middot;",$name);
$name=str_replace('"',"&quot;",$name);
$name=str_replace('
',"",$name);
return shortlinkdescription("name",255,$record,$linked_path,"",$module,1,$name);
}
?>
