<?php
session_start();

include 'dbc.php';

$userid=$_SESSION['userid'];

$inv_no=$_REQUEST["inv_no"];

  $sqlcus = "select * from purchase where id='$inv_no' 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=right colspan=2><font color=black size=6pt face=Arial>" . "Purchase Invoice" . "</font></td>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left colspan=5> <hr></th>";
echo "</tr>";
echo "<tr>";

echo "<td bgcolor=white align=left >" ."<img src='logo.jpg' />" . "</td>";
echo "<td bgcolor=white align=left colspan=5><font color=black size=2pt face=Arial>" . $userid. "<br>231- B2, Johar Town, Lahore 54000, Pakistan <br>Tel: 0304-4441302-01". "</font></td>";

echo "</tr>";
echo "<td align=left colspan=3></td>" ;
   echo "<td bgcolor=white align=left ><font color=black size=2pt face=Arial>" . "Sales Tax Registration :" . "</font></td>";
  echo "<td align=left ><font color=black size=2pt face=Arial>"  ."30037559974" . "</font></td>" ;
  echo "</tr>"; 
  echo "<tr>";
   echo "<td align=left colspan=3></td>" ;
   echo "<td bgcolor=white align=left ><font color=black size=2pt face=Arial>" . "National Tax Number : " . "</font></td>";
  echo "<td align=left ><font color=black size=2pt face=Arial>"  ."3755997-4" . "</font></td>" ;
  echo "</tr>"; 
echo "<tr>";

  echo "<td align=left colspan=3><font color=black size=3pt face=Arial>" ."To" . "<br>" .$ppp["cname"] . "</font></td>" ;
  
  echo "<td bgcolor=white align=left > <font color=black size=2pt face=Arial>" . "P.O No" . "</font></td>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$ppp["id"] . "</font></td>" ;
  echo "</tr>"; 
  echo "<tr>";
   
  echo "<td align=left colspan=3><font color=black size=2pt face=Arial>"  .$pname . "</font></td>" ;
 echo "<td bgcolor=white align=left ><font color=black size=2pt face=Arial>"  . "Date" . "</font></td>";
  echo "<td align=left ><font color=black size=1pt face=Arial>"  .$ppp["date"] . "</font></td>" ;
 
  echo "</tr>"; 
   

  echo "</table>";
  
 

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

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

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

  {
   echo "<tr>";
  
  
	 echo "<td height=10>" .$sno . "</td>";
	 echo "<td height=40>" .$row['item_name'] . "</td>";
	 echo "<td height=10>" .$row['srate'] . "</td>";
	 echo "<td height=10>" .$row['qty'] . "</td>";
	 echo "<td height=10>" .$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=3> Total    :      </th>";
 echo "<th align=center height=50>" .$tqty . "</th>" ;
 echo "<th align=center height=50>" .$treceived . "</th>" ;
 echo "</tr>";
 
 
 echo "<tr height=50>";
 echo "<th align=left bgcolor=white width=20 > Term & Comditions    </th>";
 echo "<th align=center width=80 colspan=4>" .$tc . "</th>" ;
 echo "</tr>";
 echo "<tr height=50>";
 echo "<th align=left bgcolor=white width=20 > Special Instructions    </th>";
 echo "<th align=center width=80 colspan=4>" .$si . "</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 />


