<?
 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");
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:14}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</STYLE>
<center>
<table border=0 cellpadding=2>
<th colspan=10>Search Item Purchase</th>
<TR><TD>Purchase Invoice No </td><td><input type='pinv' size=9></td>
    <td>Date from </td><td>dd<input type=text name='df' size=2 value='<?print date('d',time())?>'>
			mm<input type=text name='mf' size=2 value='<?print date('m',time())?>'>
			yy<input type=text name='yf' size=4 value='<?print date('Y',time())?>'>
</td></tr>
<tr><td colspan=2></td>
    <td>Date To </td><td>dd<input type=text name='dt' size=2 value='<?print date('d',time())?>'>
			mm<input type=text name='mt' size=2 value='<?print date('m',time())?>'>
			yy<input type=text name='yt' size=4 value='<?print date('Y',time())?>'>
</td></tr>
<th colspan=10> <input type=submit value='Show'></th>
</table>

<hr>
<?
$re=mysqli_query($db,"select a.itname,b.pno,b.purinvoice,b.pdate,b.chasis,b.taxp,b.uni_amt,b.qty,b.taxamt,b.gtot,b.code,s.code,s.supname from itemmaster a,item_purchase b,sup_master s where a.code=b.item_code and  b.sup=s.code and a.brcode='$brcode'  order by b.pno");
//$re=mysqli_query($db,"select a.itname,b.pno,b.purinvoice,b.pdate,b.chasis,b.taxp,b.uni_amt,b.qty,b.taxamt,b.gtot,b.code,s.code,s.supname from itemmaster a join item_purchase b on  a.code=b.item_code join sup_master s on  b.sup=s.code and a.brcode='aut141'  order by b.pno");

print "<table cellspacing=1 cellpadding=1 bgcolor=c1d799>";
print "<th>No <th>Name <th>P.No. <th>P.Inv<th>Date <th>Chasis<th>Tax% <th>Unit Amount <th>Qty <th>Tax <th> Amount <th> suplier <th>Action";
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "\n <tr bgcolor=white><td>".$i++."</td><td>$row[0]</td><td align=right>$row[1]</td><td align=right>$row[2]</td><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><td align=right>$row[12]</td>";
 print "<td align=right><input type=button value='Del' onClick=del('$row[10]')></td></tr>\n";
}
?>
</table>
<script>
 function del(x)
 {
  if(confirm("Delete"+x+" ?"))
   document.location='delpuritem.php?code='+x;
 }
</script>
