<?php

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

//Gilbert 28/12/2013 : adding design files and code for layout

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

$TransType = 'PV';

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


$querylog="SELECT FA_PaymentRqst as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['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_PaymentRqstApp,0) As FA_PaymentRqstApp, ifNull(Login_FastPrint,0) As Login_FastPrint, ifNull(Branch_Manager,0) as Branch_Manager, ifnull(FI_PRequestConfirmed,0) as FI_PRequestConfirmed ".
		  " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

$isHOD = 0;
$isAuth = 0;
$hasHod = 0;

$queryHod = "select distinct 1 from ".$_SESSION['dbLabel'].".HOD_Users where upper(hod_code) = upper('".$_SESSION['useraccount']."') ";	
$resHod = mysql_query($queryHod, $connection);
$rowHod = mysql_num_rows($resHod);
if ($rowHod > 0)
	$isHOD = 1;

$queryHod = "select 1 from ".$_SESSION['dbLabel'].".HOD_Users where upper(user_code) = upper('".$_SESSION['useraccount']."') ";	
$resHod = mysql_query($queryHod, $connection);
$rowHod = mysql_num_rows($resHod);
if ($rowHod > 0)
	$hasHod = 1;

$queryAuth = "select distinct 1 from Source_Fundsdt where user_code = '".$_SESSION['useraccount']."' ";	
$resAuth = mysql_query($queryAuth, $connection);
$rowAuth = mysql_num_rows($resAuth);
if ($rowAuth > 0)
	$isAuth = 1;


//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_TransStandardView,0) As Module_TransStandardView, ifNull(Module_PaymentLimit,0) as Module_PaymentLimit,  ".
			 " ifNull(Module_Grn,0) As Module_Grn, ifNull(Module_DownPayment,0) As Module_DownPayment ".
			 " From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}
$Module_TransStandardView=0;

$querycurrency="select Currency_code from currency order by currency_code";
$resultcurrency=mysql_query($querycurrency,$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);
}

$querymodule=" Select ifNull(paymentrqstNoDt,0) As paymentrqstNoDt, ifnull(toBeApprovedByHOD,0) as toBeApprovedByHOD ".
			 " From paymentsetup";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

$querypaymentmode = "select paymentmode_code, paymentmode_desc from Payment_Mode order by paymentmode_code ";
$respaymentmode   = mysql_query($querypaymentmode, $connection);
$numpaymentmode   = mysql_num_rows($respaymentmode);

$queryfunds  = "select sourceFund_Code, sourceFund_desc from Source_Funds order by sourceFund_Code ";
$resfunds	 = mysql_query($queryfunds, $connection);
$numfunds	 = mysql_num_rows($resfunds);

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

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

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

$Title = '';
$HeaderTitle = '';
$Title = 'PAYMENT REQUEST';      
if(empty($Type_dbcd)) $Type_dbcd = 'D';  

$Type_dbcd1 = 'D';
$Type_dbcd2 = 'C'; 
$Type_Label1 = 'Debit Accounts'; 
$Type_Label2 = 'Credit Accounts'; 

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


print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 



<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">
<script type="text/javascript" language="javascript">


function CheckFields(ModuleRestProj, ModuleRestCost){
  
    x = document.paymentrqst;
	
	var vDate    	= x.txtDate.value;
	var vProject 	= x.txtProjectCode.value;
	var vCostCenter = x.txtCostCentCode.value;
	var vCurr	    = x.txtCurr.value;
	var vApprovedBy = x.txtApprovedBy.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 (vApprovedBy=='' )
	{
		alert("To be Approved by is mandatory!");
		x.txtApprovedBy.focus();
		return 0;
	}
		
	
	else
	return 1 ;	
}




function ClearPage(){
	x = document.paymentrqst;
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		if(x.paymentrqstNoDt.value==1){
			var TransId     = x.txtTransId.value;
			x.action="Form_PaymentRqst_Actions.php?mode=cancelrecord&mainmode=cancelrecord&STransId="+TransId;
			x.submit();
		}
		else {
		ClearForm('All');
		
		x.mainaction.value='insert';
		x.actionmode.value='';
		x.action='Form_PaymentRqst_Actions.php';
		x.submit();
		}
	}	
}

function ClearPage1(){
	x = document.paymentrqst;
	var msg = x.message.value;
	
	ClearForm('All');
	
	x.mainaction.value='insert';
	x.actionmode.value='';
	x.message.value=msg;
	x.action='Form_PaymentRqst.php?message='+x.message.value;
	x.submit();
}

function CancelRecord(){
	x = document.paymentrqst;
	var vmode  = x.mainaction.value;
	var vmode1 = x.actionmode.value;
	var TransId = x.txtTransId.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_PaymentRqst.php';
		x.submit();
	}
    
}



