<?session_start();
include("../opendb.php");
include("../test.php");
?>
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:12}
th{background-color:c1d799}
//tr{background-color:c1d799}
.mnu{margin-left:5}
.summ{font-size:13};
</style>
<center>
 BILLING SUMMARY
<form action='<?print $PHP_SELF?>' method=post>
<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>
<th colspan=2 align=center><input type=submit name='show' value='Show'>
</td></tr>
</table>
</form>
<?
if($show)
{
$df=$y.'-'.$m.'-'.$d;
$dt=$y1.'-'.$m1.'-'.$d1;
?>
</center>
<table border=0 width=100%>
<th colspan=2 align=center><?print $branch?><br>BILLING SUMMARY <BR>FOR THE PERIOD FROM <?PRINT datetohtml($df).' To '.datetohtml($dt)?></th>
<tr><td align=center>[Printed by <?print $user?> on <?print date("r")?>
<tr><td align=center VALIGN=TOP>
<table border=0 cellspacing=1 cellpadding=3 bgcolor=silver style={font-size:13}>
<th>DA <th>Ord Date <th> Config <th>Pur Inv No. <th>Pur Date <th>Pur AMT <th>Inv No.
<th>Inv Date <th>Sale Amt <th>Type <th>Customer
<?
$res=mysqli_query($db,"select * from purorder where brcode='$brcode' and orddate>='$df' and orddate<='$dt' and dano !='DUMMY' order by ordno");
while($row=mysqli_fetch_array($res))
{
 print "<tr bgcolor=white><td align=center>$row[dano]</td><td>".datetohtml($row[orddate])."</td><td>$row[config]</td>";
  $pres=mysqli_query($db,"select invno,entrydate,sale_invoice,amt2 from veh_purchase where da='$row[dano]' and brcode='$brcode'");
   $prow=mysqli_fetch_array($pres);
   print "<td>$prow[invno]</td><td>".datetohtml($prow[entrydate])."</td><td align=right>$prow[amt2]</td>";
   print "<td align=center>$prow[sale_invoice]</td>";

$pres=mysqli_query($db,"select * from veh_invoice where da='$row[dano]' and brcode='$brcode' order by invdate desc");
   $srow=mysqli_fetch_array($pres);
  print "<td align=center>".datetohtml($srow[invdate])."</td><td align=right>$srow[amt2]</td>";
  print "<td align=center>$srow[type]</td>";

$pres1=mysqli_query($db,"select * from cust_master where code='$srow[cust]' and branch='$brcode'")or die(mysqli_error());
   $cusrow=mysqli_fetch_array($pres1);
   print "<td>$cusrow[acname]</td>";
 }
}
?>
