<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Po Card Print</title>
<style>
body{
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
}
table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
font-family:Arial, Helvetica, sans-serif;
padding:5px;
}
th
{
font-weight:bold;
font-size:12px;

}
td
{
font-size:12px;

}
</style>
<style type="text/css">
<!--
.style1 {
	color: #0000FF;
	font-weight: bold;
	font-size: 24px;
}
-->
</style>
</head>

<body>
 <!-- Progress bar holder -->


<?php

require_once ("connection_sql.php");
	
	
	
	echo "<table width=\"1000\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td width=\"100\"><b>Po No</b></td>
    <td width=\"80\"><b>Date</b></td>
    <td width=\"200\"><b>Part No</b></td>
    <td width=\"400\"><b>Supplier Name</b></td>
    <td width=\"100\"><b>Department</b></td>
    <td width=\"100\"><b>Arn No</b></td>
    <td width=\"70\"><b>Order Qty</b></td>  
    <td width=\"90\"><b>Received Qty</b></td> ";
	
	
	$sql_per="select * from view_userpermission where username='".$_SESSION["UserName"]."' and docname='Bin Card'";
	$result_per = $conn->query($sql_per);
    $row_per = $result_per->fetch();
         
	
	    
 
	echo " 
   
  </tr>";
  
	
       
	   $sql = "select * FROM s_ordtrn WHERE STK_NO='" . trim($_GET["invno"]) . "'   order by REFNO"; 

	   $result = $conn->query($sql);
                while ($row = $result->fetch()) {
                    
                $sql_1 = "select * from s_ordmas where REFNO='".$row["REFNO"]."' and cancel !='1'";
                $result_1 = $conn->query($sql_1);
                if ($row_1 = $result_1->fetch()) { 
                            
                    $sql_2="select * from s_stomas where CODE='".$row_1["DEP_CODE"]."'  ";
                	$result_2 = $conn->query($sql_2);
                    $row_2 = $result_2->fetch();
                    
                    $sql_3="select * from s_purmas where ORDNO='".$row_1["REFNO"]."' and CANCEL='0' ";
                	$result_3 = $conn->query($sql_3);
                    $row_3 = $result_3->fetch();
                    
                    $sql_3="select * from s_purtrn where REFNO='".$row_3["REFNO"]."' and STK_NO='" . trim($_GET["invno"]) . "' and CANCEL='0' ";
                	$result_3 = $conn->query($sql_3);
                    $row_3 = $result_3->fetch();
                	   		
                			echo "<tr>
                    <td>".$row["REFNO"]."</td>
                    <td>".$row["SDATE"]."</td>
                	<td>".$row["partno"]."</td>
                	<td>".$row_1["SUP_NAME"]."</td> 
                	<td>".$row_2["DESCRIPTION"]."</td> 
                	<td>".$row_3["REFNO"]."</td>
                    <td>".number_format($row["ORD_QTY"], 0, ".", ",")."</td> ";
                    if($row_3["REFNO"] ==""){
                         echo "<td></td>  ";
                    }else{
                         echo "<td>".number_format($row_3["REC_QTY"], 0, ".", ",")."</td>  "; 
                    }
                   
                	echo "</tr>"; 
            }
	
	   }
       		
	
  echo "</table>";

	


?>



</body>
</html>

