<?
 session_start();
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}

 include("../../test.php");
include("../../opendb.php");
?>
<style>
td{font-family:verdana;font-size:14}
body{background-color:ivory}
</style>
<center>
<table width=100% border=1>
<tr><td align=right>
<input type=button value="Print" onClick=window.open('prntbop.php'); style={font-family:'verdana';font-weight:bold}> </td></tr>
</table>

<font face='arial black'>
Opening Trial Balance
<table border=1>
<TR bgcolor='#5b5858'><TD COLSPAN=3 ALIGN=CENTER><font color=white>
<b>TRIAL BALANCE AS ON <?print date("d-M-Y",time())?> </TD></TR>
<tr><td>&nbsp;</td><td align=center><b>Debit</td><td align=center><b>Credit</td></tr>
<?

 $result=mysqli_query($db,"select distinct grp from ledger where brcode='$brcode'")or die(mysqli_error($db));
while($row=mysqli_fetch_row($result))
  { 
$tr=0;$tp=0;$bal=0;
        print "\n<tr><td colspan=3><b><font color='brown'>$row[0]</td></tr>";
   $sqq="select * from ledger where brcode='$brcode' and grp='$row[0]'";
//  print "<br>". $sqq;
     $re=mysqli_query($db,$sqq) or die(mysqli_error($db));
     while($row2=mysqli_fetch_array($re))
     {
//print "<br>- ".$row2[0];
	if($row2[drcr]=="Dr")
	{
		if($row2[op]!=0)
       print "<tr onMouseOver=bgColor='alice-blue'; onMouseOut=bgColor='ivory'><td> <blockquote> $row2[led]</td><td align=right>$row2[op]</td></tr>";
        $t1+=$row2[op];
	}
	else 
	{
//	$tp+=$row2[op];
		if($row2[op]!=0)
       print "<tr onMouseOver=bgColor='alice-blue'; onMouseOut=bgColor='ivory'><td> <blockquote> $row2[led]</td><td></td><td align=right>$row2[op]</td></tr>";
        $t2+=$row2[op];
	}
 }
}
//$rs=mysqli_query($db,"select opstock from plopstock");
//$vv=mysqli_fetch_array($rs);
//$t1+=$vv[0];
//print "<tr><td><font color=brown><b>Opening Stock</td><td>".putComa($vv[0])."</td></tr>";
print "<tr><td>&nbsp;</td><td>".putComa($t1)."</td><td>".putComa($t2)."</td></tr>";
$diff22=($t1-$t2);
$diff22=number_format($diff22,2,'','');
?>
</table>
<?
print "Opening Contra=".putcoma(abs($diff22)/100);
?>
