<?
 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:white}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:white}
</style>
<center>
<H3>
<?print $branch?> <br>
SALES REGISTER - 3</H3>
<?
   $result=mysqli_query($db,"select * from veh_invoice where invdate>='$df' and invdate<='$dt' and brcode='$brcode' and type!='trans-out'") or die(mysqli_error());
   if(mysqli_num_rows($result)>0)
   {
?>
 From <?print datetohtml($df).' To '.datetohtml($dt)?>
<br>[ Printed by <?print strtoupper($user).' on '.date('r')?> ]</font> <br><br>&nbsp;
<table bgcolor=silver cellspacing=1 cellpadding=1>
<th>No.<th>To <th>Inv NO.<th>Inv. Date <th>DA <th>Addr1<th>Addr2 <th>City <th>Dist.
<th>Phone1 <th>Phone 2<th>Model <th>Config <th>Eng No. <th>Chasis <th>Segment.
<?
$i=1;
     while($row=mysqli_fetch_array($result))
     {
    $addr1='';
    $dist='';
    $addr2='';
    $cust='';

 if($row[type]=='-')
  { 
   $cus_result=mysqli_query($db,"select custname,addr1,addr2,city,dist,phone1,phone2 from cust_master where code='$row[cust]'")or die  (mysqli_error());
    $cus_row=mysqli_fetch_array($cus_result);
    $cust=$cus_row[0];
    $addr1=$cus_row[addr1];
    $dist=$cus_row[dist];
    $addr2=$cus_row[addr2];
  }
 else if($row[type]=='trans-out')
 {
   $cus_result=mysqli_query($db,"select brname from br_master where code='$row[cust]'")or die  (mysqli_error());
    $cus_row=mysqli_fetch_row($cus_result);
    $cust="<font color='brown'>".$cus_row[0];
}  
else
 $cust="<font color='green'>".$row[0];
      print "<tr bgcolor=white><td align=center>".$i++."</td><td>$cust</td><td align=center>$row[invno]</td><td>".datetohtml($row[invdate])."</td><td>$row[da]</td><td>$addr1</td><td>$addr2</td>";
print "<td>$cus_row[city]</td><td>$dist</td><td>$cus_row[phone1]</td>";
  print "<td>$cus_row[phone2]</td>";
      print "<td>$row[model_code]</td><td>$row[config]</td><td>$row[engno]</td>";
      print "<td>$row[chasis]</td><td>$row[segment]</td>";
    }
}
else
 print "Record does not exist";

?>
</table>
