<?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>Print ARN</title>
<style type="text/css">
<!--
.companyname {
	color: #000000;
	font-weight: bold;
	font-size: 24px;
}

.com_address {
	color: #000000;
	font-weight: bold;
	font-size: 18px;
}

.heading {
	color: #000000;
	font-weight: bold;
	font-size: 20px;
}

body {
	color: #000000;
	font-size: 16px;
}


-->
</style>
</head>

<body style="font-family: Arial, Helvetica, sans-serif;"><center>
<?php 
require_once("connectioni.php");
	
	
	
	$sql_para="select * from invpara where flag='".$_SESSION['company']."'";  
	$result_para =mysqli_query($GLOBALS['dbinv'],$sql_para);
	$row_para = mysqli_fetch_array($result_para);
	?>
    
<table width="1000" border="0">
  <tr>
    <td colspan="5" align="center"><span class="companyname"><?php echo $row_para["COMPANY"]; ?></span></td>
  </tr>
  <tr>
    <td colspan="5" align="center"><span class="com_address"><?php echo $row_para["ADD1"]; ?></span></td>
  </tr>
   <?php
		//echo $_GET["invno"];
    			 
		$sql="Select * from s_purmas where REFNO='".$_GET["invno"]."'";
    	$result =mysqli_query($GLOBALS['dbinv'],$sql) ; 	
		$row = mysqli_fetch_array($result);			
		
		$sql3="Select * from s_stomas where CODE='".$row["DEPARTMENT"]."'";
    	$result3 =mysqli_query($GLOBALS['dbinv'],$sql3) ; 	
		$row3= mysqli_fetch_array($result3);	
        
		$sql1="Select * from vendor where CODE='".$row["SUP_CODE"]."'";
    	$result1 =mysqli_query($GLOBALS['dbinv'],$sql1) ; 	
		$row1 = mysqli_fetch_array($result1);	
		
		$sql2="Select * from viewarn where REFNO='".$_GET["invno"]."' order by ID";
		//echo $sql2;
    	$result2 =mysqli_query($GLOBALS['dbinv'],$sql2) ; 	
		
	?>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="130" align="center">    </td>
    <td colspan="2" align="center"></td>
  </tr>
    <tr>
    <th colspan="4" scope="col" class="heading"><b><u>ARRIVAL NOTE</u></b></th>
  </tr>
  <tr>
     
     <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td> 
    
    <td align="left">&nbsp;</td> 
    <td align="right">&nbsp;</td>
  </tr>
         <tr> 
    <td align="left"><b>ARN Date</b> </td>
    <td align="left"><b><?php echo $row["SDATE"]; ?></b></td>
    <td align="left"><b>PO Date</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> 
    <td align="right"><b><?php echo $row["PUR_DATE"]; ?></b></td>
  </tr>
  <tr>
    <td width="150" align="left"><b>ARN No</b> </td>
    <td width="600" align="left"><b><?php echo $row["REFNO"]; ?></b></td>
    <td width="170" align="left"><b>PO No</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> 
    <td width="266" align="right"><b><?php echo $row["ORDNO"]; ?></b></td>
  </tr>
  <tr>
     <td align="left"><b>Supplier</b> </td>
    <td align="left"><b><?php echo $row1["NAME"]; ?></b></td>
    <td align="left"><b>BL No</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> 
    <td align="right"><b><?php echo $row["blno"]; ?></b></td>
  </tr>
  <tr>
     <td align="left"><b>Brand</b> </td>
    <td align="left"><b><?php echo $row["brand"]; ?></b></td>
    <td width="170" align="left"><b>LC/TT No</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> 
    <td width="266" align="right"><b><?php echo $row["LC_No"]; ?></b></td>
  </tr>
  <tr>
     <td align="left"><b>Country</b> </td>
    <td align="left"><b><?php echo $row["COUNTRY"]; ?></b></td> 
    <td align="left"><b>CI No</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> 
    <td align="right"><b><?php echo $row["invno"]; ?></b></td>
    
  </tr>
  <tr>
      <td align="left"><b>Department</b> &nbsp;</td>
    <td align="left"><b><?php echo $row3["DESCRIPTION"]; ?></b></td> 
    
    <td align="left"><b>PI No</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> 
    <td align="right"><b><?php echo $row["pi_no"]; ?></b></td>
  </tr>
  
   <tr>
     
     <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td> 
    
    <td align="left">&nbsp;</td> 
    <td align="right">&nbsp;</td>
  </tr>
  
  
  <tr>
    <td colspan="4"><table width="1200" border="1" cellpadding="0" cellspacing="0">
      <tr>
        <th width="200" scope="col" align="center">Item Code</th>
        <th width="976" scope="col" align="center">Item Description</th>
        <th width="170" scope="col" align="center">Size</th>
        <th width="170" scope="col" align="center">Pattern</th>
        <th width="120" height="22" align="center">Order Qty</th>
        <th width="70" scope="col" align="center">Received Qty</th>
        <th width="70" scope="col" align="center">Existing Qty</th>
        <th width="150" scope="col" align="center">Total Qty</th>
        <th width="150" scope="col" align="center">FOB</th>
        <th width="140" scope="col" align="center">Cost</th> 
        <th width="180" scope="col" align="center">List Price</th>
        <th width="212" scope="col" align="center">Unit Total</th>
      </tr>
     <?php
	 	$tot=0;
	 	$oqty=0;
        $rqty=0;
        $eqty=0;
        $tqty=0;
	 	while ($row2 = mysqli_fetch_array($result2)){
	 	    	$sql4="Select * from s_mas where STK_NO='".$row2["STK_NO"]."'";
    	$result4 =mysqli_query($GLOBALS['dbinv'],$sql4) ; 	
		$row4 = mysqli_fetch_array($result4);			
		
      echo "<tr>
        <td align=center>".$row2["STK_NO"]."</td>
        <td>".$row2["DESCRIPT"]."</td>";
		
		if (($row2['REC_QTY'] > 0) and ($row2['acc_cost'] > 0) and ($row2['SELLING'] > 0)) {
					$stot = $row2['REC_QTY']* $row2['acc_cost'];
					$margine_val = ($row2['SELLING'] - $row2['acc_cost']) / $row2['acc_cost'] * 100;

				} else {
					$stot="";
					$margine_val="";
				}	
				
        echo "
        <td align=center>".$row4["SIZE"]."</td>
        <td align=center>".$row4["PART_NO"]."</td>
        <td align=center>".number_format($row2["O_QTY"], 0, ".", ",")."</td>
        <td align=center>".number_format($row2["REC_QTY"], 0, ".", ",")."</td>
        <td align=center>".number_format($row2["QTYINHAND"], 0, ".", ",")."</td>
        <td align=center>".number_format(($row2["QTYINHAND"]+$row2["REC_QTY"]), 0, ".", ",")."</td>
        <td align=right>".number_format($row2["FOB"], 2, ".", ",")."</td>
		<td align=right>".number_format($row2["acc_cost"], 2, ".", ",")."</td> 
		<td align=right>".number_format($row2["SELLING"], 2, ".", ",")."</td>
		<td align=right>".number_format(($row2["acc_cost"]*$row2["REC_QTY"]), 2, ".", ",")."</td>
		
      </tr>";
	  	$tot=$tot+($row2["acc_cost"]*$row2["REC_QTY"]);
	  	$oqty=$oqty+$row2["O_QTY"];
        $rqty=$rqty+$row2["REC_QTY"];
        $eqty=$eqty+$row2["QTYINHAND"];
        $tqty=$tqty+($row2["QTYINHAND"]+$row2["REC_QTY"]);
	  }
      ?>
      
      <tr>
        <th width="170" scope="col" colspan="4"></th>
        <th width="170" scope="col" colspan="1"><?php  echo  $oqty; ?></th>
         <th width="170" scope="col" colspan="1"><?php  echo  $rqty; ?></th>
          <th width="170" scope="col" colspan="1"><?php  echo  $eqty; ?></th>
       <th width="170" scope="col" colspan="1"><?php  echo  $tqty; ?></th>
       <th width="170" scope="col" colspan="3">Total ARN Value</th> 
        <th width="212" scope="col" align="right"><?php  echo number_format($tot, 2, ".", ","); ?></th>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr> <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td align="center">__________________________</td>
    <td>&nbsp;</td>
     <td>&nbsp;</td>
    <td align="center">__________________________</td>
  </tr>
  <tr> 
    <td align="center"><b>ENTERED BY</b></td>
    <td>&nbsp;</td>
     <td>&nbsp;</td>
    <td align="center"><b>AUTHORIZED BY</b></td>
  </tr>
</table>
</body>
</html>
