<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../../index.html'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");


$sql="select date,jvno,sum(dramt)-sum(cramt),brcode from journal2  group by jvno,brcode order by brcode";
$re=mysqli_query($sql)or die(mysqli_error());
print "<table border=1>";
while($row=mysqli_fetch_array($re))
{
 if($row[2]!=0&&$row[2]<1)//$row[2]<1&&
 {
$dif=$row[2];
$x=abs($dif);
if($dif<0)
{
$sql="insert into journal2 values('$row[date]','$row[jvno]','Dr','Round Off','$x', '0','Round of','$row[brcode]','','','','','0','0000-00-00')";
print $sql.'<br>';
//mysqli_query($sql) or die("J V Write error dif1:".mysqli_error());
}
else if($dif>0 && $dif<1)
{
 $sql="insert into journal2 values('$row[date]','$row[jvno]','Cr','Round Off','0','$x','Round of adjusted','$row[brcode]','','',' ','','0','0000-00-00')";
print $sql.'<br>';
//mysqli_query($sql) or die("J V Write error dif:".mysqli_error());
}

    print "<tr><td></td><td>$row[1]</td><td>".putComa($row[2])."</td><td>$row[brcode]</td></tr>";
 }
}
print "</table>";
?>
