<style media=print> 
    .Noprint{display:none;} 
</style>
<?php
include("connect.php");

$invid = $_POST["INVID"];
$number = $_POST["number"];
$date = $_POST["date"];
$po = $_POST["po"];
$do = $_POST["do"];
$bill_to = $_POST["bill_to"];
$ship_to = $_POST["ship_to"];
$product = $_POST["product"];
$quanlity = $_POST["quanlity"];

$line_total = $_POST["line_total"];
$sub_total = $_POST["sub_total"];
$discount = $_POST["discount"];
$Shipping = $_POST["Shipping"];
$total = $_POST["total"];
$unit_price = $_POST["unit_price"];

$line_total= $quanlity * $unit_price;
$sub_total= $line_total;
$total= $sub_total - ($discount/100) - $Shipping;

if($_POST["Submit"] == "Submit")
{
	$query = "INSERT INTO invoice (INVID,number,date,po,do,bill_to,ship_to,product,quanlity,unit_price,line_total,sub_total,discount,Shipping,total) 
VALUES('$invid','$number','$date','$po','$do','$bill_to','$ship_to','$product','$quanlity','$unit_price','$line_total','$sub_total','$discount','$Shipping','$total')";
	$result = $db->query($query);
	
	$db->close();
	echo "<table border='0' cellspacing='0' cellpadding='0' bordercolor='white' width='100%'>";


    echo "<tr>";
        echo "<td width='75%' valign='top' rowspan='4'><img src='sinlieng.png'></td>";
        echo "<td width='25%'><p style='font-size:28pt;'><b>Invoice</b><p></td>";
    echo "</tr>";
	 echo "<tr>";
      
        echo "<td>INV number: $invid<br/></td>";
    echo "</tr>";
    echo "<tr>";
        echo "<td>Date: $date<br/></td>";
    echo "</tr>";
   echo "<tr>";
        echo "<td>PO number: $po<br/></td>";
    echo "</tr>";
echo "</table>";


echo "<table border='0' cellspacing='0' cellpadding='0' bordercolor='white' width='100%'>";
    echo "<tr><br><br>";
        echo "<td width='50%'>Ship to:$ship_to</td>";
        echo "<td width='50%'>Bill to:$bill_to</td>";
    echo "</tr>";
	echo "</table>";
	
	
	echo "<table border='2' cellspacing='0' cellpadding='3' bordercolor='black' width='100%'>";
    echo "<tr><br><br>";
        echo "<td>Product</td>";
        echo "<td>Quantity</td>";
		echo "<td>Unit per price</td>";
        echo "<td>Line Total</td>";
    echo "</tr>";
	 echo "<tr>";
        echo "<td>$product</td>";
        echo "<td>$quanlity</td>";
		echo "<td>$unit_price</td>";
        echo "<td>$line_total</td>";
    echo "</tr>";
	 echo "<tr>";
		echo "<td colspan='3' align='right'>Subtotal:</td>";
        echo "<td>$sub_total</td>";
    echo "</tr>";
	
	echo "<tr>";
		echo "<td colspan='3' align='right'>Discount:</td>";
        echo "<td>$discount</td>";
    echo "</tr>";
	
	echo "<tr>";
		echo "<td colspan='3' align='right'>Shipping & handing:</td>";
        echo "<td>$Shipping</td>";
    echo "</tr>";
	
		echo "<tr>";
		echo "<td colspan='3' align='right'>Total:</td>";
        echo "<td>$total</td>";
    echo "</tr>";
	
	echo "</table>";
		echo "<p align='left'></p>";
echo "<table border='0' cellspacing='0' cellpadding='0' bordercolor='white' width='100%'>";
    echo "<tr>";
        echo "<td width='20%' valign='top'>Thank You.</td>";
       
	echo "</table>";
    echo "</tr>";
	echo "<p align='right'>";
	
	echo "<input type='button' onClick='window.print()' value='Print' class='Noprint'/>";
}

?>