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

$userid=$_SESSION['userid'];

$v_no=$_REQUEST["v_no"];

  $sqlcus = "select * from saleorder 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"];
	$disc=$ppp["disc"];
	 $sqlcus1 = "select * from onote";
   $result1=$conn->query($sqlcus1);
$ppp1 = $result1->fetch_assoc();
	 $notice=$ppp1["notice"];


 	    
		
echo "<table border=0 width=100% align=center bgcolor=white>";
echo "<tr>";
echo "<td bgcolor=white align=left colspan=3><font color=black size=2pt face=Arial>"  .$userid. "</font></td>";
echo "<td bgcolor=white align=right colspan=2><font color=black size=3pt face=Arial>" . "Sale Order" . "</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 colspan=3><font color=black size=2pt face=Arial>" . "House No3, 110 - B Block Gulberg II Hali Road<br>Near Hafeez Center, Lahore-Pakistan <br>Phone: 042-35871663".  " </font></td>";
echo "<td bgcolor=white align=right colspan=2>" ."<img src='logo.jpg' />" . "</td>";

echo "</tr>";
echo "<tr>";
echo "<td bgcolor=white align=right colspan=5>" ."<img src='barcode.gif' />" . "</td>";

echo "</tr>";
echo "<tr>";
echo "<td bgcolor=white align=right colspan=5><font color=black size=2pt face=Arial>" . $userid. "</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>" . "Invoice 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>"  .$cell . "</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 "<tr>";
   echo "<td align=left colspan=3></td>" ;
   echo "<td bgcolor=white align=left ><font color=black size=2pt face=Arial>" . "Delivery Person" . "</font></td>";
  echo "<td align=left ><font color=black size=2pt face=Arial>"  .$disc . "</font></td>" ;
  echo "</tr>"; 

 echo "</table>";
$sql1 = "select * from saleorder_details where inv_no='$v_no' 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=white align=left style=border:solid black><font color=black size=2pt face=Arial> Sr </font></th>";
  echo "<th bgcolor=white align=left style=border:solid black><font color=black size=2pt face=Arial> Item Name </font></th>";
 echo "<th bgcolor=white align=center style=border:solid black><font color=black size=2pt face=Arial> Rate </font></th>";
 echo "<th bgcolor=white align=center style=border:solid black><font color=black size=2pt face=Arial> Qty </font></th>";
 echo "<th bgcolor=white align=center style=border:solid black><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']. "<br>" . $row['rfid']. "</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=3><font color=black size=2pt face=Arial> Gross Amount    :    </font>  </th>";

 echo "<th align=right ><font color=black size=2pt face=Arial>" .$treceived . "</font></th>" ;
 echo "</tr>";
 echo "<tr>";
 echo "<th align=right bgcolor=white  colspan=3><font color=black size=2pt face=Arial> Net Amount  (PKR)  :    </font>  </th>";

 echo "<th align=right ><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 "<td align=left bgcolor=white  colspan=5><font color=black size=1pt face=Arial>" .$notice.     "</font></td>";
 echo "</tr>";

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

	 
 
?>