function PostChanges(ModuleRestProj, ModuleRestCost,paymentrqstNoDt) {
	x = document.paymentrqst;
	var TransId     = x.txtTransId.value;
	var vMainMode   = x.mainaction.value;
	var result = CheckFields(ModuleRestProj, ModuleRestCost);
	
	var vTransAmtBal1 = x.txtTransAmtBal1.value;
	var vTransAmtBal2 = x.txtTransAmtBal2.value;
	
	var ApprovedByHOD = x.toBeApprovedByHOD.value;
	
	if(paymentrqstNoDt==0){
	if (x.txtCountDetail.value == 0 || x.txtCountDetail.value == '') {
		alert('Save not allowed. Please add Details.');
	}
	}else {
		if (document.getElementById("txtProjectCode")){
		if (x.txtProjectCode.value == '') {
		alert('Save not allowed. Please add Project.');
		return 0;
		} 
		}else if (document.getElementById("txtCostCentCode")) 
		{
			if (x.txtCostCentCode.value == '') {
				alert('Save not allowed. Please add Costcenter.');
				return 0;
			}
		}
		if (ApprovedByHOD == 1 && x.txtApprovedBy.value == ''){
				alert('Save not allowed. To be Approve By is Empty.');
				x.txtApprovedBy.focus();
				return 0;
		}
		else if (x.txtConfirmed.value == 1 && x.txtConfirmedBy.value == '' && ApprovedByHOD == 1){ 
			alert('Save not allowed. To be Confirmed By is Empty.');
			x.txtConfirmedBy.focus();
			return 0;
		} 
	}
	 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;
				if(paymentrqstNoDt == 0)
				vMode = 'post';	
				else if(paymentrqstNoDt == 1 && TransId=='')
				vMode = 'saverecord';	
				else if(paymentrqstNoDt == 1 && TransId !='')
				{vMode = 'editrecord';
				vMainMode='editrecord';
				}
				x.actionmode.value='post';
				x.action="Form_PaymentRqst_Actions.php?mode="+vMode+"&mainmode="+vMainMode+"&STransId="+TransId;
				x.submit();
			}
		}
	}	
}

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

}

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

	if (TransDtType=='D') vTransDtType = 1; else vTransDtType = 2;
	
	win = window.open('Form_PaymentRqstDetail.php?mainaction='+vMainMode+'&actionmode=&PTransId='+vTransId+'&PTransDate='+vTransDate+'&PTransDtType='+vTransDtType+'&PTransDtId='+TransDtId, 'Form_PaymentRqstDetail', '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, AccountType) {
	x = document.paymentrqst;
	
	var result = CheckFields(ModuleRestProj, ModuleRestCost);

	var vTransId   		   = x.txtTransId.value;
	var vTransDate 		   = x.txtDate.value;
	var vTransRepresent    = x.txtRepresent.value;
	var vTransApprovedBy   = x.txtApprovedBy.value;
	var vTransApproved     = x.txtApproved.value;
	var vTransConfirmed    = x.txtConfirmed.value;
	var vTransCurr         = x.txtCurr.value;
	var vTransRemark       = x.txtRemark.value;
	var vTransManualNo     = x.txtManualNo.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');
	vTransApprovedBy   = vTransApprovedBy.replace('&','%26');
	vTransManualNo     = vTransManualNo.replace('&','%26');
	vTransProjectCode  = vTransProjectCode.replace('&','%26');
	vTransCostCentCode = vTransCostCentCode.replace('&','%26');
	
	if(vTransConfirmed == '') vTransConfirmed=0;
	if (result == 1) {
		win = window.open('Form_PaymentRqstDetail.php?mainaction='+vMainMode+'&actionmode=&PAccountType='+AccountType+'&PTransId='+vTransId+'&PTransDate='+vTransDate+
		                  '&PTransApproved='+vTransApproved+'&PTransConfirmed='+vTransConfirmed+'&PTransCurr='+vTransCurr+'&PTransManualNo='+vTransManualNo+'&PTransProjectCode='+vTransProjectCode+
						  '&PTransCostCentCode='+vTransCostCentCode+'&PTransRepresent='+vTransRepresent+'&PTransApprovedBy='+vTransApprovedBy+'&PTransRemark='+vTransRemark, 
						  'Form_PaymentRqstDetail', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=650,height=300,top=100');
		win.creator = self;
		win.focus();		
	}	
	
    
}

function AddCstRqst(TransDtId,TransDtCurr) {
	x = document.paymentrqst;

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

function AddChkRqst(TransDtId,TransDtCurr,LedgerActivity) {
	x = document.paymentrqst;

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



//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.paymentrqst;
	var vmode = x.actionmode.value;
	
	if (Option == 'All') {
		
		x.txtTransId.value='';
		x.txtRef.value='';
		x.txtApprovedBy.value='';
		x.txtApproved.value=0;
		x.txtConfirmed.value=0;
		x.txtDate.value='';
		x.txtRepresent.value='';
		x.txtCurr.value='';
		x.txtTotalAmount.value='';
		x.txtRemark.value='';
		x.txtManualNo.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.txtpaymentmode.value = '';
		x.txtfunds.value = '';
		x.txtConfirmedBy.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.paymentrqst;
	win = window.open('Form_PaymentRqstSearch.php', 'Form_PaymentRqstSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1050,height=500,top=100,left=0');		
	win.creator = self;
	win.focus();		
			
}

function SearchForPending(){
    //ClearForm('All');
    x = document.paymentrqst;
	win = window.open('Form_PaymentRqstSearchPending.php', 'Form_PaymentRqstSearchPending', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=580,top=100,left=0');		
	win.creator = self;
	win.focus();		
			
}

function ListToApprove(){
	x = document.paymentrqst;
	win = window.open('Form_PaymentRqstApproveList.php', 'Form_PaymentRqstApproveList', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1250,height=580,top=100,left=0');		
	win.creator = self;
	win.focus();
}

function ListToConfirm() {
	x = document.paymentrqst;
	win = window.open('Form_PaymentRqstConfirmList.php', 'Form_PaymentRqstConfirmList', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1250,height=590,top=100,left=0');		
	win.creator = self;
	win.focus();
}

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

function PrintTrans(TransId, TransRef) {
	var str = '';
	x = document.paymentrqst;
	
	if (confirm ( "Do you want to Print current Payment Request with reference "+TransRef+" ?"))
	{
		str = 'Form_PaymentRqstPreview.php?PaymentRqstId='+TransId;
		window.open(str);
	}	
	
	
}

function SetApproved() {
	x = document.paymentrqst;
	
	x.txtApproved.value = 0;
	if (x.chkApproved.checked)
		x.txtApproved.value = 1; 

}

function SetConfirmed() {
	x = document.paymentrqst;
	
	x.txtConfirmed.value = 0;
	if (x.chkConfirmed.checked)
		x.txtConfirmed.value = 1;

}

function showlistProject(str){

  window.open('List_SorProject.php?frm=14&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=14&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistUsers(str){
	var funds = document.getElementById('txtfunds').value;
	if (str == '5' && funds == '') {
		alert('Select a Source Fund First!');		
		return 0;
	}
	else
		window.open('list_users.php?frm='+str+'&funds='+funds,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function SearchConfirmedPorder(){
	x = document.paymentrqst;

	win = window.open('Form_PaymentRqst_LoadPorder.php', 'Form_PaymentRqst_LoadPorder', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1100,height=580,top=50,left=50');
	win.creator = self;
	win.focus();		
	
}

function searchUnconfirmed(){
	win = window.open('Form_PaymentRqstUnconfirmed.php', 'Unconfirmed Payment', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1100,height=580,top=50,left=50');
	win.creator = self;
	win.focus();		
}

function kd(e)
{ 

	x=document.paymentrqst;
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13) { //enter key
        //x.btnSubmitRecord.click();
		
		return false;
    }
    return true;
}

function checktype(ptype){
 if(ptype==1){
		if(document.getElementById("txtcash").checked){
			document.getElementById("txtcheck").checked=false;
			document.getElementById("txtcash").value=1;
			document.getElementById("txtcheck").value=0;
			}
		else if(!document.getElementById("txtcash").checked){
			document.getElementById("txtcheck").checked=true;
			document.getElementById("txtcash").value=0;
			document.getElementById("txtcheck").value=1;
			}
	}
	if(ptype==2){
		if(document.getElementById("txtcheck").checked){
			document.getElementById("txtcash").checked=false;
			document.getElementById("txtcash").value=0;
			document.getElementById("txtcheck").value=1;
			}
		else if(!document.getElementById("txtcheck").checked){
			document.getElementById("txtcash").checked=true;
			document.getElementById("txtcash").value=1;
			document.getElementById("txtcheck").value=0;
			}
	}
	if(ptype==3){
		if(document.getElementById("txtcostshare").checked){
			document.getElementById("txtguarantee").checked=false;
			document.getElementById("txtcostshare").value=1;
			document.getElementById("txtguarantee").value=0;
			}
		else if(!document.getElementById("txtcostshare").checked){
			document.getElementById("txtguarantee").checked=true;
			document.getElementById("txtcostshare").value=0;
			document.getElementById("txtguarantee").value=1;
			}
	}
	if(ptype==4){
		if(document.getElementById("txtguarantee").checked){
			document.getElementById("txtcostshare").checked=false;
			document.getElementById("txtcostshare").value=0;
			document.getElementById("txtguarantee").value=1;
			}
		else if(!document.getElementById("txtguarantee").checked){
			document.getElementById("txtcostshare").checked=true;
			document.getElementById("txtcostshare").value=1;
			document.getElementById("txtguarantee").value=0;
			}
	}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$HeaderTitle</title>
<style>

.style17 {color: #FFFFFF; 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='paymentrqst' 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' >
<input type='hidden' name='toBeApprovedByHOD' value='$toBeApprovedByHOD' >


HERE;

//Get Default Project
$querydflproject="select project_code as defaultproject from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['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 ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['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 PaymentRqst_Id, PaymentRqst_RefGovernment, Date_Format(PaymentRqst_Date,'%d/%m/%Y') As PaymentRqst_Date, ".
			 " PaymentRqst_Remark, PaymentRqst_Name, ifNull(PaymentRqst_App,0), Touser_account, ifNull(PaymentRqst_Confirmed,0), User_Confirmed, ".
			 " PaymentRqst_ManualNo, PaymentRqst_Desc, PaymentRqst.Project_Code, PaymentRqst.Costcent_Code, Currency_Code,  ".
			 " ifNull(PaymentRqst_AmountD1,0), ifNull(PaymentRqst_AmountD2,0), ifNull(PaymentRqst_AmountC1,0), ifNull(PaymentRqst_AmountC2,0)  ".
			 " ,paymentrqst_cash,paymentrqst_check,paymentrqst_costshare,paymentrqst_guarantee, sourceFund_Code, paymentmode_code  ".
			 " From Temp_PaymentRqst As PaymentRqst ".
	         " Where PaymentRqst_Id = ".$txtTransId;
			 
			 
	//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];
	$txtRemark        = $rows[3];
	$txtRepresent     = $rows[4];
	$txtApproved	  = $rows[5];
	$txtApprovedBy	  = $rows[6];
	$txtConfirmed	  = $rows[7];
	$txtConfirmedBy	  = $rows[8];
	$txtManualNo 	  = $rows[9];
	$txtProjectCode   = $rows[11];
	$txtCostCentCode  = $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;
	
	$txtTotalAmount = ConvertCurrency($base1, $txtCurr, insertMySQLDate($txtDate), $txtTransAmtDb1, $connection);
	$txtTotalAmount = number_format($txtTotalAmount,$DecimalBase);
	
	$txtcash 		= $rows[18];
	$txtcheck 		= $rows[19];
	$txtcostshare 	= $rows[20];
	$txtguarantee 	= $rows[21];
	$txtfunds	 	= $rows[22];
	$txtpaymentmode = $rows[23];
	
	$query = " Select Count(*) FROM Temp_PaymentRqstDt ".
			 " WHERE PaymentRqst_Id = ".$txtTransId;
	$result = selectData($connection, $query);
	$txtCountDetail = $result[0];
	if($txtCountDetail == '') $txtCountDetail = 0;
	if ($txtConfirmedBy == $_SESSION['useraccount'])
		$isAuth = 1;
	
	
}


//Search/Cancel Mode	
if ($actionmode == "cancel" && $txtTransId != '') {
	
	// Delete From Temp Tables Already Filled By Search
	$query = " DELETE FROM Temp_ChkRqst ".
			 " WHERE PaymentRqstDt_Id In (Select PaymentRqstDt_Id From Temp_PaymentRqstDt Where PaymentRqst_Id = ".$txtTransId." ) ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 
	  
	$query = " DELETE FROM Temp_BillRqst ".
			 " WHERE PaymentRqstDt_Id In (Select PaymentRqstDt_Id From Temp_PaymentRqstDt Where PaymentRqst_Id = ".$txtTransId." ) ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error();   
	  
	$query = " DELETE FROM Temp_CstRqst ".
			 " WHERE PaymentRqstDt_Id In (Select PaymentRqstDt_Id From Temp_PaymentRqstDt Where PaymentRqst_Id = ".$txtTransId." ) ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 

	$query = " DELETE FROM Temp_PaymentRqstDt ".
			 " WHERE PaymentRqst_Id = ".$txtTransId;
	if (!updateData($connection, $query, true))
      $message  = mysql_error(); 
	
	  
	$query = " DELETE FROM Temp_PaymentRqst ".
			 " WHERE PaymentRqst_Id = ".$txtTransId;
	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 cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>$Title</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='28'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";
echo "<input type='hidden' name='paymentrqstNoDt' id='paymentrqstNoDt' value='$paymentrqstNoDt' >";
	echo"       <button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>Clear Page</span></span></button>";	
echo"       <button type='button' id='btnCancel' name='btnCancel' title='Cancel Changes' ";
if ($actionmode=='cancel' || ($actionmode=='' && $mainaction!='edit'))
				echo " disabled ";
				echo" onclick='CancelRecord(); return false;'><span><span>Cancel</span></span></button>"; 	
				
echo"       <button type='button' id='btnPost' name='btnPost' title='Save Changes' ";
			if($paymentrqstNoDt==0){
			if (($actionmode=='' || $actionmode=='cancel') && $mainaction!='edit')
				echo " disabled ";
			}
			//else if($paymentrqstNoDt==1){
			//if (($actionmode=='cancel') )
			//	echo " disabled ";	}
			echo" onclick='PostChanges($Module_RestrictProjCost,$Module_RestrictCost,$paymentrqstNoDt);' 	title='Save Changes' /><span><span>Save</span></span></button>";

echo"       <button type='button' id='btnSearch' name='btnSearch' title='Search By Reference' ";

            if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit') 
			    echo " disabled ";
		    echo "  onclick='SearchForRef();'/><span><span>Search</span></span></button>";
	
echo"       <button type='button' id='btnPending' name='btnPending' title='Search Pending' ";


            if (($actionmode!='' && $actionmode!='cancel') || $mainaction=='edit')
			    echo " disabled ";
		    echo " onclick='SearchForPending();' /><span><span>Pending</span></span></button>";

if ($Module_PaymentLimit == 1 && $Branch_Manager == 1 && $txtTransId == '') {
	echo"<button type='button' id='btnApprove' name='btnApprove' onclick='ListToApprove(); return false;' title='List of Payment Requests To be Approved By B.M'><span><span>Approve List</span></span></button>";	
	//echo"    <input name='btnApprove' type='button' id='btnApprove' value='Approve List' onclick='ListToApprove();' $style title='List of Payment Requests To be Approved By B.M'  />";
	//echo"    <input name='btnConfirm' type='button' id='btnConfirm' value='Confirm List' onclick='ListToConfirm();' $style title='List of Payment Requests To be Confirmed'  />";
}
if ($Module_PaymentLimit == 1 && $FI_PRequestConfirmed == 1 && $txtTransId == '') {
echo" <button type='button' id='btnConfirm' name='btnConfirm' onclick='ListToConfirm(); return false;' title='List of Payment Requests To be Confirmed'><span><span>Confirm List</span></span></button>";	
}

if (($Module_Grn == 1 || $Module_DownPayment==1) && $txtTransId == ''){
	echo" <button type='button' id='btnSearchPorder' name='btnSearchPorder' onclick='SearchConfirmedPorder(); return false;' title='Search Confirmed Porder'><span><span>Load Purchase Order</span></span></button>";
}	
if ($toBeApprovedByHOD == 1 && ($isHOD == 1 || $isAuth == 1)){
			
	echo" <button type='button' id='btnSearchPorder' name='btnSearchPorder' onclick='searchUnconfirmed(); return false;' title='Search Confirmed Porder'><span><span>Unconfirmed Requests</span></span></button>";
}
echo"	</td></tr></table>";
echo"</td></tr>";
				
echo"<tr><td id='content-body'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
   <tr bgcolor='#F7F7F7'><td valign='top'>";	 

$strt = $_SESSION['StartFinancial_Date'];
$end = $_SESSION['EndFinancial_Date'];
print <<<HERE
		
		<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=250>
		<tr bgcolor="#F7F7F7" height='25'> 
          <td valign="center" align='left' ><span class="style1">Reference&nbsp;<span class="style16">*</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'>
  	      <td align="left"><span class="style1">Date&nbsp;<span class="style16">*</span></span></td>
		  <td colspan='3' align='left'><input type='text' size='10' name='txtDate' value='$txtDate'     onBlur=checkDateFormat(this,$strt,$end)   maxlength='10'  >
		       <a HREF="#" onClick="displayCalendar(document.paymentrqst.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 align='left' ><span class='style1'>Currency&nbsp;<span class='style16'>*</span></span></td>";


if ($txtTransId == '') {
	echo" <td ><span class='style1'><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'  style='width:85px;' ";
if($paymentrqstNoDt==0) echo " readonly ";
echo "></td>";


	echo"<td rowspan='6' valign='top'><table border='0' style='table-layout:fixed' cellspacing=0 cellpadding=0>
			";
	
	
	echo"<tr>
		<td id='total-top' style='width:240px;height:12px;'></td>
		</tr>
		<tr><td id='total-content' style='width:240px;height:12px;'>";
				
		echo"	<table border='0' cellspacing=0 width=100% >
		<col width=40>
			<col width=60>
			<col width=140>";
		
	if ($Module_TransStandardView == 1) {
		echo" <tr  height='23'>
			     <td valign='center' align='center' ><span class='style10'>$base1</span></td> 
			     <td valign='center' align='right' ><span class='style10'>Debit</span>&nbsp;</td> 
			     <td align='left'><input type='text' name='txtTransAmtDb1' value='".number_format($txtTransAmtDb1,$DecimalBase1)."' maxlength='20' readonly style='text-align:right; width:100px; height=20px;'></td>
		      </tr>
		  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Credit</span>&nbsp;</td> 
				 <td align='left'><input type='text' name='txtTransAmtCr1' value='".number_format($txtTransAmtCr1,$DecimalBase1)."' maxlength='20' readonly style='text-align:right; width:100px; height=20px;'></td>
			  </tr>
			  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Balance</span>&nbsp;</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=20px;";
				 
				  if($txtTransAmtBal1<0) echo " color:#FF0000;";
				 echo"'></td></tr>
	
	
			  <tr  height='23'>
				 <td valign='center' align='center' ><span class='style10'>$base2</span></td> 
				 <td valign='center' align='right' ><span class='style10'>Debit</span>&nbsp;</td> 
				 <td align='left'><input type='text' name='txtTransAmtDb2' value='".number_format($txtTransAmtDb2,$DecimalBase2)."' maxlength='20' readonly style='text-align:right; width:100px; height=20px;'></td>
			  </tr>
			  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Credit</span>&nbsp;</td> 
				 <td align='left'><input type='text' name='txtTransAmtCr2' value='".number_format($txtTransAmtCr2,$DecimalBase2)."' maxlength='20' readonly style='text-align:right; width:100px; height=20px;'></td>
			  </tr>
			  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Balance</span>&nbsp;</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=20px;";
				 if($txtTransAmtBal2<0) echo " color:#FF0000;";
				 
				 echo"'></td></tr>";
	
	} else {
		echo" <tr  height='23'>
			     <td valign='center' align='center' ><span class='style10'>$txtCurr</span></td> 
			     <td valign='center' align='right' ><span class='style10'>Debit</span>&nbsp;</td> 
			     <td align='left'><input type='text' name='txtTransAmtDb' value='".number_format($txtTransAmtDb,$DecimalBase)."' maxlength='20' readonly style='text-align:right; width:100px; height=20px;'></td>
		      </tr>
		  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Credit&nbsp;</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=20px;'></td>
			  </tr>
			  
			  <tr  height='23'>
				 <td valign='center' align='right' colspan='2'><span class='style10'>Balance</span>&nbsp;</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=20px;";
				 
				   if($txtTransAmtBal<0) echo " color:#FF0000;";
				 echo"'></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><tr>
					<td id='total-bottom' style='width:240px;height:12px;'></td>
				</tr>";	  
	echo"</table></td></tr>";





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

echo"     <td align='left' valign='center'><span class='style1'>Manual No</span></td>
		  <td><input type='text' name='txtManualNo' value='".htmlspecialchars($txtManualNo, ENT_QUOTES)."'  style='width:150px;' maxlength='20' ></td>";
echo"   </tr>";



if($paymentrqstNoDt==1 && $txtApprovedBy == ''){
	
	if(($Branch_Manager == 1 && $toBeApprovedByHOD == 0) || ($isHOD == 1 && $toBeApprovedByHOD == 1) ) 	{
		$txtApprovedBy = $_SESSION['useraccount'];
		$txtApproved = 1;
	}
}

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

echo"     <td align='left' valign='center'><span class='style1'>To be Approved by</span></td>
		  <td><input type='text' name='txtApprovedBy' value='".htmlspecialchars($txtApprovedBy, ENT_QUOTES)."'  style='width:140px;' maxlength='20' readonly>&nbsp;";
if ( ($toBeApprovedByHOD == 1 && $txtApproved != 1 && $hasHod == 1) || ($toBeApprovedByHOD == 0))		  
echo "<label><span class='style1'><img src='img/btnopen.jpg' title=' Select User ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistUsers('1');\"  /></span></label>";		  
echo "</td>";
echo"   </tr>";		  


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

if ($Module_PaymentLimit == 1 && $Branch_Manager == 1 && $toBeApprovedByHOD == 0) {
	echo"	<td colspan='2'><span class='style1'><input type='hidden' name='txtApproved' id='txtApproved' value='$txtApproved' size='1'/>
				<input name='chkApproved' type='checkbox' id='chkApproved' value='1' onClick='SetApproved();'   "; 
			  if ($txtApproved==1 ) echo " checked ";  echo " /> Approved by Branch Manager"; 
	echo"	</span></td>";
} else if ( $toBeApprovedByHOD == 1 && $isHOD == 1) {
	echo"	<td colspan='2'><span class='style1'><input type='hidden' name='txtApproved' id='txtApproved' value='$txtApproved' size='1'/>
				<input name='chkApproved' type='checkbox' id='chkApproved' value='1' onClick=\"SetApproved();\"   "; 
			  if ($txtApproved==1 ) echo " checked ";  echo " /> Approved by HOD"; 
	echo"	</span></td>";
} else {
	echo"	<td align='left' colspan='2'>&nbsp;<input type='hidden' name='txtApproved' id='txtApproved' value='$txtApproved' size='1'/></td>";
}	
echo"	</tr>";
if($paymentrqstNoDt==1 && $toBeApprovedByHOD != 1){
	echo"   <tr bgcolor='#F7F7F7' height='25'><td colspan='7'></td><td colspan='4'><table>
	<col width='100px'><col width='100px'><tr><td><span class='style1'><input type='checkbox' name='txtcash' id='txtcash' value='$txtcash' onclick=\"checktype(1);\" ";
	if($txtcash == 1) echo " checked ";
	echo " >Cash</span></td>";
	echo "<td ><span class='style1'><input type='checkbox' name='txtcostshare' id='txtcostshare' value='$txtcostshare' onclick=\"checktype(3);\" "; 
	if($txtcostshare == 1) echo " checked ";
	echo " >costshare</span></td></tr>";
	echo "<tr><td>
	<span class='style1'><input type='checkbox' name='txtcheck' value='$txtcheck' id='txtcheck' onclick=\"checktype(2);\" "; 
	if($txtcheck == 1) echo " checked ";
	echo " >Cheque</span></td><td ><span class='style1'><input type='hidden' name='txtguarantee' id='txtguarantee' value='$txtguarantee' >";
	/*echo "<input type='checkbox' name='txtguarantee' id='txtguarantee' value='$txtguarantee' onclick=\"checktype(4);\" "; 
	if($txtguarantee == 1) echo " checked ";
	echo " >guarantee";*/
	echo "</span></td>";
	echo "</tr></table></td></tr>";
}
else {
	echo "<input type='hidden' name='txtcash' id='txtcash' value=''>
		  <input type='hidden' name='txtcostshare' id='txtcostshare' value=''>
		  <input type='hidden' name='txtcheck' id='txtcheck' value=''>
		  <input type='hidden' name='txtguarantee' id='txtguarantee' value='' >";
	
}
echo"   <tr bgcolor='#F7F7F7' height='25'>";

if ($Module_Project	== 1) {
	echo "<td align='left' ><span class='style1'>Project&nbsp;<span class='style16'>*</span></span></td>
	      <td align='left' colspan='2'> <span class='style1'>
		    <input type='text' name='txtProjectCode' id='txtProjectCode' value='$txtProjectCode' style='width:130px;' maxlength='20' readonly /></span>
		    <label><span class='style1'><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='style1'>Costcenter&nbsp;<span class='style16'>*</span></span></td>";		
	echo" <td align='left' ><span class='style1'>
		    <input type='text' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' style='width:102px;' maxlength='20' readonly /></span>
		    <label><span class='style1'><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>";
}			

if (($Module_PaymentLimit == 1 && $FI_PRequestConfirmed == 1) || ($toBeApprovedByHOD == 1 && $isAuth == 1)) {
	if(($txtConfirmed == '' || $txtConfirmed == 0) && $txtApproved == 1 && $toBeApprovedByHOD != 1) $txtConfirmed=1;
	echo"	<td colspan='2'><span class='style1'><input type='hidden' name='txtConfirmed' id='txtConfirmed' value='$txtConfirmed' size='1'/>
				<input name='chkConfirmed' type='checkbox' id='chkConfirmed' value='1' onClick='SetConfirmed();'   "; 
			  if ($txtConfirmed==1 ) echo " checked ";  echo " /> Confirmed"; 
	echo"	</span></td>";
} else {
	echo"	<td align='left' colspan='2'>&nbsp;<input type='hidden' name='txtConfirmed' id='txtConfirmed' value='$txtConfirmed' size='1'/></td>";
}	
echo"   </tr>";
		  
echo"   <tr bgcolor='#F7F7F7' height='25'>";
if ($numpaymentmode > 0){
		echo "<td align='left' ><span class='style1'>Mode of Payment </span></td>";
		echo" <td align='left' colspan='2'><select name='txtpaymentmode' id='txtpaymentmode' style='width:130px;'>";
		echo "<option value = '' ".($txtpaymentmode==''?'selected':'')."></option>";
	while($rwmode = mysql_fetch_array($respaymentmode)){	
		echo "<option value = '$rwmode[0]' ".($rwmode[0]==$txtpaymentmode?'selected':'').">$rwmode[1]</option>";
	}		
		echo "</select></td>";
} else echo "<td align='left' colspan='3'><input type='hidden' name='txtpaymentmode' id='txtpaymentmode' value='$txtpaymentmode' /></td>";

if ($toBeApprovedByHOD == 1 && $isHOD == 1){
		echo "<td align='left' colspan='2'><span class='style1'>Source Funds </span></td>";
		echo" <td align='left' ><select name='txtfunds' id='txtfunds' style='width:125px;'>";
		echo "<option value = '' ".($txtfunds==''?'selected':'')."></option>";
	while($rwfund = mysql_fetch_array($resfunds)){	
		echo "<option value = '$rwfund[0]' ".($rwfund[0]==$txtfunds?'selected':'').">$rwfund[1]</option>";
	}		
		echo "</select></td>";
	echo "<td align='left'><span class='style1'>To be Confirmed By</span></td>
		<td><input type='text' name='txtConfirmedBy' id='txtConfirmedBy' value='$txtConfirmedBy' style='width:125px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select User ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistUsers('5');\"  /></span></label>
		</td>";	
} else if ($toBeApprovedByHOD == 1 && $isHOD != 1 && $isAuth == 1){
		echo "<td align='left' colspan='2'><span class='style1'>Source Funds </span></td>";
		echo" <td align='left' ><span class='style1'>$txtfunds</span>";
		echo "<input type='hidden' name='txtfunds' id='txtfunds' value='$txtfunds' />";
		echo "</td>";
	echo "<td align='left'><span class='style1'>To be Confirmed By</span></td>
		<td align='center'><span class='style1'>$txtConfirmedBy</span><input type='hidden' name='txtConfirmedBy' id='txtConfirmedBy' value='$txtConfirmedBy' >
		</td>";		
}
else echo "<td align='left' colspan='5'>
				<input type='hidden' name='txtfunds' id='txtfunds' value='$txtfunds' />
				<input type='hidden' name='txtConfirmedBy' id='txtConfirmedBy' value='$txtConfirmedBy'>
			</td>";

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


//Display Buttons

echo"   <tr bgcolor='#F7F7F7' height='25'>
			<td colspan='9' align='center' bgcolor=#D8D8D8>";
			
$query_buttons = " Select JourTypeButton_Name, JourTypeButton_DBCD ".
				 " From JourTypeButton ".
				 " Where JourType_code = '".$TransType."' ".
				 " Order By JourTypeButton_Order ";//echo $query_buttons;
$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"<button type='button' id='".$ButtonName."' name='".$ButtonName."'  onclick=\"AddDetails($Module_RestrictProjCost,$Module_RestrictCost,'".$ButtonName."');\"  title='".$ButtonTitle."' $InsMode><span><span>".$ButtonName."</span></span></button>";	
//	echo" <input type='button' name='".$ButtonName."' value='".$ButtonName."' onclick=\"AddDetails($Module_RestrictProjCost,$Module_RestrictCost,'".$ButtonName."');\" $style	title='".$ButtonTitle."' $InsMode/>";	
}

echo "</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' id='grid_datatable' class='grid_data'>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=100>
		  <col width=190>
		  <col width=200>
		  <col width=50>
		  <col width=80>
		  <col width=80>
		  <col width=80>
		  <col width=100>";
		  
		  //***********First Side*******************
		   
		  
		  echo"<tr bgcolor='#F7F7F7' height='25'>";
		  echo"  <td align='left' colspan='12' style='background: url(design/grid-label-bg.png); background-repeat: no-repeat; background-position: left;padding-left:15px;'><font color='#fffffff'>$Type_Label1</font></td>";
		  echo"</tr>";
		  
		  echo"<tr height='20'>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='center'>Ledger No.</span></th>";
		  echo"  <th  align='center'>Ledger Desc.</span></th>";
		  echo"  <th  align='center'>Description</span></th>";
		  echo"  <th  align='center'>Currency</span></th>";
		  echo"  <th  align='center'>Amount</span></th>";
		  echo"  <th  align='center'>Amount $base1</span></th>";
		  echo"  <th  align='center'>Amount $base2</span></th>";
		  echo"  <th  align='center'>Value Date</span></th>";
          echo"</tr>";

		  
		  if ($txtTransId != '' && $Type_dbcd1 != '') {
		     
			  
			$sub_query1 = " Select PaymentRqstDt.PaymentRqstDt_Id, PaymentRqstDt.Ledger_Number, Ledger.Ledger_Name, PaymentRqstDt_Desc, PaymentRqstDt_Desc1, ".
					      " PaymentRqstDt.Currency_Code, Round(PaymentRqstDt_Amount, ".$DecimalBase."), Round(PaymentRqstDt_Amount1, ".$DecimalBase."), ".
						  " Round(PaymentRqstDt_Amount2, ".$DecimalBase."), Date_Format(PaymentRqstDt_ValueDate,'%d/%m/%Y') As PaymentRqstDt_ValueDate, ".
						  " PaymentRqstDt_dbcd, Ledger.Ledger_Activity ".
					      " From Temp_PaymentRqstDt As PaymentRqstDt ".
						  " Left Join Ledger on PaymentRqstDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where PaymentRqstDt.PaymentRqst_Id = ".$txtTransId.
						  " And PaymentRqstDt.PaymentRqstDt_dbcd = '".$Type_dbcd1."' ".
					      " Order By PaymentRqstDt.PaymentRqstDt_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 = 'style5';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows1[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}	
				
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style5'><img src='img/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='style5'><img src='img/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='style5'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstRqst('".$sub_rows1[0]."','".$sub_rows1[5]."') title='Projects/Costcenters'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";
				
				if ($sub_rows1[11] == 1 || $sub_rows1[11] == 2 || $sub_rows1[11] == 3 || $sub_rows1[11] == 4)
					echo "	<td align='center' valign='center'><span class='style5'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkRqst('".$sub_rows1[0]."','".$sub_rows1[5]."','".$sub_rows1[11]."') title='Checks/Bills'  ></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[3]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[4]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[5]."</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='right'><span class='".$StyleDetail."'>".number_format($sub_rows1[8], $DecimalBase)."</span></td>";	
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[9]."</span></td>";
				echo "</tr>";
				
				echo "<tr ".$Color." >";
				echo "	<td align='left' colspan='4'><span class='".$StyleDetail."'>&nbsp;</span></td>";
				echo "	<td align='left' colspan='7'><span class='".$StyleDetail."'>".$sub_rows1[2]."</span></td>";
				echo "</tr>";
								
			}
			
		 }
		 
		 
		 //***********Second Side*****************************
		  
		   echo"<tr bgcolor='#F7F7F7' height='20'><td colspan='12'></td></tr>";
		   
		  echo"<tr  height='25'>";
		  echo"  <td align='left' colspan='12' style='background: url(design/grid-label-bg.png); background-repeat: no-repeat; background-position: left;padding-left:15px;'><font color='#ffffff'>$Type_Label2</font></td>";
		  echo"</tr>";
		  
		  echo"<tr height='20'>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
		  echo"  <th  align='left'>&nbsp;</span></th>";
          echo"  <th  align='center'>Ledger No.</span></th>";
		  echo"  <th  align='center'>Ledger Desc.</span></th>";
		  echo"  <th  align='center'>Description</span></th>";
		  echo"  <th  align='center'>Currency</span></th>";
		  echo"  <th  align='center'>Amount</span></th>";
		  echo"  <th  align='center'>Amount $base1</span></th>";
		  echo"  <th  align='center'>Amount $base2</span></th>";
		  echo"  <th  align='center'>Value Date</span></th>";
          echo"</tr>";
		  
		  
		  
		  if ($txtTransId != '' && $Type_dbcd2 != '') {
		     
			  
			$sub_query2 = " Select PaymentRqstDt.PaymentRqstDt_Id, PaymentRqstDt.Ledger_Number, Ledger.Ledger_Name, PaymentRqstDt_Desc, PaymentRqstDt_Desc1, ".
					      " PaymentRqstDt.Currency_Code, Round(PaymentRqstDt_Amount, ".$DecimalBase."), Round(PaymentRqstDt_Amount1, ".$DecimalBase."), ".
						  " Round(PaymentRqstDt_Amount2, ".$DecimalBase."), Date_Format(PaymentRqstDt_ValueDate,'%d/%m/%Y') As PaymentRqstDt_ValueDate, ".
						  " PaymentRqstDt_dbcd, Ledger.Ledger_Activity ".
					      " From Temp_PaymentRqstDt As PaymentRqstDt ".
						  " Left Join Ledger on PaymentRqstDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where PaymentRqstDt.PaymentRqst_Id = ".$txtTransId.
						  " And PaymentRqstDt.PaymentRqstDt_dbcd = '".$Type_dbcd2."' ".
					      " Order By PaymentRqstDt.PaymentRqstDt_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 = 'style5';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows2[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}
				
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style5'><img src='img/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='style5'><img src='img/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='style5'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstRqst('".$sub_rows2[0]."','".$sub_rows2[5]."') title='Projects/Costcenters'  ></span></td>";
				else 
					echo "	<td align='center' valign='center'>&nbsp;</td>";

				if ($sub_rows2[11] == 1 || $sub_rows2[11] == 2 || $sub_rows2[11] == 3 || $sub_rows2[11] == 4)
					echo "	<td align='center' valign='center'><span class='style5'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkRqst('".$sub_rows2[0]."','".$sub_rows2[5]."','".$sub_rows2[11]."') title='Checks/Bills'  ></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[3]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows2[4]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows2[5]."</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='right'><span class='".$StyleDetail."'>".number_format($sub_rows2[8], $DecimalBase)."</span></td>";	
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows2[9]."</span></td>";
				echo "</tr>";
				
				echo "<tr ".$Color." >";
				echo "	<td align='left' colspan='4'><span class='".$StyleDetail."'>&nbsp;</span></td>";
				echo "	<td align='left' colspan='7'><span class='".$StyleDetail."'>".$sub_rows2[2]."</span></td>";
				echo "</tr>";
								
			}
			
		 }
		 
		
		echo "</table>";   //</div>

}	else {

	echo" <table border='0' style='table-layout:fixed' id='grid_datatable' class='grid_data'>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=20>
		  <col width=100>
		  <col width=220>
		  <col width=220>
		  <col width=50>
		  <col width=100>
		  <col width=100>
		  <col width=100>";
		  
		  echo"<tr height='20'>";
		  echo"  <th align='left'>&nbsp;</th>";
		  echo"  <th  align='left'>&nbsp;</th>";
		  echo"  <th  align='left'>&nbsp;</th>";
		  echo"  <th  align='left'>&nbsp;</th>";
          echo"  <th  align='center'>Ledger No.</th>";
		  echo"  <th  align='center'>Description</th>";
		  echo"  <th  align='center'>Description1</th>";
		  echo"  <th  align='center'>Currency</th>";
		  echo"  <th  align='center'>Debit</th>";
		  echo"  <th  align='center'>Credit</th>";
		  echo"  <th  align='center'>Value Date</th>";
          echo"</tr>";

		  
		  if ($txtTransId != '') {
			  
			$sub_query1 = " Select PaymentRqstDt.PaymentRqstDt_Id, PaymentRqstDt.Ledger_Number, Ledger.Ledger_Name, PaymentRqstDt_Desc, ".
					      " PaymentRqstDt_Desc1, PaymentRqstDt.Currency_Code, ".
						  " if (PaymentRqstDt_dbcd='D', Round(PaymentRqstDt_Amount, ".$DecimalBase."),'') As DebitAmount, ".
						  " if (PaymentRqstDt_dbcd='C', Round(PaymentRqstDt_Amount, ".$DecimalBase."),'') As CreditAmount, ".
					      " Date_Format(PaymentRqstDt_ValueDate,'%d/%m/%Y') As PaymentRqstDt_ValueDate, PaymentRqstDt_dbcd, Ledger.Ledger_Activity ".
					      " From Temp_PaymentRqstDt As PaymentRqstDt ".
						  " Left Join Ledger on PaymentRqstDt.Ledger_Number = Ledger.Ledger_Number ".
					      " Where PaymentRqstDt.PaymentRqst_Id = ".$txtTransId.
					      " Order By PaymentRqstDt.PaymentRqstDt_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 = 'style5';		
				if ($ErrorRecId != '' && $ErrorRecId == $sub_rows1[0]) {
					$Color="style='background-color:#FF0000'";
					$StyleDetail = 'style17';
				}	
				
				echo "<tr ".$Color." >";
				echo "	<td align='center' valign='center'><span class='style5'><img src='img/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='style5'><img src='img/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='style5'><img src='img/cstjour.png' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddCstRqst('".$sub_rows1[0]."','".$sub_rows1[5]."') 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='style5'><img src='img/check_icon2.jpg' width='17' height='17' onMouseOver=\"style.cursor='hand'\" onclick=AddChkRqst('".$sub_rows1[0]."','".$sub_rows1[5]."','".$sub_rows1[10]."') title='Checks/Bills'  ></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[3]."</span></td>";
				echo "	<td align='left'><span class='".$StyleDetail."'>".$sub_rows1[4]."</span></td>";
				echo "	<td align='center'><span class='".$StyleDetail."'>".$sub_rows1[5]."</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>";
				
				echo "<tr ".$Color." >";
				echo "	<td align='left' colspan='4'><span class='".$StyleDetail."'>&nbsp;</span></td>";
				echo "	<td align='left' colspan='7'><span class='".$StyleDetail."'>".$sub_rows1[2]."</span></td>";
				echo "</tr>";
								
			}
			
		 }

	echo "</table>";   
	
}	

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

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


 //<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

				


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

echo"   </table></td></tr></table></td></tr><tr height='30'><td align='center' id='content-bottom' ></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>';

}	
if ($clearAll == 1){
	echo '<script type="text/javascript" language="javascript">';
	echo ' ClearPage1(); ';
	echo '</script>';
}
print <<<HERE
</form>
</body>

HERE;

$SetCurrency = 0;

?>