<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}
$code=$_REQUEST['code'];
include("../opendb.php");
include("../test.php");
?>
<link href="../css/printline.css" type="text/css" rel="stylesheet" media="print,screen"  />



<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>
J O U R N A L <?print $code?><BR>&nbsp;
<?
$jv=false;
$dt;
$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> Ref. NO
<?

while($row=mysqli_fetch_array($re))
{
  $re2=mysqli_query($db,"select * from journal2 where jvno='$row[jvno]' and brcode='$brcode' order by dramt desc") or die(mysqli_error());
  print "\n<tr bgcolor='silver'><td>".implode('-', array_reverse(explode('-', $row['date'])))."</td><td>Trans 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[no]</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());
$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)'>
