<?php
session_start();
include 'dbc.php';


$userid=$_SESSION["userid"];
$today=date("Y-m-d");
$inv_no=$_POST["inv_no"];
$username=$_POST["username"];
$barcode=$_POST["barcode"];
$qty=$_POST["qty"];
$sql1 = "SELECT * FROM items where item_no='$barcode' and  user_id='$userid'";
$result1=$conn->query($sql1);
$row2 = $result1->fetch_assoc();
$id=$row2['id'] ;
$sno=$row2['sno'] ;
$item_name=$row2['item_name'] ;
$srate=$row2['retail_price'] ;
$prate=$row2['cost_price'] ;
$type_name=$row2['type_name'] ;
$dis=$row2['disc'] ;
$rfid=$row2['rfid'] ;

		$sql = "Insert into invoice_details1 (id,date,inv_no,item_no,barcode,type_name,item_name,srate,qty,username,user_id,itemcode,prate,rfid,st)values (null,'$today','$inv_no','$sno','$barcode','$type_name','$item_name','$srate','$qty','$username','$userid','$id','$prate','$rfid','$dis')";
$conn->query($sql);


/*$sql3 = "Insert into finishbal (id,date,pro_code,pro_name,bal,user_id)values (null,'$today','$pro_code','$pro_name','$stock_in_hand','$userid')";
mysql_query($sql3) or die("Error : " . mysql_error());*/
$Message = "$inv_no";
    header("Location:Add_Invoice_Item1.php?Message={$Message}");
/*$sql="Select * from agents where userid='$user_id'";
$data=mysql_query($sql) or die ("Error:" . mysql_error());
$userdata=mysql_fetch_array($data);
$email=$userdata["e_mail"];
mail($email . ",info@lalburj.com","Candidate Information","Candidate Data Posted Successfully","Passport No:" . $app_pp_no . " of " . $app_name . "Has been Posted Successfully By:" . $_SESSION["userid"]);*/

?>


                                                                     
