<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
date_default_timezone_set('Asia/Kolkata');
$dt=date("Y-m-d H:i:s");
include_once("test.php");
include_once('opendb.php');
$invno =$_REQUEST['invno'];
$invdate=$_REQUEST['invdate'];
$invamount=$_REQUEST['invamount'];
$remark=$_REQUEST['remark'];
$amt=$_REQUEST['amt'];
$jvtp=$_REQUEST['jvtp'];
$biltyp=$_REQUEST['biltyp'];
$drjvn=$_REQUEST['drjvn'];
	$prt_total=$_REQUEST['prt_total'];
	$tbl='tmpallotreceipt'.$brcode.$user;
	$jvno=$_REQUEST['jvno'];
	$cname=$_REQUEST['cname'];
	$adjamt=$_REQUEST['adjamt'];

   

	
	
	
	
	
	
	$brres12=mysqli_query($db,"select max(receiptno) from allotreceipt where brcode='$brcode'");
	$brrow12=mysqli_fetch_array($brres12);
	if($brrow12[0]<='')
	    $receiptno = 1;
	else
	    $receiptno = $brrow12[0]+1;
	if($prt_total>=$totcramt)
	{
	    if($amt<='')
	    {
	        $amt=0;
	    }
		   
			    $sql = "update $tbl set receiptno='$receiptno',amtreceived='$amt',rec_date='$dt',remarks='$remark',adjamt='$adjamt' where brcode='$brcode' and drjvno='$drjvn'";
			    
			    
			    
			    print $sql;			
			    
			    mysqli_query($db,$sql);
		    
	    
	   // print "<script> alert('Updated !!!!');window.close();</script>";
	}
	else
	{
	    print "<script> alert('amount exceeds');</script>";
	}

?>
