<?
require_once("../../config.php");

$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
mysql_select_db($sugar_config['dbconfig']['db_name']);
mysql_query("set names utf8");
function getidsforlinkedpath($id,$ids)
{
	$z="select iddir from ecmdocuments where id='".$id."'";
	$r=mysql_fetch_array(mysql_query($z));
	$iddir=$r['iddir'];
	$ids.="||".$iddir;
	if($iddir)$ids=getidsforlinkedpath($iddir,$ids);
	return $ids;
}
	$idsy=getidsforlinkedpath($_REQUEST['record'],$_REQUEST['record']);
	$ids=explode("||",$idsy);
	for($i=count($ids)-1;$i>=0;$i--)
	{
		$z="select name,no,id from ecmdocuments where id='".$ids[$i]."'";
		$w=mysql_query($z);
		$r=mysql_fetch_array($w);
			if($_REQUEST['names'])$what="name";
			else $what="no";
			if($r[$what])$linked_path.="<a class='utilsLink' href='index.php?module=EcmDocuments&action=DetailView&record=".$r['id']."'>".$r[$what]."</a> / ";
	}
   print $linked_path;
mysql_close($sql);
?>