<?
session_start();

include_once("includes/function.php");
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$led=$_REQUEST['led'];

if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
include_once("opendb.php");

$query1 = "SELECT * FROM ledger where brcode = '$brcode' and led='$led' ";
$result = mysqli_query($db,$query1);
$row=mysqli_fetch_array($result);

$bal=0;

$balres=mysqli_query($db,"select sum(dramt),sum(cramt) from journal2 where brcode='$brcode' and partic='$row[0]'");
 $balrow=mysqli_fetch_row($balres);
 if($row[drcr]=='Dr')
 {
 $bal=($balrow[0]+$row[2])-$balrow[1]; 
 }
 else
 $bal=$balrow[1]+$row[2]-$balrow[0];

?>


<input type='hidden' name='clbal' value='<? echo $bal;?>' id='clbal'>
