<?
session_start();
$brcode = $_SESSION['brcode'];
$level  = $_SESSION['level'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.html'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
$pos =$_REQUEST['pos'];
$j=$pos-1;
$pos2=$j+1;
$k=0;
$purno=$_REQUEST['purno'];
foreach($purno as $a)
{
 $purno[$k]=$a;
 $k++;
}
$k=0;
$pbillno=$_REQUEST['pbillno'];
foreach($pbillno as $a)
{
 $pbillno[$k]=$a;
 $k++;
}
$k=0;
$taxtype=$_REQUEST['taxtype'];
foreach($taxtype as $a)
{
 $taxtype[$k]=$a; 
 $k++;
}
for($i=$j;$i<$pos2;$i++)
		{ 
		    
		  if($taxtype[$i]=='VAT')
		  {
		    mysqli_query($db,"update sparepurchase set pbillno='$pbillno[$i]' where purno='$purno[$i]' and brcode='$brcode'");
		    //echo "update sparepurchase set pbillno='$pbillno[$i]' where purno='$purno[$i]' and brcode='$brcode'";
		  }
		  else
		  {
			mysqli_query($db,"update sparepurchase set price=tot/supqty,aprice=tot,tax='0',taxamt='0',taxtype='$taxtype[$i]',pbillno='$pbillno[$i]' where purno='$purno[$i]' and brcode='$brcode'");
			//echo "update sparepurchase set price=tot/supqty,aprice=tot,tax='0',taxamt='0',taxtype='$taxtype[$i]',pbillno='$pbillno[$i]' where purno='$purno[$i]' and brcode='$brcode'";
		  }
		}

?>
<script>document.location='update_vendorinv.php'</script>