<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>

   
<!-- <button class="btn btn-warning" onclick="printData1();">Print me</button> -->
<div class="row">
<button type="button" class="btn btn-rounded btn-success" onclick="btnExport_monthly();">
<span class="btn-icon-left text-success"><i class="fa fa-download color-success"></i>
</span>Download</button>
<div class="col-12">
 <div class="card">
<div class="card-body">
<div class="table-responsive">
<div class="table-responsive" id="container">
            <h3></h3>
                <table id="example5" class="table table-striped table-bordered dataTable no-footer" style="min-width: 775px">
                    <thead>
                <tr>
                    <th>Company </th>
                    <th>S.O #</th>
                    <th>Product</th>
                    <th>Amount</th>
                    <th>Recived Amount</th>
                    </tr>
            </thead>
            <tbody>
                <?php
                if(!empty($filter_data)){
                foreach ($filter_data as $value) {  ?>
                <tr>
                <td><?php $so_party_id =  so_party_id($value['so_id']);
                echo party_name($so_party_id);
                ?></td>
                <td><?php echo so_number($value['so_id']); ?></td>
                <td><?php $product =  sale_order_pro($value['so_id']); 
                    echo product_name($product);
                ?></td>
                <td><?php echo "Rs. ". intval($value['total_value']*95.5/100); ?></td>
                <td><?php echo "Rs. ".$value['amount']; ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table> 
          </div>  
</div>
</div>
 </div>
</div>
                </div>    
        <?php } ?>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

  <script type="text/javascript">
  $(document).ready(function() {
    $('#example5').DataTable();
  });
</script>
  <script type="text/javascript">
            function printData1()
            {
                var divToPrint=document.getElementById("container");
                newWin= window.open("");
                newWin.document.write(divToPrint.outerHTML);
                newWin.print();
                newWin.close();
            }

            

function btnExport_monthly()
{
    
    var tab_text="<table border='2px'><tr bgcolor='#ebebeb'>";
    var textRange; var j=0;
    tab = document.getElementById('example5'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
    {
        txtArea2.document.open("txt/html","replace");
        txtArea2.document.write(tab_text);
        txtArea2.document.close();
        txtArea2.focus(); 
        sa=txtArea2.document.execCommand("SaveAs",true,"Banking");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
        </script>
        