<?php 
session_start();
include('../includes/dbcon.php');

$str=" ";

$error=0;

$edate=date("Y-m-d");
$userid=$_SESSION['hrm_id'];

$tdate= trim($_POST['tdate']);
$loc= trim($_POST['loc']);
//$estock= trim($_POST['estock']);
$note= trim($_POST['note']);
//echo $estock;


///!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     Validation    !!!!!!!!!!
if (empty($loc)){
	$loc=0;
}
else {

}
///~~~~~~~~~~~~~~~~~~~~~~~~~~End of Validation ~~~~~~~~~~~~~~~~~~~





mysqli_begin_transaction($con);

/////!!!!!!!!!!!!!!!!!!  sequence   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$querydoc=mysqli_query($con,"select * from sequence where seq_id=10 ")or die(mysqli_error());
while($row=mysqli_fetch_array($querydoc)){  
$adj_no=$row['cno'];
}
///~~~~~~~~~~~~~~~~~~~~~~~~~~~   End of sequence ~~~~~~~~~~~~~~~~~~

if ( mysqli_query($con,"INSERT INTO stock_adjust_temp_header(tran_id,from_loc_id,refnote,tran_date,userid,edate) 
			 VALUES($adj_no,'$loc','$note','$tdate',$userid,'$edate' )  ")or die(mysqli_error($con)))
	        {

	        		//echo $grn_no;	
	        			if ( mysqli_query($con,"update sequence set cno =cno + 1  where seq_id=10 ")or die(mysqli_error($con)))			
						{   

							mysqli_commit($con);
							echo "<script>document.location='stock_adjust1.php?trn_no=$adj_no '</script>"; 

						}  
	        }




