<?php

session_start();
if($HTTP_SESSION_VARS['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");
include("Functions_Trans.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");


if ($TransType == 'PV') 
	$querylog="SELECT FA_Payment as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";
else if ($TransType == 'RV') 
	$querylog="SELECT FA_Receipt as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";	
else if ($TransType == 'DV') 
	$querylog="SELECT FA_DebitNote as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";		
else if ($TransType == 'CV') 
	$querylog="SELECT FA_CreditNote as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";		
else if ($TransType == 'CT') 
	$querylog="SELECT FA_Contra as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";
	
	
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");


$querylog=" select ifNull(FA_PaymentApp,0) As FA_PaymentApp, ifNull(FA_ReceiptApp,0) As FA_ReceiptApp, ifNull(FA_CreditNoteApp,0) As FA_CreditNoteApp, ".
          " ifNull(FA_DebitNoteApp,0) As FA_DebitNoteApp, ifNull(FA_ContraApp,0) As FA_ContraApp, ifNull(Login_FastPrint,0) As Login_FastPrint, ".
		  " ifNull(AllowedPaymentDirect,0) As AllowedPaymentDirect ".
		  " from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['useraccount']."' and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

	
//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2  from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

//Read From TransSetup Table							
$querytranssetup= " select DefaultCur  from transsetup where JournalType = '".$TransType."'";
$resulttranssetup=mysql_query($querytranssetup,$connection) or die(mysql_error());
while($rowtranssetup=mysql_fetch_array($resulttranssetup)){
	extract($rowtranssetup);
}

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostcenterDt,0) As Module_CostCenterDt, ".
			 " ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost, ".
			 " ifNull(Module_MultiCashType,0) As Module_MultiCashType, ifNull(Module_TransStandardView,0) As Module_TransStandardView, ".
			 " ifNull(Module_AcctrxPostPV,0) As Module_AcctrxPostPV, ifNull(Module_AcctrxPostRV,0) As Module_AcctrxPostRV, ".
			 " ifNull(Module_AcctrxPostDV,0) As Module_AcctrxPostDV, ifNull(Module_AcctrxPostCV,0) As Module_AcctrxPostCV, ".
			 " ifNull(Module_AcctrxPostCT,0) As Module_AcctrxPostCT, ifNull(Module_AcctrxPost,0) As Module_AcctrxPost, ".
			 " ifNull(Module_RestrictCashType,0) As Module_RestrictCashType, ifNull(Module_RestrictCashTypePV,0) As Module_RestrictCashTypePV, ".
			 " ifNull(Module_RestrictCashTypeRV,0) As Module_RestrictCashTypeRV, ifNull(Module_RestrictCashTypeCV,0) As Module_RestrictCashTypeCV, ".
			 " ifNull(Module_RestrictCashTypeDV,0) As Module_RestrictCashTypeDV, ifNull(Module_RestrictCashTypeCT,0) As Module_RestrictCashTypeCT, ".
			 " ifNull(Module_InvoiceGridPV,0) As Module_InvoiceGridPV, ifNull(Module_InvoiceGridRV,0) As Module_InvoiceGridRV, ".
			 " ifNull(Module_InvoiceGridDV,0) As Module_InvoiceGridDV, ifNull(Module_InvoiceGridCV,0) As Module_InvoiceGridCV, ".
			 " ifNull(Module_InvoiceGridCT,0) As Module_InvoiceGridCT, ifNull(Module_PaymentRqst,0) As Module_PaymentRqst, ".
			 " ifNull(Module_ShowBalance,0) As Module_ShowBalance ".
			 " From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


$querycurrency="select Currency_code from currency order by currency_code";
$resultcurrency=mysql_query($querycurrency,$connection) or die(mysql_error());

$querycashtype=" select CashType_Code, CashType_Description from cashtype where Journal_Type = '".$TransType."'".
               " order by CashType_Description";
$resultcashtype=mysql_query($querycashtype,$connection) or die(mysql_error());

$queryjourtype="select Type_Cash, Type_dbcd from JourType where Type_Name = '".$TransType."'";
$resultjourtype=mysql_query($queryjourtype,$connection) or die(mysql_error());
while($rowjourtype=mysql_fetch_array($resultjourtype)){
	extract($rowjourtype);
}

$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];}   
$mainaction = $_POST["mainaction"]; if ($mainaction == ""){$mainaction = $_GET["mainaction"];}   

//Access Mode On Insert/Edit/Delete
$InsMode = '';
	
if ($TransType == 'PV' && $FA_PaymentApp == 0) 
	$InsMode = ' disabled ';
else if ($TransType == 'RV' && $FA_ReceiptApp == 0) 
	$InsMode = ' disabled ';
else if ($TransType == 'CV' && $FA_CreditNoteApp == 0) 
	$InsMode = ' disabled ';
else if ($TransType == 'DV' && $FA_DebitNoteApp == 0) 
	$InsMode = ' disabled ';
else if ($TransType == 'CT' && $FA_ContraApp == 0) 
	$InsMode = ' disabled ';	
		
if ($TransType == 'PV') {
	$ModulePostTrx = $Module_AcctrxPostPV;
	$ModuleRestrictCashType = $Module_RestrictCashTypePV;
	$ModuleInvoiceGrid = $Module_InvoiceGridPV;
}	 
else if ($TransType == 'RV') {
	$ModulePostTrx = $Module_AcctrxPostRV;
	$ModuleRestrictCashType = $Module_RestrictCashTypeRV;
	$ModuleInvoiceGrid = $Module_InvoiceGridRV;
}	
else if ($TransType == 'CV') {
	$ModulePostTrx = $Module_AcctrxPostCV;
	$ModuleRestrictCashType = $Module_RestrictCashTypeCV;
	$ModuleInvoiceGrid = $Module_InvoiceGridCV;
}	
else if ($TransType == 'DV') {
	$ModulePostTrx = $Module_AcctrxPostDV;
	$ModuleRestrictCashType = $Module_RestrictCashTypeDV;
	$ModuleInvoiceGrid = $Module_InvoiceGridDV;
}	
else if ($TransType == 'CT') {
	$ModulePostTrx = $Module_AcctrxPostCT;
	$ModuleRestrictCashType = $Module_RestrictCashTypeCT;
	$ModuleInvoiceGrid = $Module_InvoiceGridCT;
}	

if (empty($mainaction))
	$mainaction = 'insert';
	
if (empty($SetCurrency))
	$SetCurrency = 0;	
	

$message = ereg_replace("'"," ",$message);

$Title = '';
$HeaderTitle = '';
if ($TransType == 'PV')      {  $Title = 'PAYMENT';      if(empty($Type_dbcd)) $Type_dbcd = 'D';  }
else if ($TransType == 'RV') {  $Title = 'RECEIPT';      if(empty($Type_dbcd)) $Type_dbcd = 'C';  }
else if ($TransType == 'CV') {  $Title = 'CREDIT NOTE';  if(empty($Type_dbcd)) $Type_dbcd = 'C';  }
else if ($TransType == 'DV') {  $Title = 'DEBIT NOTE';   if(empty($Type_dbcd)) $Type_dbcd = 'D';  }
else if ($TransType == 'CT') {  $Title = 'CONTRA';       if(empty($Type_dbcd)) $Type_dbcd = 'D';  }

