<?php
session_start();

include 'dbc.php';

$userid=$_SESSION['userid'];

$v_no=$_REQUEST["v_no"];

  $sqlcus = "select * from purchase where v_no='$v_no' and user_id='$userid'";
   $result=$conn->query($sqlcus);
$ppp = $result->fetch_assoc();
    $date=$ppp["date"];
	$cell=$ppp["cell"];
	$netamount=$ppp["netamount"];
	$discount=$ppp["discount"];
	$gamount=$ppp["gamount"];
	$cashrec=$ppp["cashrec"];
	$balret=$ppp["balret"];
	 $sqlcus1 = "select * from feenote";
   $result1=$conn->query($sqlcus1);
$ppp1 = $result1->fetch_assoc();
	 $notice=$ppp1["notice"];


 	    
		
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>  231- B2, Johar Town, Lahore 54000, Pakistan </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=5>  Tel: 0092-42-35236054 </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 >  Date </th>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$ppp["date"] . "</font></td>" ;
  echo "<th bgcolor=white align=left > Invoice No </th>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$ppp["id"] . "</font></td>" ;
  echo "</tr>"; 
  echo "<tr>";
  echo "<th bgcolor=white align=left > Vendor Name </th>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$ppp["cname"] . "</font></td>" ;
  echo "<th bgcolor=white align=left > City </th>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$cell . "</font></td>" ;
  echo "</tr>"; 

 echo "</table>";
$sql1 = "select * from purchase_details where inv_no='$v_no' and user_id='$userid'";
   $result1=$conn->query($sql1);
echo "<table border=1 width=100% align=center bgcolor=white>";
 echo "<tr>";
 echo "<th bgcolor=white align=left ><font color=black size=2pt face=Arial> Sr </font></th>";
  echo "<th bgcolor=white align=left ><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 "</table>";
echo "<table border=0 width=100% align=center bgcolor=white>";

 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 "<th align=right bgcolor=white  colspan=4><font color=black size=2pt face=Arial> Discount    :    </font>  </th>";
 echo "<th align=center ><font color=black size=2pt face=Arial>" .$discount . "</font></th>" ;
 echo "</tr>";
  echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=4><font color=black size=2pt face=Arial> Net Amount    :     </font> </th>";
 echo "<th align=center ><font color=black size=2pt face=Arial>" .$gamount . "</font></th>" ;
 echo "</tr>";
  echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=4><font color=black size=2pt face=Arial> Cash Received    :   </font>   </th>";
 echo "<th align=center ><font color=black size=2pt face=Arial>" .$cashrec . "</font></th>" ;
 echo "</tr>";
  echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=4> <font color=black size=2pt face=Arial>Bal Return    :   </font>   </th>";
 echo "<th align=center ><font color=black size=2pt face=Arial>" .$balret . "</font></th>" ;
 echo "</tr>";*/
 echo "<tr>";
 echo "</tr>";
 echo "<tr>";

 echo "</tr>";
  echo "<tr>";
 echo "<th align=left bgcolor=white  colspan=5><font color=black size=1pt face=Arial> $notice     </font></th>";
 echo "</tr>";

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

	 
 
?>



