GLOBAL $LINENUMBERS;
$LINENUMBERS=0;

global $FCOLOR;
$FCOLOR=`RED`;

$ProjectId=$_SESSION[`ProjectId`];

$sel=$_REQUEST[`VendorSelect`];
if ($sel!=~~)
{
   $_SESSION[`Instance`]=ShowQueryResultScalar(~select rInstance from Responses where rUnique=`$sel` and isDeleted=0~);
/*
   SetForm(`VendorClient_Detail`);
*/
   $CaseId=ShowQueryResultScalar(~select CaseID from Responses where rUnique=`$sel` and isDeleted=0~);
/*
   SetInstanceCaseForm($_SESSION[`Instance`],$CaseId,`VendorClient_Detail`);
*/
   SetCaseForm($CaseId,`VendorClient_Detail`);
}

echo ~<input type=hidden name=VendorSelect>~;

echo ~<h4>Vendors and Clients</h4> ~;

ExecuteSQL(~create temporary table b as (select CaseID,rValue as Name,rInstance from Responses where qID=`CaseFirstName` and ProjectId=`$ProjectId` and isDeleted=0) ~);

ExecuteSQL(~create temporary table a as (select CaseID,tText as Type, rInstance from Responses,ResponseType where qID=`CaseType` and rValue in (`V`,`C`) and ProjectId=`$ProjectId` and isDeleted=0 and tID=`CSType` and tValue=rValue) ~);

echo `<div style=~height:295; overflow: scroll;~>`;
ShowQueryResult(~select distinct concat(`<input type=button value=`,substring(replace(cast(100000+cast(a.CaseID as unsigned) as char(6)),` `,`0`),2,5),` onclick=javascript:Xsel(`,a.CaseID,`);>`) as Detail, Type, Name from a,b where b.CaseID=a.CaseID order by Name ~);
echo ~</div>~;

echo ~<p>~;