<? 
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");
?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<body class=bd onSubmit="return valid()">
<form action='<?print $PHP_SELF?>'>
<table border=1>
<tr><td>Select Invoice Number </td><td>
<?
$re=mysqli_query($db,"select purinvoice from item_purchase where sale_invoice='-'")or die(mysqli_error());
print "<select name='inv'>";
while($row=mysqli_fetch_row($re))
{
 print "<option>$row[0]</option>";
}
?>
</select>
</td> <td><input type=submit value='Show' name='sh'></tr></table>
</form>

<table border=1>
<th>Item <th>Unit Amt. <th>Tax% <th>Qty <th>Gross <th>Disc <th>Net <th>Tax Amt <th> G.Tot
<th>Dis/Free <th>Qty<th>Ret.
<?
if($sh)
{
 $re=mysqli_query($db,"select b.itname,a.uni_amt,a.taxp,a.qty,a.gross,a.disc,a.net,a.taxamt,a.gtot,a.disfree,a.code from item_purchase a, itemmaster b where a.item_code=b.code and a.purinvoice='$inv'")or die(mysqli_error());

  while($row=mysqli_fetch_row($re))
  {
   print "<tr><td>$row[0]</td><td align=right>$row[1]</td><td align=right>$row[2]</td>";
   print "<td align=right>$row[3]</td><td align=right>$row[4]</td>";
   print "<td align=right>$row[5]</td><td align=right>$row[6]</td><td align=right>$row[7]</td>";
   print "<td align=right>$row[8]</td><td align=right>$row[9]</td>";
   print "<td><input type=text name=qty[] size=2></td><td><input type=checkbox name='ch[]' value='$row[10]'></td></tr>";
  }
}
?>
