<?
session_start();
include("test.php");
include("opendb.php");
//include("includes/function.php");
//include("workshop_calstock.php");
//$tbl2="stocksummary1".$brcode.$user;
$qry= mysqli_query($db,"select sum(qty) from workshop_invoicecsh where item_code='$part' and brcode='$brcode'");
$row=mysqli_fetch_array($qry);
$qry1= mysqli_query($db,"select sum(qty) from workshop_slsretncash where item_code='$part' and brcode='$brcode'");
$row1=mysqli_fetch_array($qry1);
$bal_qty=$row[0]-$row1[0];



 	if($bal_qty<$qty)
	{
	?>
	<input type='hidden' name='totalamt' id='totalamt' value='0'>
	<input type='hidden' name='untprice' id='untprice' value='0'>
	<input type='hidden' name='alertmsg' id='alertmsg' value='0'>
       <input type='hidden' name='typ_val' id='typ_val' value=''>
	
	<?
	}
	else
	{
	//$tot_qty=$qty+$preqty;
	//if($row[2]<$tot_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='1'>
     
	
	<?
  	 //}
 	 //else
   	 //{

	if($qty>=5)
	$upr=$row[3];
	else
	$upr=$row[4];
	$tot=($upr*$qty)-$dis;

	?>
	<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='1'>
      
	<?
	//}
	}


	?>