<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='index.php'; </script>";
 return;
}
     include_once("opendb.php");
     include_once("test.php");
$jtype=$_REQUEST[prod];
$jrqry=mysqli_query($db,"select max(tr_no) from journal2 where brcode='$brcode' and j_type='$jtype'");
    if(mysqli_num_rows($jrqry)<1)
    {
	$invno=$jtype.'000001'; 
    }
    else
    {
	$row=mysqli_fetch_array($jrqry);
        $inv=substr($row[0],-6)+1;
	$inv=substr('000000'.$inv,-6);
	if($inv==0)
	{
		$inv='000001'; 
	}
	$invno=$jtype.$inv; 
    }
?>
<? echo $invno ?>

