<? session_start();
$brcode = $_SESSION['brcode'];
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:c1d7bb;font-size:13}
.mnu{margin-left:5}
</style>
<center>
<form action='<?print $PHP_SELF?>'>
<table>
<tr><td> Enter DA </td><td><input type=text name='da'></td>
    <td><input type=submit value='Search' name='sea'></td>
</tr>
</table>
</form>
<hr>
<?
$sea = $_REQUEST['sea'];
$da = $_REQUEST['da'];
if($sea)
{
    $da=trim($da);
    print "<br>";
    $re=mysqli_query($db,"select * from vehopstock where dano='$da' and brcode='$brcode'")
    or die(mysqli_error());
    if(mysqli_num_rows($re)>0)
    {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Vehicle Opening Stock </font></th><tr><th>Model<th>Config";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white><td>$row[mcode]</td><td>$row[config]</td>";
    }
 print "</table>";
 }

//******************
$re=mysqli_query($db,"select * from purorder where dano='$da' and brcode='$brcode'")
or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
 {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Purchase Order</font></th><tr><th>Ord NO <th>Ord Date<th>M code <th>Config";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white align=center><td>$row[ordno]</td><td>".datetohtml($row[orddate])."</td><td>$row[mcode]</td><td>$row[config]</td>";
    }
 print "</table>";
 }
//*******************************
print "<br>";
$re=mysqli_query($db,"select * from veh_purchase where da='$da' and brcode='$brcode'")
or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
 {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Vehicle Purchase </font></th><tr><th>Ledger<th>Entry Date <th>Pur No <th>M code <th>Config <th>Type";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white align=center><td>$row[ledger]</td><td>".datetohtml($row[entrydate])."</td>";
      print "<td>$row[pur_no]</td><td>$row[mcode]</td><td>$row[config]</td><td align=center>$row[type]</td>";
    }
 print "</table>";
 }

//*******************************
print "<br>";
$re=mysqli_query($db,"select * from veh_invoice where da='$da' and brcode='$brcode'")
or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
 {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Vehicle Invoice </font></th><tr><th>Invno<th>Inv Date <th>Config <th>Type";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white align=center><td>$row[invno]</td><td>".datetohtml($row[invdate])."</td>";
      print "<td>$row[config]</td><td align=center>$row[type]</td>";
    }
 print "</table>";
 }
//*******************************
print "<br>";
$re=mysqli_query($db,"select * from crnote where da='$da' and brcode='$brcode'")
or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
 {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Cr Note (Discount Allowed) </font></th><tr><th>Cr no<th>Date <th>Sale Inv <th>Amt2";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white align=center><td>$row[ret_num]</td><td>".datetohtml($row[date])."</td>";
      print "<td>$row[sale_invoice]</td><td align=right>$row[amt2]</td>";
    }
 print "</table>";
 }

//*******************************
print "<br>";
$re=mysqli_query($db,"select * from journal2 where no='$da' and brcode='$brcode' and against='DA'")
or die(mysqli_error());
 if(mysqli_num_rows($re)>0)
 {
   print "<table cellspacing=1 cellpadding=2 bgcolor='gray'> <th colspan=10>Found DA $da in Table <font color=blue>Accounts  </font></th><tr><th>Date <th>JV No <th>Ledger <th>dramt <th>cramt <th>Narr";
    while($row=mysqli_fetch_array($re))
    {
      print "<tr bgcolor=white><td>".datetohtml($row[date])."</td>";
      print "<td>$row[jvno]</td><td>$row[partic]</td><td align=right>$row[dramt]</td>";
      print "<td align=right>$row[cramt]</td><td>$row[narr]</td>";
    }
 print "</table>";
 }
}// end if sea
?>
