<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$part=$_REQUEST['part'];
$qty=$_REQUEST['qty'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

$qry=mysqli_query($db,"select * from spareprmast where partcode='$part'");
$row=mysqli_fetch_array($qry);
$nqry=mysqli_query($db,"select gname,rbtbl,rbtvl,reduction from partmaster where partcode='$part'");
$nrow=mysqli_fetch_array($nqry);
$sql="select * from groupmaster where gname='$nrow[0]'";
$rs=mysqli_query($db,$sql);
$rw=mysqli_fetch_array($rs);
if($itmtp=='D')
    {
        $stksl="select curstk_dam from sparestock where itemcode='$part' and brcode='$brcode'";
    }
else
    {
        $stksl="select curstk from sparestock where itemcode='$part' and brcode='$brcode'";
    }
  
$stkrs=mysqli_query($db,$stksl);
$stkrw=mysqli_fetch_array($stkrs);
$balqty=$stkrw[0]-$qty;

if($rw[rebt_aply]=='1')
{
$strbt=$rw[stat_rbt];
}
else
{
$strbt=0;
}
/*
if($rw[redct_aply]=='1')
{
$itmrdct=$rw[reduct];
}
else
{
$itmrdct=0;
}
*/
if($rw[kvic_aply]=='1')
{
$kvicdis=$rw[grp_kvic];
}
else
{
$kvicdis=0;
}
if($rw[kvspl_aply]=='1')
{
$kvsplrdt=$rw[grp_kvicspl];
}
else
{
$kvsplrdt=0;
}
if($rw[tax_aply]=='1')
{
$txprc=$rw[grp_tax];
}
else
{
$txprc=0;
}	

$upr=$row[4];
$itmrdctvl=0;
$itemvl=0;
     
	
	$tot=($upr*$qty);
	
	
  
       
	?>
	<input type='hidden' name='totalamt' id='totalamt' value='<? print $tot;?>'>
	<input type='hidden' name='untprice' id='untprice' value='<? print $upr;?>'>
	<input type='hidden' name='alertmsg' id='alertmsg' value='<? print $msgvl;?>'>
	