<?
session_start();
 session_register("depovar");
 $depovar=$depot;

include("test.php");
include("opendb.php");
?>
<font face=verdana>
Purchase report of <?print $depot." from $df to $dt"?>
</font>
<?

$result2=mysqli_query($db,"select distinct item from purchase") or die (mysqli_error());
while($row2=mysqli_fetch_row($result2))
{
 $totq=0; $totp=0;
?>
<table border=0 cellspacing=1 cellpadding=1 bgcolor=black width=>
<tr bgcolor='white'><td width=5><center><b>Date</td><td width=200><center><b>Item Name </td><td width=250><center><b>From </td><td><center><b>Rate</b> (Rs.)</td><td><center><b>Quantity</b> (Kg.)</td><td><center><b>Price</b> (Rs.)</td></tr>
<?
$sql="select * from purchase where depot='$depot' and date>='".parseDate($df)."' and date<='".parseDate($dt)."' and item ='$row2[0]' order by date";
$result=mysqli_query($db,$sql) or die(mysqli_error());
while($row=mysqli_fetch_array($result))
{
 $totq+=$row[qty];
 $totp+=($row[rate]*$row[qty]);
 print "<tr bgcolor='white' ><td>".datetoHtml($row[0])."</td><td>$row[1]</td><td>$row[2] ($row[6]) $row[7]</td><td align=right>". putComa($row[4],1)."</td><td align=right>".putComa($row[5])."</td>";
$price=($row[4]*$row[5]);
printf("<td align=right>%s</td></tr>",putComa($price));
}
printf("<tr bgcolor=white><td colspan=4 align=center><b>Total</td><td align=right>%s</td><td align=right>%s</td></tr>",putComa($totq),putComa($totp));
?>
<tr><td></tr></td>
</table>
<br>
<?
}
include("abspurrepo.php");
?>


