<?
 session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../test.php");

if($unit=='Telcon')
include("../opendb.php");
else if($unit=='Mahindra')
{
 $brcode="VEH967";
$db=mysqli_connect("localhost","root");
mysqli_select_db("mahdb1") or die(mysqli_error());
print $unit;
}
?>
<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>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('prnvehpreg.php?df=$df&dt=$dt');</script>";
}
 if($show)
  {
   $df=$y.'-'.$m.'-'.$d;
   $dt=$y1.'-'.$m1.'-'.$d1;
   $result=mysqli_query($db,"select * from veh_purchase where entrydate>='$df' and entrydate<='$dt' and brcode='$brcode' order by entrydate") or die(mysqli_error());
   if(mysqli_num_rows($result)>0)
   {
?>
<table bgcolor=silver cellspacing=1 cellpadding=1>
<th>No.<th>Tono <th>Inv NO.<th>Inv. Date <th>Entry Date<th>MSNO <th>Model <th>Config <th>Before Tax
<th>Tax <th>Tax% <th>Net Amt.
<?
$i=1;
     while($row=mysqli_fetch_array($result))
     {
      print "<tr bgcolor=white><td>".$i++."</td><td><center>$row[tono]</td><td>$row[pinvno]</td><td>".datetohtml($row[pinvdate])."</td><td>".datetohtml($row[entrydate])."</td>";
      print "<td>$row[msno]</td><td>$row[model]</td><td>$row[config]</td>";
      print "<td align=right>".putComa($row[amt])."</td>";
      print "<td align=right>$row[taxamt]</td><td align=right>$row[taxp]</td>";
      print "<td align=right>".putComa($row[amt2])."</td></tr>";
    }
}
else
 print "Record does not exist";
}
?>
</table>
