<?
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>
<?
$sql="select distinct to_branch from sparetransout where brcode='$br' and received='N' order by to_branch";
$brres=mysqli_query($db,$sql);
while($brrow=mysqli_fetch_array($brres))
{
 print "<h3>".getbrname($brrow[0])."</h3>";
$sql="select * from sparetransout where brcode='$br' and received='N' and to_branch='$brrow[0]'";
$res=mysqli_query($db,$sql);
print "<table border=1 width=80%><th width=90>Tr NO <th>Date <th>Part Code <th>Part Name<th>Qty <th>Amount";
while($row=mysqli_fetch_array($res))
{
$tamt+=($row[qty]*$row[amount]);
print "<tr><td>$row[tr_no]</td><td>".datetohtml($row[entrydate])."</td>";
print "<td>$row[partcode]</td><td>$row[partname]</td><td  align=right>$row[qty]</td>";
print "<td align=right>".($row[qty]*$row[amount])."</td></tr>";
}
print "<tr><td colspan=5>Total</td><td align=right>".putComa($tamt)."</td></tr>";
$tamt=0;
print "</table>";
}
?>
</table>
