<?
session_start();
//include("../opendb.php");
//include("../test.php");
?>

<link rel="stylesheet" href="../style.css" type="text/css" />

<style>
	//tr1{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<center>
<?
$tbl="sparetmp_br".$user;

include ("../util/seaitminbrsum.php");
if($sea)
{
 $seare=mysqli_query($db,"select * from $tbl where partcode='$pcode'");
 print "<table bgcolor=silver><th colspan=10>Search Result</th><tr>";
print "<th>No.<th>Part Code <th>Part Name<th>Quantity <th>Lst Price <th>Amount <th>Location";
$i=1;
 while($searow=mysqli_fetch_array($seare))
 {
  print "<tr bgcolor=white><td>".$i++."</td>";
 print "<td>$searow[partcode]</td><td>$searow[partname]</td><td align=right>$searow[supqty]</td>";
  $prres=mysqli_query($db,"select lstprice from spareprmast where partcode='$searow[0]' order by effect from desc limit 1");
  $prrow=mysqli_fetch_row($prres);
 $pr=($prrow[0]*$row[supqty]);
 $tprice+=$pr;
 print "<td align=right>".putComa($prrow[0])."</td><td align=right>".putcoma($pr)."</td>";
  $locres=mysqli_query($db,"select location from sparelocmast where itemcode='$searow[partcode]' and brcode='$brcode'");
  $locrow=mysqli_fetch_row($locres);
 print "<td>$locrow[0]</td></tr>";
 }
 print "</table>";
}
?>

<?
/*$re=mysqli_query($db,"select partcode,partname,sum(supqty) from $tbl group by partcode order by partcode")or die(mysqli_error());
print "<table border=0 cellspacing=1 cellpadding=3 bgcolor='lightsteelblue'>"; 
print "<th>No.<th>Part Code <th>Part Name<th>Quantity <th>Cost Price <th>Amount <th>Location";
$i=1;
$tprice=0;
while($row=mysqli_fetch_array($re))
{
 print "<tr bgcolor=white onMouseOver=bgColor='silver'; onMouseOut=bgColor='white'><td>".$i++."</td>";
 print "<td>$row[partcode]</td><td>$row[partname]</td><td align=right>$row[supqty]</td>";
  $prres=mysqli_query($db,"select ndpcost from spareprmast where partcode='$row[0]' order by effectfrom desc");
  $prrow=mysqli_fetch_row($prres);
 $pr=($prrow[0]*$row[supqty]);
 $tprice+=$pr;
 $tqty+=$row[supqty];
 print "<td align=right>".putComa($prrow[0])."</td><td align=right>".putcoma($pr)."</td>";
  $locres=mysqli_query($db,"select location from sparelocmast where itemcode='$row[partcode]' and brcode='$brcode'");
  $locrow=mysqli_fetch_row($locres);
 print "<td>$locrow[0]</td></tr>";
 }
 print "<tr ><td colspan=3 align=center bgcolor='silver'>Total</td>";
 print "<td>$tqty</td><td></td>";
 print "<td  bgcolor='silver' align=right>".putComa($tprice)."</td><td bgcolor='silver'></td></tr>";
*/
?>
</table>



