<?php
session_start();

include 'dbc.php';

$userid=$_SESSION['userid'];

$id=$_REQUEST["id"];

  $sqlcus = "select * from purchase where id='$id' and user_id='$userid'";
   $result=$conn->query($sqlcus);
$ppp = $result->fetch_assoc();
    $date=$ppp["date"];
	$ven_name=$ppp["ven_name"];
	$netamount=$ppp["netamount"];



 	    
		
echo "<table border=0 width=100% align=center bgcolor=white>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=5>  $userid </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=5>  0423-6525757 </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=5>  Purchase Invoice </th>";
echo "</tr>";
echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3>  Date </th>";
  echo "<td align=left colspan=2><font color=black size=1pt face=Arial>"  .$ppp["date"] . "</font></td>" ;
  echo "</tr>"; 
  echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3> Invoice No </th>";
  echo "<td align=left colspan=2><font color=black size=1pt face=Arial>"  .$ppp["id"] . "</font></td>" ;
  echo "</tr>"; 
  echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3> Vendor </th>";
  echo "<td align=left colspan=2><font color=black size=1pt face=Arial>"  .$ven_name . "</font></td>" ;
  echo "</tr>";
 
$sql1 = "select * from purchase_details where inv_no='$id' and user_id='$userid'";
   $result1=$conn->query($sql1);

 echo "<tr>";
 echo "<th bgcolor=white align=center ><font color=black size=2pt face=Arial> Sr </font></th>";
  echo "<th bgcolor=white align=center ><font color=black size=2pt face=Arial> Item Name </font></th>";
 echo "<th bgcolor=white align=center ><font color=black size=2pt face=Arial> Rate </font></th>";
 echo "<th bgcolor=white align=center ><font color=black size=2pt face=Arial> Qty </font></th>";
 echo "<th bgcolor=white align=center ><font color=black size=2pt face=Arial> Amount </font></th>";

 
 echo "</tr>";
  $sno=1;
  while($row = $result1->fetch_assoc())

  {
   echo "<tr>";
  
	 echo "<td height=30><font color=black size=1pt face=Arial>" .$sno . "</font></td>";
	 echo "<td height=30><font color=black size=1pt face=Arial>" . $row['item_name']. "</font>  </td>";
	 echo "<td  height=30 align=center><font color=black size=1pt face=Arial>" .$row['srate'] . "</font></td>";
	 echo "<td height=30 align=center><font color=black size=1pt face=Arial>" .$row['qty'] . "</font></td>";
	 echo "<td  height=30 align=center><font color=black size=1pt face=Arial>" .$row['amount'] . "</font></td>";
	
		
		
  echo "</tr>";
 
  $sno=$sno + 1;
  $treceived=$treceived + $row['amount'];
  $tqty=$tqty + $row['qty'];
  
  }
  

 echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=4><font color=black size=2pt face=Arial> Total    :    </font>  </th>";

 echo "<th align=center ><font color=black size=2pt face=Arial>" .$treceived . "</font></th>" ;
 echo "</tr>";
  
 echo "<tr>";
 echo "</tr>";
 echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=5> <font color=black size=1pt face=Arial>------------------------------------------  </th>";
 echo "</tr>";
  

 echo "</table>";
  echo "<hr>";

	 
 
?>



