<?
session_start();
include("../opendb.php");
include("../test.php");

?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
//	tr{background-color:white}
	th{background-color:steelblue;color:white}
	td{font-size:12}
.right{text-align:right};
</style>
<center>
<h3>SPARE INVOICE REPORT -1</H3>
<?
$invre=mysqli_query($db,"select distinct invtype from spareinvoice where brcode='$brcode'");
while($invrow=mysqli_fetch_array($invre))
{
$gtot1=0;
$re=mysqli_query($db,"select invno,invdate,saleordno,customer,sum(tot) gtot ,sum(qty) gqty,vatorcst,invtype from spareinvoice  where brcode='$brcode' and invtype='$invrow[0]' group by invno");
print "<table border=0 cellspacing=1 cellpadding=3 bgcolor='lightsteelblue'>";
print "<th colspan=10><h3>Invoice Type $invrow[0]</th></tr>";
print " <th>Inv No <th>Invoice Date ";
print "<th>Sale Ord <th>Customer<th>Qty <th>Amount";
if($level==5)
print"<th>Action";
while($row=mysqli_fetch_array($re))
{
 print "\n<tr bgcolor=white><td>$row[invno]</td><td>".datetohtml($row[invdate]);
 print "</td><td><center>$row[saleordno]</td>";
 print "<td>$row[customer]</td><td align=right>$row[gqty]</td>";
  
 print "<td align=right>".putComa($row[gtot])."</td>";
if($level>=4)
 print "\n<td><input type=button value='Del' onClick=javascript:delfun('$row[invno]','$invrow[invtype]','$row[vatorcst]')></td></tr>";
 $gtot1+=$row[gtot];
}
print "<tr><td colspan=5><center><b>Total</td><td>".putComa($gtot1)."</td></tr></table><br>";

}
?>
<tr><td colspan=10></td>
</table>

<script>
 function delfun(x,y,z)
 {
  if(confirm('Do you want to delete invoice no '+x))
   document.location='delspinvoice.php?invno='+x+'&invtype='+y+'&vatorcst='+z;
 }
</script>