$Type_dbcd1 = $Type_dbcd;
if ($Type_dbcd1 == 'D') {
	$Type_dbcd2 = 'C'; 
	$Type_Label1 = 'Debit Accounts'; 
	$Type_Label2 = 'Credit Accounts'; 
} else {
	$Type_dbcd2 = 'D';
	$Type_Label1 = 'Credit Accounts'; 
	$Type_Label2 = 'Debit Accounts';
}	

$HeaderTitle = ucfirst(strtolower($Title));

print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="default.css" type="text/css" />
<script type="text/javascript" language="javascript">





function CheckFields(ModuleRestProj, ModuleRestCost, ModuleRestCashType){
  
    x = document.trans;
	
	var vDate = x.txtDate.value;
	var vProject = x.txtProjectCode.value;
	var vCostCenter = x.txtCostCentCode.value;
	var vCurr = x.txtCurr.value;
	var vCashType = x.txtCashType.value;

	
	
	if (vDate=='' )
	{
		alert("Date is mandatory!");
		x.txtDate.focus();
		return 0;
	}
	else if (vProject=='' && ModuleRestProj==1)
	{
		alert("Project is mandatory!");
		x.txtProjectCode.focus();
		return 0;
	}
	else if (vCostCenter=='' && ModuleRestCost==1)
	{
		alert("CostCenter is mandatory!");
		x.txtCostCentCode.focus();
		return 0;
	}
	else if (vCurr=='' )
	{
		alert("Currency is mandatory!");
		x.txtCurr.focus();
		return 0;
	}
	else if (vCashType=='' && ModuleRestCashType==1)
	{
		alert("Cash Type is mandatory!");
		x.txtCashType.focus();
		return 0;
	}
		
	
	else
	return 1 ;	
}




function ClearPage(){
	x = document.trans;
	var vTransType = x.TransType.value;
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		
		x.mainaction.value='insert';
		x.actionmode.value='';
		x.action='Form_Trans.php?TransType='+vTransType;
		x.submit();
	}	
}

function ClearPage1(){
	x = document.trans;
	var msg = x.message.value;
	var vTransType = x.TransType.value;
	
	ClearForm('All');
	
	x.mainaction.value='insert';
	x.actionmode.value='';
	x.message.value=msg;
	x.action='Form_Trans.php?TransType='+vTransType+'&message='+x.message.value;
	x.submit();
}

function CancelRecord(){
	x = document.trans;
	var vmode  = x.mainaction.value;
	var vmode1 = x.actionmode.value;
	var TransId = x.txtTransId.value;
	var vTransType = x.TransType.value;
		
	if (confirm ( "Are you sure you want to Delete current pending Transaction permenantly?"))
	{
		ClearForm('All');
		x.txtTransId.value = TransId;
		x.mainaction.value='insert';
		x.actionmode.value='cancel';
		x.action='Form_Trans.php?TransType='+vTransType;
		x.submit();
	}
    
}



function PostChanges(ModuleRestProj, ModuleRestCost, ModuleRestCashType) {
	x = document.trans;
	var TransId     = x.txtTransId.value;
	var vTransType  = x.TransType.value;
	var vMainMode   = x.mainaction.value;
	var result = CheckFields(ModuleRestProj, ModuleRestCost, ModuleRestCashType);
	
	var vTransAmtBal1 = x.txtTransAmtBal1.value;
	var vTransAmtBal2 = x.txtTransAmtBal2.value;
	
	
	
	if (x.txtCountDetail.value == 0 || x.txtCountDetail.value == '') {
		alert('Save not allowed. Please add Details.');
	}
	else if (vTransAmtBal1 != 0 || vTransAmtBal2 != 0) {
		alert('Save not allowed. Please check for Balances.');
	}
	else {
	
		if (result == 1) {
			if (confirm ( "Are you sure you want to Save current Transaction?"))
			{
				x.btnPost.disabled = true;
				x.btnCancel.disabled = true;
				x.btnClear.disabled = true;
				//x.btnDetail1.disabled = true;
				//x.btnDetail2.disabled = true;
				
				if (document.getElementById('btnPostTrx'))
					x.btnPostTrx.disabled = true;
				
				
				x.actionmode.value='post';
				x.action="Form_Trans_Actions.php?mode=post&mainmode="+vMainMode+"&TransType="+vTransType+"&STransId="+TransId;
				x.submit();
			}
		}
	}	
}

	
function DeleteTransDt(TransDtId) {
	x = document.trans;
	
	var vTransId   = x.txtTransId.value;
	var vTransType = x.TransType.value;
	var vMainMode  = x.mainaction.value;
	var vDelMsg = 'Are you sure you want to Delete Record.';
	
	   
	if (confirm ( vDelMsg ))
	{
		x.action="Form_Trans_Actions.php?mode=deletedt&mainmode="+vMainMode+"&TransType="+vTransType+"&STransId="+vTransId+"&STransDtId="+TransDtId;
		x.submit();
	}

}

