<?
session_start();
$brcode = $_SESSION['brcode'];
$branch = $_SESSION['branch'];
$user   = $_SESSION['user'];
$level   = $_SESSION['level'];
$code=$_REQUEST['code'];

if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='../ind.php' </script>";
  return;
}

include("../../opendb.php");
include("../../test.php");
?>
<style>
BODY,td,th{margin-left:6; letter-spacing:1;font-family:arial narrow}
th{background-color:c1d7bf}
</style>
<!-- <link rel="stylesheet" href="../style.css" type="text/css" /> -->
<CENTER><B>
Document No. <?print $code?><BR>&nbsp;
<?
$jv=false;
$dt;
//print "select distinct jvno,date from journal2 where jvno='$code' and brcode='$brcode'order by date";
$re=mysqli_query($db,"select distinct jvno,date from journal2 where jvno='$code' and brcode='$brcode'order by date");
?>
<table bgcolor='ivory' border=0 cellspacing=3 cellpadding=1 width=100% class="grid">  

<th>Date <th>Particulars <th>Debit <th>Credit <th>Narration <th>Type <th>Ref. <th> PlantCode
<?

while($row=mysqli_fetch_array($re))
{
   // print "select * from journal2 where jvno='$row[jvno]' and brcode='$brcode'";
    
  $re2=mysqli_query($db,"select * from journal2 where jvno='$row[jvno]' and brcode='$brcode'") or die(mysqli_error($db));
  print "\n<tr bgcolor='silver'><td>".datetohtml($row['date'])."</td><td>Document No:$row[jvno]</td>";
// $dt=$row[date];
  print "<td></td><td></td><td></td><td></td><td></td><td></td></tr>";
    while($jvrow=mysqli_fetch_array($re2))
    {
        print "\n<tr><td>&nbsp;</td><td>$jvrow[partic]</td>";
        print "<td align=right>".nozero(putComa($jvrow['dramt']))."</td>";
        print "\n<td align=right>".nozero(putComa($jvrow['cramt']))."</td><td>$jvrow[narr]</td><td>$jvrow[j_type]</td>";
        print "<td>$jvrow[against]</td><td>$jvrow[brcode]</td></tr>";
     if($jvrow['j_type']=='JV') 
       $jv=true;
  }

if($jv)
{

$us=mysqli_query($db,"select level from bruser where username='$user'")or die(mysqli_error($db));
$r=mysqli_fetch_row($us);
$user_level=$r[0];

if($user_level>=4)
{
     print "\n<tr><form action='editjour.php'><input type=hidden name=jvno value='$code'>";
     print "<input type=hidden name='dt' value='$dt'><td colspan=9 bgcolor=silver align=right><input type=submit value='Edit'> <input type=button value='Delete'></td></form></tr>";
}
}

}
?>
</table>
</CENTER>
<CENTER><B>
Document No. <?print $code?><BR>&nbsp;
<?
$jv=false;
$dt;
//print "select distinct jvno,date from journal2 where jvno='$code' and brcode='$brcode'order by date";
$re=mysqli_query($db,"select distinct jvno,date from journal2_log where jvno='$code' and brcode='$brcode'order by date");
?>
<table bgcolor='ivory' border=0 cellspacing=3 cellpadding=1 width=100% class="grid">  

<th>Date <th>Particulars <th>Debit <th>Credit <th>Narration <th>Type <th>Ref. <th> PlantCode
<?

while($row=mysqli_fetch_array($re))
{
   // print "select * from journal2 where jvno='$row[jvno]' and brcode='$brcode'";
    
  $re2=mysqli_query($db,"select * from journal2_log where jvno='$row[jvno]' and brcode='$brcode'") or die(mysqli_error($db));
  print "\n<tr bgcolor='silver'><td>".datetohtml($row['date'])."</td><td>Document No:$row[jvno]</td>";
// $dt=$row[date];
  print "<td></td><td></td><td></td><td></td><td></td><td></td></tr>";
    while($jvrow=mysqli_fetch_array($re2))
    {
        print "\n<tr><td>&nbsp;</td><td>$jvrow[partic]</td>";
        print "<td align=right>".nozero(putComa($jvrow['dramt']))."</td>";
        print "\n<td align=right>".nozero(putComa($jvrow['cramt']))."</td><td>$jvrow[narr]</td><td>$jvrow[j_type]</td>";
        print "<td>$jvrow[against]</td><td>$jvrow[brcode]</td></tr>";
     if($jvrow['j_type']=='JV') 
       $jv=true;
  }

if($jv)
{

$us=mysqli_query($db,"select level from bruser where username='$user'")or die(mysqli_error($db));
$r=mysqli_fetch_row($us);
$user_level=$r[0];

if($user_level>=4)
{
     print "\n<tr><form action='editjour.php'><input type=hidden name=jvno value='$code'>";
     print "<input type=hidden name='dt' value='$dt'><td colspan=9 bgcolor=silver align=right><input type=submit value='Edit'> <input type=button value='Delete'></td></form></tr>";
}
}

}
?>
</table>
</CENTER>
<input type=button value='<- Back' onClick='history.back(1)'>
