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

	td,th,body{font-size:15;font-family:'arial narrow';letter-spacing:1}
	th{background-color:silver}
</style>
<center>
<h3>
PSN TELCON <?PRINT $branch?><BR>
PURCHASE REPORT (SPARE WISE)</H3>
AS ON
<?
print date('r').' Printed by '.$user;
$re=mysqli_query($db,"select distinct partcode,partname from sparepurchase where brcode='$brcode'");
print "<table border=1>";
while($purrow=mysqli_fetch_array($re))
{
 print "<tr><td colspan=10><b>$purrow[0] ($purrow[1])</td></tr>";
 print "<th>PBill No<th>Supplier<th>Pur_Date <th>Entry_Dt.<th>Qty<th>Price<th>Disc%";
 $res=mysqli_query($db,"select * from sparepurchase where partcode='$purrow[0]' and brcode='$brcode' order by entrydate");
 while($row=mysqli_fetch_array($res))
 {
  print "<tr><td>$row[pbillno]</td><td>$row[suplier]</td>";
  print "<td>".datetohtml($row[purdate])."</td><td>".datetohtml($row[entrydate])."</td>";
  print "<td align=right>$row[supqty]</td><td align=right>$row[price]</td><td align=right>$row[disc]</td></tr>";
 }
}
print "</table>";
?>
