<?
session_start();
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($db,$sql)or die(mysqli_error());
print "<table border=1>";
while($row=mysqli_fetch_array($re))
{
$f=$row[2];
$xx=abs($f);

 if($xx!=0&&$xx<=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]','','','','')";
print $sql.'<br>';
mysqli_query($db,$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]','','',' ','')";
print $sql.'<br>';
mysqli_query($db,$sql) or die("J V Write error dif:".mysqli_error());
}

    print "<tr><td><a href='../multientry/viewtrans.php?code=$row[1]'>$row[0]</a></td><td>$row[1]</td><td>".putComa($row[2])."</td><td>$row[brcode]</td></tr>";
 }
}
print "</table>";
?>
