<?
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 * from journal2 where partic='Spare transfer out (WAR)' and brcode='PAT649'";
$re=mysqli_query($db,$sql);
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "<table border=1>";
 $re2=mysqli_query($db,"select * from journal2 where jvno='$row[jvno]' and brcode='pat649'");
   while($row2=mysqli_fetch_array($re2))
   {
    print "<tr><td>$row2[date]</td><td>$row2[jvno] </td><td> $row2[type] ";
    print "</td><td> $row2[partic] </td><td>$row2[dramt] </td><td>$row[cramt]</td>";
    print "<td>$row2[tr_no]</td></tr>";
    $sql="delete from journal2 where jvno='$row2[jvno]' and brcode='PAT649' and date='$row2[date]' and dramt=0 and cramt=0";
   }
    print "<tr><td colspan=10>$i -$sql</td></tr>";
    $i++;
    //mysqli_query($db,$sql) or die(mysqli_error());
 print "</table>";
}


/*
$tbl="spareinvwarPAT649";
$re=mysqli_query($db,"select * from $tbl where trans='y'");
while($row=mysqli_fetch_array($re))
{
 $sql="insert into warsparetransout(warno,partcode,partname,psnqty,telcqty,price,tobr,date,brcode)
    values('$row[warno]','$row[partcode]','$row[partname]','$row[psnqty]','$row[telcqty]','$row[price]','SER516','$row[date]','PAT649')";
 print $sql."<br>";
}
*/
?>
