<?
 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:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}
</style>
<H3>SALES RETURN 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('prnsretreg.php?df=$df&dt=$dt');</script>";
}
 if($show)
  {
   $df=$y.'-'.$m.'-'.$d;
   $dt=$y1.'-'.$m1.'-'.$d1;
$i=1;
   $result=mysqli_query($db,"select * from veh_salereturn where date>='$df' and date<='$dt' and brcode='$brcode'") or die(mysqli_error());
   if(mysqli_num_rows($result)>0)
   {
?>
<table bgcolor=silver cellspacing=1 cellpadding=1>
<th>No.<th>To <th>Ret NO.<th>Date <th>Sale_invoice <th>DA <th>MCode <th>Config <th>Before tax
<th>Tax Amt <th>Cess Amt <th>Net
<?
   while($row=mysqli_fetch_array($result))
     {
       $cus_result=mysqli_query($db,"select custname from cust_master where code='$row[retfrom]'")or die(mysqli_error());
        $cus_row=mysqli_fetch_row($cus_result);
if($brcode=='AUT009'|| $brcode=='AUT103')
{
$q=0;
}
else
{
$q=round($row[tax]*1/100,2);
}  

 print "\n<tr bgcolor=white><td>".$i++."</td>";
if ($row[typ]=='dealer')
{
print "<td>$row[retfrom]</td><td>$row[ret_num]</td>";
}
else
{

print"<td>$cus_row[0]</td><td>$row[ret_num]</td>";
} 
   print "<td>".datetohtml($row[date])."</td>";
    print "<td>$row[sale_invoice]</td><td>$row[da]</td><td>$row[mcode]</td><td>$row[config]</td>";
    print "<td align=right>$row[amt2]</td>";
    print "<td align=right>$row[tax]</td><td align=right>$q</td><td align=right>$row[netamt]</td></tr>";
   }
 }
}
?>
</table>
<br>
