<?php

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


include("config.inc.php");


$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");
	
	
//Read From Setup Table							
$querysetup= " select grid_color1, grid_color2 from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}



 

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 ShowDetail() {
		if(document.FinancialReportDt.ShowDt.checked){
			document.FinancialReportDt.Ledger_ShowDt.value=1;

		}
		else
		{
			document.FinancialReportDt.Ledger_ShowDt.value=0;

		}
}

function ClearPage(){

        if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		
		x.action='Form_FinancialAccountsDetail.php';
		x.submit();
	}	
}

function ClearForm(){

		x = document.FinancialReportDt;
		x.ledger_number.value='';
		x.Financial_order.value='';
		x.ShowDt.value='';
		x.Ledger_ShowDt.value='';

}

function SubmitRecord() {
    
	x = document.FinancialReportDt;
	//vmodedt = x.modedt.value;
	var vFinancialOrder = x.Financial_order.value;
	
	if (x.FinancialTemplate_ID.value  == '')
		vmodedt = 'insert';	
	else
		vmodedt = 'editdt';	
		
		
	if (x.ledgerNbr.value =="")
	{
	alert("Ledger Number is mandatory!");
	x.ledgerNbr.focus();
	return 0;
	}

	else if (vFinancialOrder =="" || vFinancialOrder*1 != vFinancialOrder/1 )
	{
	alert("Order is mandatory and should be numeric!");
	x.Financial_order.focus();
	return 0;
	}

	x.action="Form_FinancialAccounts_Actions.php?modedt1="+vmodedt;
	x.submit();
	opener.document.FinancialReport.submit();
	
}


function showLedger(str){

  window.open('List_Agents_orderbycode.php?str='+str,'mywindow','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function ChangeLocation() {
	x = document.FinancialReportDt;
	var vmodedt = x.modedt.value;
	
	if (vmodedt == 'insert') {
		
		opener.document.FinancialReport.mode.value = x.modedt.value;
		opener.document.FinancialReport.Financial_code.value = x.PFinancial_code.value;
		opener.document.FinancialReport.submit();
		
	} 
	else if (vmodedt == 'insert' || vmodedt == 'editdt') {
		opener.document.FinancialReport.mode.value = x.modedt.value;
		opener.document.FinancialReport.Financial_code.value = x.PFinancial_code.value;
		opener.document.FinancialReport.submit();
		
		self.close();
	
	}
	
	//x.txtItemCode.focus();
}



</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Financial Accounts Detail</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: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {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>
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="tabs.css">
</head>
<body onLoad='ChangeLocation();'>
<form name='FinancialReportDt' method='post'>
<input type=hidden name='modedt' value='$modedt'>
<input type=hidden name='PFinancial_code' value='$PFinancial_code'>
<input type=hidden name='PFinancial_label' value='$PFinancial_label'>
<input type=hidden name='PFinancial_relatedcode' value='$PFinancial_relatedcode'>
<input type=hidden name='message' value='$message'>


HERE;
if (empty($modedt)) $modedt = 'insert';
$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">';


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


print <<< HERE
		<tr><th height="15" colspan="9" align="center" valign="top"><span class="style3">Add Detail</span></th></tr>
		<tr bgcolor='#F7F7F7' >	
			 <td colspan='9' align='center'><font size='1' color='#FF0000' face='Verdana'><b>$message</b></font></td></tr>			 
       <tr>
      <td>
HERE;

if ($FinancialTemplate_ID != ''){
$querydt= " select FinancialTemplate_ID, financialtemplate.Ledger_Number, ledger.ledger_name, Financial_order,Ledger_ShowDT
			from financialtemplate inner join ledger on financialtemplate.Ledger_Number = Ledger.Ledger_Number 
		    where FinancialTemplate_ID='".$FinancialTemplate_ID."' ";
			
	//echo $querydt;		
    $resultdt = mysql_query($querydt, $connection);
	while($rowdt=mysql_fetch_row($resultdt)){
        
		$ledgerNbr=$rowdt[1];
		$ledgerName=$rowdt[2];
		$Financial_order=$rowdt[3];
		$Ledger_ShowDt=$rowdt[4];
	}
}

	  
	echo"<table border='0' style='table-layout:fixed' align='left' valign='top'>
		  <col width=160>
		  <col width=120>
		  <col width=400>";

echo "<tr bgcolor='#F7F7F7'><td>&nbsp;</td><td>&nbsp;<input type='hidden' name ='FinancialTemplate_ID' value='$FinancialTemplate_ID'></td><td colspan='2'></td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style11'>Ledger Number/Name&nbsp;<span class='style26'></span></span></td>";

echo"<td><input type='text' name='ledgerNbr'  value='$ledgerNbr' size='13'>";
echo"</label></td>";	
echo"<td colspan='2'><label>";
echo"<input type='text' name='ledgerName'  value='$ledgerName' size='25'><img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showLedger(6); return false'>";
echo"</label></td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style11'>Order&nbsp;<span class='style26'></span></span></td>";
    echo"<td><input type='text' name='Financial_order'  value='".htmlspecialchars($Financial_order, ENT_QUOTES)."' $status maxlength='3' size='13'></td><td colspan='2'></td></tr>";
	
echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style11'>Show Detail</span></td>";
echo"<td valign='center' align='left' width=5%><span class='style11'><input type=checkbox name='ShowDt' ";
if ($Ledger_ShowDt==1)
 echo " checked ";
 
echo" onclick='ShowDetail()'>
	<input type='hidden' name='Ledger_ShowDt' id='Ledger_ShowDt' value='$Ledger_ShowDt' /><td colspan='2'></td>";	
	
	echo"</table></td></tr>";	


			
	echo"<tr><td ><table border=0 align=left width=100%> <tr bgcolor=#D8D8D8 height='35'>";
		
	

	echo"<td align='center'><input type='button' name='btnPost' id='btnPost' value='Submit Record' ";//post
	echo" onclick='SubmitRecord();' $style	title='Save Changes' /></td>";

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


							
		

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


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

HERE;

?>