<?
session_start();
include("../opendb.php");
include("../test.php");
$res=mysqli_query($db,"select * from spareopstock where brcode='$brcode'");
?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
	tr{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<center>
<h3>SPARE OPENING STOCK</H3>
<table border=0 cellspacing=1 cellpadding=3>
<th>No <th>Part Code <th> Part Name <th>Location <th>Qty<th>Lst Price <th>Price
<?
$i=1;
$tprice=0;
while($row=mysqli_fetch_array($res))
{
 print "<tr><td>".$i++."</td><td>$row[0]</td><td>$row[1]</td>";
  $locres=mysqli_query($db,"select location from sparelocmast where itemcode='$row[0]'");
  $locrow=mysqli_fetch_row($locres);
 print "<td>$locrow[0]</td><td align=right>$row[qty]</td>";
  $prres=mysqli_query($db,"select ndpcost from spareprmast where partcode='$row[0]' order by effectfrom desc limit 1");
  $prrow=mysqli_fetch_row($prres);
 $pr=($prrow[0]*$row[qty]);
 $tprice+=$pr;
$tqty+=$row[qty];
 print "<td align=right>$prrow[0]</td><td align=right>".putcoma($pr)."</td></tr>";
}
 print "<tr><td colspan=4 align=center bgcolor='silver'>Total</td>";
 print "<td bgcolor='silver' align=right>$tqty</td>";
 print "<td  colspan=2 bgcolor='silver' align=right>".putComa($tprice)."</td></tr>";

?>
</table>