function UpdateTransDt(TransDtId,TransDtType) {
    x = document.trans; 
	x.SetCurrency.value = 0;
	
	var vTransId   = x.txtTransId.value;
	var vTransType = x.TransType.value;
	var vTransDate = x.txtDate.value;
	var vMainMode  = x.mainaction.value;

	if (TransDtType=='D') vTransDtType = 1; else vTransDtType = 2;
	
	win = window.open('Form_TransDetail.php?mainaction='+vMainMode+'&actionmode=&PTransId='+vTransId+'&PTransType='+vTransType+'&PTransDate='+vTransDate+'&PTransDtType='+vTransDtType+'&PTransDtId='+TransDtId, 'Form_TransDetail', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=650,height=300,top=100');
	win.creator = self;
	win.focus();	

}

function AddDetails(ModuleRestProj, ModuleRestCost, ModuleRestCashType, AccountType, AllowedPaymentDirect, ModulePaymentRqst) {
	x = document.trans;
	
	var result = CheckFields(ModuleRestProj, ModuleRestCost, ModuleRestCashType);

	var vTransId    = x.txtTransId.value;
	var vTransType  = x.TransType.value;
	var vTransDate  = x.txtDate.value;
	var vTransRepresent    = x.txtRepresent.value;
	var vTransCurr         = x.txtCurr.value;
	var vTransRemark       = x.txtRemark.value;
	var vTransManualNo     = x.txtManualNo.value;
	var vTransCashType     = x.txtCashType.value;
	var vTransProjectCode  = x.txtProjectCode.value;
	var vTransCostCentCode = x.txtCostCentCode.value;
	
	var vMainMode = x.mainaction.value;
	var vMode = x.actionmode.value;
	
	
	vTransRemark       = vTransRemark.replace('&','%26');
	vTransRepresent    = vTransRepresent.replace('&','%26');
	vTransManualNo     = vTransManualNo.replace('&','%26');
	vTransProjectCode  = vTransProjectCode.replace('&','%26');
	vTransCostCentCode = vTransCostCentCode.replace('&','%26');
	
	if (result == 1 && ModulePaymentRqst == 1 && AllowedPaymentDirect != 1 && vTransType == 'PV') {
		alert('You are not allowed to do direct payment.');
		return false;
	}
	
	if (result == 1) {
		win = window.open('Form_TransDetail.php?mainaction='+vMainMode+'&actionmode=&PAccountType='+AccountType+'&PTransId='+vTransId+'&PTransType='+vTransType+'&PTransDate='+vTransDate+
		                  '&PTransCurr='+vTransCurr+'&PTransCashType='+vTransCashType+'&PTransManualNo='+vTransManualNo+'&PTransProjectCode='+vTransProjectCode+
						  '&PTransCostCentCode='+vTransCostCentCode+'&PTransRepresent='+vTransRepresent+'&PTransRemark='+vTransRemark, 
						  'Form_TransDetail', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=650,height=300,top=100');
		win.creator = self;
		win.focus();		
	}	
	
    
}

function AddCstjourDt(TransDtId,TransDtCurr) {
	x = document.trans;

	var vTransId   = x.txtTransId.value;
	var vTransType = x.TransType.value;
	var vMainMode  = x.mainaction.value;
	
	
	win = window.open('Form_Trans_CstJour.php?mainaction='+vMainMode+'&actionmode=&PTransId='+vTransId+'&PTransType='+vTransType+'&PTransDtId='+TransDtId+'&PTransDtCurr='+TransDtCurr,
					  'Form_Trans_CstJour', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=770,height=300,top=100');		
	win.creator = self;
	win.focus();		
	
    
}

function AddChkjourDt(TransDtId,TransDtCurr,LedgerActivity) {
	x = document.trans;

	var vTransId   = x.txtTransId.value;
	var vTransType = x.TransType.value;
	var vMainMode  = x.mainaction.value;
	
	var str='';
	if (LedgerActivity==1 || LedgerActivity==2)
		str = 'Form_Trans_ChkJour.php';
	else
		str = 'Form_Trans_BillJour.php';
	
	win = window.open(str+'?mainaction='+vMainMode+'&actionmode=&PTransId='+vTransId+'&PTransType='+vTransType+'&PTransDtId='+TransDtId+'&PTransDtCurr='+TransDtCurr,
					  'Form_Trans_ChkJour', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=820,height=300,top=100');		
	win.creator = self;
	win.focus();		
	
    
}

function AddInvoice(TransDtId,TransDtCurr) {
	x = document.trans;

	var vTransId   = x.txtTransId.value;
	var vTransType = x.TransType.value;
	var vMainMode  = x.mainaction.value;
	
	var str='Form_Trans_Invoices.php';
	
	win = window.open(str+'?mainaction='+vMainMode+'&actionmode=&PTransId='+vTransId+'&PTransType='+vTransType+'&PTransDtId='+TransDtId+'&PTransDtCurr='+TransDtCurr,
					  'Form_Trans_Invoices', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=580,height=300,top=100,left=0');		
	win.creator = self;
	win.focus();		
	
    
}



//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.trans;
	var vmode = x.actionmode.value;
	
	if (Option == 'All') {
		
		x.txtTransId.value='';
		x.txtRef.value='';
		x.txtTransType.value='';
		x.txtJvRef.value='';
		x.txtJvFolio.value='';
		x.txtDate.value='';
		x.txtRepresent.value='';
		x.txtCurr.value='';
		x.txtTotalAmount.value='';
		x.txtRemark.value='';
		x.txtManualNo.value='';
		x.txtCashRef.value='';
		x.txtCashType.value='';
		x.txtProjectCode.value='';
		x.txtCostCentCode.value='';
		
		x.txtTransAmtDb1.value='';
		x.txtTransAmtDb2.value='';
		x.txtTransAmtCr1.value='';
		x.txtTransAmtCr2.value='';
		x.txtTransAmtBal1.value='';
		x.txtTransAmtBal2.value='';
		
		if (document.getElementById('txtTransAmtDb'))
			x.txtTransAmtDb.value='';
		if (document.getElementById('txtTransAmtCr'))
			x.txtTransAmtCr.value='';
		if (document.getElementById('txtTransAmtBal'))
			x.txtTransAmtBal.value='';		
		
		/*x.txtTransDtId1.value='';
		x.txtTransDtdbcd1.value='';
		x.txtLedgerNo1.value='';
		x.txtLedgerName1.value='';
		x.txtTransDtDesc1.value='';
		x.txtTransDtCurr1.value='';
		x.txtTransDtAmount1.value='';
		x.txtTransDtAmount1B1.value='';
		x.txtTransDtAmount1B2.value='';
		x.txtTransDtAmount1_D.value='';
		x.txtTransDtAmount1B1_D.value='';
		x.txtTransDtAmount1B2_D.value='';
		x.txtTransDtValueDate1.value='';
		
		x.txtTransDtId2.value='';
		x.txtTransDtdbcd2.value='';
		x.txtLedgerNo2.value='';
		x.txtLedgerName2.value='';
		x.txtTransDtDesc2.value='';
		x.txtTransDtCurr2.value='';
		x.txtTransDtAmount2.value='';
		x.txtTransDtAmount2B1.value='';
		x.txtTransDtAmount2B2.value='';
		x.txtTransDtAmount2_D.value='';
		x.txtTransDtAmount2B1_D.value='';
		x.txtTransDtAmount2B2_D.value='';
		x.txtTransDtValueDate2.value='';*/
		
		x.txtCountDetail.value='';
		x.SetCurrency.value='';
		x.ErrorRecId.value='';
		x.message.value='';
		
		x.actionmode.value = '';
		x.mainaction.value = '';
	} 
}



function SearchForRef(){
    
	//ClearForm('All');
    x = document.trans;
	var vTransType = x.TransType.value;
    win = window.open('Form_TransSearch.php?TransType='+vTransType, 'Form_TransSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1080,height=450,top=100,left=0');		
	win.creator = self;
	win.focus();		
			
}

function SearchForPending(){
    //ClearForm('All');
    x = document.trans;
	var vTransType = x.TransType.value;
    win = window.open('Form_TransSearchPending.php?TransType='+vTransType, 'Form_TransSearchPending', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=900,height=450,top=100,left=0');		
	win.creator = self;
	win.focus();		
			
}

function SearchUnPosted() {
	x = document.trans;
	var vTransType = x.TransType.value;
    win = window.open('Form_TransSearchUnPosted.php?TransType='+vTransType, 'Form_Trans_Posting', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1120,height=450,top=100,left=50');		
	win.creator = self;
	win.focus();
}

function SearchPayRequests() {
	x = document.trans;
	var vTransType = x.TransType.value;
    win = window.open('Form_TransSearchRequests.php?TransType='+vTransType, 'Form_TransSearchRequests', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1100,height=450,top=100,left=50');		
	win.creator = self;
	win.focus();
}

function ChangeCurrency() {
	x = document.trans;
	x.SetCurrency.value = 1;
	x.submit();
}

function PrintTrans(TransId, TransRef) {
	var str = '';
	x = document.trans;
	var vTransType = x.TransType.value;
	
	if (confirm ( "Do you want to Print current Transaction with reference "+TransRef+" ?"))
	{
		str = 'Form_TransPreview.php?TransId='+TransId+'&TransType='+vTransType;
		window.open(str);
	}	
	
	
}


function showlistProject(str){

  window.open('List_SorProject.php?frm=4&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistCostcenter(str){

  window.open('List_SorCostcenter.php?frm=4&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}





function kd(e)
{ 

	x=document.trans;
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13) { //enter key
        //x.btnSubmitRecord.click();
		
		/*el = x.elements;
		var w = '';
		for(var i=0;i<el.length;i++){
		
			el[i].getfocus=function(){
				w=this.name;
				alert(w);
			}
		}*/
		

		return false;
    }
    return true;
}


</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$HeaderTitle</title>


<script type="text/javascript" src="dropdown.js"></script>
<link rel="stylesheet" href="default.css" type="text/css" />
<link rel="stylesheet" href="short.css" type="text/css" />
<link rel="stylesheet" href="dropdown.css" type="text/css" />
<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style11 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 11px;
	color: #FF0000;
	font-weight: bold;
}
.style13 {
	font-size: 11px;
	color: #5151FF;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style17 {color: #FFFFFF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}

</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

</head>
<body>
<form name='trans' method='post' action=''>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='message' value='$message' size='200'>
<input type='hidden' name='TransType' value='$TransType' >
<input type='hidden' name='SetCurrency' value='$SetCurrency' >
<input type='hidden' name='ErrorRecId' value='$ErrorRecId' >

HERE;

//$message='';

	
//Initializations

	
//Get Default Project
$querydflproject="select project_code as defaultproject from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
	extract($rows);
}
	
//Get Default Coscenter
$querydflcostcent="select costcent_code as defaultcostcent from ".$HTTP_SESSION_VARS['dbLabel'].".loginstk where user_account='".$HTTP_SESSION_VARS['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
	extract($rows);
}


if ((empty($txtProjectCode)) && $Module_Project == 1)
	$txtProjectCode = $defaultproject;
if ((empty($txtCostCentCode)) && $Module_CostCenter == 1)
	$txtCostCentCode = $defaultcostcent;	

if (empty($txtCurr))
	$txtCurr = $DefaultCur;

if (empty($txtDate))	
	$txtDate = displayToday();

	
		
if ($txtTransId != '' && $actionmode != 'cancel') {
	// Read From Temp Tables For Selected Record				 
	$query = " Select Trans_ID, Trans_Reference, Date_Format(Trans_Date,'%d/%m/%Y') As Trans_Date, ".
			 " Trans_Type, Trans_Remark, Trans_Representative, Trans_CashReference, CashType_code,  ".
			 " Trans_ManualNo, Trans.Project_Code, Trans.Costcent_code, Journal.Journal_folio, Journal.Journal_refgovernment, Currency_Code,  ".
			 " ifNull(Trans_AmountDb1,0), ifNull(Trans_AmountDb2,0), ".
			 " ifNull(Trans_Amountcd1,0), ifNull(Trans_Amountcd2,0)  ".
			 " From Temp_Trans As Trans ".
			 " Left Join Journal on Trans.Journal_ID = Journal.Journal_ID ".
	         " Where Trans_ID = ".$txtTransId;
			 //" And Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
			 
			 
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);
	
	$txtTransId       = $rows[0];
	$txtRef           = $rows[1];
	$txtDate          = $rows[2];
	$txtTransType     = $rows[3];
	$txtRemark        = $rows[4];
	$txtRepresent     = $rows[5];
	$txtCashRef       = $rows[6];
	$txtCashType 	  = $rows[7];
	$txtManualNo 	  = $rows[8];
	$txtProjectCode   = $rows[9];
	$txtCostCentCode  = $rows[10];
	$txtJvFolio       = $rows[11];
	$txtJvRef         = $rows[12];
	
	if ($SetCurrency != 1) $txtCurr = $rows[13];
	
	$txtTransAmtDb1   = $rows[14];
	$txtTransAmtDb2   = $rows[15];
	$txtTransAmtCr1   = $rows[16];
	$txtTransAmtCr2   = $rows[17];
	$txtTransAmtBal1  = $txtTransAmtDb1 - $txtTransAmtCr1;
	$txtTransAmtBal2  = $txtTransAmtDb2 - $txtTransAmtCr2;
	
	$txtTransAmtDb    = ConvertCurrency($base1, $txtCurr, insertMySQLDate($txtDate), $txtTransAmtDb1, $connection); 
	$txtTransAmtCr    = ConvertCurrency($base1, $txtCurr, insertMySQLDate($txtDate), $txtTransAmtCr1, $connection);
	$txtTransAmtBal   = $txtTransAmtDb - $txtTransAmtCr;
	
	if ($Type_dbcd1 == 'D') {
		$txtTotalAmount = ConvertCurrency($base1, $txtCurr, insertMySQLDate($txtDate), $txtTransAmtDb1, $connection);
		$txtTotalAmount = number_format($txtTotalAmount,$DecimalBase);
	}
	else {
		$txtTotalAmount = ConvertCurrency($base1, $txtCurr, insertMySQLDate($txtDate), $txtTransAmtCr1, $connection);
		$txtTotalAmount = number_format($txtTotalAmount,$DecimalBase);
	}
	
	
	$query = " Select Count(*) FROM Temp_TransDt ".
			 " WHERE Trans_id = ".$txtTransId;
	$result = selectData($connection, $query);
	$txtCountDetail = $result[0];
	if($txtCountDetail == '') $txtCountDetail = 0;
	
	
}


//Search/Cancel Mode	
if ($actionmode == "cancel" && $txtTransId != '') {
	
	// Delete From Temp Tables Already Filled By Search
	$query = " DELETE FROM Temp_ChkJourDt ".
			 " WHERE TransDt_id In (Select TransDt_id From Temp_TransDt Where Trans_id = ".$txtTransId." ) ";
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 
	  
	$query = " DELETE FROM Temp_BillJourDt ".
			 " WHERE TransDt_id In (Select TransDt_id From Temp_TransDt Where Trans_id = ".$txtTransId." ) ";
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 


	$query = " DELETE FROM Temp_CstJourDt ".
			 " WHERE TransDt_id In (Select TransDt_id From Temp_TransDt Where Trans_id = ".$txtTransId." ) ";
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 

	$vMainCompanyName=explode('_',$HTTP_SESSION_VARS['dbName']);  
	$DirCompany  = $vMainCompanyName[0];
	$DirYear	 = $vMainCompanyName[1]; 
	
	$query = " DELETE FROM ".$HTTP_SESSION_VARS['dbLabel'].".Temp_AccLink ".
			 " WHERE Journal_ID In (Select TransDt_id From Temp_TransDt Where Trans_id = ".$txtTransId." ) ".
			 " And Temp_AccLink.Journal_Type = '".$TransType."' ".
			 " And upper(Temp_AccLink.CompanyName) = upper('".$DirCompany."') ".
			 " And upper(Temp_AccLink.DirYear) = upper('".$DirYear."') ";
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 	  
		
	$query = " DELETE FROM Temp_TransDt ".
			 " WHERE Trans_id = ".$txtTransId;
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))
      $message  = mysql_error(); 
	  
	
	  
	$query = " DELETE FROM Temp_Trans ".
			 " WHERE Trans_id = ".$txtTransId;
			 //" AND Logged_Code = '".$HTTP_SESSION_VARS['useraccount']."' ";
	if (!updateData($connection, $query, true))
      $message  = mysql_error();   

	$txtTransId = '';
}






$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

echo"<table border=0 width='100%'>";
echo '<tr><td colspan="9" align="left" valign="top">';

include_once("MenuBar.php");

print <<< HERE
       </td>
      </tr>
HERE;


print <<<HERE
		<tr><th height="20" colspan="9" align="left" valign="top"><span class="style3">$Title </span></th></tr>
		<tr><td height="20" colspan="9" align='center'><font size='1' color='#FF0000' face='Verdana'><b>$message</b></font></td></tr>
		<tr><td>
		<table border="0" style='table-layout:fixed'>
		  <col width=105>
		  <col width=90>
		  <col width=65>
		  <col width=60>
		  <col width=40>
		  <col width=130>
		  <col width=90>
		  <col width=170>
		  <col width=220>
		<tr bgcolor="#F7F7F7" height='25'> 
          <td valign="center" align='left' ><span class="style11">Reference&nbsp;<span class="style26">*</span></span></td>
		  <td><font face='Verdana' size='2'><b>&nbsp;$txtRef</b></font><input type='hidden' name='txtCountDetail' value='$txtCountDetail' >
			  <input type='hidden' name='txtTransId' value='$txtTransId' size='10'>
			  <input type="hidden" name="txtRef" value="$txtRef" size='10'><input type="hidden" name="txtTransType" value="$txtTransType" size='10'></td>
  	      <td align='left'><span class='style11'>JV Ref.</span></td>	
		  <td><font face='Verdana' size='2'><b>&nbsp;$txtJvRef</b></font><input type='hidden' name='txtJvRef' value='$txtJvRef' ></td>
		  <td align='left'><span class='style11'>Folio</span></td>	
		  <td><font face='Verdana' size='2'><b>&nbsp;$txtJvFolio</b></font><input type='hidden' name='txtJvFolio' value='$txtJvFolio' ></td>
		  <td align="left"><span class="style11">Date&nbsp;<span class="style26">*</span></span></td>
		  <td><input type='text' size='10' name='txtDate' value='$txtDate'  maxlength='10'  >
		                   <A HREF="#" onClick="displayCalendar(document.trans.txtDate,'dd/mm/yyyy',this);  return false; " NAME="anchor1" ID="anchor1"><img src='./img/cal.gif' border=0 align=center></A></td>

HERE;


	echo"<td rowspan='6' valign='top'><table border='0' style='table-layout:fixed'>
			<col width=40>
			<col width=60>
			<col width=110>";
	
	if ($Module_TransStandardView == 1) {
		echo" <tr bgcolor='#D8D8D8' height='20'>
			     <td valign='center' align='center' ><span class='style12'>$base1</span></td> 
			     <td valign='center' align='right' ><span class='style12'>Debit</span></td> 
			     <td align='left'><input type='text' name='txtTransAmtDb1' value='".number_format($txtTransAmtDb1,$DecimalBase1)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		      </tr>
		  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style12'>Credit</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtCr1' value='".number_format($txtTransAmtCr1,$DecimalBase1)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>
			  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style12'>Balance</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtBal1' value='".number_format(Round($txtTransAmtBal1,$DecimalBase1),$DecimalBase1)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>
	
	
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='center' ><span class='style13'>$base2</span></td> 
				 <td valign='center' align='right' ><span class='style13'>Debit</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtDb2' value='".number_format($txtTransAmtDb2,$DecimalBase2)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>
			  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style13'>Credit</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtCr2' value='".number_format($txtTransAmtCr2,$DecimalBase2)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>
			  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style13'>Balance</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtBal2' value='".number_format(Round($txtTransAmtBal2,$DecimalBase2),$DecimalBase2)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>";
	
	} else {
		echo" <tr bgcolor='#D8D8D8' height='20'>
			     <td valign='center' align='center' ><span class='style12'>$txtCurr</span></td> 
			     <td valign='center' align='right' ><span class='style12'>Debit</span></td> 
			     <td align='left'><input type='text' name='txtTransAmtDb' value='".number_format($txtTransAmtDb,$DecimalBase)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
		      </tr>
		  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style12'>Credit</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtCr' value='".number_format($txtTransAmtCr,$DecimalBase)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>
			  
			  <tr bgcolor='#D8D8D8' height='20'>
				 <td valign='center' align='right' colspan='2'><span class='style12'>Balance</span></td> 
				 <td align='left'><input type='text' name='txtTransAmtBal' value='".number_format(Round($txtTransAmtBal,$DecimalBase),$DecimalBase)."' maxlength='20' readonly style='text-align:right; width:100px; height=18px;'></td>
			  </tr>";
		echo" <tr>
				 <td align='left' colspan='3'>
					<input type='hidden' name='txtTransAmtDb1' value='".number_format($txtTransAmtDb1,$DecimalBase2)."'>
					<input type='hidden' name='txtTransAmtCr1' value='".number_format($txtTransAmtCr1,$DecimalBase2)."'>
					<input type='hidden' name='txtTransAmtBal1' value='".number_format($txtTransAmtBal1,$DecimalBase2)."'>
					<input type='hidden' name='txtTransAmtDb2' value='".number_format($txtTransAmtDb2,$DecimalBase2)."'>
					<input type='hidden' name='txtTransAmtCr2' value='".number_format($txtTransAmtCr2,$DecimalBase2)."'>
					<input type='hidden' name='txtTransAmtBal2' value='".number_format($txtTransAmtBal2,$DecimalBase2)."'>
				</td>
			  </tr>";
	}	
		  
	echo"</table></td></tr>";





echo"   <tr bgcolor='#F7F7F7'  height='25'>
		  <td align='left' ><span class='style11'>Representative</span></td>
          <td colspan='5' ><span class='style11'><input type='text' name='txtRepresent' id='txtRepresent' value='".htmlspecialchars($txtRepresent, ENT_QUOTES)."' style='width:365px;' maxlength='51' /></span></td>";

echo"     <td align='left' ><span class='style11'>Currency&nbsp;<span class='style26'>*</span></span></td>";


if ($txtTransId == '') {
	echo" <td ><span class='style11'><select name='txtCurr' id='txtCurr' style='width:60px;' onChange='ChangeCurrency();' >";
			echo"<option></option>";
			while($curf=mysql_fetch_row($resultcurrency)){
			echo"<option ";
				if ($txtCurr==$curf[0])
					echo " selected ";
				echo" value='$curf[0]'>$curf[0] </option>";
			}
			echo"</select></span>";	
} else {
	echo" <td ><input type='hidden' name='txtCurr' id='txtCurr' value='$txtCurr' ><font face='Verdana' size='2'><b>&nbsp;$txtCurr</b></font>";

}			
			
echo"     <input type='text' name='txtTotalAmount' value='$txtTotalAmount'  size='10' readonly ></td>";

echo"   </tr>";





echo"   <tr bgcolor='#F7F7F7'  height='30'>
		  <td align='left' valign='center' rowspan='2'><span class='style11'>Remark</span></td><td colspan='5' rowspan='2'> <span class='style11'>
		  <textarea name='txtRemark' rows='3' cols='43'>".htmlspecialchars($txtRemark, ENT_QUOTES)."</textarea></td>";

echo"     <td align='left' valign='center'><span class='style11'>Manual No</span></td>
		  <td><input type='text' name='txtManualNo' value='".htmlspecialchars($txtManualNo, ENT_QUOTES)."'  size='21' maxlength='20' ></td>";
echo"   </tr>";		  


echo"   <tr bgcolor='#F7F7F7'  height='30'>";

	if ($Module_MultiCashType == 1 && $Type_Cash == 1) {
 		echo"  <td align='left'><span class='style11'>Cash Ref</span></td>	
			   <td><font face='Verdana' size='2'><b>&nbsp;$txtCashRef</b></font><input type='hidden' name='txtCashRef' value='$txtCashRef' ></td>";
	} else
		echo"  <td colspan='2'>&nbsp;<input type='hidden' name='txtCashRef' value='$txtCashRef' ></td>	";
		
echo"	</tr>";		  


echo"   <tr bgcolor='#F7F7F7' height='25'>";

if ($Module_Project	== 1) {
	echo "<td align='left' ><span class='style11'>Project&nbsp;<span class='style26'>*</span></span></td>
	      <td align='left' colspan='2'> <span class='style11'>
		    <input type='text' name='txtProjectCode' id='txtProjectCode' value='$txtProjectCode' style='width:120px;' maxlength='15' readonly /></span>
		    <label><span class='style11'><img src='img/btnopen.jpg' title=' Select Project ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(1); '  /></span></label></td>";
} else	{
	echo "<td align='left' colspan='3'><input type='hidden' name='txtProjectCode' id='txtProjectCode' value='$txtProjectCode' /></td>";
}		

if ($Module_CostCenter == 1) {		  
	echo" <td align='left' colspan='2'><span class='style11'>Costcenter&nbsp;<span class='style26'>*</span></span></td>";		
	echo" <td align='left' ><span class='style11'>
		    <input type='text' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' style='width:103px;' maxlength='15' readonly /></span>
		    <label><span class='style11'><img src='img/btnopen.jpg' title=' Select Costcenter ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  onClick='showlistCostcenter(1); ' /></span></label></td>";
} else {
	echo "<td align='left' colspan='3'><input type='hidden' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' /></td>";
}			

//echo"     <td align='left' colspan='2'>&nbsp;</td>";
if ($Module_MultiCashType == 1 && $Type_Cash == 1) {
	echo"     <td align='left' valign='center'><span class='style11'>Cash Type</span></td>";
	echo"     <td ><span class='style11'><select name='txtCashType' id='txtCashType' style='height:20px; width:160px; font-size:10px;'>";
				echo"<option></option>";
				while($ctype=mysql_fetch_row($resultcashtype)){
				echo"<option ";
					if ($txtCashType==$ctype[0])
						echo " selected ";
					echo" value='$ctype[0]'>$ctype[1] </option>";
				}
				echo"</select></span></td>";
} else 
	echo" <td colspan='2'>&nbsp;<input type='hidden' name='txtCashType' id='txtCashType' value='$txtCashType' /></td>";				
			

echo"   </tr>";
		  
		  
echo"   <tr bgcolor='#F7F7F7' height='20'><td colspan='9'>&nbsp</td></tr>";		



//Display Buttons

echo"   <tr bgcolor='#F7F7F7'>
			<td colspan='9' align='center' bgcolor=#D8D8D8>";
			
$query_buttons = " Select JourTypeButton_Name, JourTypeButton_DBCD ".
				 " From JourTypeButton ".
				 " Where JourType_code = '".$TransType."' ".
				 " Order By JourTypeButton_Order ";
$result_buttons=mysql_query($query_buttons,$connection) or die(mysql_error());
while($rows_buttons=mysql_fetch_array($result_buttons)){
	extract($rows_buttons);
	
	$ButtonName = $JourTypeButton_Name;
	
	if ($JourTypeButton_DBCD == 'D') $ButtonTitle = 'Add Debit';
	else $ButtonTitle = 'Add Credit';

	echo" <input type='button' name='".$ButtonName."' value='".$ButtonName."' onclick=\"AddDetails($Module_RestrictProjCost,$Module_RestrictCost,$ModuleRestrictCashType,'".$ButtonName."',$AllowedPaymentDirect,$Module_PaymentRqst);\" $style	title='".$ButtonTitle."' $InsMode/>";	
}

echo "</tr>";
	
/*echo"   <tr bgcolor='#F7F7F7' height='25'>
			<td colspan='9' align='center' bgcolor=#D8D8D8>
				<input type='button' name='btnDetail1' id='btnDetail1' value='Debit' onclick=\"AddDetails($Module_RestrictProjCost,$Module_RestrictCost,1);\" $style	style='width:55px;' title='Add Debit' $InsMode/>
				<input type='button' name='btnDetail2' id='btnDetail2' value='Credit' onclick=\"AddDetails($Module_RestrictProjCost,$Module_RestrictCost,2);\" $style	style='width:55px;' title='Add Credit' $InsMode/>
		</tr>";  */

echo"   <tr><td colspan='9' valign='top'>";
//<div style='overflow:scroll; height:180px; width:980px;' >

if ($Module_TransStandardView == 1) {
	echo" <table border='0' style='table-layout:fixed'>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=100>
		  <col width=120>
		  <col width=80>
		  <col width=90>
		  <col width=80>
		  <col width=50>
		  <col width=80>
		  <col width=80>
		  <col width=80>
		  <col width=100>";
		  
		  //***********First Side*******************
		   
		  
		  echo"<tr bgcolor='#F7F7F7' height='20'>";
		  echo"  <td align='center' colspan='15'><span class='style16'>$Type_Label1</span></td>";
		  echo"</tr>";
		  
		  echo"<tr height='20'>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
          echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger No.</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger Desc.</span></td>";
		  
		  if($Module_ShowBalance == 1) {
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Balance</span></td>";
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Description</span></td>";
		  }	else {
			echo"  <td bgcolor='#F7F7F7' align='center' colspan='2'><span class='style27'>Description</span></td>";
		  }
		  
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>ManualNo</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Currency</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount $base1</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount $base2</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Value Date</span></td>";
          echo"</tr>";

		  
		  if ($txtTransId != '' && $Type_dbcd1 != '') {
		     
			  
			$sub_query1 = " Select TransDt.TransDt_id, TransDt.Ledger_Number, Ledger.Ledger_Name, TransDt_Description, TransDt.Currency_Code, ".
					      " Round(Transdt_Amount, ".$DecimalBase."), Round(Transdt_Amount1, ".$DecimalBase."), Round(Transdt_Amount2, ".$DecimalBase."), ".
					      " Date_Format(TransDt_ValueDate,'%d/%m/%Y') As TransDt_ValueDate, TransDt_dbcd, Ledger.Ledger_Activity, TransDt_ManualNo ".
					      " From Temp_TransDt As TransDt Left Join Ledger on TransDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where TransDt.Trans_ID = ".$txtTransId.
						  " And TransDt.TransDt_dbcd = '".$Type_dbcd1."' ".
					      " Order By TransDt.TransDt_ID Desc ";
			//echo $sub_query1;
			$sub_result1=mysql_query($sub_query1,$connection) or die(mysql_error());
			while($sub_rows1=mysql_fetch_array($sub_result1)){
			    
				$ct+=1;

				if($ct%2==0)
					$Color="style='background-color:".$grid_color1."'";
				else			
					$Color="style='background-color:".$grid_color2."'";	
				
				$StyleDetail = 'style15';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows1[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}	
				
				if ($sub_rows1[1] != "" && $Module_ShowBalance == 1) {
					$querybalance  = "SELECT IFNULL(SUM(if(journaldt_dbcd = 'D', journaldt_amount1, (-1)*journaldt_amount1)), 0) As Balance FROM journaldt where ledger_number = '".$sub_rows1[1]."' and date_format(journaldt.journal_date,'%Y%m%d') <= date_format('".insertMySQLDate($txtDate)."','%Y%m%d')";
					$resultbalance = selectData($connection, $querybalance);
					$CurrBalance   = $resultbalance[0];
				}
				
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=UpdateTransDt('".$sub_rows1[0]."','".$Type_dbcd1."') title='Edit Record'  ></span></td>";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=DeleteTransDt('".$sub_rows1[0]."') title='Delete Record'  ></span></td>";
				
				
				if ($Module_Project == 1 || $Module_ProjectDt == 1 || $Module_CostCenter == 1 || $Module_CostCenterDt == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstjourDt('".$sub_rows1[0]."','".$sub_rows1[4]."') title='Projects/Costcenters'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
				
				if ($sub_rows1[10] == 1 || $sub_rows1[10] == 2 || $sub_rows1[10] == 3 || $sub_rows1[10] == 4)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkjourDt('".$sub_rows1[0]."','".$sub_rows1[4]."','".$sub_rows1[10]."') title='Checks/Bills'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
					
				if (((($TransType == 'RV' || $TransType == 'CV') && $sub_rows1[9] == 'C') || (($TransType == 'PV' || $TransType == 'DV') && $sub_rows1[9] == 'D')) && $ModuleInvoiceGrid == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/invoice_icon.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddInvoice('".$sub_rows1[0]."','".$sub_rows1[4]."') title='Invoice'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";			
					
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[1]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[2]."</span></td>";
				//echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[3]."</span></td>";
				
				if($Module_ShowBalance == 1) {
					echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($CurrBalance, $DecimalBase1)."</span></td>";
					echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[3]."</span></td>";
				} else {
					echo "	<td align='left' colspan='2'><span class='".$StyleDetail."'>".$sub_rows1[3]."</span></td>";
				}
				
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[10]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[4]."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[5], $DecimalBase)."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[6], $DecimalBase)."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[7], $DecimalBase)."</span></td>";	
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[8]."</span></td>";
				
				echo "</tr>";
								
			}
			
		 }
		 
		 
		 //***********Second Side*****************************
		  
		 
		  echo"<tr bgcolor='#F7F7F7' height='20'>";
		  echo"  <td align='center' colspan='15'><span class='style16'>$Type_Label2</span></td>";
		  echo"</tr>";
		  
		  echo"<tr height='20'>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
          echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger No.</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger Desc.</span></td>";
		  
		  if($Module_ShowBalance == 1) {
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Balance</span></td>";
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Description</span></td>";
		  }	else {
			echo"  <td bgcolor='#F7F7F7' align='center' colspan='2'><span class='style27'>Description</span></td>";
		  }
		  
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>ManualNo</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Currency</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount $base1</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Amount $base2</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Value Date</span></td>";
          echo"</tr>";
		  
		  
		  
		  if ($txtTransId != '' && $Type_dbcd2 != '') {
		     
			  
			$sub_query2 = " Select TransDt.TransDt_id, TransDt.Ledger_Number, Ledger.Ledger_Name, TransDt_Description, TransDt.Currency_Code, ".
					      " Round(Transdt_Amount, ".$DecimalBase."), Round(Transdt_Amount1, ".$DecimalBase."), Round(Transdt_Amount2, ".$DecimalBase."), ".
					      " Date_Format(TransDt_ValueDate,'%d/%m/%Y') As TransDt_ValueDate, TransDt_dbcd, Ledger.Ledger_Activity, TransDt_ManualNo ".
					      " From Temp_TransDt As TransDt Left Join Ledger on TransDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where TransDt.Trans_ID = ".$txtTransId.
						  " And TransDt.TransDt_dbcd = '".$Type_dbcd2."' ".
					      " Order By TransDt.TransDt_ID Desc ";
			//echo $sub_query2;
			$sub_result2=mysql_query($sub_query2,$connection) or die(mysql_error());
			while($sub_rows2=mysql_fetch_array($sub_result2)){
			    
				$ct+=1;

				if($ct%2==0)
					$Color="style='background-color:".$grid_color1."'";
				else			
					$Color="style='background-color:".$grid_color2."'";	
						
				$StyleDetail = 'style15';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows2[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}
				
				if ($sub_rows2[1] != "" && $Module_ShowBalance == 1) {
					$querybalance  = "SELECT IFNULL(SUM(if(journaldt_dbcd = 'D', journaldt_amount1, (-1)*journaldt_amount1)), 0) As Balance FROM journaldt where ledger_number = '".$sub_rows2[1]."' and date_format(journaldt.journal_date,'%Y%m%d') <= date_format('".insertMySQLDate($txtDate)."','%Y%m%d')";
					$resultbalance = selectData($connection, $querybalance);
					$CurrBalance   = $resultbalance[0];
				}
				
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=UpdateTransDt('".$sub_rows2[0]."','".$Type_dbcd2."') title='Edit Record'  ></span></td>";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=DeleteTransDt('".$sub_rows2[0]."') title='Delete Record'  ></span></td>";
				
				if ($Module_Project == 1 || $Module_ProjectDt == 1 || $Module_CostCenter == 1 || $Module_CostCenterDt == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstjourDt('".$sub_rows2[0]."','".$sub_rows2[4]."') title='Projects/Costcenters'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";

				if ($sub_rows2[10] == 1 || $sub_rows2[10] == 2 || $sub_rows2[10] == 3 || $sub_rows2[10] == 4)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkjourDt('".$sub_rows2[0]."','".$sub_rows2[4]."','".$sub_rows2[10]."') title='Checks/Bills'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
					
				if (((($TransType == 'RV' || $TransType == 'CV') && $sub_rows2[9] == 'C') || (($TransType == 'PV' || $TransType == 'DV') && $sub_rows2[9] == 'D')) && $ModuleInvoiceGrid == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/invoice_icon.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddInvoice('".$sub_rows2[0]."','".$sub_rows2[4]."') title='Invoice'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";		
					
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[1]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[2]."</span></td>";
				//echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[3]."</span></td>";
				
				if($Module_ShowBalance == 1) {
					echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($CurrBalance, $DecimalBase1)."</span></td>";
					echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[3]."</span></td>";
				} else {
					echo "	<td align='left' colspan='2'><span class='".$StyleDetail."'>".$sub_rows2[3]."</span></td>";
				}
				
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[10]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows2[4]."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows2[5], $DecimalBase)."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows2[6], $DecimalBase)."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows2[7], $DecimalBase)."</span></td>";	
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows2[8]."</span></td>";
				
				echo "</tr>";
								
			}
			
		 }
		 
		
		echo "</table>";   //</div>

}	else {

	echo" <table border='0' style='table-layout:fixed'>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=100>
		  <col width=150>
		  <col width=85>
		  <col width=120>
		  <col width=80>
		  <col width=50>
		  <col width=100>
		  <col width=100>
		  <col width=80>";
		  
		  echo"<tr height='20'>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='left'><span class='style27'>&nbsp;</span></td>";
          echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger No.</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Ledger Desc.</span></td>";
		  
		  if($Module_ShowBalance == 1) {
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Balance</span></td>";
			echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Description</span></td>";
		  }	else {
			echo"  <td bgcolor='#F7F7F7' align='center' colspan='2'><span class='style27'>Description</span></td>";
		  }
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>ManualNo</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Currency</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Debit</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Credit</span></td>";
		  echo"  <td bgcolor='#F7F7F7' align='center'><span class='style27'>Value Date</span></td>";
          echo"</tr>";

		  
		  if ($txtTransId != '') {
			  
			$sub_query1 = " Select TransDt.TransDt_id, TransDt.Ledger_Number, Ledger.Ledger_Name, TransDt_Description, TransDt.Currency_Code, ".
					      " if (TransDt_dbcd='D', Round(Transdt_Amount, ".$DecimalBase."),'') As DebitAmount, ".
						  " if (TransDt_dbcd='C', Round(Transdt_Amount, ".$DecimalBase."),'') As CreditAmount, ".
					      " Date_Format(TransDt_ValueDate,'%d/%m/%Y') As TransDt_ValueDate, TransDt_dbcd, Ledger.Ledger_Activity, TransDt_ManualNo ".
					      " From Temp_TransDt As TransDt Left Join Ledger on TransDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where TransDt.Trans_ID = ".$txtTransId.
					      " Order By TransDt.TransDt_ID Desc ";
			//echo $sub_query1;
			$sub_result1=mysql_query($sub_query1,$connection) or die(mysql_error());
			while($sub_rows1=mysql_fetch_array($sub_result1)){
			    
				$ct+=1;

				if($ct%2==0)
					$Color="style='background-color:".$grid_color1."'";
				else			
					$Color="style='background-color:".$grid_color2."'";	
				
				$StyleDetail = 'style15';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows1[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}	
				
				if ($sub_rows1[1] != "" && $Module_ShowBalance == 1) {
					$querybalance  = "SELECT IFNULL(SUM(if(journaldt_dbcd = 'D', journaldt_amount1, (-1)*journaldt_amount1)), 0) As Balance FROM journaldt where ledger_number = '".$sub_rows1[1]."' and date_format(journaldt.journal_date,'%Y%m%d') <= date_format('".insertMySQLDate($txtDate)."','%Y%m%d')";
					$resultbalance = selectData($connection, $querybalance);
					$CurrBalance   = $resultbalance[0];
				}
		
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=UpdateTransDt('".$sub_rows1[0]."','".$Type_dbcd1."') title='Edit Record'  ></span></td>";
				echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=DeleteTransDt('".$sub_rows1[0]."') title='Delete Record'  ></span></td>";
				
				
				if ($Module_Project == 1 || $Module_ProjectDt == 1 || $Module_CostCenter == 1 || $Module_CostCenterDt == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstjourDt('".$sub_rows1[0]."','".$sub_rows1[4]."') title='Projects/Costcenters'  ></span></td>";
					else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
				
				if ($sub_rows1[9] == 1 || $sub_rows1[9] == 2 || $sub_rows1[9] == 3 || $sub_rows1[9] == 4)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkjourDt('".$sub_rows1[0]."','".$sub_rows1[4]."','".$sub_rows1[9]."') title='Checks/Bills'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
					
				if (((($TransType == 'RV' || $TransType == 'CV') && $sub_rows1[8] == 'C') || (($TransType == 'PV' || $TransType == 'DV') && $sub_rows1[8] == 'D')) && $ModuleInvoiceGrid == 1)
					echo "	<td align='center' valign='center'><span class='style15'><img src='img/invoice_icon.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddInvoice('".$sub_rows1[0]."','".$sub_rows1[4]."') title='Invoice'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";	
					
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[1]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[2]."</span></td>";
				
				if($Module_ShowBalance == 1) {
					echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($CurrBalance, $DecimalBase1)."</span></td>";
					echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[3]."</span></td>";
				} else {
					echo "	<td align='left' colspan='2'><span class='".$StyleDetail."'>".$sub_rows1[3]."</span></td>";
				}
				
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[10]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[4]."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[5], $DecimalBase)."</span></td>";
				echo "	<td align='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[6], $DecimalBase)."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[7]."</span></td>";
				
				echo "</tr>";
								
			}
			
		 }

	echo "</table>";   
	
}	

echo"   </td></tr>";

echo"   <tr bgcolor='#D8D8D8' height='30'><td colspan='9' align='center'>";

echo"       <input type='button' id='btnClear' name='btnClear' value='Clear Page'   onclick='ClearPage();' $style title='Clear Page'>";
				
echo"       <input type='button' name='btnCancel' id='btnCancel' value='Cancel' ";//cancel
			if ($actionmode=='cancel' || ($actionmode=='' && $mainaction!='edit'))
				echo " disabled ";
			echo" onclick='CancelRecord();' $style title='Cancel Changes'>";
				
echo"       <input type='button' name='btnPost' id='btnPost' value='Save' ";//post
			if (($actionmode=='' || $actionmode=='cancel') && $mainaction!='edit')
				echo " disabled ";
			echo" onclick='PostChanges($Module_RestrictProjCost,$Module_RestrictCost,$ModuleRestrictCashType);' $style	title='Save Changes' />";

echo"       <input name='btnSearch' type='button' id='btnSearch' value='Search' onclick='SearchForRef();' $style title='Search By Reference' ";
            if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit') 
			    echo " disabled ";
		    echo " />";
				
echo"       <input name='btnPending' type='button' id='btnPending' value='Pending' onclick='SearchForPending();' $style title='Search Pending'  ";
            if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit')
			    echo " disabled ";
		    echo " />";

if ($ModulePostTrx == 1 && $txtTransId == '') {
	echo"	<input name='btnPostTrx' type='button' id='btnPostTrx' value='Post Transactions' onclick='SearchUnPosted();' $style title='Post Transactions'  />";
}

if ($Module_PaymentRqst == 1 && $TransType == 'PV' && $txtTransId == '') {
	echo"	<input name='btnLoadRequests' type='button' id='btnLoadRequests' value='Payment Requests' onclick='SearchPayRequests();' $style title='Load Payment Request'  />";
}

echo"   </td></tr>";	

echo"   </table></td></tr>"; 

echo" </table>  ";//end of last table menu

if ($actionmode == "post"  && $PrTransId != '') {
	echo '<script type="text/javascript" language="javascript">';
	
	if ($Login_FastPrint == 1) 
		echo ' PrintTrans(\''.$PrTransId.'\', \''.$PrTransRef.'\'); ';
		
	echo ' ClearPage1(); ';
	echo '</script>';

}	

print <<<HERE
</form>
</body>

HERE;

$SetCurrency = 0;

?>