<?php
session_start();
include 'dbc.php';

$userid=$_SESSION['userid'];

$id=$_REQUEST["id"];

  $sqlcus = "select * from invoice_st where id='$id' and user_id='$userid'";
   $result=$conn->query($sqlcus);
$ppp = $result->fetch_assoc();
    $date=$ppp["date"];
	$cell=$ppp["cell"];
	$cname=$ppp["cname"];
	$pname=$ppp["pname"];
	$netamount=$ppp["netamount"];
	$netamount=$ppp["stamount"];
	$tnetamount=$ppp["tnetamount"];
	$discount=$ppp["discount"];
	$gamount=$ppp["gamount"];
	$cashrec=$ppp["cashrec"];
	$balret=$ppp["balret"];
	$disc=$ppp["disc"];
	$dno=$ppp["dno"];
	$pno=$ppp["pno"];
	
	 $sqlcus1 = "select * from feenote";
   $result1=$conn->query($sqlcus1);
$ppp1 = $result1->fetch_assoc();
	 $notice=$ppp1["notice"];
	  $sqlcus2 = "select * from customer where bname='$cname' and user_id='$userid'";
   $result2=$conn->query($sqlcus2);
$ppp2 = $result2->fetch_assoc();
	 $ntnno=$ppp2["ntnno"];


 	    
		
echo "<table border=0 width=100% align=center bgcolor=white>";
echo "<tr>";


echo "<td bgcolor=white align=left colspan=6>" ."<img src='logo.jpg' />" . "</td>";
echo "<td bgcolor=white align=right colspan=3><font color=black size=5pt face=Arial>" . $userid. "<br><font color=black size=2pt face=Arial>782 H BLOCK SABZAZAR LAHORE PAKISTAN <br>Tel: 03224469145<br> mstraders145@gmail.com <br>Sales Tax Registration : 3277876123764 <br>National Tax Number : 7226487-0 ". "</font></td>";
echo "</tr>";

echo "<tr>";
echo "<td bgcolor=white align=left colspan=9><font color=black size=6pt face=Arial>" . "Delivery Chalan" . "</font></td>";
echo "</tr>";




echo "<tr>";

  echo "<td align=left colspan=9><font color=black size=3pt face=Arial>" ."To" . "<br>" .$ppp["cname"] .  "<br>NTN:" . $ntnno . "</font></td>" ;
 
  echo "</tr>"; 
  echo "<tr>";
  echo "<td align=right colspan=8 width=80%></td>" ;
 echo "<td bgcolor=white align=left width=20%><font color=black size=2pt face=Arial>" . "Invoice No:" .$ppp["id"]  .  "</font></td>";
 echo "</tr>"; 
 echo "<tr>";
  echo "<td align=right colspan=8></td>" ;
 echo "<td bgcolor=white align=left><font color=black size=2pt face=Arial>" . "Date:"  .$ppp["date"] . "</font></td>";
 echo "</tr>"; 
  
  echo "<tr>";
   echo "<td align=right colspan=8></td>" ;
   echo "<td bgcolor=white align=left><font color=black size=2pt face=Arial>"  . "PO No:"  .$ppp["pno"] . "</font></td>";
 
  echo "</tr>"; 
  
 
 
  
 echo "</table>";
$sql1 = "select * from invoice_details_st where inv_no='$id' and user_id='$userid'";
   $result1=$conn->query($sql1);
echo "<table border=1 style=border:solid black width=100% align=center bgcolor=white>";
 echo "<tr>";
 echo "<th bgcolor=#0099FF align=center style=border:solid black ><font color=white size=2pt face=Arial> Sr </font></th>";
  echo "<th bgcolor=#0099FF align=center style=border:solid black><font color=white size=2pt face=Arial> Item Name </font></th>";
  echo "<th bgcolor=#0099FF align=center style=border:solid black><font color=white size=2pt face=Arial> UM Unit </font></th>";
   echo "<th bgcolor=#0099FF align=center style=border:solid black><font color=white size=2pt face=Arial> Qty </font></th>";
 

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

  {
   echo "<tr>";
  
	 echo "<td height=30 align=center><font color=black size=3pt face=Arial>" .$sno . "</font></td>";
	 echo "<td height=30><font color=black size=3pt face=Arial>" . $row['item_name']. "</font>  </td>";
	  echo "<td height=30 align=center><font color=black size=3pt face=Arial>" . $row['rfid']. "</font>  </td>";
	  echo "<td height=30 align=center><font color=black size=3pt face=Arial>" .$row['qty'] . "</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 "<td align=left colspan=8></td>" ;
 echo "<th align=right bgcolor=white ><font color=black size=2pt face=Arial> Total Qty    :    </font>  </th>";

 echo "<th align=left ><font color=black size=2pt face=Arial>" .$tqty . "</font></th>" ;
 echo "</tr>";

 
 echo "<tr>";
 echo "</tr>";
 echo "<tr>";

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


 echo "</table>";
  

	 
 
?>



