<?
 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:13}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<H3>ITEM PURCHASE REGISTER</H3>
<form action='<?print $PHP_SELF?>'>
<table bgcolor='silver'>
<tr><td> Date from </td><td>dd<input type=text name='d' size=2 value='<?print date("d",time())?>'>
				mm<input type=text name='m' size=2 value='<?print date("m",time())?>'>
				yy<input type=text name='y' size=4 value='<?print date("Y",time())?>'>
			</td></tr>

<tr><td> To </td><td>dd<input type=text name='d1' size=2 value='<?print date("d",time())?>'>
				mm<input type=text name='m1' size=2 value='<?print date("m",time())?>'>
				yy<input type=text name='y1' size=4 value='<?print date("Y",time())?>'>
			</td>
</tr>
<tr><td colspan=2 align=center><input type=submit name='show' value='Show'>
<input type=submit value='Print' name='prn'></td></tr>
</table>
</form>
<?
if($prn)
{
   $df=$y.'-'.$m.'-'.$d;
   $dt=$y1.'-'.$m1.'-'.$d1;
       print "<script> window.open('prnitmreg.php?df=$df&dt=$dt');</script>";
}
 if($show)
  {
   $df=$y.'-'.$m.'-'.$d;
   $dt=$y1.'-'.$m1.'-'.$d1;
   $tq=$tuni=$ttax=$tgtot=$tnet=0;

   $re=mysqli_query($db,"select * from item_purchase where curdate>='$df' and curdate<='$dt' and brcode='$brcode'");
    if(mysqli_num_rows($re)>0)
    {
     print "<table bgcolor=silver cellspacing=1 cellpadding=3 width=100%>";
     print "<th>P.No <th>Date<th>Item <th> Unit Amt. <th>Qty <th> Tax Amt <th>Tax% <th>Cess Amt.";
     print "<th> Net Amt.<th>P.Inv. <th>Supplier";
        while($row=mysqli_fetch_array($re))
       {
   $ss=mysqli_query($db,"select itname from itemmaster where code='$row[item_code]'");
  $itrow=mysqli_fetch_array($ss);

   $ss=mysqli_query($db,"select supname from sup_master where code='$row[sup]'");
  $srow=mysqli_fetch_array($ss);

   print "<tr bgcolor='white'><td align=center>$row[pno]</td>";
   print "<td>".datetohtml($row[curdate])."</td>";
   print "<td>$itrow[itname]</td>";
   print "<td align=right>$row[net]</td><td align=center>$row[qty]</td>";
   print "<td align=right>$row[taxamt]</td><td align=right>$row[taxp]</td><td align=right>$row[cessamt]</td><td align=right>$row[gross]</td><td align=right>$row[purinvoice]</td>";
   print "<td>$srow[supname]</td>";
  $tq+=$row[qty];
  $tuni+=$row[gross];
  $ttax+=$row[taxamt];
  $tgtot+=$row[cessamt];
  $tnet+=$row[net];
  }
   print "<tr><td colspan=3 align=center><b>Total </td><td align=right>".putComa($tnet)."</td>";
   print "<td align=center>".($tq)."</td>";
   print "<td align=right>".putComa($ttax)."</td>";
   print "<td> &nbsp; </td><td align=right>".putComa($tgtot)."</td>";
   print "<td align=right>".putComa($tuni)."</td>";

   
 }
}
?>


