<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$code=$_REQUEST['code'];
$dmqt=$_REQUEST['dmqt'];
$shpsl=$_REQUEST['shpsl'];
$ctpc=$_REQUEST['ctpc'];
$rdid=$_REQUEST['rdid'];
$chngqty=$dmqt+$shpsl+$ctpc;
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}

//$find_jv=mysqli_query($db,"select * from sparestock where itemcode='$code' and brcode='$brcode'");
//$f_j=mysqli_fetch_row($find_jv);
//$j_no=$f_j[22];
//$sql="delete from qtytransf where itemcode='$code' and brcode='$brcode' and nor_qty='$chngqty'";
//echo $sql;
mysqli_query($db,"update sparestock set curstk=(curstk+'$chngqty'),curstk_dam=(curstk_dam-'$dmqt'),curstk_soil=(curstk_soil-'$shpsl'),curstk_cut=(curstk_cut-'$ctpc') where itemcode='$code' and brcode='$brcode'");
	
mysqli_query($db,"delete from qtytransf where itemcode='$code' and brcode='$brcode' and id='$rdid'");
print "<script> alert('Data Has been Deleted');document.location='qtytransfer.php'; </script>";

?>
