<?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["cname"];
	$netamount=$ppp["netamount"];
	$tc=$ppp["tc"];
	$si=$ppp["si"];
	 

 	    
		
echo "<table border=0 width=100% align=center bgcolor=white>";
echo "<tr>";
echo "<td bgcolor=white align=center colspan=9>" ."<img src='logo.jpg' />" . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=white align=center colspan=9><font color=black size=8pt face=Impact>" . $userid. "</font></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=white align=center colspan=9><font color=black size=3pt face=Arial> NTN : 3343901 , STR# : 3277876163176</font></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=white align=center colspan=9><font color=black size=2pt face=Arial>Basment # 107 Bank Squre Market Model Town Lahore Tel: +92-423-5845106/+92-321-8403888</font></td>";
echo "</tr>";


echo "<tr>";
echo "<td bgcolor=white align=center colspan=9><font color=black size=3pt face=Arial>" . "Sales Tax Invoice" . "</font></td>";
echo "</tr>";




echo "<tr>";
  echo "<td align=left colspan=2><font color=black size=3pt face=Arial>" ."Bill To" . "</font></td>" ;
  echo "<td align=left colspan=3><font color=black size=2pt face=Arial>" .$ppp["cname"] .   "</font></td>" ;
  echo "<td bgcolor=white align=right colspan=4><font color=black size=3pt face=Arial>" . "Invoice No:" .$ppp["id"]  .  "</font></td>";
  echo "<tr>";
  echo "<td align=left colspan=2><font color=black size=3pt face=Arial>" ."Address" . "</font></td>" ;
  echo "<td align=left colspan=3><font color=black size=2pt face=Arial>" .$ppp["address"] .   "</font></td>" ;
  echo "<td bgcolor=white align=right colspan=4><font color=black size=3pt face=Arial>" . "Date:"  .$ppp["date"] . "</font></td>";
  echo "<tr>";
  echo "<td align=left colspan=5><font color=black size=3pt face=Arial>" ."NTN:" . $ntnno . "</font></td>" ;
   echo "<td bgcolor=white align=right colspan=4><font color=black size=3pt face=Arial>"  . "PO No:"  .$ppp["pno"] . "</font></td>";
  echo "</tr>"; 
  echo "<tr>";
  echo "<td align=left colspan=5><font color=black size=3pt face=Arial>" ."STR #:" . $saletaxno . "</font></td>" ;
  echo "</tr>"; 
  

  echo "</table>";
  
 

$sql1 = "select * from purchase_details where inv_no='$id' and user_id='$userid' order by id";
   $result1=$conn->query($sql1);
 echo "<table border=1 width=100% bgcolor=white>";
 echo "<tr>";
 
 echo "<th bgcolor=silver align=left height=50> S.No </th>";
 echo "<th bgcolor=silver align=left height=50> Code </th>";

  echo "<th bgcolor=silver align=left height=50> Item Name </th>";
 echo "<th bgcolor=silver align=left height=50> Rate </th>";
 echo "<th bgcolor=silver align=left height=50> Qty </th>";
 echo "<th bgcolor=silver align=left height=50> Amount </th>";

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

  {
   echo "<tr>";
  
  
	 echo "<td >" .$sno . "</td>";
	 echo "<td >" .$row['item_no'] . "</td>";
	 echo "<td >" .$row['item_name'] . "</td>";
	 echo "<td >" .$row['srate'] . "</td>";
	 echo "<td >" .$row['qty'] . "</td>";
	 echo "<td >" .$row['amount'] . "</td>";
	
		
		
  echo "</tr>";
 
  $sno=$sno + 1;
  $treceived=$treceived + $row['amount'];
  $tqty=$tqty + $row['qty'];
  
  }
  

 echo "<tr>";
 echo "<th align=right bgcolor=white height=50 colspan=4> Total    :      </th>";
 echo "<th align=center height=50>" .$tqty . "</th>" ;
 echo "<th align=center height=50>" .$treceived . "</th>" ;
 echo "</tr>";
 
 

 echo "</table>";
	 
 
?>

<br />
<h3><br />
  <br />
  <br />
  <br />
Director:________ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Accounts Manager:________
<br />

<br />

<br />

<br />

<br />


