<?php include("../../include/dbconnect.php");  
?>
<style type="text/css">
body{
font-family:Verdana, Arial, Helvetica, sans-serif;
}
</style>
<link rel="stylesheet" href="../../include/style.css">
<body oncontextmenu = "javascript:return false;" ondragdrop= "javascript:return false;" onselectstart="javascript:return false;"><center>
<table cellpadding=0 cellspacing=4 width=590>
<tr>
<td style="padding:3px;" class="tdhead"  colspan="100%"><b>View Opening Balances</b></td>

</tr>



		<form name='myForm02' >
		<?
if($branch == 'ALL')
{		
		$result=mysqli_query($conn,"select  openbalance.record,branches.name,acctmast.description,openbalance.opening_balance,openbalance.db_cr,openbalance.account_year from openbalance,acctmast,branches where acctmast.acctcode = '$acctcode' and  openbalance.branch_code = branches.code and openbalance.compcode = '$compcode' and openbalance.account_year = '$account_year' and openbalance.acctcode = acctmast.acctcode    ") or die(mysqli_error());
		$number_cols=mysqli_num_fields($result);
		echo "<table border=1 cellspacing='0' cellpadding='2' class='tdindent'> \n";
		echo "<tr align=center class='tablecolor'> \n";
		for($i=0;$i<$number_cols;$i++)
		{
		echo "<th>" . mysqli_field_name($result,$i).   "</th>\n";
		}
		echo "<tr>\n";
		
		//layout table
		
		while($row = mysqli_fetch_row($result))
		{
		echo "<tr align=left> \n";
		echo "<td>";
		if(!isset($row[0])) //test for null value
		{
		echo "NULL";
		}
		else
		{

		echo($row[0]);

		
		}
		
		for($i=1;$i<$number_cols;$i++)
		{
		echo "<td>";
		if(!isset($row[$i])) //test for null value
		{
		echo "NULL";
		}
		else
		{
		echo "" .$row[$i];
		}
		echo "&nbsp;</td>\n";
		}
		echo "</tr> \n";
		}
		echo"</table>";
}
else
{
		$result=mysqli_query($conn,"select  openbalance.record,acctmast.description,openbalance.opening_balance,openbalance.db_cr,openbalance.account_year from openbalance,acctmast where  openbalance.branch_code = '$branch' and openbalance.compcode = '$compcode' and openbalance.account_year = '$account_year' and openbalance.acctcode = '$acctcode' and openbalance.acctcode = acctmast.acctcode   ") or die(mysqli_error());
		$number_cols=mysqli_num_fields($result);
		echo "<table border=1 cellspacing='0' cellpadding='2' class='tdindent'> \n";
		echo "<tr align=center class='tablecolor'> \n";
		for($i=0;$i<$number_cols;$i++)
		{
		echo "<th>" . mysqli_field_name($result,$i).   "</th>\n";
		}
		echo "<tr>\n";
		
		//layout table
		
		while($row = mysqli_fetch_row($result))
		{
		echo "<tr align=left> \n";
		echo "<td>";
		if(!isset($row[0])) //test for null value
		{
		echo "NULL";
		}
		else
		{

			echo($row[0]);

		
		}
		
		for($i=1;$i<$number_cols;$i++)
		{
		echo "<td>";
		if(!isset($row[$i])) //test for null value
		{
		echo "NULL";
		}
		else
		{
		echo "" .$row[$i];
		}
		echo "&nbsp;</td>\n";
		}
		echo "</tr> \n";
		}
		echo"</table>";


}
?>
<input type="hidden" name="fname" value="<?echo $filename;?>"><form>
<br>
<br>
<font size=1>
<center><a href= "#" onClick="javascript:window.close();">Close Window</a>
</center>
 
</body>
