<?
 session_start();
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); 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}
//tr{background-color:white} 
th{background-color:c1d799;font-size:13}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style> 

<?
$sq="select * from orderform where brcode='$brcode' and formno='$fno'";
$res=mysqli_query($db,$sq);
$row=mysqli_fetch_array($res);
?>
<table border=0 width=100%>
<tr><td>

<input type=hidden name='formno' value='<?print $fno?>'>
<table cellspacing=1 cellpadding=3 border=1>
<th colspan=2>ORDER FORM DETAILS</TH>
<?
print "<tr><td>Location</td><td>".$row[location]."</td></tr>";

print "<tr><td>Entry Date</td><td>".datetohtml($row[dt])."</td></tr>";
print "<tr><td>Orderform Date</td><td>".datetohtml($row[ofdate])."</td></tr>";
print "<tr><td>Name </td><td>$row[cust]</td></tr>";
print "<tr><td>Address</td><td>$row[addr]</td></tr>";
print "<tr><td>Phone</td><td>$row[phone]</td></tr>";
print "<tr><td>Model</td><td>$row[model] Config : $row[config]</td></tr>";
$segres = mysqli_query($db,"select sname from seg_master where code='$row[seg]'");
$segrow=mysqli_fetch_array($segres);

print "<tr><td>Segment</td><td>$segrow[0]</td></tr>";
$fres=mysqli_query($db,"select * from fin_master where branch='$brcode' and code='$row[fine]'");
$frow=mysqli_fetch_array($fres);
print "<tr><td>Financer</td><td>$frow[finname]</td></tr>";
print "<tr><td>Exchange</td><td>$row[exch]</td></tr>";
print "<tr><td>Description</td><td>$row[descr]</td></tr>";
print "<tr><td>Exchange Value</td><td>$row[exvalue]</td></tr>";

print "<tr><td>Invoice Amt</td><td>$row[invalue]</td></tr>";
print "<tr><td>Opening</td><td>$row[op]</td></tr>";

print "<tr><td>Discount</td><td>$row[disamt]</td></tr>";
print "<tr><td>Net Amount</td><td>$row[netamt]</td></tr>";
print "<tr><td>Other Information</td><td>$row[oinf]</td></tr>";

print "<tr><td colspan=2 align=center>
<input type=button value='Back' onClick=history.back(1)>
</td></tr>
</table>";
print "</form>";
?>
</td>
<td valign=top>
<?
    $advres=mysqli_query($db,"select * from advcollection where formno='$row[formno]'");
    print "\n<table><tr bgcolor=white><td colspan=8><table bgcolor=silver width=300><tr><td colspan=3 align=center><b>Payment Details</td></tr>";
    if(mysqli_num_rows($advres)>0)
    {
     print "<th>Date <th>Type <th>Amount <th>Cleared";
     $t=0;
    while($advrow=mysqli_fetch_array($advres))
    {
      
       print "\n<tr bgcolor=white><td>".datetohtml($advrow[date])."</td><td>$advrow[type]</td><td align=right>$advrow[amount]</td><td align=center>$advrow[clearing]</td></tr>";
    $t+=$advrow[amount];
   }
     print "\n<tr bgcolor=white><td colspan=2><b>Total</td><td align=right><b>".putComa($t)."</td></tr>";
   print "\n<tr><td colspan=2>Vehicle Amount</td><td align=right>".putComa($row[netamt])."</td></tr>";
 $bal=putComa($row[netamt]-$t);
  if($bal<=0)
   print "<tr><td colspan=2><font color=red><blink><b>Balance Amount</td><td align=right><b>".$bal."</td></tr>";
else
   print "\n<tr><td colspan=2><b>Balance Amount</td><td align=right><b>".$bal."</td></tr>";

  }
print " </table>";

?>

</td>
</tr>
</table>


