<?
session_start();
$brcode=$_SESSION['brcode'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
include("opendb.php");
include("test.php");

$qry=mysqli_query($db,"select partcode,gname from partmaster order by partcode");
$i=1;
while($row=mysqli_fetch_array($qry))
{
	$mpartcode = $row[0];
	$mgname = $row[1];
	$sql ="update sparestock set item_grp = '$mgname' where itemcode = '$mpartcode' and brcode = '$brcode'";
	mysqli_query($db,$sql)or die(mysqli_error($db));
	print $i."==".$sql."\n"; 

	$sql ="update brtransferout set gname = '$mgname' where brcode='$brcode' and item_code = '$mpartcode'";
	mysqli_query($db,$sql)or die(mysqli_error($db));
	print $i."==".$sql."\n";

	$sql ="update prod_invoice set gname = '$mgname' where brcode='$brcode' and item_code = '$mpartcode'";
	mysqli_query($db,$sql)or die(mysqli_error($db));
	print $i."==".$sql."\n";

	$sql ="update brtransferin set gname = '$mgname' where brcode='$brcode' and item_code = '$mpartcode'";
	mysqli_query($db,$sql)or die(mysqli_error($db));
	print $i."==".$sql."\n";


	$sql="update salesretn set gname='$mgname' where brcode='$brcode' and item_code = '$mpartcode'";
	mysqli_query($db,$sql)or die(mysqli_error($db));
	print $i."==".$sql."\n";

	$i++;
}
?>
<style>

	td,th,body{font-size:14;font-family:'arial narrow';letter-spacing:1}
</style>
