<?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>Deliver Order</title>
<style type="text/css">
<!--
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
	text-decoration:underline;
}
.style2 {
	font-family: Arial;
	font-size: 15px;
}
.style4 {
	font-size: 22px;
	font-weight: bold;
}
-->
</style>
</head>

<body><center>
<?php 
require_once("config.inc.php");
	require_once("DBConnector.php");
	$db = new DBConnector();
	?>
    
    <?php
			$sql_invpara="SELECT * from invpara where COMCODE='" . $_SESSION['company'] . "'";
			$result_invpara =$db->RunQuery($sql_invpara);
			$row_invpara = mysql_fetch_array($result_invpara);
			
			 $sql4 = "Select * from s_domas where REF_NO='" . $_GET["invno"] . "'";
            $result4 = $db->RunQuery($sql4);
            $row14 = mysql_fetch_array($result4);
			
			 $sql1 = "Select * from vendor where CODE='" . $row14["C_CODE"] . "'";
            $result1 = $db->RunQuery($sql1);
            $row1 = mysql_fetch_array($result1);


			echo $_GET["CURRENT_USER"];

		   $txtrepono = $_GET["CURRENT_USER"] . " " . date("Y-m-d") . "  " . date("H:i:s");

$adress=$_GET["invdate"];
$cusname=$_GET["cus_name"];
	
	?>
<table width="922" height="433" border="0">
  <tr>
      <!--<img src='images/aas_Logo.jpg' style='width:115px;height:50px;'>-->
    <td height="30" colspan="1" align="right"></td>
    <td colspan="5" align="center" ><span class="style4"><?php echo $row_invpara["COMPANY"]; ?></span></br><span style='font-size: 14px;'><b>Importers & Distributors of all Types of Diesel Engine Spare Parts</b></span></td>
    <td>&nbsp;</td>
  </tr>
    
 <tr>
    <td colspan="8" align="center"><span style='font-size: 12px;'; ><?php echo $row_invpara["ADD1"]; ?> TEL :<?php echo $row_invpara["TELE"]; ?> FAX:0112 388930 <span/></td>
   
  </tr>
  <tr>
    <td colspan="3"></td>
     <td colspan="3"></td>
     <td colspan="3"><b>Date : &nbsp
      <?php echo $_GET["invdate"]; ?></b></td>
   
  </tr>
    <tr style="margin-top: 100px;">
        <td colspan="6"><b>To :&nbsp  <?php echo $row1["NAME"]; ?></b></td> 
      <td colspan="4"><b>Delivery No :&nbsp  <?php echo $_GET["invno"]; ?></b></td>
   
  </tr>

  
  
  <tr>
    <td height="164" colspan="7"><table border="1" cellpadding="0" cellspacing="0"><tr><td><table width="900" height="81" border="0" cellspacing="0">
      <tr  bgcolor="#999999">
        <td width="120" height="30"><span class="style1">Stock No</span></td>
        <td width="400"><span class="style1">Description</span></td>
        <td width="100"><span class="style1">Brand</span></td>
        <td width="50" align="right"><span class="style1">Qty</span></td>
        <td width="100" align="right"><span class="style1">PRICE</span></td>
        <td width="120" align="right"><span class="style1">Discount (%)</span></td>
        <td width="130" align="right"><span class="style1">Sub Total</span></td>
        </tr>
      <?php 
	  	$sql_rsPrInv="SELECT * from s_dotrn where REF_NO= '" . trim($_GET["invno"]) . "'  order by id";
		
		$totdis=0;
    	$result_rsPrInv =$db->RunQuery($sql_rsPrInv);	
		while ($row_rsPrInv = mysql_fetch_array($result_rsPrInv)){	
		    	$sql5="SELECT * from s_mas where  STK_NO='".$row_rsPrInv["STK_NO"]."'"; 
			 $result5 = $db->RunQuery($sql5);
            $row15 = mysql_fetch_array($result5);
           
            if($row14["C_CODE"]=="D0133-B"){ 
                $itemcode = (int)filter_var($_GET["invno"], FILTER_SANITIZE_NUMBER_INT).$row_rsPrInv["STK_NO"]; 
                 
            }else{
                $itemcode=$row_rsPrInv["STK_NO"];
            }
			 
			echo "<tr height=\"40\"><td><span class=\"style2\">".$itemcode."</span></td>
			<td><span class=\"style2\">".$row_rsPrInv["DESCRIPT"]."</span></td>
			<td><span class=\"style2\">".$row15["BRAND_NAME"]."</span></td>
			<td  align=\"right\"><span class=\"style2\">".number_format($row_rsPrInv["QTY"], 0, ".", ",")."</span></td>
			<td align=\"right\"><span class=\"style2\">".number_format($row_rsPrInv["PRICE"], 2, ".", ",")."</span></td>
			<td align=\"right\"><span class=\"style2\">".number_format($row_rsPrInv["DIS_per"], 2, ".", ",")."</span></td>";
			
			$dis=($row_rsPrInv["PRICE"]*$row_rsPrInv["QTY"])-($row_rsPrInv["PRICE"]*$row_rsPrInv["QTY"]*$row_rsPrInv["DIS_per"]/100);
			echo "<td align=\"right\"><span class=\"style2\">".number_format($dis, 2, ".", ",")."</span></td></tr>";
			
			$totdis=$totdis+$dis;
		}	
	  	
		$tax=0;
		
		$final_total=0;
		if ((trim($_GET["tax"])!="") and ($_GET["tax"]>0) and ($_GET["tax"]!="0.00")){
			$tax=$totdis*$row_invpara["vatrate"]/100;
			echo "<tr><td colspan=6></td><td align=right><b>".number_format($totdis, 2, ".", ",")."</b></td></tr>";
			echo "<tr><td colspan=5></td><td>VAT ".$row_invpara["vatrate"]."%</td><td align=right><b>".number_format($tax, 2, ".", ",")."</b></td></tr>";
			$tot=$totdis+$tax;
			$final_total=$tot;
			echo "<tr><td colspan=6></td><td align=right><b><u>".number_format($tot, 2, ".", ",")."</u></b></td></tr>";
		}	else {
			echo "<tr><td colspan=6></td><td align=right><b><u>".number_format($totdis, 2, ".", ",")."</u></b></td></tr>";
			$final_total=$totdis;
		}
		
	   ?>
      
     
      
    </table></td></tr></table></td>
  </tr>
  <tr>
    <td height="94" colspan="2" valign="bottom">_______________________</td>
    <td>&nbsp;</td>
    <td colspan="2" valign="bottom">________________________</td>
    <td valign="bottom">__________________________</td>
    <td valign="bottom" align="right">_______________________</td>
  </tr>
  <tr>
    <td colspan="2"  align="center">Sales Person </td>
    <td>&nbsp;</td>
    <td colspan="2"  align="center">Marketing Manager</td>
    <td align="center">Authorized By 1</td>
    <td align="center">Authorized By 2</td>
  </tr>
  <tr>
    <td height="50" colspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
    
  
  
</table>





</body>
</html>
