<?
session_start();
$brcode = $_SESSION['brcode'];
$branch = $_SESSION['branch'];
$user   = $_SESSION['user'];
$level   = $_SESSION['level'];
 include("../../test.php");
 include ("../../opendb.php");

$chkres=mysqli_query($db,"select jvno,date,sum(dramt),sum(cramt),narr from journal2 where brcode='$brcode' group by jvno") or die(mysqli_error($db));
$i=1;
?>
<table border=1>
<?
$mdiff_tot = 0;
while($row=mysqli_fetch_array($chkres))
{
	if (abs($row[2]-$row[3]) > .00)
	{
		if($i==1)
             {
                  print "<font color=red> Following Transactions are not tallying </font> <br>";
		    print "<tr><td>Sl No</td><td>JV No.</td><td>Date</td><td>Total Dr</td><td>Total Cr</td><td>Difference</td><td>Narration</td></tr>";
              }
              $mdiff = $row[2]-$row[3];
		$mdiff_tot += $mdiff; 
              print "<tr><td>$i</td><td>$row[0]  </td><td>$row[1]  </td><td>$row[2]</td><td>$row[3]</td><td>$mdiff</td><td>$row[4]</td></tr>";
		$i++;
	}
}
print "<tr><td>Total</td><td></td><td></td><td></td><td></td><td>$mdiff_tot</td><td></td></tr>";
?>
