<?
session_start();
//include("test.php");
class prepo
{
 var $group="",$item="",$qty=0.0,$value=0.0;
}

$i=0;
?>
<style>
th{background-color:silver;font-family:verdana}
</style>

<table border=1>
<th>Item Name<th>Quanty<th>Value

<?
$sql="select distinct groupcode from purchase where depot='$depovar' and date>='".parseDate($df)."' and date<='".parseDate($dt)."'";
//print $sql;
$result=mysqli_query($db,$sql) or die(mysqli_error());

while($row=mysqli_fetch_row($result))
{
 $result3=mysqli_query($db,"select name from groups where groupcode='$row[0]'");
 $gn=mysqli_fetch_row($result3);
 $tq=0.0;$tv=0.0;
$result2=mysqli_query($db,"select item,sum(qty),sum(rate*qty) from purchase where depot='$depovar' and date>='".parseDate($df)."' and date<='".parseDate($dt)."' and groupcode='$row[0]' group by item") or die(mysqli_error());

print "<tr><td colspan=3>".strtoupper($gn[0])."</td></tr>";
while($row2=mysqli_fetch_row($result2))
{
 print "<tr bgcolor=#fffcd6><td>$row2[0]</td><td align=right>".putComa($row2[1])."</td><td align=right>".putComa($row2[2])."</tr>";
 $tq+=$row2[1];
 $tv+=$row2[2];
}
 printf("<tr bgcolor=silver><td><b>Total</td><td align=right>%s ",putComa($tq));
 printf("</td><td align=right>%s </td></tr>",putComa($tv));
}
?>
