<?PHP 
include("header.php");
//session_start();
//error_reporting(0);
include "checksession.php";
include "include/db-connect.php";
?>

<!--------------------print script--------------------------------------->
<script type="text/javascript">     
        function PrintDiv() 
		{    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=300,height=300');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
		}
</script>
<!-----------------Ending print script----------------------------------->
<div style="margin-left:40px; margin-top:5px;">
<input type="image" src="images/print.jpg" onClick="PrintDiv();" width="40" title="Print Invoice"/>Print Invoice
</div>
  
  
  
<div style="margin-left:300px; margin-top:20px; height:auto; margin-bottom:100px;">
 <div id="divToPrint" >      <!--Print content start-->
  
  <?php
  $oid=$_REQUEST['oid'];
  
  $setrxxxx=mysql_query("select * from orders where order_id='$oid'");
  $fetxxxr=mysql_fetch_array($setrxxxx);
  $pay_type=$fetxxxr['pay'];
  $tot_amountRRRR=$fetxxxr['tot_amount'];
  $cus_name=$fetxxxr['name'];
  $phone=$fetxxxr['phone'];
  
  $setrrr=mysql_query("select * from orders where order_id='$oid' and pay='Paymentgateway'");
  $fetrrr=mysql_fetch_array($setrrr);
  $txn_amount=$fetrrr['txn_amount'];
  
  $setgggg=mysql_query("select * from orders where order_id='$oid' and pay='COD'");
  $fetgggg=mysql_fetch_array($setgggg);
  $tot_amount=$fetgggg['tot_amount'];
  
  
  $se1212=mysql_query("select ship from orders where order_id='$oid'");
  $fe1212=mysql_fetch_array($se1212);
  $shipp=$fe1212['ship'];
  
  
  
  $setqqqqoooo=mysql_query("select * from mail_contact where id='1'");
  $fetqqqqoooo=mysql_fetch_array($setqqqqoooo);
  $mobnum1=$fetqqqqoooo['mobnum1'];
  $mobnum2=$fetqqqqoooo['mobnum2'];
  
  
  $seyyyyy=mysql_query("select * from `invoice_no` where `order_id`='$oid'");
  $feyyyyy=mysql_fetch_array($seyyyyy);
  $invno=$feyyyyy['invno'];
  
 
  ?>

    
  <div style="width:800px; height:auto; border:groove; border-width:thin" >
  <div style="width:800px; height:auto; margin-top:50px;" align="center">
  <span style="font-size:16px; font-weight:bold; text-transform:uppercase;">SUDHAN TEX STYLES<br />SALES INVOICE</span><br />
   SUDHAN TEX STYLES, SHED NO. 167-C, <br />
SIDCO INDUSTRIAL ESTATE KAPPALUR,<br />
MADURAI -16,TAMILNADU.<br />
   Mobile No&nbsp;:&nbsp;<?php echo $mobnum1;?>, Phone No&nbsp;:&nbsp;<?php echo $mobnum2;?>  </div>
  
  <div style="width:380px; height:70px; margin-top:10px; float:left;" align="center">
 &nbsp;&nbsp;&nbsp;&nbsp; Order ID : <?php echo $oid;?><br />
  15-04-2016&nbsp;&nbsp;&nbsp;&nbsp;11:01 AM <br /> <br /> 
  Payment Type: &nbsp;&nbsp;&nbsp;&nbsp;<?php echo $pay_type;?>  
  
  </div>
  
  <div style="width:400px; height:70px; margin-top:10px; float:left;" align="center">
  Customer Name : <?php echo $cus_name;?><br />
 &nbsp;&nbsp;&nbsp;&nbsp;  Mobile No&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<?php echo $phone;?> <br><br>
  INV No&nbsp;&nbsp;&nbsp;&nbsp; :  <?php echo $invno;?> </div>
  
    
  
  <table width="70%" align="center">
  <tr>
  <td colspan="6"><hr /></td>
  </tr>
  <tr>
  <td width="120">Product ID</td>
  <td width="200">Product Name</td>
  <td width="100">Price</td>
  <td width="100">Qty</td>
  <td width="100" align="right">Total Amount</td>
  </tr>
  <tr>
  <td colspan="6"><hr /></td>
  </tr>
  <?php
  $set=mysql_query("select * from profit where order_id='$oid' and product_id!=''");
  while($fet=mysql_fetch_array($set))
  { 
  $product_id=$fet['product_id'];
  $quantity=$fet['quantity'];
 
  $set222=mysql_query("select * from products where serial='$product_id'");
  $fet222=mysql_fetch_array($set222);
  
  $price=$fet222['price'];
  $name=$fet222['name'];
  $tot_price=$price*$quantity;
  
  $net_total+=$tot_price;
  ?>             
  <tr>
  <td><?php echo $fet222['product_id'];?></td>
  <td><?php echo $name;?></td>
  <td><?php echo $fet222['price'];?></td>
  <td><?php echo $quantity;?></td>
  <td align="right"><?php echo number_format($tot_price,2);?></td>
  </tr>
  <?php } ?>
   <tr>
  <td colspan="55"><hr /></td>
  </tr>
   <tr>
  <td colspan="4" align="right"> Total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</td>
  <td align="right"><?php echo number_format($net_total,2);?></td>
  </tr>
   <tr>
  <td colspan="4" align="right"> Shipping Cost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</td>
  <td align="right"><?php echo number_format($fetxxxr['shipping_cost'],2);?></td>
  </tr>
  <tr>
  <td colspan="4" align="right"> Net Total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</td>
  <td align="right"><?php echo number_format($net_total+$fetxxxr['shipping_cost'],2);?></td>
  </tr>
   <tr>
   <tr>
  <td colspan="4" align="right">Received Amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</td>
  <td align="right"><?php echo number_format($txn_amount,2);?></td>
  </tr>
   <tr>
 <td colspan="4" align="right">Receivable Amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</td>
  <td align="right"><?php echo number_format($tot_amount,2);?></td>
  </tr>
   <tr>
  <td colspan="5"><hr /></td>
  </tr>
  </table>
  </div>
  </div><!--print invoice-->
</div> 
</div>
<?php include("footer.php"); ?>