<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
$sql="select a.code,a.item_code,b.itname,a.taxp,a.uni_amt,a.gross,a.disc,a.net,a.taxamt,a.gtot, a.chasis from item_purchase a,itemmaster b where a.item_code=b.code and a.brcode='$brcode' and (a.qty-a.sale_count)>0 group by a.chasis";

$result=mysqli_query($db,$sql)or die("Retrieve err:".mysqli_error());
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
tr{background-color:white} 
th{background-color:c1d799;font-size:13}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<CENTER>
<h3>ITEM SALE REPORT </H3>
<table border=0 cellspacing=1 cellpadding=2 bgcolor=gray>
<th>No <th>Item Name <th>Sold To <th>DA <th>Inv No. <th>Sale Type <th>Inv Date
<th>Net <th>Tax Amt <th>Gross
<?
$res=mysqli_query($db,"select * from invoice_item where brcode='$brcode'");
$i=1;
while($row=mysqli_fetch_array($res))
{
 $sql="select itname from itemmaster where code='$row[item_code]'";
  $itmres=mysqli_query($db,$sql)or die(mysqli_error());
  $itemrow=mysqli_fetch_row($itmres);
 print "<tr><td>".$i++."</td><td>$itemrow[0]</td><td>$row[soldto]</td><td>$row[da]</td>";
 print "<td>$row[invno]</td><td>".strtoupper($row[saletype])."</td><td>".datetohtml($row[invdate])."</td>";
 print "<td>$row[net]</td><td>$row[taxamt]</td><td>$row[gross]</td>";
}
?>
