<?php require('../db/db.php'); 

$orderid=$_GET['order_print'];

?>


<!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>Untitled Document</title>
</head>
<style>

.invoice_print{
	font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
}
table.bottomBorder { border-collapse:collapse; }
table.bottomBorder td, table.bottomBorder th { border-bottom:1px dotted black;padding:5px; font-size:12px;
	font-family:Arial, Helvetica, sans-serif;}	
@media print
{    
    .no-print, .no-print *
    {
        display: none !important;
    }

}
</style>

<body>



<table width="100%" border="0" class="invoice_print">
<p align="right">
  <SCRIPT LANGUAGE="JavaScript"> 
if (window.print) {
document.write('<form class="no-print"><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script></p>
<div class="invoice_print" align="center"><p><strong>MEDICS DR AMER's</strong></br>
Address: 317 A-one Township Lahore</br> Phone: 042-35151666</br> e: medics@gmail.com</p>
</div>
<?php 
$result = mysqli_query($con,"SELECT * FROM product_order WHERE order_id='$orderid'");
while ($row = mysqli_fetch_array($result))
{
?><tr>
    <td>Date: <?php echo date('d,M,Y', strtotime( $row['order_date'])); ?></td>
    <td>Time:<?php echo date('h:i:s a', strtotime($row['order_date']));?></td>
  </tr>
  <tr>
    <td>Order No:<?php echo $orderid; ?></td>
    <td>Created by: <?PHP echo $row['username'];?></td>
  </tr>
  <tr>
    <td>Supplier name:<?PHP echo $row['supplier_id'];?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

<table width="100%" border="0"  class="invoice_print bottomBorder">

    <th align="left">S#</th>
    <th align="left">Product</th>
    <th align="left">Rate</th>
    <th align="left">Qty</th>
    <th align="right">Amount</th>
  </tr>
  <?php $raw_result1 = mysql_query("SELECT * FROM product_orderitems WHERE order_id='$orderid'") or die(mysql_error());
  $x=1; 
while ($row1 = mysql_fetch_array($raw_result1)){ $productid=$row1['product_id'];?>  <tr><tr>
    <td><?php echo $x++;?></td>
    <td><?php $raw_results2 = mysqli_query($con,"SELECT * FROM products where product_id='$productid'");
		$row2 = mysqli_fetch_array($raw_results2); echo $row2['product_name']. " - " . $row2['medicine_type'] ;?></td>
    <td><?php echo $row1['trade_price'];?></td>
    <td><?php echo $row1['qty_to_order'];?></td>
    <td align="right"><?php echo $row1['net_total'];?></td>
  </tr><?php }?>
</table>
<div class="invoice_print"> <p>Total Items: <?php echo mysql_num_rows($raw_result1);?></p> </div>
<tr>
    <td>&nbsp;</td>
</tr>
<div align="right">
<table width="50%" border="0" class="invoice_print">
  
  <tr>
    <td width="50%">Total:</td><td align="right"> <?php echo number_format($row['order_amount']); ?></td>
  </tr>
  <tr>
    <td width="50%">Discount:</td><td align="right">  <?PHP echo $row['discount']."%";?></td>
  </tr>
  <tr>
    <td width="50%">Net Bill:</td><td align="right"><strong>Rs. <?php echo  number_format($row['amount_payable']); ?> </strong></td>
  </tr>
  <tr>
    <td width="50%">Total Payable:</td><td align="right">Rs. <?php echo  number_format($row['amount_payable']); ?></td>
  </tr>
  
  <?php }?>
</table>
</div>

<div class="invoice_print">
<p  style="border-top:1px dotted black;">Terms &amp; Conditions</p>
<p>&nbsp;</p>
<p>DESIGNED By Softusion Pvt Ltd (www.softusion.com)</p>
</div>
</body>
</html>