<?php
session_start();

include 'dbc.php';

$userid=$_SESSION['userid'];

$pname=$_REQUEST["pname"];

   
		
echo "<table border=0 width=100% align=center bgcolor=white>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=7>  $userid </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=7>  Purchase Invoice </th>";
echo "</tr>";


  echo "</table>";
  
 

$sql1 = "select * from purchase_details where item_name='$pname' 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> Date </th>";
   echo "<th bgcolor=white align=left height=50> PO 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())

  {
   $inv_no = $row['inv_no'];	
   echo "<tr>";
  
	 echo "<td height=40>" .$row['date'] . "</td>";
	 echo "<td height=40>" .$row['ivn_no'] . "</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"<th> <a href ='Item_Details_Purchase.php?inv_no=$inv_no'>"?><button type="button" class="btn btn-primary">Purchase Details View</button><?php "</a>";
		
  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 bgcolor=white align=center colspan=7>  $userid </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=center colspan=7>  Sale Invoice </th>";
echo "</tr>";


  echo "</table>";
$sql = "select * from invoice_details where item_name='$pname' and user_id='$userid'";
   $result=$conn->query($sql);
 echo "<table border=1 width=100% bgcolor=white>";
 echo "<tr>";

echo "<th bgcolor=white align=left height=50> Date </th>";
 echo "<th bgcolor=white align=left height=50> Invoice 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>";
  $sno1=1;
  while($row1 = $result->fetch_assoc())

  {
   $inv_no = $row1['inv_no'];	
   echo "<tr>";
  echo "<td height=40>" .$row1['date'] . "</td>";
   echo "<td height=40>" .$row1['ivn_no'] . "</td>";
	
	 echo "<td height=40>" .$row1['item_name'] . "</td>";
	 echo "<td height=10>" .$row1['srate'] . "</td>";
	 echo "<td height=10>" .$row1['qty'] . "</td>";
	 echo "<td height=10>" .$row1['amount'] . "</td>";
	
		
		 echo"<th> <a href ='Item_Details_Sale.php?inv_no=$inv_no'>"?><button type="button" class="btn btn-primary">Sale Details View</button><?php "</a>";
  echo "</tr>";
 
  $sno1=$sno1 + 1;
  $treceived1=$treceived1 + $row1['amount'];
  $tqty1=$tqty1 + $row1['qty'];
  
  }
  


 
 echo "</table>";
	 
 
?>

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

<br />

<br />

<br />

<br />


