GLOBAL $LINENUMBERS;
$LINENUMBERS=0;
global $FCOLOR;
$FCOLOR='RED';
$CaseId=$_SESSION['CaseId'];
$wHit=$_SESSION['PM_wHit'];
$exte=$_REQUEST['exte'];
if ($exte==1) $wHit=800;
//echo ~ wHit=$wHit exte=$exte~;
$sel=$_REQUEST['ExpenseSelect'];
if ($sel!=~~)
{
$_SESSION['Instance']=ShowQueryResultScalar(~select rInstance from Responses where rUnique='$sel' and isDeleted=0~);
SetForm('Transaction_Detail');
}
echo ~~;
$tmpREyear=$_SESSION['PM_REyear'];
//$tmpREyear=$_POST['tmpREyear'];
if ($tmpREyear==~All years~ or $tmpREyear=='') $Yfilter='';
else
{
$Yfilter=~ and substring(rValue,1,4)='$tmpREyear' ~;
}
//echo ~ tmpREyear=$tmpREyear Yfilter=$Yfilter ~;
$tmpREcase=$_REQUEST['tmpREcase'];
if ($tmpREcase!='')
{
$CaseId=$tmpREcase;
$_SESSION['CaseId']=$CaseId;
}
//echo ~
$CaseId Transactions
~;
ExecuteSQL(~create temporary table b select rUnique,rValue as Description,rInstance from Responses where qID='RE_X_Description' and CaseID='$CaseId' and isDeleted=0 ~);
ExecuteSQL(~create temporary table c select rUnique,rValue as Date,rInstance from Responses where qID='RE_X_Date' and CaseID='$CaseId' and isDeleted=0 $Yfilter ~);
ExecuteSQL(~create temporary table d select rUnique,cast(substr(rValue,1,8) as decimal(8,2)) as Amount,rInstance from Responses where rValue<>'' and qID='RE_X_Amount' and CaseID='$CaseId' and isDeleted=0 ~);
ExecuteSQL(~create temporary table f select rUnique,rValue as VendorClient from Responses where qID='CaseFirstName' ~);
//ShowQueryResult(~select * from f~);
ExecuteSQL(~create temporary table g select rValue as Vid,rInstance from Responses where qID='RE_X_VendorClient' and CaseID='$CaseId' and isDeleted=0 ~);
//ShowQueryResult(~select * from g~);
ExecuteSQL(~create temporary table h select rInstance,VendorClient from f,g where cast(rUnique as char)=Vid~);
//ShowQueryResult(~select f.*,g.* from f left join g on rUnique=Vid~);
//ShowQueryResult(~select * from h~);
//ShowQueryResult(~select b.*,h.* from b,h where h.rInstance=b.rInstance~);
//ShowQueryResult(~select b.*,h.* from b left join h on h.rInstance=b.rInstance~);
//(~select * from h order by rInstance~);
//ShowQueryResult(~select * from b order by rInstance~);
$ttl=ShowQueryResultScalar(~select sum(Amount) from d,c where d.rInstance=c.rInstance~);
echo '
';
global $NOSORT;
$NOSORT=0;
$order=$_REQUEST['orderby'];
if ($order=='') $orderby='Date';
else $orderby=$order.', Date';
//ShowQueryResult(~select distinct concat('') as Detail, VendorClient, Description, Date, Amount from b,c,d,h where c.rInstance=b.rInstance and d.rInstance=b.rInstance and h.rInstance=b.rInstance order by $orderby DESC~);
ShowQueryResult(~select distinct concat('') as Detail, VendorClient, Description, Date, Amount from b left join h on h.rInstance=b.rInstance ,c,d where c.rInstance=b.rInstance and d.rInstance=b.rInstance order by $orderby DESC~);
//ShowQueryResult(~select distinct concat('') as Detail, Description, Date, Amount from b,c,d where c.rInstance=b.rInstance and d.rInstance=b.rInstance order by $orderby DESC~);
echo ~
$CaseId=$_SESSION['CaseId'];
$UserId=$_SESSION['UserId'];
$Instance=ShowQueryResultScalar(~select rUnique from Responses where CaseID='$CaseId' and rInstance='Expense'~);
if ($Instance==~~)
{
ExecuteSQL(~insert into Responses (CaseID,qID,uID,rInstance,ProjectId) select '$CaseId','RE_X_Category','$UserId','Expense','~.$_SESSION['ProjectId'].~'~);
$Instance=ShowQueryResultScalar(~select rUnique from Responses where CaseID='$CaseId' and rInstance='Expense'~);
ExecuteSQL(~update Responses set rInstance='$Instance' where rUnique='$Instance'~);
}
$_SESSION['Instance']=$Instance;
SetForm('Transaction_Detail');
$stat=1;