<?
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>

<?
print "<h3>PSN TELCON - ".$branch;
print "</H3>SPARE INVOICE REPORT FOC";
$invre=mysqli_query($db,"select distinct invtype from spareinvoicefoc 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 spareinvoicefoc  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<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>";
 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='delspinvoicefoc.php?invno='+x+'&invtype='+y+'&vatorcst='+z;
 }
</script>
