<?session_start(); include("test.php");
?>

<?
 include("opendb.php");
 $sql="select * from sales where depot='$depot' and date>='".parseDate($df)."' and date<='".parseDate($dt)."'";
 $result=mysqli_query($db,$sql) or die(mysqli_error());
 if(mysqli_num_rows($result)<=0)
 {
   print "<br><font face=verdana color=red>There are no sales in this period</font>";
   return;
 }
$result2=mysqli_query($db,"select distinct groupcode from sales");
while($row2=mysqli_fetch_row($result2))
{
 $totq=0;$totp=0;
 $sql="select * from sales where depot='$depot' and date>='".parseDate($df)."' and date<='".parseDate($dt)."' and groupcode='$row2[0]'";
 $result=mysqli_query($db,$sql) or die(mysqli_error());
?>
<CENTER>
ALPHONSA HOSPITAL, PULLURAMPARA <BR>
<? print "Sales report of <b>$depot</b>  from $df to $dt";?>
<table border=0 cellspacing=1 cellpadding=1 bgcolor=black width=100%>

<tr bgcolor='white'><td width=75><center><b>Date</td><td width=100><center><b>Invoice No.</td><td width=200><center><b>To </td><td width=100><center><b>Item</td><td width=20><center><b>Rate</b> (Rs.)</td><td width=20><center><b>Quantity</b> (Kg.)</td><td width=20><center><b>Price</b> (Rs.)</td> <td><center><b>Remark</td></tr>

<?
 while($row=mysqli_fetch_array($result))
 {
 $totq+=$row[qty];
 $totp+=($row[rate]*$row[qty]);
  print "\n<tr bgcolor='white'><td>".datetoHtml($row[0])."</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td>";
printf("<td  align=right>%s</td>",putComa($row[4]));
printf("<td  align=right>%s</td>",putComa($row[5]));
$price=($row[4]*$row[5]);
printf("<td align=right>%s</td><td>$row[7]</td></tr>",putComa($price));
}
printf("\n<tr bgcolor=white><td colspan=5 align=center><b>Total</td><td align=right>%10.2f</td><td align=right>%s</td><td></td></tr>",$totq,putComa($totp));
?>
<tr><td></tr></td>
</table>
<br>
<?
}
?>


